mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-22 04:07:49 -05:00
Support EVAL CODE on CMake <3.18
This commit is contained in:
committed by
Craig Hutchinson
parent
cbe5144f79
commit
b847af65c0
@@ -505,6 +505,16 @@ function(cpm_override_fetchcontent contentName)
|
||||
set_property(GLOBAL PROPERTY ${propertyName} TRUE)
|
||||
endfunction()
|
||||
|
||||
macro(cpm_cmake_eval)
|
||||
set(__ARGN "${ARGN}")
|
||||
if(COMMAND cmake_language)
|
||||
cmake_language(EVAL CODE "${__ARGN}")
|
||||
else()
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/eval.cmake "${__ARGN}")
|
||||
include(${CMAKE_CURRENT_BINARY_DIR}/eval.cmake)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Download and add a package from source
|
||||
macro(CPMAddPackage)
|
||||
set(__ARGN "${ARGN}")
|
||||
@@ -518,7 +528,7 @@ macro(CPMAddPackage)
|
||||
foreach(__ARG IN LISTS __ARGN)
|
||||
string(APPEND __ARGN_Quoted " [==[${__ARG}]==]")
|
||||
endforeach()
|
||||
cmake_language(EVAL CODE "cpm_add_package_multi_arg( ${__ARGN_Quoted} )")
|
||||
cpm_cmake_eval("cpm_add_package_multi_arg( ${__ARGN_Quoted} )")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -944,7 +954,7 @@ function(cpm_declare_fetch PACKAGE VERSION INFO)
|
||||
foreach(__item IN LISTS ARGN)
|
||||
string(APPEND __argsQuoted " [==[${__item}]==]")
|
||||
endforeach()
|
||||
cmake_language(EVAL CODE "FetchContent_Declare(${PACKAGE} ${__argsQuoted} )")
|
||||
cpm_cmake_eval("FetchContent_Declare(${PACKAGE} ${__argsQuoted} )")
|
||||
endfunction()
|
||||
|
||||
# returns properties for a package previously defined by cpm_declare_fetch
|
||||
|
||||
Reference in New Issue
Block a user