[CMake] Order of enable_testing and add_subdirectory
Marcel Loose
loose at astron.nl
Mon Feb 1 04:21:33 EST 2010
On Sun, 2010-01-31 at 01:20 +0000, Mateusz Loskot wrote:
> 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,
Hi Mateusz,
Yes, your conclusion is correct. I think the docs are clear about this.
>From the docs:
enable_testing: Enable testing for current directory and below.
add_test: Add a test to the project with the specified arguments.
If the ENABLE_TESTING command has been run, this command adds a test
target to the current directory. If ENABLE_TESTING has not been run,
this command does nothing.
So order *does* matter here.
Best regards,
Marcel Loose.
More information about the CMake
mailing list