Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 18 additions & 3 deletions cmake/chaiscript.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <chrono> include).
add_subdirectory(${chaiscript_SOURCE_DIR} ${chaiscript_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
Loading