summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2022-01-24 12:05:00 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-01-24 12:05:07 (GMT)
commit7e72a179a92bfbc8e73a96382466a73e5862e7a8 (patch)
tree6f1f66aed7b21ad09f102a06f3116380d33a6839
parent6424f7dc7d3da1523d31c502c52e666034e0aa62 (diff)
parent5fbac2bb24250eeeb64e2fb4868dcf976ee29d64 (diff)
downloadCMake-7e72a179a92bfbc8e73a96382466a73e5862e7a8.zip
CMake-7e72a179a92bfbc8e73a96382466a73e5862e7a8.tar.gz
CMake-7e72a179a92bfbc8e73a96382466a73e5862e7a8.tar.bz2
Merge topic 'ep-refactor-scripts'
5fbac2bb24 ExternalProject: Move inline scripts to separate files 8feaa41ee9 ExternalProject: Ensure _ep_set_directories records cmake paths 036517fe0b ExternalProject: Move existing step scripts to separate subdirectory Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !6888
-rw-r--r--Modules/ExternalProject.cmake373
-rw-r--r--Modules/ExternalProject/RepositoryInfo.txt.in (renamed from Modules/RepositoryInfo.txt.in)0
-rw-r--r--Modules/ExternalProject/cfgcmd.txt.in1
-rw-r--r--Modules/ExternalProject/download.cmake.in (renamed from Modules/ExternalProject-download.cmake.in)0
-rw-r--r--Modules/ExternalProject/extractfile.cmake.in65
-rw-r--r--Modules/ExternalProject/gitclone.cmake.in73
-rw-r--r--Modules/ExternalProject/gitupdate.cmake.in (renamed from Modules/ExternalProject-gitupdate.cmake.in)0
-rw-r--r--Modules/ExternalProject/hgclone.cmake.in49
-rw-r--r--Modules/ExternalProject/mkdirs.cmake.in19
-rw-r--r--Modules/ExternalProject/verify.cmake.in (renamed from Modules/ExternalProject-verify.cmake.in)0
10 files changed, 350 insertions, 230 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index fc15a0f..411a1a9 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -1254,7 +1254,25 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
"ExternalProject module."
)
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name init_submodules git_submodules_recurse git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
+function(_ep_write_gitclone_script
+ script_filename
+ source_dir
+ git_EXECUTABLE
+ git_repository
+ git_tag
+ git_remote_name
+ init_submodules
+ git_submodules_recurse
+ git_submodules
+ git_shallow
+ git_progress
+ git_config
+ src_name
+ work_dir
+ gitclone_infofile
+ gitclone_stampfile
+ tls_verify)
+
if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5)
# Use `git checkout <tree-ish> --` to avoid ambiguity with a local path.
set(git_checkout_explicit-- "--")
@@ -1300,136 +1318,48 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git
endif()
string (REPLACE ";" " " git_options "${git_options}")
- file(WRITE ${script_filename}
-"
-if(EXISTS \"${gitclone_stampfile}\" AND EXISTS \"${gitclone_infofile}\" AND
- \"${gitclone_stampfile}\" IS_NEWER_THAN \"${gitclone_infofile}\")
- message(STATUS \"Avoiding repeated git clone, stamp file is up to date: '${gitclone_stampfile}'\")
- return()
-endif()
-
-execute_process(
- COMMAND \${CMAKE_COMMAND} -E rm -rf \"${source_dir}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
-endif()
-
-# try the clone 3 times in case there is an odd git clone issue
-set(error_code 1)
-set(number_of_tries 0)
-while(error_code AND number_of_tries LESS 3)
- execute_process(
- COMMAND \"${git_EXECUTABLE}\" ${git_options} clone ${git_clone_options} \"${git_repository}\" \"${src_name}\"
- WORKING_DIRECTORY \"${work_dir}\"
- RESULT_VARIABLE error_code
- )
- math(EXPR number_of_tries \"\${number_of_tries} + 1\")
-endwhile()
-if(number_of_tries GREATER 1)
- message(STATUS \"Had to git clone more than once:
- \${number_of_tries} times.\")
-endif()
-if(error_code)
- message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\")
-endif()
-
-execute_process(
- COMMAND \"${git_EXECUTABLE}\" ${git_options} checkout ${git_tag} ${git_checkout_explicit--}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
-endif()
-
-set(init_submodules ${init_submodules})
-if(init_submodules)
- execute_process(
- COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update ${git_submodules_recurse} --init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
-endif()
-if(error_code)
- message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
-endif()
-
-# Complete success, update the script-last-run stamp file:
-#
-execute_process(
- COMMAND \${CMAKE_COMMAND} -E copy
- \"${gitclone_infofile}\"
- \"${gitclone_stampfile}\"
- RESULT_VARIABLE error_code
+ configure_file(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/gitclone.cmake.in
+ ${script_filename}
+ @ONLY
)
-if(error_code)
- message(FATAL_ERROR \"Failed to copy script-last-run stamp file: '${gitclone_stampfile}'\")
-endif()
-
-"
-)
-
endfunction()
-function(_ep_write_hgclone_script script_filename source_dir hg_EXECUTABLE hg_repository hg_tag src_name work_dir hgclone_infofile hgclone_stampfile)
+function(_ep_write_hgclone_script
+ script_filename
+ source_dir
+ hg_EXECUTABLE
+ hg_repository
+ hg_tag
+ src_name
+ work_dir
+ hgclone_infofile
+ hgclone_stampfile)
+
if("${hg_tag}" STREQUAL "")
message(FATAL_ERROR "Tag for hg checkout should not be empty.")
endif()
- file(WRITE ${script_filename}
-"
-if(EXISTS \"${hgclone_stampfile}\" AND EXISTS \"${hgclone_infofile}\" AND
- \"${hgclone_stampfile}\" IS_NEWER_THAN \"${hgclone_infofile}\")
- message(STATUS \"Avoiding repeated hg clone, stamp file is up to date: '${hgclone_stampfile}'\")
- return()
-endif()
-
-execute_process(
- COMMAND \${CMAKE_COMMAND} -E rm -rf \"${source_dir}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
-endif()
-execute_process(
- COMMAND \"${hg_EXECUTABLE}\" clone -U \"${hg_repository}\" \"${src_name}\"
- WORKING_DIRECTORY \"${work_dir}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to clone repository: '${hg_repository}'\")
-endif()
-
-execute_process(
- COMMAND \"${hg_EXECUTABLE}\" update ${hg_tag}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to checkout tag: '${hg_tag}'\")
-endif()
-
-# Complete success, update the script-last-run stamp file:
-#
-execute_process(
- COMMAND \${CMAKE_COMMAND} -E copy
- \"${hgclone_infofile}\"
- \"${hgclone_stampfile}\"
- RESULT_VARIABLE error_code
+ configure_file(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/hgclone.cmake.in
+ ${script_filename}
+ @ONLY
)
-if(error_code)
- message(FATAL_ERROR \"Failed to copy script-last-run stamp file: '${hgclone_stampfile}'\")
-endif()
-
-"
-)
-
endfunction()
-function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name init_submodules git_submodules_recurse git_submodules git_repository work_dir git_update_strategy)
+function(_ep_write_gitupdate_script
+ script_filename
+ git_EXECUTABLE
+ git_tag
+ git_remote_name
+ init_submodules
+ git_submodules_recurse
+ git_submodules
+ git_repository
+ work_dir
+ git_update_strategy)
+
if("${git_tag}" STREQUAL "")
message(FATAL_ERROR "Tag for git checkout should not be empty.")
endif()
@@ -1443,13 +1373,27 @@ function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_r
endif()
configure_file(
- "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject-gitupdate.cmake.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/gitupdate.cmake.in"
"${script_filename}"
@ONLY
)
endfunction()
-function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inactivity_timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file)
+function(_ep_write_downloadfile_script
+ script_filename
+ REMOTE
+ LOCAL
+ timeout
+ inactivity_timeout
+ no_progress
+ hash
+ tls_verify
+ tls_cainfo
+ userpwd
+ http_headers
+ netrc
+ netrc_file)
+
if(timeout)
set(TIMEOUT_ARGS TIMEOUT ${timeout})
set(TIMEOUT_MSG "${timeout} seconds")
@@ -1465,7 +1409,6 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inac
set(INACTIVITY_TIMEOUT_MSG "none")
endif()
-
if(no_progress)
set(SHOW_PROGRESS "")
else()
@@ -1553,7 +1496,7 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inac
# * USERPWD_ARGS
# * HTTP_HEADERS_ARGS
configure_file(
- "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject-download.cmake.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/download.cmake.in"
"${script_filename}"
@ONLY
)
@@ -1574,7 +1517,7 @@ function(_ep_write_verifyfile_script script_filename LOCAL hash)
# * EXPECT_VALUE
# * LOCAL
configure_file(
- "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject-verify.cmake.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/verify.cmake.in"
"${script_filename}"
@ONLY
)
@@ -1597,68 +1540,11 @@ function(_ep_write_extractfile_script script_filename name filename directory)
return()
endif()
- file(WRITE ${script_filename}
-"# Make file names absolute:
-#
-get_filename_component(filename \"${filename}\" ABSOLUTE)
-get_filename_component(directory \"${directory}\" ABSOLUTE)
-
-message(STATUS \"extracting...
- src='\${filename}'
- dst='\${directory}'\")
-
-if(NOT EXISTS \"\${filename}\")
- message(FATAL_ERROR \"error: file to extract does not exist: '\${filename}'\")
-endif()
-
-# Prepare a space for extracting:
-#
-set(i 1234)
-while(EXISTS \"\${directory}/../ex-${name}\${i}\")
- math(EXPR i \"\${i} + 1\")
-endwhile()
-set(ut_dir \"\${directory}/../ex-${name}\${i}\")
-file(MAKE_DIRECTORY \"\${ut_dir}\")
-
-# Extract it:
-#
-message(STATUS \"extracting... [tar ${args}]\")
-execute_process(COMMAND \${CMAKE_COMMAND} -E tar ${args} \${filename}
- WORKING_DIRECTORY \${ut_dir}
- RESULT_VARIABLE rv)
-
-if(NOT rv EQUAL 0)
- message(STATUS \"extracting... [error clean up]\")
- file(REMOVE_RECURSE \"\${ut_dir}\")
- message(FATAL_ERROR \"error: extract of '\${filename}' failed\")
-endif()
-
-# Analyze what came out of the tar file:
-#
-message(STATUS \"extracting... [analysis]\")
-file(GLOB contents \"\${ut_dir}/*\")
-list(REMOVE_ITEM contents \"\${ut_dir}/.DS_Store\")
-list(LENGTH contents n)
-if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\")
- set(contents \"\${ut_dir}\")
-endif()
-
-# Move \"the one\" directory to the final directory:
-#
-message(STATUS \"extracting... [rename]\")
-file(REMOVE_RECURSE \${directory})
-get_filename_component(contents \${contents} ABSOLUTE)
-file(RENAME \${contents} \${directory})
-
-# Clean up:
-#
-message(STATUS \"extracting... [clean up]\")
-file(REMOVE_RECURSE \"\${ut_dir}\")
-
-message(STATUS \"extracting... done\")
-"
-)
-
+ configure_file(
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/extractfile.cmake.in"
+ "${script_filename}"
+ @ONLY
+ )
endfunction()
@@ -1674,6 +1560,7 @@ function(_ep_set_directories name)
endif()
endif()
if(prefix)
+ file(TO_CMAKE_PATH "${prefix}" prefix)
set(tmp_default "${prefix}/tmp")
set(download_default "${prefix}/src")
set(source_default "${prefix}/src/${name}")
@@ -1681,6 +1568,7 @@ function(_ep_set_directories name)
set(stamp_default "${prefix}/src/${name}-stamp")
set(install_default "${prefix}")
else()
+ file(TO_CMAKE_PATH "${base}" base)
set(tmp_default "${base}/tmp/${name}")
set(download_default "${base}/Download/${name}")
set(source_default "${base}/Source/${name}")
@@ -1709,6 +1597,7 @@ function(_ep_set_directories name)
if(NOT IS_ABSOLUTE "${${var}_dir}")
get_filename_component(${var}_dir "${top}/${${var}_dir}" ABSOLUTE)
endif()
+ file(TO_CMAKE_PATH "${${var}_dir}" ${var}_dir)
set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}")
endforeach()
@@ -1720,6 +1609,7 @@ function(_ep_set_directories name)
if(NOT IS_ABSOLUTE "${log_dir}")
get_filename_component(log_dir "${top}/${log_dir}" ABSOLUTE)
endif()
+ file(TO_CMAKE_PATH "${log_dir}" log_dir)
set_property(TARGET ${name} PROPERTY _EP_LOG_DIR "${log_dir}")
get_property(source_subdir TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR)
@@ -1731,6 +1621,7 @@ function(_ep_set_directories name)
else()
# Prefix with a slash so that when appended to the source directory, it
# behaves as expected.
+ file(TO_CMAKE_PATH "${source_subdir}" source_subdir)
set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "/${source_subdir}")
endif()
if(build_in_source)
@@ -1742,22 +1633,19 @@ function(_ep_set_directories name)
endif()
endif()
- # Make the directories at CMake configure time *and* add a custom command
- # to make them at build time. They need to exist at makefile generation
- # time for Borland make and wmake so that CMake may generate makefiles
- # with "cd C:\short\paths\with\no\spaces" commands in them.
- #
- # Additionally, the add_custom_command is still used in case somebody
- # removes one of the necessary directories and tries to rebuild without
- # re-running cmake.
- foreach(var ${places})
- string(TOUPPER "${var}" VAR)
- get_property(dir TARGET ${name} PROPERTY _EP_${VAR}_DIR)
- file(MAKE_DIRECTORY "${dir}")
- if(NOT EXISTS "${dir}")
- message(FATAL_ERROR "dir '${dir}' does not exist after file(MAKE_DIRECTORY)")
- endif()
- endforeach()
+ # This script will be used both here and by the mkdir step. We create the
+ # directories now at configure time and ensure they exist again at build
+ # time (since somebody might remove one of the required directories and try
+ # to rebuild without re-running cmake). They need to exist now at makefile
+ # generation time for Borland make and wmake so that CMake may generate
+ # makefiles with "cd C:\short\paths\with\no\spaces" commands in them.
+ set(script_filename "${tmp_dir}/${name}-mkdirs.cmake")
+ configure_file(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/mkdirs.cmake.in
+ ${script_filename}
+ @ONLY
+ )
+ include(${script_filename})
endfunction()
@@ -2523,22 +2411,14 @@ endfunction()
function(_ep_add_mkdir_command name)
- ExternalProject_Get_Property(${name}
- source_dir binary_dir install_dir stamp_dir download_dir tmp_dir log_dir)
-
- _ep_get_configuration_subdir_suffix(cfgdir)
+ ExternalProject_Get_Property(${name} tmp_dir)
+ set(script_filename "${tmp_dir}/${name}-mkdirs.cmake")
ExternalProject_Add_Step(${name} mkdir
INDEPENDENT TRUE
COMMENT "Creating directories for '${name}'"
- COMMAND ${CMAKE_COMMAND} -E make_directory ${source_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${binary_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${install_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${tmp_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${stamp_dir}${cfgdir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${download_dir}
- COMMAND ${CMAKE_COMMAND} -E make_directory ${log_dir}
- )
+ COMMAND ${CMAKE_COMMAND} -P ${script_filename}
+ )
endfunction()
@@ -2613,7 +2493,7 @@ function(_ep_add_download_command name)
set(module ${cvs_module})
set(tag ${cvs_tag})
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-cvsinfo.txt"
@ONLY
)
@@ -2638,7 +2518,7 @@ function(_ep_add_download_command name)
set(module)
set(tag ${svn_revision})
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-svninfo.txt"
@ONLY
)
@@ -2714,7 +2594,7 @@ function(_ep_add_download_command name)
set(module)
set(tag ${git_remote_name})
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-gitinfo.txt"
@ONLY
)
@@ -2754,7 +2634,7 @@ function(_ep_add_download_command name)
set(module)
set(tag)
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-hginfo.txt"
@ONLY
)
@@ -2795,7 +2675,7 @@ function(_ep_add_download_command name)
set(module "${url}")
set(tag "${hash}")
configure_file(
- "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-urlinfo.txt"
@ONLY
)
@@ -2850,7 +2730,21 @@ function(_ep_add_download_command name)
get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD)
get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER)
set(download_script "${stamp_dir}/download-${name}.cmake")
- _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${inactivity_timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}")
+ _ep_write_downloadfile_script(
+ "${download_script}"
+ "${url}"
+ "${file}"
+ "${timeout}"
+ "${inactivity_timeout}"
+ "${no_progress}"
+ "${hash}"
+ "${tls_verify}"
+ "${tls_cainfo}"
+ "${http_username}:${http_password}"
+ "${http_headers}"
+ "${netrc}"
+ "${netrc_file}"
+ )
set(cmd ${CMAKE_COMMAND} -P "${download_script}"
COMMAND)
if (no_extract)
@@ -2868,11 +2762,20 @@ function(_ep_add_download_command name)
set(steps "verify and extract")
endif ()
set(comment "Performing download step (${steps}) for '${name}'")
- _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}")
+ _ep_write_verifyfile_script(
+ "${stamp_dir}/verify-${name}.cmake"
+ "${file}"
+ "${hash}"
+ )
endif()
list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake)
if (NOT no_extract)
- _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}")
+ _ep_write_extractfile_script(
+ "${stamp_dir}/extract-${name}.cmake"
+ "${name}"
+ "${file}"
+ "${source_dir}"
+ )
list(APPEND cmd COMMAND ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake)
else ()
set_property(TARGET ${name} PROPERTY _EP_DOWNLOADED_FILE ${file})
@@ -3035,9 +2938,18 @@ function(_ep_add_update_command name)
_ep_get_git_submodules_recurse(git_submodules_recurse)
- _ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
- ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules_recurse}" "${git_submodules}" ${git_repository} ${work_dir} ${git_update_strategy}
- )
+ _ep_write_gitupdate_script(
+ "${tmp_dir}/${name}-gitupdate.cmake"
+ "${GIT_EXECUTABLE}"
+ "${git_tag}"
+ "${git_remote_name}"
+ "${git_init_submodules}"
+ "${git_submodules_recurse}"
+ "${git_submodules}"
+ "${git_repository}"
+ "${work_dir}"
+ "${git_update_strategy}"
+ )
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
set(always 1)
elseif(hg_repository)
@@ -3279,10 +3191,11 @@ function(_ep_add_configure_command name)
# used, cmake args or cmake generator) then re-run the configure step.
# Fixes issue https://gitlab.kitware.com/cmake/cmake/-/issues/10258
#
- if(NOT EXISTS ${tmp_dir}/${name}-cfgcmd.txt.in)
- file(WRITE ${tmp_dir}/${name}-cfgcmd.txt.in "cmd='\@cmd\@'\n")
- endif()
- configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt)
+ configure_file(
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/cfgcmd.txt.in
+ ${tmp_dir}/${name}-cfgcmd.txt
+ @ONLY
+ )
list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt)
list(APPEND file_deps ${_ep_cache_args_script})
diff --git a/Modules/RepositoryInfo.txt.in b/Modules/ExternalProject/RepositoryInfo.txt.in
index df8e322..df8e322 100644
--- a/Modules/RepositoryInfo.txt.in
+++ b/Modules/ExternalProject/RepositoryInfo.txt.in
diff --git a/Modules/ExternalProject/cfgcmd.txt.in b/Modules/ExternalProject/cfgcmd.txt.in
new file mode 100644
index 0000000..b3f09ef
--- /dev/null
+++ b/Modules/ExternalProject/cfgcmd.txt.in
@@ -0,0 +1 @@
+cmd='@cmd@'
diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject/download.cmake.in
index ff8c659..ff8c659 100644
--- a/Modules/ExternalProject-download.cmake.in
+++ b/Modules/ExternalProject/download.cmake.in
diff --git a/Modules/ExternalProject/extractfile.cmake.in b/Modules/ExternalProject/extractfile.cmake.in
new file mode 100644
index 0000000..d7f5756
--- /dev/null
+++ b/Modules/ExternalProject/extractfile.cmake.in
@@ -0,0 +1,65 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.5)
+
+# Make file names absolute:
+#
+get_filename_component(filename "@filename@" ABSOLUTE)
+get_filename_component(directory "@directory@" ABSOLUTE)
+
+message(STATUS "extracting...
+ src='${filename}'
+ dst='${directory}'"
+)
+
+if(NOT EXISTS "${filename}")
+ message(FATAL_ERROR "File to extract does not exist: '${filename}'")
+endif()
+
+# Prepare a space for extracting:
+#
+set(i 1234)
+while(EXISTS "${directory}/../ex-@name@${i}")
+ math(EXPR i "${i} + 1")
+endwhile()
+set(ut_dir "${directory}/../ex-@name@${i}")
+file(MAKE_DIRECTORY "${ut_dir}")
+
+# Extract it:
+#
+message(STATUS "extracting... [tar @args@]")
+execute_process(COMMAND ${CMAKE_COMMAND} -E tar @args@ ${filename}
+ WORKING_DIRECTORY ${ut_dir}
+ RESULT_VARIABLE rv
+)
+
+if(NOT rv EQUAL 0)
+ message(STATUS "extracting... [error clean up]")
+ file(REMOVE_RECURSE "${ut_dir}")
+ message(FATAL_ERROR "Extract of '${filename}' failed")
+endif()
+
+# Analyze what came out of the tar file:
+#
+message(STATUS "extracting... [analysis]")
+file(GLOB contents "${ut_dir}/*")
+list(REMOVE_ITEM contents "${ut_dir}/.DS_Store")
+list(LENGTH contents n)
+if(NOT n EQUAL 1 OR NOT IS_DIRECTORY "${contents}")
+ set(contents "${ut_dir}")
+endif()
+
+# Move "the one" directory to the final directory:
+#
+message(STATUS "extracting... [rename]")
+file(REMOVE_RECURSE ${directory})
+get_filename_component(contents ${contents} ABSOLUTE)
+file(RENAME ${contents} ${directory})
+
+# Clean up:
+#
+message(STATUS "extracting... [clean up]")
+file(REMOVE_RECURSE "${ut_dir}")
+
+message(STATUS "extracting... done")
diff --git a/Modules/ExternalProject/gitclone.cmake.in b/Modules/ExternalProject/gitclone.cmake.in
new file mode 100644
index 0000000..3312171
--- /dev/null
+++ b/Modules/ExternalProject/gitclone.cmake.in
@@ -0,0 +1,73 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.5)
+
+if(EXISTS "@gitclone_stampfile@" AND EXISTS "@gitclone_infofile@" AND
+ "@gitclone_stampfile@" IS_NEWER_THAN "@gitclone_infofile@")
+ message(STATUS
+ "Avoiding repeated git clone, stamp file is up to date: "
+ "'@gitclone_stampfile@'"
+ )
+ return()
+endif()
+
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E rm -rf "@source_dir@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to remove directory: '@source_dir@'")
+endif()
+
+# try the clone 3 times in case there is an odd git clone issue
+set(error_code 1)
+set(number_of_tries 0)
+while(error_code AND number_of_tries LESS 3)
+ execute_process(
+ COMMAND "@git_EXECUTABLE@" @git_options@
+ clone @git_clone_options@ "@git_repository@" "@src_name@"
+ WORKING_DIRECTORY "@work_dir@"
+ RESULT_VARIABLE error_code
+ )
+ math(EXPR number_of_tries "${number_of_tries} + 1")
+endwhile()
+if(number_of_tries GREATER 1)
+ message(STATUS "Had to git clone more than once: ${number_of_tries} times.")
+endif()
+if(error_code)
+ message(FATAL_ERROR "Failed to clone repository: '@git_repository@'")
+endif()
+
+execute_process(
+ COMMAND "@git_EXECUTABLE@" @git_options@
+ checkout "@git_tag@" @git_checkout_explicit--@
+ WORKING_DIRECTORY "@work_dir@/@src_name@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to checkout tag: '@git_tag@'")
+endif()
+
+set(init_submodules @init_submodules@)
+if(init_submodules)
+ execute_process(
+ COMMAND "@git_EXECUTABLE@" @git_options@
+ submodule update @git_submodules_recurse@ --init @git_submodules@
+ WORKING_DIRECTORY "@work_dir@/@src_name@"
+ RESULT_VARIABLE error_code
+ )
+endif()
+if(error_code)
+ message(FATAL_ERROR "Failed to update submodules in: '@work_dir@/@src_name@'")
+endif()
+
+# Complete success, update the script-last-run stamp file:
+#
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "@gitclone_infofile@" "@gitclone_stampfile@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to copy script-last-run stamp file: '@gitclone_stampfile@'")
+endif()
diff --git a/Modules/ExternalProject-gitupdate.cmake.in b/Modules/ExternalProject/gitupdate.cmake.in
index 0de2372..0de2372 100644
--- a/Modules/ExternalProject-gitupdate.cmake.in
+++ b/Modules/ExternalProject/gitupdate.cmake.in
diff --git a/Modules/ExternalProject/hgclone.cmake.in b/Modules/ExternalProject/hgclone.cmake.in
new file mode 100644
index 0000000..e2b55ba
--- /dev/null
+++ b/Modules/ExternalProject/hgclone.cmake.in
@@ -0,0 +1,49 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.5)
+
+if(EXISTS "@hgclone_stampfile@" AND EXISTS "@hgclone_infofile@" AND
+ "@hgclone_stampfile@" IS_NEWER_THAN "@hgclone_infofile@")
+ message(STATUS
+ "Avoiding repeated hg clone, stamp file is up to date: "
+ "'@hgclone_stampfile@'"
+ )
+ return()
+endif()
+
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E rm -rf "@source_dir@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to remove directory: '@source_dir@'")
+endif()
+
+execute_process(
+ COMMAND "@hg_EXECUTABLE@" clone -U "@hg_repository@" "@src_name@"
+ WORKING_DIRECTORY "@work_dir@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to clone repository: '@hg_repository@'")
+endif()
+
+execute_process(
+ COMMAND "@hg_EXECUTABLE@" update @hg_tag@
+ WORKING_DIRECTORY "@work_dir@/@src_name@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to checkout tag: '@hg_tag@'")
+endif()
+
+# Complete success, update the script-last-run stamp file:
+#
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy "@hgclone_infofile@" "@hgclone_stampfile@"
+ RESULT_VARIABLE error_code
+)
+if(error_code)
+ message(FATAL_ERROR "Failed to copy script-last-run stamp file: '@hgclone_stampfile@'")
+endif()
diff --git a/Modules/ExternalProject/mkdirs.cmake.in b/Modules/ExternalProject/mkdirs.cmake.in
new file mode 100644
index 0000000..d30a2e7
--- /dev/null
+++ b/Modules/ExternalProject/mkdirs.cmake.in
@@ -0,0 +1,19 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.5)
+
+file(MAKE_DIRECTORY
+ "@source_dir@"
+ "@binary_dir@"
+ "@install_dir@"
+ "@tmp_dir@"
+ "@stamp_dir@"
+ "@download_dir@"
+ "@log_dir@"
+)
+
+set(configSubDirs @CMAKE_CONFIGURATION_TYPES@)
+foreach(subDir IN LISTS configSubDirs)
+ file(MAKE_DIRECTORY "@stamp_dir@/${subDir}")
+endforeach()
diff --git a/Modules/ExternalProject-verify.cmake.in b/Modules/ExternalProject/verify.cmake.in
index c06da4e..c06da4e 100644
--- a/Modules/ExternalProject-verify.cmake.in
+++ b/Modules/ExternalProject/verify.cmake.in