diff --git a/CMakeLists.txt b/CMakeLists.txt index 1607cfcb9..1502787ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ option(TTG_EXAMPLES "Whether to build examples" OFF) option(TTG_ENABLE_ASAN "Whether to enable address sanitizer" OFF) option(TTG_FETCH_BOOST "Whether to fetch+build Boost, if missing" OFF) -option(TTG_IGNORE_BUNDLED_EXTERNALS "Whether to skip installation and use of bundled external depenedencies (Boost.CallableTraits)" OFF) +option(TTG_IGNORE_BUNDLED_EXTERNALS "Whether to skip installation and use of bundled external dependencies (Boost.CallableTraits)" OFF) option(TTG_ENABLE_TRACE "Whether to enable ttg::trace() output" OFF) # See https://medium.com/@alasher/colored-c-compiler-output-with-ninja-clang-gcc-10bfe7f2b949 option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." TRUE) diff --git a/cmake/modules/ExternalDependenciesVersions.cmake b/cmake/modules/ExternalDependenciesVersions.cmake index b3d7c8e55..d4bc3bea5 100644 --- a/cmake/modules/ExternalDependenciesVersions.cmake +++ b/cmake/modules/ExternalDependenciesVersions.cmake @@ -3,7 +3,7 @@ # need Boost.CallableTraits (header only, part of Boost 1.66 released in Dec 2017) for wrap.h to work set(TTG_TRACKED_BOOST_VERSION 1.66) -set(TTG_TRACKED_VG_CMAKE_KIT_TAG d5c0a6f9ff6dc97cbb5132912733e1eb1cf73f1e) # used to provide "real" FindOrFetchBoost +set(TTG_TRACKED_VG_CMAKE_KIT_TAG 7ea2d4d3f8854b9e417f297fd74d6fc49aa13fd5) # used to provide "real" FindOrFetchBoost set(TTG_TRACKED_CATCH2_VERSION 3.5.0) set(TTG_TRACKED_CEREAL_VERSION 1.3.0) set(TTG_TRACKED_MADNESS_TAG 8788aea9758bfe6479cc23d39e6c77b7528009db) diff --git a/cmake/modules/FindOrFetchBoost.cmake b/cmake/modules/FindOrFetchBoost.cmake index ed1fc9b2a..dc1a0a654 100644 --- a/cmake/modules/FindOrFetchBoost.cmake +++ b/cmake/modules/FindOrFetchBoost.cmake @@ -1,15 +1,31 @@ # Boost can be discovered by every (sub)package but only the top package can *build* it ... -# in either case must declare the components used by TA +# in either case must declare the components used by TTG set(required_components headers callable_traits ) +set(optional_components +) if (TTG_PARSEC_USE_BOOST_SERIALIZATION) - list(APPEND required_components + list(APPEND optional_components serialization iostreams ) endif() + +# if not allowed to fetch Boost make all Boost optional +if (NOT DEFINED Boost_FETCH_IF_MISSING AND TTG_FETCH_BOOST) + set(Boost_FETCH_IF_MISSING 1) +endif() +if (NOT Boost_FETCH_IF_MISSING) + foreach(__component IN LISTS required_components) + list(APPEND optional_components + ${__component} + ) + endforeach() + set(required_components ) +endif() + if (DEFINED Boost_REQUIRED_COMPONENTS) list(APPEND Boost_REQUIRED_COMPONENTS ${required_components}) @@ -17,8 +33,6 @@ if (DEFINED Boost_REQUIRED_COMPONENTS) else() set(Boost_REQUIRED_COMPONENTS "${required_components}" CACHE STRING "Components of Boost to discovered or built") endif() -set(optional_components -) if (DEFINED Boost_OPTIONAL_COMPONENTS) list(APPEND Boost_OPTIONAL_COMPONENTS ${optional_components} @@ -28,10 +42,6 @@ else() set(Boost_OPTIONAL_COMPONENTS "${optional_components}" CACHE STRING "Optional components of Boost to discovered or built") endif() -if (NOT DEFINED Boost_FETCH_IF_MISSING AND TTG_FETCH_BOOST) - set(Boost_FETCH_IF_MISSING 1) -endif() - # Bring ValeevGroup cmake toolkit, if not yet available if (NOT DEFINED vg_cmake_kit_SOURCE_DIR) include(FetchContent) @@ -53,3 +63,6 @@ if (NOT DEFINED vg_cmake_kit_SOURCE_DIR) endif() include(${vg_cmake_kit_SOURCE_DIR}/modules/FindOrFetchBoost.cmake) +if (TARGET Boost::headers) + set(TTG_HAS_BOOST 1) +endif() diff --git a/cmake/ttg-config.cmake.in b/cmake/ttg-config.cmake.in index 41663c806..82f7c2ae6 100644 --- a/cmake/ttg-config.cmake.in +++ b/cmake/ttg-config.cmake.in @@ -6,11 +6,10 @@ set(TTG_EXT_VERSION "@TTG_EXT_VERSION@") set(PaRSEC_CONFIG "@PaRSEC_CONFIG@") set(MADNESS_CONFIG "@MADNESS_CONFIG@") -set(Boost_CONFIG "@Boost_CONFIG@") set(CXX_COROUTINE_COMPONENT "@CXX_COROUTINE_COMPONENT@") set(TTG_TRACKED_BOOST_VERSION "@TTG_TRACKED_BOOST_VERSION@") - +set(TTG_HAS_BOOST @TTG_HAS_BOOST@) set(TTG_IGNORE_BUNDLED_EXTERNALS @TTG_IGNORE_BUNDLED_EXTERNALS@) # make TTG CMake modules discoverable + load AddTTGExecutable by default @@ -19,6 +18,10 @@ include(AddTTGExecutable) @PACKAGE_INIT@ +if (TTG_HAS_BOOST) +@Boost_CONFIG_FILE_CONTENTS@ +endif(TTG_HAS_BOOST) + if (NOT TARGET MADworld AND MADNESS_CONFIG) get_filename_component(MADNESS_CONFIG_DIR "${MADNESS_CONFIG}" DIRECTORY) find_package(MADNESS 0.10.1 CONFIG QUIET REQUIRED COMPONENTS world PATHS "${MADNESS_CONFIG_DIR}" NO_DEFAULT_PATH) @@ -29,12 +32,6 @@ if (NOT TARGET PaRSEC::parsec AND PaRSEC_CONFIG) find_package(PaRSEC CONFIG QUIET REQUIRED COMPONENTS parsec PATHS "${PaRSEC_CONFIG_DIR}" NO_DEFAULT_PATH) endif() -# if Boost was discovered and used at TTG configure time discover Boost at the same path -if (NOT TARGET Boost::boost AND Boost_CONFIG) - get_filename_component(Boost_CONFIG_DIR "${Boost_CONFIG}" DIRECTORY) - find_package(Boost ${TTG_TRACKED_BOOST_VERSION} CONFIG QUIET REQUIRED OPTIONAL_COMPONENTS serialization PATHS "${Boost_CONFIG_DIR}" NO_DEFAULT_PATH) -endif() - # if C++ coroutines were used discover same version of them if (NOT TARGET std::coroutine AND CXX_COROUTINE_COMPONENT) find_package(CXXStdCoroutine MODULE QUIET REQUIRED COMPONENTS "${CXX_COROUTINE_COMPONENT}") @@ -48,13 +45,4 @@ if(NOT TARGET ttg) endif() endif() -# if don't have Boost, use bundled Boost.CallableTraits -if (NOT TARGET Boost::boost) - if (TTG_IGNORE_BUNDLED_EXTERNALS) - find_package(Boost ${TTG_TRACKED_BOOST_VERSION} QUIET REQUIRED) - else() - target_compile_definitions(ttg INTERFACE TTG_USE_BUNDLED_BOOST_CALLABLE_TRAITS=1) - endif() -endif() - set(TTG_FOUND TRUE) diff --git a/ttg/CMakeLists.txt b/ttg/CMakeLists.txt index 5d40c5b20..307135ca0 100644 --- a/ttg/CMakeLists.txt +++ b/ttg/CMakeLists.txt @@ -101,8 +101,10 @@ if (TARGET Boost::headers) list(APPEND ttg-deps Boost::headers) endif() else () # if Boost::headers is missing must use bundled Boost.CallableTraits - list(APPEND ttg-defs "$") - list(APPEND ttg-incs "$") + list(APPEND ttg-defs "TTG_USE_BUNDLED_BOOST_CALLABLE_TRAITS=1") + list(APPEND ttg-incs + "$" + "$") endif () if (TARGET TTG_Libunwind) list(APPEND ttg-deps TTG_Libunwind)