From 81600602e315f713fc56644f8415107bd3348f26 Mon Sep 17 00:00:00 2001 From: zhangyi1357 <34409786+zhangyi1357@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:23:01 +0800 Subject: [PATCH] build: simplify Boost fetching logic (#26) Streamline the process of finding and downloading Boost by removing unnecessary checks and consolidating the logic, making it easier to manage and maintain dependencies. --- cmake/GetBoost.cmake | 60 +++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/cmake/GetBoost.cmake b/cmake/GetBoost.cmake index bf82dc170..bcf4b1502 100644 --- a/cmake/GetBoost.cmake +++ b/cmake/GetBoost.cmake @@ -3,46 +3,32 @@ include(FetchContent) -message(STATUS "Searching for Boost...") +message(STATUS "get boost...") -set(BOOST_VERSION 1.82.0) set(boost_DOWNLOAD_URL - "https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}.tar.xz" + "https://github.com/boostorg/boost/releases/download/boost-1.82.0/boost-1.82.0.tar.xz" CACHE STRING "") -find_package(Boost ${BOOST_VERSION} QUIET) - -if(Boost_FOUND) - if(Boost_VERSION VERSION_EQUAL ${BOOST_VERSION}) - message(STATUS "Found compatible Boost version ${Boost_VERSION}") - else() - message(WARNING "Found newer Boost version ${Boost_VERSION}. Using local version, but this may cause issues.") - endif() +if(boost_LOCAL_SOURCE) + FetchContent_Declare( + boost + SOURCE_DIR ${boost_LOCAL_SOURCE} + OVERRIDE_FIND_PACKAGE) else() - message(STATUS "Boost ${BOOST_VERSION} or greater not found locally. Downloading Boost ${BOOST_VERSION}") - - if(boost_LOCAL_SOURCE) - FetchContent_Declare( - boost - SOURCE_DIR ${boost_LOCAL_SOURCE} - OVERRIDE_FIND_PACKAGE) - message(STATUS "Using local Boost source") - else() - FetchContent_Declare( - boost - URL ${boost_DOWNLOAD_URL} - DOWNLOAD_EXTRACT_TIMESTAMP ON - OVERRIDE_FIND_PACKAGE) - endif() - - FetchContent_GetProperties(boost) - if(NOT boost_POPULATED) - set(BOOST_INCLUDE_LIBRARIES asio beast) - - set(Boost_USE_STATIC_LIBS - ON - CACHE BOOL "") - - FetchContent_MakeAvailable(boost) - endif() + FetchContent_Declare( + boost + URL ${boost_DOWNLOAD_URL} + DOWNLOAD_EXTRACT_TIMESTAMP ON + OVERRIDE_FIND_PACKAGE) +endif() + +FetchContent_GetProperties(boost) +if(NOT boost_POPULATED) + set(BOOST_INCLUDE_LIBRARIES asio beast) + + set(Boost_USE_STATIC_LIBS + ON + CACHE BOOL "") + + FetchContent_MakeAvailable(boost) endif()