From 0c0a8404e662bb6ed5533b560f2ad7542033207d Mon Sep 17 00:00:00 2001 From: leftibot Date: Fri, 17 Apr 2026 08:15:41 -0600 Subject: [PATCH] Fix CI build: accommodate CMake 4.x and skip upstream chai REPL The CI introduced in #34 surfaced two failures rooted in the outdated CMakeLists.txt fetched as part of ChaiScript 6.1.0: 1. macOS runners ship CMake 4.x, which removes compatibility with cmake_minimum_required(VERSION < 3.5). The fetched subproject still declares VERSION 2.8 and configure aborts. Setting CMAKE_POLICY_VERSION_MINIMUM to 3.5 before add_subdirectory forces an acceptable floor for the transitive project. 2. Windows MSVC builds fail compiling ChaiScript's own src/main.cpp (the `chai` REPL) - a missing include in upstream 6.1.0. The REPL target is unconditionally declared by the subproject, so adding EXCLUDE_FROM_ALL on add_subdirectory keeps it out of the default build. chaiscript_extras only needs ChaiScript's headers, so nothing else changes. Also modernized: bump cmake_minimum_required to 3.16, drop the now-unused BUILD_MODULES toggle, and explicitly opt into CMP0169 OLD so the deprecated FetchContent_Populate call is kept quiet on CMake 3.30+. Note: this PR does not address the unrelated ASAN/UBSAN heap-use-after-free surfaced by string_methods_test - that is a runtime bug in the extras+ChaiScript 6.1.0 interaction and will be tracked separately. Co-Authored-By: Claude Opus 4.7 (1M context) --- CMakeLists.txt | 2 +- cmake/chaiscript.cmake | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bf1629..c125127 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11) # FetchContent requires CMake 3.11 +cmake_minimum_required(VERSION 3.16) project(chaiscript_extras) # MINGW does not yet support C++11's concurrency features diff --git a/cmake/chaiscript.cmake b/cmake/chaiscript.cmake index 1d00c2e..8f16bf6 100644 --- a/cmake/chaiscript.cmake +++ b/cmake/chaiscript.cmake @@ -4,6 +4,14 @@ find_package(chaiscript ${CHAISCRIPT_VERSION} QUIET) if (NOT chaiscript_FOUND) include(FetchContent) + # FetchContent_Populate is deprecated in CMake 3.30+, but it still gives us the + # fine-grained control (EXCLUDE_FROM_ALL on add_subdirectory) we need to keep + # the upstream `chai` REPL target out of the default build. Opt into the OLD + # behaviour explicitly. + if(POLICY CMP0169) + cmake_policy(SET CMP0169 OLD) + endif() + FetchContent_Declare( chaiscript GIT_REPOSITORY https://github.com/ChaiScript/ChaiScript.git @@ -12,14 +20,21 @@ if (NOT chaiscript_FOUND) FetchContent_GetProperties(chaiscript) if (NOT chaiscript_POPULATED) - set(FETCHCONTENT_QUIET NO) FetchContent_Populate(chaiscript) set(BUILD_SAMPLES OFF CACHE BOOL "" FORCE) - set(BUILD_MODULES ON CACHE BOOL "" FORCE) + set(BUILD_MODULES OFF CACHE BOOL "" FORCE) set(BUILD_TESTING OFF CACHE BOOL "" FORCE) set(BUILD_LIBFUZZ_TESTER OFF CACHE BOOL "" FORCE) - add_subdirectory(${chaiscript_SOURCE_DIR} ${chaiscript_BINARY_DIR}) + # ChaiScript 6.1.0's root CMakeLists.txt declares + # cmake_minimum_required(VERSION 2.8), which CMake 4.x refuses. Force a + # floor so the fetched subproject is accepted. + set(CMAKE_POLICY_VERSION_MINIMUM 3.5) + + # EXCLUDE_FROM_ALL keeps ChaiScript's `chai` REPL out of the default build. + # We only consume ChaiScript's headers here, and its src/main.cpp in 6.1.0 + # does not compile on current MSVC (missing include). + add_subdirectory(${chaiscript_SOURCE_DIR} ${chaiscript_BINARY_DIR} EXCLUDE_FROM_ALL) endif() endif()