[CMake] add_custom_command location
Tomasz Grobelny
tomasz at grobelny.oswiecenia.net
Mon Nov 7 11:51:18 EST 2011
I have a project which is configured in several CMakeLists.txt files. The
problem is that add_custom_command works or doesn't work depending on where
the command is located. If I put add_custom_command just after add_library
then it works fine. Like this:
add_library(mylib SHARED ${SOURCES} ${PRIVATE_HEADERS}
${PUBLIC_HEADERS})
add_custom_command(TARGET mylib POST_BUILD
COMMAND cmd
)
But when I try to do something like this:
CMakeLists.txt
add_directory(src)
add_custom_command(TARGET mylib POST_BUILD
COMMAND cmd
)
src/CMakeLists.txt
add_library(mylib SHARED ${SOURCES} ${PRIVATE_HEADERS}
${PUBLIC_HEADERS})
Then it doesn't work (no error, just cmd is not executed). Why is that?
And what can I do about it? If this is due to target mylib not being
visible in root CMakeLists.txt then is there a way to forward declare it?
And either way: if the command is not going to work anyway then an error
would be expected IMHO.
--
Regards,
Tomasz Grobelny
More information about the CMake
mailing list