]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Make git dependency optional if GIT_VERSION is set
authorAntoine Fontaine <antoine.fontaine@epfl.ch>
Thu, 10 Feb 2022 21:14:17 +0000 (22:14 +0100)
committerAntoine Fontaine <antoine.fontaine@epfl.ch>
Thu, 10 Feb 2022 21:14:17 +0000 (22:14 +0100)
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}")