[CMake] Order of enable_testing and add_subdirectory

Mateusz Loskot mateusz at loskot.net
Sat Jan 30 20:20:17 EST 2010


Hi,

I have just learned by trial and error that enable_testing()
macro should be called before a subdirector(y|ies) with tests
are added, otherwise tests are not configured.

Here is a bit of CMakeLists.txt in root directory of my project

1) This option works properly

enable_testing()
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(tests) # Here are my tests

2) This does not configure any tests

add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(tests) # Here are my tests
enable_testing()

and make test or ctest -N does not show anything but message like:

Running tests...
Test project /home/mloskot/dev/geos/_svn/build
No tests were found!!!


Is my conclusion correct, that the order of enable_testing and
add_subdirectory is relevant?
If it is, perhaps it would be good to update the manual
appropriate note on how things in the CMakeLists.txt are being processed.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org


More information about the CMake mailing list