Merge branch 'make-git-dependency-optional' into 'master'
authorThomas Debesse <dev@illwieckz.net>
Tue, 15 Feb 2022 22:08:33 +0000 (22:08 +0000)
committerThomas Debesse <dev@illwieckz.net>
Tue, 15 Feb 2022 22:08:33 +0000 (22:08 +0000)
Make git dependency optional if GIT_VERSION is set

See merge request xonotic/netradiant!191

CMakeLists.txt

index be945731044fe6c2e7eeefd0a4a175642edc9108..d865faf5ab091ade78031e66c28a187fdb6f2b09 100644 (file)
@@ -148,19 +148,21 @@ set(RADIANT_VERSION "${RADIANT_VERSION_MAJOR}.${RADIANT_VERSION_MINOR}.${RADIANT
 
 set(RADIANT_ABOUTMSG "Custom build" CACHE STRING "About message")
 
-find_package(Git REQUIRED)
+set(RADIANT_VERSION_STRING "${RADIANT_VERSION}n")
 
-execute_process(
-     COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
-     WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
-     OUTPUT_VARIABLE GIT_VERSION
-     OUTPUT_STRIP_TRAILING_WHITESPACE
-)
+if (NOT DEFINED GIT_VERSION)
+     find_package(Git REQUIRED)
 
-set(RADIANT_VERSION_STRING "${RADIANT_VERSION}n")
+     execute_process(
+          COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
+          WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+          OUTPUT_VARIABLE GIT_VERSION
+          OUTPUT_STRIP_TRAILING_WHITESPACE
+     )
 
-if (GIT_VERSION)
-    set(RADIANT_VERSION_STRING "${RADIANT_VERSION_STRING}-git-${GIT_VERSION}")
+     if (GIT_VERSION)
+         set(RADIANT_VERSION_STRING "${RADIANT_VERSION_STRING}-git-${GIT_VERSION}")
+     endif ()
 endif ()
 
 message(STATUS "Building ${PROJECT_NAME} ${RADIANT_VERSION_STRING} ${RADIANT_ABOUTMSG}")