summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CMP0150/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Wright <chris@inkyspider.co.uk>2023-04-21 06:47:19 (GMT)
committerCraig Scott <craig.scott@crascit.com>2023-04-26 08:30:36 (GMT)
commit550f63447d4c7d2db6ccbeaf1f6378aa6f7af4ed (patch)
tree2f9dca56e1a6891f614c52c78d8884f71c7e84ed /Tests/RunCMake/CMP0150/CMakeLists.txt
parente256e35daa79732a200883cef398fcd0f8227a3d (diff)
downloadCMake-550f63447d4c7d2db6ccbeaf1f6378aa6f7af4ed.zip
CMake-550f63447d4c7d2db6ccbeaf1f6378aa6f7af4ed.tar.gz
CMake-550f63447d4c7d2db6ccbeaf1f6378aa6f7af4ed.tar.bz2
ExternalProject/FetchContent: Support relative remote URLs
Teach `ExternalProject_Add` and `FetchContent_Declare` to resolve relative remote URLs provided via `GIT_REPOSITORY`. Add policy CMP0150 to maintain compatibility. Fixes: #24211 Co-Authored-By: Craig Scott <craig.scott@crascit.com>
Diffstat (limited to 'Tests/RunCMake/CMP0150/CMakeLists.txt')
-rw-r--r--Tests/RunCMake/CMP0150/CMakeLists.txt27
1 files changed, 27 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0150/CMakeLists.txt b/Tests/RunCMake/CMP0150/CMakeLists.txt
new file mode 100644
index 0000000..371dccc
--- /dev/null
+++ b/Tests/RunCMake/CMP0150/CMakeLists.txt
@@ -0,0 +1,27 @@
+cmake_minimum_required(VERSION 3.25)
+project(${RunCMake_TEST} NONE)
+
+find_package(Git REQUIRED)
+
+function(execGitCommand workDir)
+ execute_process(
+ WORKING_DIRECTORY "${workDir}"
+ COMMAND "${GIT_EXECUTABLE}" ${ARGN}
+ COMMAND_ECHO STDOUT
+ COMMAND_ERROR_IS_FATAL ANY
+ )
+endfunction()
+
+function(initGitRepo workDir)
+ # init.defaultBranch only works with git 2.28 or later, so we must use the
+ # historical default branch name "master". Force the old default in case test
+ # sites have overridden the default to something else.
+ execGitCommand("${workDir}" -c init.defaultBranch=master init)
+ execGitCommand("${workDir}" config user.email "testauthor@cmake.org")
+ execGitCommand("${workDir}" config user.name testauthor)
+ execGitCommand("${workDir}" config core.autocrlf false)
+ execGitCommand("${workDir}" add CMakeLists.txt)
+ execGitCommand("${workDir}" commit -m "Initial commit")
+endfunction()
+
+include(${RunCMake_TEST}.cmake)