[CMake] CTest with multiple directories: problem with absolute paths
Tyler Roscoe
tyler at cryptio.net
Thu May 28 13:01:59 EDT 2009
Assume a project like this:
- top-level CMakeLists (calls add_subdirectory() on:)
- unittest CMakeLists where add_test() is called on a bunch of
unit tests in this directory
- (there are many pockets of unit tests in different unittest
directories.)
I want to be able to run ctest either from the unittest level, where it
will run just the unit tests in that directory; or from the top level,
where it will default to running all the unit tests in the system (but
where ctest may run a subset of all the unit tests as instructed by -R
or -E or -I).
Running at the unittest level already works.
To try to get it to work at the top level, the first thing I had to do
was enable_testing() in my top-level CMakeLists. Doing this caused CMake
to generate a CTestTestfile.cmake in my top-level binary directory.
CTestTestfile.cmake includes, among other things:
SUBDIRS(/path/to/unittest/_build/linux/debug)
Question 1: Why is CTestTestfile.cmake using the deprecated SUBDIRS()
command instead of add_subdirectory()?
Question 2: Why doesn't this work?
$ ctest
Start processing tests
Test project /path/to/toplevel/_build/linux/debug
No tests were found!!!
I have verified that all paths are correct and accessible.
Question 3: Why *does* it work if I switch to using relative paths
instead of absolute paths?
If I edit my CTestTestfile.cmake to instead use a relative path to that
same directory:
SUBDIRS(../../../../path/to/unittest/_build/linux/debug)
now it works great:
$ ctest
Start processing tests
Test project /path/to/toplevel/_build/linux/debug
1/ 7 Testing SomeTest Passed
2/ 7 Testing SomeTest Passed
3/ 7 Testing SomeTest Passed
4/ 7 Testing SomeTest Passed
5/ 7 Testing SomeTest Passed
6/ 7 Testing SomeTest Passed
7/ 7 Testing SomeTest Passed
100% tests passed, 0 tests failed out of 7
TIA,
tyler
More information about the CMake
mailing list