pfultz2 / cget

C++ package retrieval
http://cget.readthedocs.io
Other
453 stars 27 forks source link

'--test' flag does not run the 'check' target? #66

Open thoughton opened 6 years ago

thoughton commented 6 years ago

Hi,

It's possible that I'm just misunderstanding the documentation here, but in the docs it says that using the --test flag on the build command wil make cget "try to run the check target" after building.

Does this mean that it will try to execute the resulting executable that is generated from building the check target? If so, this does not seem to happen.

Or am I misunderstanding and the docs mean something else by saying it will "run" the target?

Thanks!

pfultz2 commented 6 years ago

Sorry for the late reply. I think maybe the documentation could be worded better. By running a target, it means it invokes the target with make check. It wont run the executables created, to do that you need to have check be a custom target that runs the executable, and then make the building of the executables dependent on the target.

Although with cmake you can run the test executables with add_test. And then have the check target run ctest:

add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR})

For every executable you add you will need to make it dependent on the check target:

add_executable(main_test main.cpp)
add_dependencies(check main_test)

Alternatively, you can just add test executables to the main build when BUILD_TESTING=On and then do add_test to run them and cget will invoke ctest for you when using --test.