[CMake] Question about dependencies and paths

Eric Noulard eric.noulard at gmail.com
Wed Dec 30 10:32:37 EST 2009


2009/12/30 Talin <viridia at gmail.com>:
> I've got a problem that has been vexing me for several months: It seems that
> when I create a custom rule using add_custom_command, the DEPENDS clause
> sometimes works and sometimes doesn't, and I can't figure out why.
> Here's what my custom rule looks like:
>   # Link with stdlib
>   string(REGEX REPLACE ".tart\$" ".s" ASM_FILE "${SRC_FILE}")
>   add_custom_command(OUTPUT ${ASM_FILE}
>       COMMAND tartln -disable-fp-elim -filetype=asm ${TARTLN_OPTIONS}
> ${BC_FILE}
>           "${PROJECT_BINARY_DIR}/stdlib/stdlib.bc"
>           "${PROJECT_BINARY_DIR}/libext/testing/testing.lib.bc"
>       DEPENDS "${BC_FILE}" tartln stdlib testing.lib
>       COMMENT "Linking Tart bitcode file ${BC_FILE}")
> Now, the targets 'stdlib' and 'testing.lib' are almost identical in
> definition, however when I attempt to execute this rule it complains that it
> can't find a rule to build 'testing.lib'. However, I can make both stdlib
> and testing.lib manually by typing "make stdlib" or "make testing.lib"
> respectively on the command line. So I know that both targets work.
> The only significant difference between the two targets, as far as I can
> tell, is that the testing.lib target is one level deeper in the build
> hierarchy. That is, in my top-level CMakeLists.txt file, I include the
> subdirectories "stdlib/" and "libext/testing/", which contain the
> CMakeLists.txt for the two libraries.
> I've tried putting $PROJECT_BINARY_DIR and $CMAKE_BINARY_DIR in front of
> testing.lib, neither of which seems to make any difference. I've also tried
> depending on the actual build product (testing.lib.bc) rather than the
> abstract target testing.lib. Still no luck.
> Can anyone suggest something else to try?

How is you "testing.lib" target defined?

Is it

1)  ADD_LIBRARY(testing  <whatever-source-list>)
or
2) ADD_LIBRARY(testing.lib <whatever-source-list>)

if it is defined as 1) then your DEPENDS line should be:

DEPENDS "${BC_FILE}" tartln stdlib testing

NO ".libs" at the end of testing.

"testing" is the target name
whereas
"testing.lib"  may be the **output** name of the ADD_LIBRARY target?

DEPENDS takes into account "file dependencies" and "target" dependencies
file dependencies are handled for files appearing in the OUTPUT statement
of an add_custom_command.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list