From 3210410eec1296f48c73f804253eb41dffded0df Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 30 Apr 2024 20:52:00 +0700 Subject: [PATCH] DONT MERGE --- CMakeLists.txt | 2 +- cmake/GitCheckout.cmake | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03fd32f..c245ec6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.19) +cmake_minimum_required(VERSION 3.24) project( GitCheckout diff --git a/cmake/GitCheckout.cmake b/cmake/GitCheckout.cmake index e5501b1..a477bae 100644 --- a/cmake/GitCheckout.cmake +++ b/cmake/GitCheckout.cmake @@ -3,6 +3,8 @@ include_guard(GLOBAL) +cmake_minimum_required(VERSION 3.24) + # Find the Git executable. # # It will set the 'GIT_EXECUTABLE' variable to the location of the Git executable. @@ -38,10 +40,13 @@ function(_git_incomplete_clone URL) if(EXISTS ${ARG_DIRECTORY}) execute_process( - COMMAND ${GIT_EXECUTABLE} -C ${ARG_DIRECTORY} rev-parse --is-inside-work-tree + COMMAND ${GIT_EXECUTABLE} -C ${ARG_DIRECTORY} rev-parse --show-toplevel RESULT_VARIABLE RES + OUTPUT_VARIABLE OUT ) - if(NOT RES EQUAL 0) + string(STRIP ${OUT} OUT) + message(WARNING "'${OUT}' compared to '${CMAKE_CURRENT_BINARY_DIR}/${ARG_DIRECTORY}'") + if(NOT RES EQUAL 0 OR NOT OUT PATH_EQUAL ${CMAKE_CURRENT_BINARY_DIR}/${ARG_DIRECTORY}) message(FATAL_ERROR "Unable to clone '${URL}' to '${ARG_DIRECTORY}' because the path already exists and is not a Git repository") endif() else()