Boost logo

Boost :

Subject: Re: [boost] [cmake] Pull request announcement
From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2018-09-17 12:30:48


> Out of curiosity, I looked at Hana and Yap as two examples that
> already have CMakeLists files and neither bothers to do so. Both
> assume that they are the project being built, and do not support
> add_subdirectory use.
What they do is they use "EXCLUDE_FROM_ALL" on all tests (checked Hana
only). This way tests are only build when requested explicitly. There is
a custom target called `tests` which builds all those tests. Hence you
do `make tests` to build them. Not sure how well this is handled by
"make test"/ctest though.

My proposal would be a check like
`if(CMAKE_SOURCE_DIR==PROJECT_SOURCE_DIR OR BOOST_BUILD_TESTS OR
BOOST_<LIBRARY> _BUILD_TESTS)`

> The two options I see for running the tests are

The tests should not have any dependencies above the library
dependencies. And even then they will be brought in by the
"top-top-level" CMakeLists (that does add_subdirectory on all libraries)
They can then be "just" used.

The cleaner approach is conditionally including the "tests" folder.
(Same for "docs" etc)

Besides that: Don't use upward-references ("../some/foo") but rather
e.g. "PROJECT_SOURCE_DIR" etc.




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk