summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Tests/ExternalProject/CMakeLists.txt14
-rw-r--r--Tests/ExternalProject/gitrepo-sub-rec.tgzbin9008 -> 2086 bytes
-rw-r--r--Tests/ExternalProject/gitrepo-sub.tgzbin1911 -> 2229 bytes
-rwxr-xr-xTests/ExternalProject/gitrepo.bash129
-rw-r--r--Tests/ExternalProject/gitrepo.tgzbin1934 -> 1817 bytes
5 files changed, 136 insertions, 7 deletions
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index 8fd44b4..132abf4 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -329,7 +329,7 @@ if(do_git_tests)
set(proj TutorialStep1-GIT-byhash)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
- GIT_TAG d1970730310fe8bc07e73f15dc570071f9f9654a
+ GIT_TAG 57418671a0a0e371e7bac532337152595fbe0df5 # generated by gitrepo.bash
UPDATE_COMMAND ""
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
@@ -664,23 +664,23 @@ endif()
if(do_git_tests)
add_test(TutorialStep1-GIT-byhash
- "${binary_base}/TutorialStep1-GIT-byhash/Tutorial" 100)
+ ${CMAKE_COMMAND} -P "${binary_base}/TutorialStep1-GIT-byhash/example.cmake")
add_test(TutorialStep1-GIT-bytag
- "${binary_base}/TutorialStep1-GIT-bytag/Tutorial" 99)
+ ${CMAKE_COMMAND} -P "${binary_base}/TutorialStep1-GIT-bytag/example.cmake")
add_test(TutorialStep1-GIT-bytag-withsubmodules
- "${binary_base}/TutorialStep1-GIT-bytag-withsubmodules/Tutorial" 99)
+ ${CMAKE_COMMAND} -P "${binary_base}/TutorialStep1-GIT-bytag-withsubmodules/example.cmake")
add_test(TutorialStep1-GIT-shallow-master
- "${binary_base}/TutorialStep1-GIT-shallow-master/Tutorial" 98)
+ ${CMAKE_COMMAND} -P "${binary_base}/TutorialStep1-GIT-shallow-master/example.cmake")
add_test(TutorialStep1-GIT-master
- "${binary_base}/TutorialStep1-GIT-master/Tutorial" 98)
+ ${CMAKE_COMMAND} -P "${binary_base}/TutorialStep1-GIT-master/example.cmake")
if(NOT git_version VERSION_LESS 1.7.7)
add_test(TutorialStep1-GIT-config
- "${binary_base}/TutorialStep1-GIT-config/Tutorial" 98)
+ ${CMAKE_COMMAND} -P "${binary_base}/TutorialStep1-GIT-config/example.cmake")
endif()
endif()
diff --git a/Tests/ExternalProject/gitrepo-sub-rec.tgz b/Tests/ExternalProject/gitrepo-sub-rec.tgz
index b0f3f18..0e63651 100644
--- a/Tests/ExternalProject/gitrepo-sub-rec.tgz
+++ b/Tests/ExternalProject/gitrepo-sub-rec.tgz
Binary files differ
diff --git a/Tests/ExternalProject/gitrepo-sub.tgz b/Tests/ExternalProject/gitrepo-sub.tgz
index c0b5360..ab34fff 100644
--- a/Tests/ExternalProject/gitrepo-sub.tgz
+++ b/Tests/ExternalProject/gitrepo-sub.tgz
Binary files differ
diff --git a/Tests/ExternalProject/gitrepo.bash b/Tests/ExternalProject/gitrepo.bash
new file mode 100755
index 0000000..c341f28
--- /dev/null
+++ b/Tests/ExternalProject/gitrepo.bash
@@ -0,0 +1,129 @@
+#!/usr/bin/env bash
+
+set -e
+set -x
+
+readonly tmpdir="$(mktemp -d)"
+trap "rm -rf '$tmpdir'" EXIT
+
+readonly outdir="${BASH_SOURCE%/*}"
+readonly defaultBranch='master'
+
+export GIT_AUTHOR_NAME='testauthor'
+export GIT_AUTHOR_EMAIL='testauthor@cmake.org'
+export GIT_COMMITTER_NAME='testauthor'
+export GIT_COMMITTER_EMAIL='testauthor@cmake.org'
+
+(
+cd "$tmpdir"
+
+git --bare init -b "$defaultBranch" gitrepo.git
+rm -f gitrepo.git/hooks/*.sample
+
+mkdir gitrepo
+cd gitrepo
+git init -b "$defaultBranch"
+echo 'cmake_minimum_required(VERSION 3.19)
+project(Example NONE)
+add_custom_target(example ALL
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/example.cmake.in example.cmake
+)' >CMakeLists.txt
+echo 'message(STATUS example)' >example.cmake.in
+git add CMakeLists.txt example.cmake.in
+git commit -m "Initial import into repo."
+git push ../gitrepo.git "$defaultBranch"
+cd ../gitrepo.git
+git gc --prune
+cd ..
+ln -s gitrepo.git GIT
+
+git --bare init -b "$defaultBranch" gitrepo-sub.git
+rm -f gitrepo-sub.git/hooks/*.sample
+
+mkdir gitrepo-sub
+cd gitrepo-sub
+git init -b "$defaultBranch"
+echo 'cmake_minimum_required(VERSION 3.19)
+project(ExampleWithSub NONE)
+file(STRINGS "${CMAKE_SOURCE_DIR}/.git/config" git_config_strings
+ REGEX "^\\[submodule")
+foreach(submodule m1 m2)
+ option(WITH_${submodule} "Enable ${submodule}" OFF)
+ set(${submodule}_INITED FALSE)
+ set(${submodule}_UPDATED FALSE)
+ foreach(s ${git_config_strings})
+ if("${s}" MATCHES "${submodule}")
+ set(${submodule}_INITED TRUE)
+ endif()
+ endforeach()
+ if(EXISTS "${CMAKE_SOURCE_DIR}/m/${submodule}/CMakeLists.txt")
+ set(${submodule}_UPDATED TRUE)
+ endif()
+ if(WITH_${submodule})
+ if(NOT ${submodule}_INITED)
+ message(FATAL_ERROR "${submodule} not inited")
+ elseif(NOT ${submodule}_UPDATED)
+ message(FATAL_ERROR "${submodule} not updated")
+ endif()
+ else()
+ if(${submodule}_INITED)
+ message(FATAL_ERROR "${submodule} inited")
+ elseif(${submodule}_UPDATED)
+ message(FATAL_ERROR "${submodule} updated")
+ endif()
+ endif()
+endforeach()' >CMakeLists.txt
+git add CMakeLists.txt
+git submodule add -- ../GIT m/m1
+git submodule add -- ../GIT m/m2
+git submodule add -- ../GIT m/m3
+git commit -m "Initial import into repo."
+git push ../gitrepo-sub.git "$defaultBranch"
+cd ../gitrepo-sub.git
+git gc --prune
+cd ..
+ln -s gitrepo-sub.git GIT-with-submodules
+
+git --bare init -b "$defaultBranch" gitrepo-sub-rec.git
+rm -f gitrepo-sub-rec.git/hooks/*.sample
+
+mkdir gitrepo-sub-rec
+cd gitrepo-sub-rec
+git init -b "$defaultBranch"
+echo 'cmake_minimum_required(VERSION 3.19)
+project(ExampleWithRecSub NONE)
+set(top_submodule_dir "${CMAKE_SOURCE_DIR}/submodule")
+if(NOT EXISTS "${top_submodule_dir}/CMakeLists.txt")
+ message(FATAL_ERROR "Top submodule not updated")
+endif()
+option(WITH_RECURSIVE "Submodules are updated recursively" ON)
+foreach(submodule m1 m2 m3)
+ set(${submodule}_UPDATED FALSE)
+ if(EXISTS "${top_submodule_dir}/m/${submodule}/CMakeLists.txt")
+ set(${submodule}_UPDATED TRUE)
+ endif()
+ if(WITH_RECURSIVE)
+ if(NOT ${submodule}_UPDATED)
+ message(FATAL_ERROR "${submodule} not updated")
+ endif()
+ else()
+ if(${submodule}_UPDATED)
+ message(FATAL_ERROR "${submodule} updated")
+ endif()
+ endif()
+endforeach()' >CMakeLists.txt
+git add CMakeLists.txt
+git submodule add -- ../GIT-with-submodules submodule
+git commit -m "Initial import into repo."
+git push ../gitrepo-sub-rec.git "$defaultBranch"
+cd ../gitrepo-sub-rec.git
+git gc --prune
+cd ..
+)
+
+tar cvzf "$outdir/gitrepo.tgz" -C "$tmpdir" gitrepo.git
+tar cvzf "$outdir/gitrepo-sub.tgz" -C "$tmpdir" gitrepo-sub.git
+tar cvzf "$outdir/gitrepo-sub-rec.tgz" -C "$tmpdir" gitrepo-sub-rec.git
+
+git_tag=$(cd "$tmpdir/gitrepo.git" ; git rev-parse HEAD)
+sed -i "/generated by gitrepo.bash/ s/ [0-9a-f]\\+ / $git_tag /" "$outdir/CMakeLists.txt"
diff --git a/Tests/ExternalProject/gitrepo.tgz b/Tests/ExternalProject/gitrepo.tgz
index 0a84bda..8d2d144 100644
--- a/Tests/ExternalProject/gitrepo.tgz
+++ b/Tests/ExternalProject/gitrepo.tgz
Binary files differ