[CMake] file depending on a target
Brad King
brad.king at kitware.com
Mon May 15 15:01:32 EDT 2006
Brandon J. Van Every wrote:
> How can I make a file depend on a target? I have a lexer SILEX.EXE that
> I generate. I need other files to depend on the existence of SILEX.EXE,
> so that I can lex and create new output. It seems like
> target-depends-on-target is dealt with, and file-depends-on-file, and
> even target-depends-on-file. But not file-depends-on-target.
>
> My current headscratching code:
>
> EXE_C_TARGET(silex) # Generates silex.c from silex.scm
> ADD_EXECUTABLE(silex ${Chicken_BINARY_DIR}/silex.c)
> SET_TARGET_PROPERTIES(silex PROPERTIES COMPILE_FLAGS "${STATIC_FLAGS}")
> TARGET_LINK_LIBRARIES(silex libchicken-static)
>
> ADD_CUSTOM_COMMAND(
> OUTPUT ${Chicken_BINARY_DIR}/easyffi.l.silex
> MAIN_DEPENDENCY ${Chicken_SOURCE_DIR}/easyffi.l
> DEPENDS silex
> COMMAND silex ${Chicken_SOURCE_DIR}/easyffi.l
> ${Chicken_BINARY_DIR}/easyffi.l.silex
> )
>
> ADD_FILE_DEPENDENCIES(${Chicken_BINARY_DIR}/easyffi.c
> ${Chicken_BINARY_DIR}/easyffi.l.silex
> )
>
>
> It seems that "DEPENDS silex" will not refer to the SILEX.EXE target.
> Rather, it thinks it's an ordinary file level dependency.
That's okay. The make process that evaluates the file-level dependency
will not be executed until it is known that the exe target is up to
date. That is what the target-level dependency does.
-Brad
More information about the CMake
mailing list