How to run ctest after building my project with cmake

前端 未结 1 1294
一生所求
一生所求 2020-11-30 08:52

I want my tests to be launched each time my project is successfully built. And if some tests are broken I want my build to be broken too. By default I need to run tests manu

相关标签:
1条回答
  • 2020-11-30 09:13

    This form of add_custom_command will only execute if another CMake target has a dependency on "tests.txt". I assume that no other target has "tests.txt" as an input file, hence the custom command never runs.

    I think you could use the second form of add_custom_command to achieve your goal; something like:

    add_custom_command(TARGET MainTest
                       POST_BUILD
                       COMMAND ctest -C $<CONFIGURATION> --output-on-failure)
    
    0 讨论(0)
提交回复
热议问题