@@ -42,11 +42,7 @@ if(NOT COMMAND cpm_message)
4242 endfunction ()
4343endif ()
4444
45- if (DEFINED EXTRACTED_CPM_VERSION)
46- set (CURRENT_CPM_VERSION "${EXTRACTED_CPM_VERSION}${CPM_DEVELOPMENT} " )
47- else ()
48- set (CURRENT_CPM_VERSION 0.40.8)
49- endif ()
45+ set (CURRENT_CPM_VERSION 0.40.0)
5046
5147get_filename_component (CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR} " REALPATH)
5248if (CPM_DIRECTORY)
@@ -166,7 +162,7 @@ set(CPM_SOURCE_CACHE
166162 CACHE PATH "Directory to download CPM dependencies"
167163)
168164
169- if (NOT CPM_DONT_UPDATE_MODULE_PATH AND NOT DEFINED CMAKE_FIND_PACKAGE_REDIRECTS_DIR )
165+ if (NOT CPM_DONT_UPDATE_MODULE_PATH)
170166 set (CPM_MODULE_PATH
171167 "${CMAKE_BINARY_DIR} /CPM_modules"
172168 CACHE INTERNAL ""
@@ -273,25 +269,10 @@ endfunction()
273269# finding the system library
274270function (cpm_create_module_file Name )
275271 if (NOT CPM_DONT_UPDATE_MODULE_PATH)
276- if (DEFINED CMAKE_FIND_PACKAGE_REDIRECTS_DIR)
277- # Redirect find_package calls to the CPM package. This is what FetchContent does when you set
278- # OVERRIDE_FIND_PACKAGE. The CMAKE_FIND_PACKAGE_REDIRECTS_DIR works for find_package in CONFIG
279- # mode, unlike the Find${Name}.cmake fallback. CMAKE_FIND_PACKAGE_REDIRECTS_DIR is not defined
280- # in script mode, or in CMake < 3.24.
281- # https://cmake.org/cmake/help/latest/module/FetchContent.html#fetchcontent-find-package-integration-examples
282- string (TOLOWER ${Name} NameLower)
283- file (WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR} /${NameLower} -config.cmake
284- "include(\"\$ {CMAKE_CURRENT_LIST_DIR}/${NameLower} -extra.cmake\" OPTIONAL)\n "
285- "include(\"\$ {CMAKE_CURRENT_LIST_DIR}/${Name} Extra.cmake\" OPTIONAL)\n "
286- )
287- file (WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR} /${NameLower} -config-version .cmake
288- "set(PACKAGE_VERSION_COMPATIBLE TRUE)\n " "set(PACKAGE_VERSION_EXACT TRUE)\n "
289- )
290- else ()
291- file (WRITE ${CPM_MODULE_PATH} /Find ${Name} .cmake
292- "include(\" ${CPM_FILE} \" )\n ${ARGN} \n set(${Name} _FOUND TRUE)"
293- )
294- endif ()
272+ # erase any previous modules
273+ file (WRITE ${CPM_MODULE_PATH} /Find ${Name} .cmake
274+ "include(\" ${CPM_FILE} \" )\n ${ARGN} \n set(${Name} _FOUND TRUE)"
275+ )
295276 endif ()
296277endfunction ()
297278
@@ -494,18 +475,15 @@ function(cpm_add_patches)
494475
495476 # Find the patch program.
496477 find_program (PATCH_EXECUTABLE patch)
497- if (CMAKE_HOST_WIN32 AND NOT PATCH_EXECUTABLE)
478+ if (WIN32 AND NOT PATCH_EXECUTABLE)
498479 # The Windows git executable is distributed with patch.exe. Find the path to the executable, if
499- # it exists, then search `../usr/bin` and `../ ../usr/bin` for patch.exe.
480+ # it exists, then search `../../usr/bin` for patch.exe.
500481 find_package (Git QUIET )
501482 if (GIT_EXECUTABLE)
502483 get_filename_component (extra_search_path ${GIT_EXECUTABLE} DIRECTORY )
503- get_filename_component (extra_search_path_1up ${extra_search_path} DIRECTORY )
504- get_filename_component (extra_search_path_2up ${extra_search_path_1up} DIRECTORY )
505- find_program (
506- PATCH_EXECUTABLE patch HINTS "${extra_search_path_1up} /usr/bin"
507- "${extra_search_path_2up} /usr/bin"
508- )
484+ get_filename_component (extra_search_path ${extra_search_path} DIRECTORY )
485+ get_filename_component (extra_search_path ${extra_search_path} DIRECTORY )
486+ find_program (PATCH_EXECUTABLE patch HINTS "${extra_search_path} /usr/bin" )
509487 endif ()
510488 endif ()
511489 if (NOT PATCH_EXECUTABLE)
@@ -867,9 +845,7 @@ function(CPMAddPackage)
867845 endif ()
868846 endif ()
869847
870- if (NOT "${DOWNLOAD_ONLY} " )
871- cpm_create_module_file(${CPM_ARGS_NAME} "CPMAddPackage(\" ${ARGN} \" )" )
872- endif ()
848+ cpm_create_module_file(${CPM_ARGS_NAME} "CPMAddPackage(\" ${ARGN} \" )" )
873849
874850 if (CPM_PACKAGE_LOCK_ENABLED)
875851 if ((CPM_ARGS_VERSION AND NOT CPM_ARGS_SOURCE_DIR) OR CPM_INCLUDE_ALL_IN_PACKAGE_LOCK)
@@ -886,39 +862,14 @@ function(CPMAddPackage)
886862 )
887863
888864 if (NOT CPM_SKIP_FETCH)
889- # CMake 3.28 added EXCLUDE, SYSTEM (3.25), and SOURCE_SUBDIR (3.18) to FetchContent_Declare.
890- # Calling FetchContent_MakeAvailable will then internally forward these options to
891- # add_subdirectory. Up until these changes, we had to call FetchContent_Populate and
892- # add_subdirectory separately, which is no longer necessary and has been deprecated as of 3.30.
893- # A Bug in CMake prevents us to use the non-deprecated functions until 3.30.3.
894- set (fetchContentDeclareExtraArgs "" )
895- if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.30.3" )
896- if (${CPM_ARGS_EXCLUDE_FROM_ALL} )
897- list (APPEND fetchContentDeclareExtraArgs EXCLUDE_FROM_ALL )
898- endif ()
899- if (${CPM_ARGS_SYSTEM} )
900- list (APPEND fetchContentDeclareExtraArgs SYSTEM )
901- endif ()
902- if (DEFINED CPM_ARGS_SOURCE_SUBDIR)
903- list (APPEND fetchContentDeclareExtraArgs SOURCE_SUBDIR ${CPM_ARGS_SOURCE_SUBDIR} )
904- endif ()
905- # For CMake version <3.28 OPTIONS are parsed in cpm_add_subdirectory
906- if (CPM_ARGS_OPTIONS AND NOT DOWNLOAD_ONLY)
907- foreach (OPTION ${CPM_ARGS_OPTIONS} )
908- cpm_parse_option("${OPTION} " )
909- set (${OPTION_KEY} "${OPTION_VALUE} " )
910- endforeach ()
911- endif ()
912- endif ()
913865 cpm_declare_fetch(
914- "${CPM_ARGS_NAME} " ${fetchContentDeclareExtraArgs} "${CPM_ARGS_UNPARSED_ARGUMENTS} "
866+ "${CPM_ARGS_NAME} " " ${CPM_ARGS_VERSION} " " ${PACKAGE_INFO} " "${CPM_ARGS_UNPARSED_ARGUMENTS} "
915867 )
916-
917- cpm_fetch_package("${CPM_ARGS_NAME} " ${DOWNLOAD_ONLY} populated ${CPM_ARGS_UNPARSED_ARGUMENTS} )
868+ cpm_fetch_package("${CPM_ARGS_NAME} " populated)
918869 if (CPM_SOURCE_CACHE AND download_directory)
919870 file (LOCK ${download_directory} /../cmake.lock RELEASE)
920871 endif ()
921- if (${populated} AND ${CMAKE_VERSION} VERSION_LESS "3.30.3" )
872+ if (${populated} )
922873 cpm_add_subdirectory(
923874 "${CPM_ARGS_NAME} "
924875 "${DOWNLOAD_ONLY} "
@@ -1029,7 +980,7 @@ function(CPMGetPackageVersion PACKAGE OUTPUT)
1029980endfunction ()
1030981
1031982# declares a package in FetchContent_Declare
1032- function (cpm_declare_fetch PACKAGE)
983+ function (cpm_declare_fetch PACKAGE VERSION INFO )
1033984 if (${CPM_DRY_RUN} )
1034985 cpm_message(STATUS "${CPM_INDENT} Package not declared (dry run)" )
1035986 return ()
@@ -1105,7 +1056,7 @@ endfunction()
11051056
11061057# downloads a previously declared package via FetchContent and exports the variables
11071058# `${PACKAGE}_SOURCE_DIR` and `${PACKAGE}_BINARY_DIR` to the parent scope
1108- function (cpm_fetch_package PACKAGE DOWNLOAD_ONLY populated)
1059+ function (cpm_fetch_package PACKAGE populated)
11091060 set (${populated}
11101061 FALSE
11111062 PARENT_SCOPE
@@ -1120,24 +1071,7 @@ function(cpm_fetch_package PACKAGE DOWNLOAD_ONLY populated)
11201071 string (TOLOWER "${PACKAGE} " lower_case_name)
11211072
11221073 if (NOT ${lower_case_name} _POPULATED)
1123- if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.30.3" )
1124- if (DOWNLOAD_ONLY)
1125- # MakeAvailable will call add_subdirectory internally which is not what we want when
1126- # DOWNLOAD_ONLY is set. Populate will only download the dependency without adding it to the
1127- # build
1128- FetchContent_Populate(
1129- ${PACKAGE}
1130- SOURCE_DIR "${CPM_FETCHCONTENT_BASE_DIR} /${lower_case_name} -src"
1131- BINARY_DIR "${CPM_FETCHCONTENT_BASE_DIR} /${lower_case_name} -build"
1132- SUBBUILD_DIR "${CPM_FETCHCONTENT_BASE_DIR} /${lower_case_name} -subbuild"
1133- ${ARGN}
1134- )
1135- else ()
1136- FetchContent_MakeAvailable(${PACKAGE} )
1137- endif ()
1138- else ()
1139- FetchContent_Populate(${PACKAGE} )
1140- endif ()
1074+ FetchContent_Populate(${PACKAGE} )
11411075 set (${populated}
11421076 TRUE
11431077 PARENT_SCOPE
0 commit comments