[CMake] Testing an installation

clinton at elemtech.com clinton at elemtech.com
Tue Dec 3 08:56:45 EST 2013


----- Original Message -----
> I need to implement a "test" that does an installation of my project into a
> location and then check that all the files indeed got installed or if there
> are any errors during the installation. Is there a "best practice" way of
> achieving this with CMake? Does CMake itself do something like this in their
> own test suite?
> 

I'm not sure if there is a best practice for this, but I make a test like this:
add_test(package ${CMAKE_CPACK_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE} --config "${CMAKE_BINARY_DIR}/CPackConfig.cmake")

With it being verbose (-V), I can get extra information to show up on cdash in case there are problems.

I also have additional install commands
install(CODE/SCRIPT ...)
to check if the installation is OK.  That includes things like BundleUtilities, and a test run of the program.

Clint


More information about the CMake mailing list