Hi CMakers,

I'm looking for a way to
1. build and run executable targets, after one of their dependency has been 
changed and
2. to run these executable targets every time whether they were rebuild or not.

The first point is more important to me that the second one. A little 
background:
I am working on automatical created, build and run tests. These tests use the 
Boost Test Framework. They are created by CMake by using configure_file() and a 
template, which works very well.
After that the target is created and the dependencies are set:
add_executable(${target}_tests EXCLUDE_FROM_ALL 
${CMAKE_CURRENT_SOURCE_DIR}/tests/${target}_Tests.cpp)
target_link_libraries(${target}_tests ${target})
target_link_libraries(${target}_tests ${Boost_LIBRARIES})

After that add_custom_command makes the executable run after the build:
add_custom_command(     TARGET "${target}_tests"
 POST_BUILD
 COMMAND "${CMAKE_BINARY_DIR}/bin/${target}_tests${CMAKE_EXECUTABLE_SUFFIX}"
 ARGS "--log_format=XML 
--log_sink=${CMAKE_TEST_RESULTS}/${target}-test_results.xml --log-level=all 
--report_level=detailed"
 DEPENDS "${target}"
 )
There are two versions, one for Visual Studio which looks similiar.
This works, too. But only the first time the code is build or when the code of 
the test is changed, not when the target it should test is changed.

To the first point: I thought this should work out of the box, but it does not 
seem to. What would you suggest to solve this issue?
Regarding the second point: I tried to use the touch command offered by CMake 
to make the tests targets to look as if they changed. Also I tried to use a 
custom_target (which I made all tests depend on), to have a target which is 
always out-of-date and forces the tests to be rebuild.
Non of these attempts worked. So I now hope for your help.

Best regards,
Philipp
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to