<div> </div><div> </div><div>07.08.2017, 20:50, "Clément Gregoire" <lectem@gmail.com>:</div><blockquote type="cite"><p>This is mainly why I started this thread, I want to know the best way to do this without using those variables.<br />CMAKE_lang_FLAGS is a pain as soon as someone wants to use add_subdirectory (be it to add an external project or your project being used in another) or a user wants to change the value. Those variables should really only be set by the toolchain file or from the command-line.</p></blockquote><div><br />There's ExternalProject for this purpose</div><div> </div><blockquote type="cite"><p>Other solutions were mentioned in my first mail, the easiest one being to add a new build type.<br />The other option is to uses something like a special script that will set those variables before your Cmakelists.txt (ie a toolchain file).<br /><br /> </p> <div><div>Le lun. 7 août 2017 à 17:22, Konstantin Tokarev <<a href="mailto:annulen@yandex.ru">annulen@yandex.ru</a>> a écrit :</div> <blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex;">07.08.2017, 17:24, "Clément Gregoire" <<a target="_blank" href="mailto:lectem@gmail.com">lectem@gmail.com</a>>:<br />>> I usually stop reading Cmakelists.txt as soon as I see this<br />>><br />>> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -pthread -g -O0<br />>> -fprofile-arcs -ftest-coverage")<br />>><br />>> The pthread thing there is likely wrong anyway, and the -Wall is entirely optional. The other things are needed, otherwise gcov will not produce any useful output.<br />><br />> I don't have an issue with the flags per se, but with the usage of set(CMAKE_CXX_FLAGS). Setting flags like that should be banned from modern cmake scripts.<br /><br />How can one set global compiler flags without use of CMAKE_CXX_FLAGS or setting flags for each individual target?<br /><br />><br />>> Also you need to use the SETUP_TARGET_FOR_COVERAGE for every single test<br />>> target, which seems to be a difficult to scale on big projects<br />>><br />>> No, you don't. It's entirely fine if you just run "make test" as I do in OSM2go.<br />> From what I saw in the documentation of the script :<br />><br />>> # Param _testrunner The name of the target which runs the tests<br />><br />> It seems to call directly the command named _testrunner, which is somehow confirmed from the cmakelists :<br />><br />>> # src/CMakelists.txt<br />>> add_executable(tests ${TEST_FILES})<br />>><br />>> # Linking up all libraries<br />>><br />>> target_link_libraries(tests complex)<br />>><br />>> add_test(NAME example_test COMMAND tests)<br />>> # CMakelists.txt<br />>> setup_target_for_coverage(${PROJECT_NAME}_coverage tests coverage)<br />> From this I deduce that you need to call setup_target_for_coverage for each different test executable.<br />><br />> <span>2017-08-07 13</span>:37 GMT+02:00 Rolf Eike Beer <<a target="_blank" href="mailto:eike@sf-mail.de">eike@sf-mail.de</a>>:<br />>> Am <span>2017-08-07 11</span>:06, schrieb Clément Gregoire:<br />>> I usually stop reading Cmakelists.txt as soon as I see this<br />>><br />>> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -pthread -g -O0<br />>> -fprofile-arcs -ftest-coverage")<br />>><br />>> The pthread thing there is likely wrong anyway, and the -Wall is entirely optional. The other things are needed, otherwise gcov will not produce any useful output.<br />>><br />>> Also you need to use the SETUP_TARGET_FOR_COVERAGE for every single test<br />>> target, which seems to be a difficult to scale on big projects<br />>><br />>> No, you don't. It's entirely fine if you just run "make test" as I do in OSM2go.<br />>><br />>> Eike<br />>> --<br />>><br />>> Powered by <a target="_blank" href="http://www.kitware.com/">www.kitware.com</a><br />>><br />>> Please keep messages on-topic and check the CMake FAQ at: <a target="_blank" href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><br />>><br />>> Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br />>><br />>> CMake Support: <a target="_blank" href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a><br />>> CMake Consulting: <a target="_blank" href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a><br />>> CMake Training Courses: <a target="_blank" href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/training.html</a><br />>><br />>> Visit other Kitware open-source projects at <a target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br />>><br />>> Follow this link to subscribe/unsubscribe:<br />>> <a target="_blank" href="http://public.kitware.com/mailman/listinfo/cmake">http://public.kitware.com/mailman/listinfo/cmake</a><br />> ,--<br />><br />> Powered by <a target="_blank" href="http://www.kitware.com/">www.kitware.com</a><br />><br />> Please keep messages on-topic and check the CMake FAQ at: <a target="_blank" href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><br />><br />> Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br />><br />> CMake Support: <a target="_blank" href="http://cmake.org/cmake/help/support.html">http://cmake.org/cmake/help/support.html</a><br />> CMake Consulting: <a target="_blank" href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a><br />> CMake Training Courses: <a target="_blank" href="http://cmake.org/cmake/help/training.html">http://cmake.org/cmake/help/training.html</a><br />><br />> Visit other Kitware open-source projects at <a target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br />><br />> Follow this link to subscribe/unsubscribe:<br />> <a target="_blank" href="http://public.kitware.com/mailman/listinfo/cmake">http://public.kitware.com/mailman/listinfo/cmake</a><br /><br /><br />-- <br />Regards,<br />Konstantin</blockquote></div></blockquote><div> </div><div> </div><div>-- <br />Regards,</div><div>Konstantin</div><div> </div>