From e1aeef1543a31f197ba5968740763279e14d163b Mon Sep 17 00:00:00 2001 From: FrogTheFrog Date: Thu, 27 Jun 2024 12:41:35 +0300 Subject: [PATCH 1/3] fix: Boost is now properly found using find_package --- cmake/Boost_DD.cmake | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/cmake/Boost_DD.cmake b/cmake/Boost_DD.cmake index 6f60cd0..25a9711 100644 --- a/cmake/Boost_DD.cmake +++ b/cmake/Boost_DD.cmake @@ -4,25 +4,33 @@ # include_guard(GLOBAL) +# Limit boost to the required libraries only +set(REQUIRED_HEADER_LIBRARIES + algorithm + scope + preprocessor + uuid +) + find_package(Boost 1.85 QUIET GLOBAL) if(NOT Boost_FOUND) message(STATUS "Boost v1.85.x package not found in the system. Falling back to FetchContent.") include(FetchContent) - # Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24: - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") - cmake_policy(SET CMP0135 NEW) - endif() - - # Limit boost to the required libraries only - set(BOOST_INCLUDE_LIBRARIES - algorithm - scope - uuid) + set(BOOST_INCLUDE_LIBRARIES ${REQUIRED_HEADER_LIBRARIES}) FetchContent_Declare( Boost + DOWNLOAD_EXTRACT_TIMESTAMP URL https://github.com/boostorg/boost/releases/download/boost-1.85.0/boost-1.85.0-cmake.tar.xz URL_HASH MD5=BADEA970931766604D4D5F8F4090B176 ) FetchContent_MakeAvailable(Boost) +else() + # For whatever reason the Boost::headers from find_package is not the same as the one from FetchContent + # (differ in linked targets). + # Also, FetchContent creates Boost:: targets, whereas find_package does not. Since we cannot extend + # Boost::headers as it is an ALIAS target, this is the workaround: + foreach (HEADER_LIB ${REQUIRED_HEADER_LIBRARIES}) + add_library(Boost::${HEADER_LIB} ALIAS Boost::headers) + endforeach () endif() From 2ddb020a8d58d1788db15b73f17120b40f43c67b Mon Sep 17 00:00:00 2001 From: FrogTheFrog Date: Thu, 27 Jun 2024 16:22:22 +0300 Subject: [PATCH 2/3] meh --- cmake/Boost_DD.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Boost_DD.cmake b/cmake/Boost_DD.cmake index 25a9711..6c2bd2a 100644 --- a/cmake/Boost_DD.cmake +++ b/cmake/Boost_DD.cmake @@ -20,9 +20,9 @@ if(NOT Boost_FOUND) set(BOOST_INCLUDE_LIBRARIES ${REQUIRED_HEADER_LIBRARIES}) FetchContent_Declare( Boost - DOWNLOAD_EXTRACT_TIMESTAMP URL https://github.com/boostorg/boost/releases/download/boost-1.85.0/boost-1.85.0-cmake.tar.xz URL_HASH MD5=BADEA970931766604D4D5F8F4090B176 + DOWNLOAD_EXTRACT_TIMESTAMP ) FetchContent_MakeAvailable(Boost) else() From e0c5d6cb706695c84052dc09943e88bb97c12131 Mon Sep 17 00:00:00 2001 From: FrogTheFrog Date: Thu, 27 Jun 2024 16:46:10 +0300 Subject: [PATCH 3/3] meh 2 --- cmake/Boost_DD.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Boost_DD.cmake b/cmake/Boost_DD.cmake index 6c2bd2a..391cd30 100644 --- a/cmake/Boost_DD.cmake +++ b/cmake/Boost_DD.cmake @@ -30,7 +30,7 @@ else() # (differ in linked targets). # Also, FetchContent creates Boost:: targets, whereas find_package does not. Since we cannot extend # Boost::headers as it is an ALIAS target, this is the workaround: - foreach (HEADER_LIB ${REQUIRED_HEADER_LIBRARIES}) - add_library(Boost::${HEADER_LIB} ALIAS Boost::headers) + foreach (lib ${REQUIRED_HEADER_LIBRARIES}) + add_library(Boost::${lib} ALIAS Boost::headers) endforeach () endif()