[CMake] Run the tests in an installed tree on another machine

Samuel Loury konubinix at gmail.com
Wed Jun 20 08:46:30 EDT 2012


A non-text attachment was scrubbed...
Name: cmake_install_example.tar.gz
Type: application/octet-stream
Size: 1529 bytes
Desc: cmake install example
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120620/963eacd3/attachment-0001.obj>
-------------- next part --------------
Hi,
   My purpose is to create a package that contains tests validating that
it works well out of the box.
I looked into the mailing list, the documentation, the web in general
and I did not find any relevant way of doing this.

Testing in the build tree is nice, but the fact that the tests pass on
here do not imply the package will be good: some files may be missing in
the package, the rpath are stripped, etc.  For that reason, I would like
to be able to run ctest on the installed package.

The problems I listed are:
 A- the binaries must be retrieved in the install tree
 B- the tests must be shipped with the package
 C- not all the tests should be exported because some are specific to
    the build tree (test that the install passed for instance is not
    needed in the installed package)

For A, I found out the install(EXPORT command would be useful to get the
paths of the targets.

For B and C, I guessed of some solutions, but no one was good enough:
1. the generated CTestTestfile.cmake could be used, but in this file the
   paths are absolute and the targets are not taken into account. For
   instance, from a test like
     add_test(NAME MyTest COMMAND main),
   the content of the CTestTestfile.cmake would be
     add_test(MyTest /home/.../main)
   and in this form, it is not directly exploitable anywhere.  Moreover,
   I should parse it anyway to remove the not wanted tests.

2. at the end of the CMakeLists.cmake of the project, I could gather all
   the tests that have been added and write down a file like
   CTestTestfile.cmake. This does not work for tests added in sub
   directories because the content of the tests and their properties are
   forgotten when going back to the parent directory.

3. wrap add_test and set_tests_properties into custom macros that write
   down files that look like the CTestTestfile.cmake, but with the good
   form. IMHO, This seems to be the better choice.

I have implemented the third solution to illustrate what I said. It is
attached with the mail.

Is there a solution more CMake-ish to do that? Is there any better
solution?

Samuel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120620/963eacd3/attachment-0001.pgp>


More information about the CMake mailing list