summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/CMP0150/CMakeLists.txt
blob: 371dccc7b29647a661143c9235d53413bd8e22a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)