[CMake] output of custom_command ?
Michael Hertling
mhertling at online.de
Thu Dec 1 11:27:09 EST 2011
On 12/01/2011 03:50 PM, Anders Wallin wrote:
> Hi all,
>
> I'm building some Lyx documentation with asymptote figures.
>
> I'm generating the figures in EPS format like this:
> add_custom_command(
> OUTPUT ${ASYFIG}.eps
> COMMAND asy ${CMAKE_CURRENT_SOURCE_DIR}/${ASYFIG}.asy
> DEPENDS ${ASYFIG}.asy
> )
>
> and the the document in PDF format like this:
> add_custom_command(
> OUTPUT manual.pdf
> COMMAND lyx --export pdf ${CMAKE_CURRENT_SOURCE_DIR}/manual.lyx
> DEPENDS manual.lyx
> )
>
> I put all .asy source files and .lyx source files in one directory.
>
> When I do an out-of-source build in e.g. /src/bld/ the .eps files
> which are produced from the first
> custom_command are put in CMAKE_CURRENT_BINARY_DIR
>
> Two questions/problems:
>
> 1. the pdf file from the second custom_command gets placed in
> CMAKE_CURRENT_SOURCE_DIR.
> Why is that happening?
Refer to <http://wiki.lyx.org/FAQ/ImportExport#cl>:
"... This will create the output file in
the same directory as the input file."
> 2.
> Since the input of the second custom_command, and the .eps files are
> now in different directories, lyx is not finding the EPS-files.
> How could I have the second custom_command run in
> CMAKE_CURRENT_BINARY_DIR so that the figures would be found
> and the output pdf would be generated in CMAKE_CURRENT_BINARY_DIR ?
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/manual.pdf
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/manual.lyx
${CMAKE_CURRENT_BINARY_DIR}/manual.lyx
COMMAND lyx --export pdf ${CMAKE_CURRENT_BINARY_DIR}/manual.lyx
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/manual.lyx)
Moreover, be aware of possible in-source-builds and non-symlink-aware
platforms, and definitely heed David's advice w.r.t. the dependencies.
Regards,
Michael
More information about the CMake
mailing list