From 3b6f06f882598e3edbfc832a61080741406345b3 Mon Sep 17 00:00:00 2001 From: scawful Date: Sat, 11 Oct 2025 03:38:42 -0400 Subject: [PATCH] feat(cmake): update yaml-cpp dependency handling for CMake compatibility - Modified the CMake configuration for yaml-cpp to use version 0.8.0 with an inline patch, ensuring compatibility with CMake 3.31+. - Implemented a manual population and patching process to adjust the minimum required CMake version in the yaml-cpp CMakeLists.txt, enhancing build reliability. Benefits: - Improved compatibility with newer CMake versions. - Streamlined dependency management for yaml-cpp. --- cmake/dependencies.cmake | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 2ab5e11d..da6006b4 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -101,11 +101,27 @@ set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Disable yaml-cpp tools" FORCE) set(YAML_CPP_INSTALL OFF CACHE BOOL "Disable yaml-cpp install" FORCE) set(YAML_CPP_FORMAT_SOURCE OFF CACHE BOOL "Disable yaml-cpp format target" FORCE) +# Use yaml-cpp 0.8.0 with inline patch for CMake 3.31+ compatibility +# yaml-cpp 0.8.0 requires CMake 2.8.12 which is incompatible with CMake 3.31+ FetchContent_Declare(yaml-cpp GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git GIT_TAG 0.8.0 ) -FetchContent_MakeAvailable(yaml-cpp) + +# Manually populate and patch to avoid cmake_minimum_required compatibility issue +FetchContent_GetProperties(yaml-cpp) +if(NOT yaml-cpp_POPULATED) + FetchContent_Populate(yaml-cpp) + + # Patch CMakeLists.txt to use CMake 3.5 minimum (compatible with 3.31+) + file(READ "${yaml-cpp_SOURCE_DIR}/CMakeLists.txt" YAML_CMAKE_CONTENT) + string(REPLACE "cmake_minimum_required(VERSION 2.8.12)" + "cmake_minimum_required(VERSION 3.5)" + YAML_CMAKE_CONTENT "${YAML_CMAKE_CONTENT}") + file(WRITE "${yaml-cpp_SOURCE_DIR}/CMakeLists.txt" "${YAML_CMAKE_CONTENT}") + + add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR}) +endif() # nlohmann_json (header only) if(YAZE_WITH_JSON)