Hi,<br><br>I want some help to organize tests within cmake.<br>Currently I have a test directory which contains some test files, eg :<br>test_foo.cpp<br>test_bar.cpp<br><br>In the CMakeLists.txt, I had:<br>add_executable(test_foo test_foo.cpp)<br>
add_test(test_foo test_foo)<br><br>add_executable(test_bar test_bar.cpp)<br>add_test(test_bar test_bar)<br><br>test_bar and test_foo have not the same dependencies so I did:<br>find_package(Boost COMPONENTS thread)<br>add_executable(test_foo test_foo.cpp)<br>
add_test(test_foo test_foo)<br>target_link_libraries(test_foo ${Boost_LIBRARIES} my-project)<br>
<br>find_package(Boost COMPONENTS system)<br>
add_executable(test_bar test_bar.cpp)<br>
add_test(test_bar test_bar)<br>target_link_libraries(test_bar ${Boost_LIBRARIES} my-project)<br><br>but it does not work as I expected (see bug <a href="http://www.cmake.org/Bug/view.php?id=13244">http://www.cmake.org/Bug/view.php?id=13244</a>).<br>
I realized that is not a cmake bug but my misunderstanding of cmake.<br><br>Correct me if I am wrong but I think the cmake way looks like:<br>test/CMakeLists.txt<br>add_subdirectory(foo)<br>add_subdirectory(bar)<br><br>test/foo/CMakeLists.txt<br>
find_package(Boost COMPONENTS thread)<br>
add_executable(test_foo test_foo.cpp)<br>
add_test(test_foo test_foo)<br>
target_link_libraries(test_foo ${Boost_LIBRARIES} my-project)<br><br>test/bar/CMakeLists.txt<br>
find_package(Boost COMPONENTS system)<br>
add_executable(test_bar test_bar.cpp)<br>
add_test(test_bar test_bar)<br>
target_link_libraries(test_bar ${Boost_LIBRARIES} my-project)<br><br>but I think this solution is a bit verbose because we need to create a directory for each test.<br><br>So, I have 2 questions:<br>- how do you organize your tests within cmake? / what is the cmake way to organize test?<br>
- how do you handle multiple targets in the same CMakeLists.txt with differents dependencies? / what is the cmake way to handle multiple targets in the same CMakeLists.txt with differents dependencies?<br><br>Regards,<br>
Damien R.<br>