From: azv Date: Thu, 1 Dec 2016 10:57:16 +0000 (+0300) Subject: Correct placing pre-commit Git hook when Shaper is built as a submodule. X-Git-Tag: V_2.6.0~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7ccd19392b8eb45c4bd907bbe522bf70d48f219c;p=modules%2Fshaper.git Correct placing pre-commit Git hook when Shaper is built as a submodule. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd0e3bf0..7ab0eb874 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,7 +117,15 @@ add_custom_target(uninstall endif (CMAKE_GENERATOR MATCHES "NMake Makefiles") # Add special Git hooks -if(EXISTS "${CMAKE_SOURCE_DIR}/.git") - configure_file("${CMAKE_SOURCE_DIR}/GitHooks/pre-commit.in" - "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit") +if((EXISTS "${CMAKE_SOURCE_DIR}/.git") AND (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")) + if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git") + set(GIT_SUBMODULE_PATH ".git") + else() + file(READ "${CMAKE_CURRENT_SOURCE_DIR}/.git" GIT_SUBMODULE_PATH) + string(REGEX REPLACE "gitdir: " "" GIT_SUBMODULE_PATH "${GIT_SUBMODULE_PATH}") + string(REGEX REPLACE "\n" "" GIT_SUBMODULE_PATH "${GIT_SUBMODULE_PATH}") + endif() + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/GitHooks/pre-commit.in" + "${CMAKE_CURRENT_SOURCE_DIR}/${GIT_SUBMODULE_PATH}/hooks/pre-commit") endif()