aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Winter <winter@kde.org>2022-07-15 10:05:38 -0400
committerAllen Winter <winter@kde.org>2022-07-15 10:05:38 -0400
commitce726d388a59b941e2e6f6f487132532511af03d (patch)
tree4ac8c55859b3e1c705af1b49bc468796c91c0844
parent7d9d14e769bd921dc4372ae9077ccc70381314a6 (diff)
downloadextra-cmake-modules-5.97.0-rc1.tar.gz
extra-cmake-modules-5.97.0-rc1.tar.bz2
kde-modules/KDEGitCommitHooks.cmake - handle non-toplevel projectv5.97.0-rc1v5.97.0
Only install pre-commit hooks if KDE_CONFIGURE_GIT_PRE_COMMIT_HOOK is called frm CMAKE_CURRENT_PROEJECT, eg. don't install pre-commit hooks if ECM is inside a submodule or fetched-content.
-rw-r--r--kde-modules/KDEGitCommitHooks.cmake5
1 files changed, 5 insertions, 0 deletions
diff --git a/kde-modules/KDEGitCommitHooks.cmake b/kde-modules/KDEGitCommitHooks.cmake
index f9c48ae4..44e0e0fa 100644
--- a/kde-modules/KDEGitCommitHooks.cmake
+++ b/kde-modules/KDEGitCommitHooks.cmake
@@ -51,6 +51,11 @@ function(KDE_CONFIGURE_GIT_PRE_COMMIT_HOOK)
set(_multiValueArgs CHECKS)
cmake_parse_arguments(ARG "" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN} )
+ if(NOT CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
+ message(STATUS "Project is not top level project - pre-commit hook not installed")
+ return()
+ endif()
+
if(NOT ARG_CHECKS)
message(FATAL_ERROR "No checks were specified")
endif()