summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--cmake/GenerateVersion.cmake2
-rw-r--r--cmake/Version.cmake12
3 files changed, 11 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66d67a4..26e786f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,7 +63,7 @@ set(INCLUDE_VERSION_HEADER ${PROJECT_INCLUDE_DIR}/xloop/version.h)
set(INCLUDE_VERSION_HEADER_TEMPLATE ${PROJECT_INCLUDE_DIR}/xloop/version.h.in)
set(INCLUDE_VERSION_HEADER_GENERATE ${PROJECT_INCLUDE_GEN_DIR}/xloop/version.h)
set(INCLUDE_VERSION_HEADER_GENERATE_PREFIX ${PROJECT_INCLUDE_DIR_PREFIX}/xloop)
-gen_project_version(${INCLUDE_VERSION_HEADER} ${INCLUDE_VERSION_HEADER_TEMPLATE} ${INCLUDE_VERSION_HEADER_GENERATE})
+gen_project_version(${INCLUDE_VERSION_HEADER} ${INCLUDE_VERSION_HEADER_TEMPLATE} ${INCLUDE_VERSION_HEADER_GENERATE} ${GIT_EXECUTABLE} ${CMAKE_SOURCE_DIR})
# generate project build type C header file from template
# exposes xloop-generate-build and xloop-build target
@@ -82,7 +82,7 @@ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG")
# define packaging if Release build is enabled
if(CMAKE_BUILD_TYPE MATCHES "Release")
# get version source package or Git repository
- get_repository_version(REPOSITORY_VERSION ${INCLUDE_VERSION_HEADER} ${CMAKE_BUILD_TYPE})
+ get_repository_version(REPOSITORY_VERSION ${INCLUDE_VERSION_HEADER} ${CMAKE_BUILD_TYPE} ${GIT_EXECUTABLE} ${CMAKE_SOURCE_DIR})
# define project version
if(KernelHeaders_VERSION)
diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake
index 73b0771..c714428 100644
--- a/cmake/GenerateVersion.cmake
+++ b/cmake/GenerateVersion.cmake
@@ -11,7 +11,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
include(Version)
# get Git version of Git repository
-get_repository_version(XLOOP_VERSION ${VERSION_INPUT_FILE} ${VERSION_BUILD_TYPE})
+get_repository_version(XLOOP_VERSION ${VERSION_INPUT_FILE} ${VERSION_BUILD_TYPE} ${GIT_EXECUTABLE} ${REPOSITORY_DIR})
# generate version header if header does not exists
if(NOT EXISTS ${VERSION_INPUT_FILE})
diff --git a/cmake/Version.cmake b/cmake/Version.cmake
index 5c72c35..d785e1f 100644
--- a/cmake/Version.cmake
+++ b/cmake/Version.cmake
@@ -3,7 +3,7 @@
# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
#
-macro(gen_project_version VERSION_INPUT_FILE VERSION_INPUT_FILE_TEMPLATE VERSION_OUTPUT_FILE)
+macro(gen_project_version VERSION_INPUT_FILE VERSION_INPUT_FILE_TEMPLATE VERSION_OUTPUT_FILE GIT_EXECUTABLE REPOSITORY_DIR)
get_filename_component(VERSION_OUTPUT_FILENAME ${VERSION_OUTPUT_FILE} NAME)
# command that will trigger a rebuild of version.h every time
add_custom_command(OUTPUT regenerate-version-file
@@ -17,6 +17,8 @@ macro(gen_project_version VERSION_INPUT_FILE VERSION_INPUT_FILE_TEMPLATE VERSION
-D VERSION_INPUT_FILE_TEMPLATE=${VERSION_INPUT_FILE_TEMPLATE}
-D VERSION_OUTPUT_FILE=${VERSION_OUTPUT_FILE}
-D VERSION_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
+ -D REPOSITORY_DIR=${REPOSITORY_DIR}
-P ${PROJECT_MODULES_DIR}/GenerateVersion.cmake
COMMENT "Generating ${VERSION_OUTPUT_FILENAME}"
DEPENDS regenerate-version-file)
@@ -29,7 +31,7 @@ macro(gen_project_version VERSION_INPUT_FILE VERSION_INPUT_FILE_TEMPLATE VERSION
endmacro(gen_project_version VERSION_INPUT_FILE VERSION_INPUT_FILE_TEMPLATE VERSION_OUTPUT_FILE)
# macro to get Git version information
-macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUILD_TYPE)
+macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUILD_TYPE GIT_EXECUTABLE REPOSITORY_DIR)
# check if generated version header from source package is available
if(EXISTS ${VERSION_HEADER_FILE})
# get version information from the generated version header of the source package
@@ -38,7 +40,8 @@ macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUIL
set(GIT_VERSION "${CMAKE_MATCH_1}")
else(EXISTS ${VERSION_HEADER_FILE})
# get detailed Git version information from Git repository
- execute_process(COMMAND git describe HEAD
+ execute_process(COMMAND ${GIT_EXECUTABLE} describe HEAD
+ WORKING_DIRECTORY ${REPOSITORY_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -51,7 +54,8 @@ macro(get_repository_version REPOSITORY_VERSION VERSION_HEADER_FILE VERSION_BUIL
endif(GIT_VERSION STREQUAL "")
# get status of Git repository
- execute_process(COMMAND git status --porcelain
+ execute_process(COMMAND ${GIT_EXECUTABLE} status --porcelain
+ WORKING_DIRECTORY ${REPOSITORY_DIR}
OUTPUT_VARIABLE GIT_STATUS
OUTPUT_STRIP_TRAILING_WHITESPACE)