diff --git a/CMake/BoostCore.cmake b/CMake/BoostCore.cmake index c714b0d7d..a25c01425 100644 --- a/CMake/BoostCore.cmake +++ b/CMake/BoostCore.cmake @@ -313,7 +313,20 @@ macro(boost_library_project LIBNAME) if(BUILD_TESTING AND THIS_PROJECT_TESTDIRS) # Testing is enabled globally and this project has some - # tests. So, include the tests + # tests. Check whether we should include these tests. + if (BOOST_TEST_LIBRARIES) + set(SAVED_TESTDIRS ${THIS_PROJECT_TESTDIRS}) + set(THIS_PROJECT_TESTDIRS) + foreach (TESTLIB ${BOOST_TEST_LIBRARIES}) + if (${TESTLIB} STREQUAL ${libname}) + # We are allowed to test this library; restore the set of + # test directories for this library. + set(THIS_PROJECT_TESTDIRS ${SAVED_TESTDIRS}) + endif() + endforeach () + endif() + + # Include the test directories. foreach(SUBDIR ${THIS_PROJECT_TESTDIRS}) add_subdirectory(${SUBDIR}) endforeach() diff --git a/CMake/BoostTesting.cmake b/CMake/BoostTesting.cmake index 8567430f1..1afdfbd73 100644 --- a/CMake/BoostTesting.cmake +++ b/CMake/BoostTesting.cmake @@ -43,6 +43,9 @@ if (BUILD_TESTING) enable_testing() option(TEST_INSTALLED_TREE "Enable testing of an already-installed tree" OFF) + + set(BOOST_TEST_LIBRARIES "" + CACHE STRING "Semicolon-separated list of Boost libraries to test") if (TEST_INSTALLED_TREE) include("${CMAKE_INSTALL_PREFIX}/lib/Boost${BOOST_VERSION}/boost-targets.cmake")