@@ -4,6 +4,20 @@ if (MSVC)
44 add_compile_options (-wd5045) #Disable warning about Spectre mitigation
55endif ()
66
7+ function (add_subdirectory_compat)
8+ #
9+ # This is for CMake 4.0 compatibility.
10+ #
11+ # CMake 4.0 drops support CMake policies below 3.5 and some of our dependencies
12+ # declare their minimum required version as 3.4, and CMake 4.0 is not happy
13+ # with that. The CMAKE_POLICY_VERSION_MINIMUM option allows us to override that
14+ # without having to touch the dependency's source code.
15+ #
16+ # https://cmake.org/cmake/help/latest/variable/CMAKE_POLICY_VERSION_MINIMUM.html
17+ set (CMAKE_POLICY_VERSION_MINIMUM 3.5)
18+ add_subdirectory (${ARGV} )
19+ endfunction ()
20+
721# Generates gRPC and protobuf C++ sources and headers from the given .proto files
822#
923# generate_grpc_cpp (<SRCS> <DEST> [<ARGN>...])
@@ -61,7 +75,7 @@ option(YAML_CPP_BUILD_TOOLS OFF)
6175option (YAML_CPP_BUILD_CONTRIB OFF )
6276option (YAML_CPP_BUILD_TESTS OFF )
6377
64- add_subdirectory (yaml-cpp EXCLUDE_FROM_ALL )
78+ add_subdirectory_compat (yaml-cpp EXCLUDE_FROM_ALL )
6579set_target_properties (yaml-cpp PROPERTIES POSITION_INDEPENDENT_CODE ON )
6680
6781add_library (yaml INTERFACE )
@@ -94,7 +108,7 @@ target_compile_definitions(scope_guard INTERFACE
94108 SG_REQUIRE_NOEXCEPT_IN_CPP17)
95109
96110# semver library
97- add_subdirectory (semver EXCLUDE_FROM_ALL )
111+ add_subdirectory_compat (semver EXCLUDE_FROM_ALL )
98112target_include_directories (semver INTERFACE
99113 ${CMAKE_CURRENT_SOURCE_DIR} /semver/include )
100114set_target_properties (semver PROPERTIES POSITION_INDEPENDENT_CODE ON )
0 commit comments