diff options
author | Chris Robinson <[email protected]> | 2016-12-21 11:41:45 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-12-21 11:41:45 -0800 |
commit | 1b104dd77baeb6d991ec2ff279c87e6e46527d44 (patch) | |
tree | e9e6464bdc6053bb046a81fb5b359753667f1023 /CMakeLists.txt | |
parent | e270a9784bdacecedb98312a4e2e9ef75ef7df62 (diff) |
More robustly generate the git commit ID and branch
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e1e9a851..55c832ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1174,23 +1174,24 @@ IF(LIBTYPE STREQUAL "STATIC") SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS}) ENDIF() -IF(EXISTS "${OpenAL_SOURCE_DIR}/.git") +FIND_PACKAGE(Git) +IF(GIT_FOUND AND EXISTS "${OpenAL_SOURCE_DIR}/.git") # Get the current working branch and its latest abbreviated commit hash - EXECUTE_PROCESS( - COMMAND git rev-parse --abbrev-ref HEAD + ADD_CUSTOM_TARGET(version + ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} + -D LIB_VERSION=${LIB_VERSION} + -D SRC=${OpenAL_SOURCE_DIR}/version.h.in + -D DST=${OpenAL_BINARY_DIR}/version.h + -P ${OpenAL_SOURCE_DIR}/version.cmake WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}" - OUTPUT_VARIABLE GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - EXECUTE_PROCESS( - COMMAND git log -1 --format=%h - WORKING_DIRECTORY "${OpenAL_SOURCE_DIR}" - OUTPUT_VARIABLE GIT_COMMIT_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE + VERBATIM ) ELSE() SET(GIT_BRANCH "UNKNOWN") SET(GIT_COMMIT_HASH "unknown") + CONFIGURE_FILE( + "${OpenAL_SOURCE_DIR}/version.h.in" + "${OpenAL_BINARY_DIR}/version.h") ENDIF() # Needed for openal.pc.in @@ -1203,9 +1204,6 @@ SET(PACKAGE_VERSION "${LIB_VERSION}") # End configuration CONFIGURE_FILE( - "${OpenAL_SOURCE_DIR}/version.h.in" - "${OpenAL_BINARY_DIR}/version.h") -CONFIGURE_FILE( "${OpenAL_SOURCE_DIR}/config.h.in" "${OpenAL_BINARY_DIR}/config.h") CONFIGURE_FILE( @@ -1296,6 +1294,9 @@ IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC") ENDIF() TARGET_LINK_LIBRARIES(${LIBNAME} common ${EXTRA_LIBS}) +IF(TARGET version) + ADD_DEPENDENCIES(${LIBNAME} version) +ENDIF() IF(ALSOFT_INSTALL) # Add an install target here |