<div dir="auto">Afaik, Ctest should be run in the build directory. From your command it seems you run it in the source. I'm not surprised it doesn't work.<div dir="auto"><br></div><div dir="auto">Edo</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Oct 28, 2017 6:59 AM, "Maarten Anonymous" <<a href="mailto:anonymous.maarten@gmail.com">anonymous.maarten@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey,<br><br>I have a question about using CMake+CTest+CTest scripts for coverage tests.<br><br>If I manually build the project and run "make ExperimantalCoverage" in a build folder,<br>the coverage succeeds.<br>If I run the coverage from within a CTest script,<br>it fails.<br><br>Am I forgetting something?<div><br></div><div>A minimum example that exhibits my problem can be found at <a href="https://gist.github.com/madebr/07ebd0de59e789cd819643b58db25df9" target="_blank">https://gist.github.com/<wbr>madebr/<wbr>07ebd0de59e789cd819643b58db25d<wbr>f9</a>.</div><div><br></div><div>This works:</div><div>mkdir build && cd build && cmake .. && make && make test && make ExperimentalCoverage && cd ..<br></div><div>This fails:</div><div>ctest -S test.ctest<br></div><div><br>Source listing:<div>###################</div><div>#CMakeLists.txt:</div><div>###################<br><div><div>cmake_minimum_required(VERSION 3.9)</div><div>project(cmake_coverage)</div><div><br></div><div>file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/<wbr>main.c" "int main() {return 0;}")</div><div><br></div><div>add_executable(main</div><div>    main.c</div><div>    )</div><div><br></div><div>target_compile_options(main</div><div>    PUBLIC</div><div>        "-O0"</div><div>        "-fprofile-arcs"</div><div>        "-ftest-coverage"</div><div>    )</div><div><br></div><div>target_link_libraries(main</div><div>    gcov</div><div>    )</div><div><br></div><div>include(CTest)</div><div>enable_testing()</div><div><br></div><div>add_test(NAME test</div><div>    COMMAND main</div><div>    )</div></div><div><br></div><div>##############</div><div># test.ctest:</div><div>##############<br></div><div><div>set(CTEST_SOURCE_DIRECTORY "${CTEST_SCRIPT_DIRECTORY}")</div><div>set(CTEST_BINARY_DIRECTORY "${CTEST_SCRIPT_DIRECTORY}/<wbr>build/ctest")</div><div><br></div><div>ctest_empty_binary_directory("<wbr>${CTEST_BINARY_DIRECTORY}")</div><div><br></div><div>set(CTEST_SITE "${CMAKE_SYSTEM_NAME}")</div><div>set(CTEST_BUILD_NAME "experimental build")</div><div><br></div><div>set(CTEST_CMAKE_GENERATOR "Ninja")</div><div>set(CTEST_COVERAGE_COMMAND "gcov")</div><div><br></div><div>ctest_start("Experimental")</div><div>ctest_configure()</div><div>ctest_build()</div><div>ctest_test()</div><div>ctest_coverage()</div><div><div><br class="m_4158230757402375609gmail-Apple-interchange-newline">##############</div><div># CTestConfig.cmake:</div><div>##############</div></div></div><div>set(CTEST_PROJECT_NAME "Simple ctest_coverage project")<br></div><div><br></div><div><br></div></div></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/<wbr>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 href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/cmake</a><br></blockquote></div></div>