]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake/modules/FindBoost: sync with upstream FindBoost.cmake
authorKefu Chai <tchaikov@gmail.com>
Mon, 30 Jun 2025 02:01:20 +0000 (10:01 +0800)
committerKefu Chai <tchaikov@gmail.com>
Mon, 30 Jun 2025 05:15:39 +0000 (13:15 +0800)
Update our local FindBoost.cmake module to match CMake upstream's
latest version to properly handle Boost component dependencies.

While commit b446290f prevented warnings when checking Boost 1.87,
it failed to update the boost component dependency mappings. This
change synchronizes our module with upstream to ensure correct
dependency resolution.

Additionally, this prepares for Boost 1.88.0 support (released
April 3, 2025) which some distributions have already adopted.
Since CMake upstream hasn't yet added 1.88 support, this sync
provides the foundation for adding 1.88.0 compatibility in a
subsequent commit.

Changes made:
- Sync with upstream CMake FindBoost.cmake (commit 17726227)
  (at https://github.com/Kitware/CMake/blob/1772622772133fad3b348ca4a5b4df3bbd69da75/Modules/FindBoost.cmake)
- Reapply local modifications from commit 06824bc1

Note: New dependencies can be scanned using:
```
cmake -DBOOST_DIR=/path/to/boost_1_88_0 -P
  Utilities/Scripts/BoostScanDeps.cmake
```

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
cmake: adapt FindBoost.cmake to our needs

the vanilla FindBoost.cmake pulled from cmake has couple assumptions
which do not hold in our environment. so address them case by case.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
cmake/modules/FindBoost.cmake

index 633900522b4f090f82a22987f6b8e1ab3fbeaa7d..d0a8dda9ccf7034e9ac399efce247730ed7eb591 100644 (file)
@@ -1,10 +1,15 @@
 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
+# file LICENSE.rst or https://cmake.org/licensing for details.
 
 #[=======================================================================[.rst:
 FindBoost
 ---------
 
+.. versionchanged:: 3.30
+  This module is available only if policy :policy:`CMP0167` is not set to
+  ``NEW``.  Port projects to upstream Boost's ``BoostConfig.cmake`` package
+  configuration file, for which ``find_package(Boost)`` now searches.
+
 Find Boost include dirs and libraries
 
 Use this module by invoking :command:`find_package` with the form:
@@ -379,6 +384,18 @@ the Boost CMake package configuration for details on what it provides.
 Set ``Boost_NO_BOOST_CMAKE`` to ``ON``, to disable the search for boost-cmake.
 #]=======================================================================]
 
+if(POLICY CMP0167)
+  cmake_policy(GET CMP0167 _FindBoost_CMP0167)
+  if(_FindBoost_CMP0167 STREQUAL "NEW")
+    message(FATAL_ERROR "The FindBoost module has been removed by policy CMP0167.")
+  endif()
+endif()
+
+if(_FindBoost_testing)
+  set(_FindBoost_included TRUE)
+  return()
+endif()
+
 # The FPHSA helper provides standard way of reporting final search results to
 # the user including the version and component checks.
 include(FindPackageHandleStandardArgs)
@@ -389,6 +406,9 @@ cmake_policy(SET CMP0057 NEW) # if IN_LIST
 if(POLICY CMP0102)
   cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var)
 endif()
+if(POLICY CMP0159)
+  cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
+endif()
 
 function(_boost_get_existing_target component target_var)
   set(names "${component}")
@@ -1380,7 +1400,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
       set(_Boost_TIMER_DEPENDENCIES chrono)
       set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic)
       set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
-    elseif(Boost_VERSION_STRING VERSION_LESS 1.84.0)
+    elseif(Boost_VERSION_STRING VERSION_LESS 1.87.0)
       set(_Boost_CONTRACT_DEPENDENCIES thread chrono)
       set(_Boost_COROUTINE_DEPENDENCIES context)
       set(_Boost_FIBER_DEPENDENCIES context)
@@ -1392,7 +1412,6 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
       set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
       set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
       set(_Boost_THREAD_DEPENDENCIES chrono atomic)
-      set(_Boost_TIMER_DEPENDENCIES chrono)
       set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic)
       set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
     else()
@@ -1401,7 +1420,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
       set(_Boost_FIBER_DEPENDENCIES context)
       set(_Boost_IOSTREAMS_DEPENDENCIES regex)
       set(_Boost_JSON_DEPENDENCIES container)
-      set(_Boost_LOG_DEPENDENCIES log_setup filesystem thread regex chrono atomic)
+      set(_Boost_LOG_DEPENDENCIES log_setup filesystem thread regex atomic)
       set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
       set(_Boost_MPI_DEPENDENCIES serialization)
       set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)