diff --git a/CMakeLists.txt b/CMakeLists.txt index fd22abdb..b5b2a5c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,7 +164,20 @@ endif() find_package(absl REQUIRED) # Boost setup. -include(ObakeFindBoost) +# NOTE: stacktrace available since 1.65.0. +set(_OBAKE_MIN_BOOST_VERSION "1.69") +# NOTE: we look for Boost in CONFIG mode first, as that has become the official supported way +# of locating Boost in recent Boost/CMake versions. If we fail, we try again in +# MODULE mode as last resort. +find_package(Boost ${_OBAKE_MIN_BOOST_VERSION} QUIET COMPONENTS serialization CONFIG) +if(NOT ${Boost_FOUND}) + message(STATUS "Boost not found in CONFIG mode, retrying in MODULE mode.") + find_package(Boost ${_OBAKE_MIN_BOOST_VERSION} QUIET MODULE COMPONENTS serialization) +endif() +if(NOT ${Boost_FOUND}) + message(FATAL_ERROR "Could not locate Boost in either CONFIG or MODULE mode.") +endif() +message(STATUS "Found Boost version ${Boost_VERSION}.") # libbacktrace. if(OBAKE_WITH_LIBBACKTRACE) @@ -421,7 +434,6 @@ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindDbgEng.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindTBB.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Findlibbacktrace.cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ObakeFindBoost.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ObakeFindDl.cmake" DESTINATION "${OBAKE_INSTALL_LIBDIR}/cmake/obake") install(EXPORT obake_export NAMESPACE obake:: DESTINATION "${OBAKE_INSTALL_LIBDIR}/cmake/obake") diff --git a/cmake/ObakeFindBoost.cmake b/cmake/ObakeFindBoost.cmake deleted file mode 100644 index adf995e2..00000000 --- a/cmake/ObakeFindBoost.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# NOTE: stacktrace available since 1.65.0. -set(_OBAKE_BOOST_MINIMUM_VERSION 1.65.0) -find_package(Boost ${_OBAKE_BOOST_MINIMUM_VERSION} REQUIRED COMPONENTS serialization) - -message(STATUS "Detected Boost version: ${Boost_VERSION}") -message(STATUS "Boost include dirs: ${Boost_INCLUDE_DIRS}") - -# Might need to recreate targets if they are missing (e.g., older CMake versions). -if(NOT TARGET Boost::boost) - message(STATUS "The 'Boost::boost' target is missing, creating it.") - add_library(Boost::boost INTERFACE IMPORTED) - set_target_properties(Boost::boost PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}") -endif() - -if(NOT TARGET Boost::serialization) - message(STATUS "The 'Boost::serialization' imported target is missing, creating it.") - add_library(Boost::serialization UNKNOWN IMPORTED) - set_target_properties(Boost::serialization PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}" - ) - set_target_properties(Boost::serialization PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${Boost_SERIALIZATION_LIBRARY}" - ) -endif() - -if(NOT TARGET Boost::disable_autolinking) - message(STATUS "The 'Boost::disable_autolinking' target is missing, creating it.") - add_library(Boost::disable_autolinking INTERFACE IMPORTED) - if(WIN32) - set_target_properties(Boost::disable_autolinking PROPERTIES INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB") - endif() -endif() - -unset(_OBAKE_BOOST_MINIMUM_VERSION) diff --git a/obake-config.cmake.in b/obake-config.cmake.in index d34a80b8..e0917c0d 100644 --- a/obake-config.cmake.in +++ b/obake-config.cmake.in @@ -9,7 +9,6 @@ if(${mp++_VERSION} VERSION_LESS @_OBAKE_MIN_MPPP_VERSION@) message(FATAL_ERROR "The minimum mp++ version required by obake is @_OBAKE_MIN_MPPP_VERSION@, but version ${mp++_VERSION} was found instead.") endif() find_package(absl REQUIRED) -include(ObakeFindBoost) # TBB. Try to find it first in config mode (supported # since version 2021 after the oneTBB rename), and, if this # fails, fall back to our own FindTBB.cmake. This is of course