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.