Am 2012-09-12 12:36, schrieb Brett Delle Grazie:
Hi,
I've come across some strange behaviour when using add_custom_target
and an
add_custom_command( PRE_BUILD or PRE_LINK ) in nested projects.
We have a number of static analysis checks that were working using
cppcheck.
The technique was to add a non-automatic global custom target called
'all_static_checks' like:
add_custom_target(all_static_checks)
set_target_properties(all_static_checks PROPERTIES EXCLUDE_FROM_ALL
TRUE)
This make target 'all_static_checks' is run by the build system and
generates output from
the static analysis tool on a per-project basis.
For each sub-project we would:
add_custom_command(TARGET all_static_checks PRE_BUILD
COMMAND custom command goes here
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
VERBATIM)
This works when the add_custom_command and the add_custom_target are
defined within the same CMakeLists.txt
But it fails in the nested case (when the add_custom_command part is
added in a sub-directory). In the nested case
no PRE_BUILD commands are executed.
Targets and commands added by add_custom_target()/add_custom_command()
may only be referenced from the same directory.
Why don't you just do add_test()?
Eike
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake