<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>OK, so I guess there is no way to do that like with autotools...<br></div><div><br></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>De: </b>"Franck Houssen" <franck.houssen@inria.fr><br><b>À: </b>"CMake Mail List" <cmake@cmake.org><br><b>Envoyé: </b>Mercredi 10 Janvier 2018 12:22:39<br><b>Objet: </b>Re: [CMake] test depending on code compilation<br><div><br></div><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000" data-mce-style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000;"><div>I tried to reduce the example:<br></div><div><br></div><div>>> ls<br>CMakeLists.txt  main.cpp  mytest.cpp  mytest.sh<br><div><br></div></div><div>>> more *<br>::::::::::::::<br>CMakeLists.txt<br>::::::::::::::<br>cmake_minimum_required(VERSION 3.7)<br>enable_language(CXX)<br><div><br></div>project(main)<br>add_executable(main main.cpp)<br>add_executable(mytestcpp mytest.cpp)<br><div><br></div>include(CTest)<br>enable_testing()<br>configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mytest.sh" "${CMAKE_CURRENT_BINARY_DIR}/mytest.sh")<br>add_test(NAME mytestsh COMMAND ./mytest.sh WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")<br><div><br></div>add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS mytestcpp)<br>::::::::::::::<br>main.cpp<br>::::::::::::::<br>int main() {return 0;}<br>::::::::::::::<br>mytest.cpp<br>::::::::::::::<br>int main() {return 0;}<br>::::::::::::::<br>mytest.sh<br>::::::::::::::<br>#!/bin/bash<br>exit 0<br><div><br></div></div><div>I want make to build only main => KO<br></div><div>>> make<br>[ 50%] Built target main<br>[100%] Built target mytestcpp<br><div><br></div></div><div><div>I want make check to build mytestcpp and run tests => OK but verbose is KO.</div><div>>> make check ARGS="-V"<br>[100%] Built target mytestcpp<br>Test project /tmp/BUILD<br>    Start 1: mytestsh<br>1/1 Test #1: mytestsh .........................   Passed    0.00 sec<br><div><br></div></div></div><div><div>I want make test to run test only => OK and verbose is OK.</div><div><br></div></div><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><b>De: </b>"Franck Houssen" <franck.houssen@inria.fr><br><b>À: </b>"CMake Mail List" <cmake@cmake.org><br><b>Envoyé: </b>Mercredi 10 Janvier 2018 10:47:34<br><b>Objet: </b>[CMake] test depending on code compilation<br><div><br></div><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000" data-mce-style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000;"><div>I need to design a test (= a bash script) such that :</div><div>1) run a dedicated executable for the test (to be compiled)</div><div>2) diff the run output with a reference log file<br></div><div><br></div><div>The test is created with : add_test(mytest ./mytest.sh). The bash script would look like:<br></div><div>>> more mytest.sh<br></div><div>/path/to/mytestexe > out.log<br></div><div>diff out.log out.ref<br></div><div><br></div><div>The dedicated executable for the test is created with : add_executable(mytestexe mytestexe.cpp)<br></div><div><br></div><div>Ideally, I would like mytestexe to be compiled when I type "make test" (before to run the test) but not "make".<br></div><div><br></div><div>Seems impossible to add a dependencie with : add_dependencies(mytest mytestexe). I googled this and found <a href="https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests" target="_blank" data-mce-href="https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests">https://stackoverflow.com/questions/733475/cmake-ctest-make-test-doesnt-build-tests</a> but this was not really clear to me...I added : add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS mytestexe).<br></div><div><br></div><div>The 2 unexpected problems I have left are:<br></div><div>1) mytestexe is compiled everytime I type "make" which is a solution but is not really what I am looking for (also compiled when I type "make check" which is expected).</div><div>    => is there a way for make not to compile mytestexe (note I didn't added ALL in add_custom_target so I am not sure to know why make builds mytestexe)<br></div><div>2) Also the verbosity is broken with check : make test ARGS="-V" is verbose , but, make check ARGS="-V" is not.<br></div><div>    => how to deal with that ?<br></div></div><br>-- <br><div><br></div>Powered by www.kitware.com<br><div><br></div>Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ<br><div><br></div>Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br><div><br></div>CMake Support: http://cmake.org/cmake/help/support.html<br>CMake Consulting: http://cmake.org/cmake/help/consulting.html<br>CMake Training Courses: http://cmake.org/cmake/help/training.html<br><div><br></div>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<br><div><br></div>Follow this link to subscribe/unsubscribe:<br>https://cmake.org/mailman/listinfo/cmake<br></blockquote><div><br></div></div><br>-- <br><div><br></div>Powered by www.kitware.com<br><div><br></div>Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ<br><div><br></div>Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br><div><br></div>CMake Support: http://cmake.org/cmake/help/support.html<br>CMake Consulting: http://cmake.org/cmake/help/consulting.html<br>CMake Training Courses: http://cmake.org/cmake/help/training.html<br><div><br></div>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<br><div><br></div>Follow this link to subscribe/unsubscribe:<br>https://cmake.org/mailman/listinfo/cmake<br></blockquote><div><br></div></div></body></html>