@@ -31,14 +31,27 @@ endif()
31
31
32
32
set (BOOST_COMPONENTS "filesystem;unit_test_framework;program_options;system" )
33
33
34
+ # CMake >= 3.30 should not use the vendored boost
35
+ if (POLICY CMP0167 )
36
+ cmake_policy (SET CMP0167 NEW )
37
+ endif ()
34
38
if (WIN32 )
35
39
# Boost 1.77 fixes a bug that causes crashes on Windows for some relative paths in --allow-paths.
36
40
# See https://github.com/boostorg/filesystem/issues/201
37
41
find_package (Boost 1.77.0 QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
38
42
else ()
39
43
# Boost 1.65 is the first to also provide boost::get for rvalue-references (#5787).
40
44
# Boost 1.67 moved container_hash into is own module.
41
- find_package (Boost 1.67.0 QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
45
+ # Boost 1.70 comes with its own BoostConfig.cmake and is the new (non-deprecated) behavior
46
+ find_package (Boost 1.70.0 QUIET COMPONENTS ${BOOST_COMPONENTS} )
47
+ if (NOT ${Boost_FOUND} )
48
+ # If the boost version is < 1.70.0, there is no boost config delivered with it, revert to old behavior
49
+ # todo drop this once cmake minimum version >= 3.30 is reached
50
+ if (POLICY CMP0167 )
51
+ cmake_policy (SET CMP0167 OLD )
52
+ endif ()
53
+ find_package (Boost 1.67.0 QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
54
+ endif ()
42
55
endif ()
43
56
44
57
# If cmake is older than boost and boost is older than 1.70,
@@ -49,8 +62,7 @@ if (NOT TARGET Boost::boost) # header only target
49
62
add_library (Boost::boost INTERFACE IMPORTED )
50
63
set_property (TARGET Boost::boost APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS} )
51
64
endif ()
52
- get_property (LOCATION TARGET Boost::boost PROPERTY INTERFACE_INCLUDE_DIRECTORIES )
53
- message (STATUS "Found Boost headers in ${LOCATION} " )
65
+ message (STATUS "Found Boost ${Boost_VERSION} headers in ${Boost_INCLUDE_DIRS} " )
54
66
55
67
foreach (BOOST_COMPONENT IN LISTS BOOST_COMPONENTS )
56
68
if (NOT TARGET Boost::${BOOST_COMPONENT} )
0 commit comments