Allow setting VERSION_GIT

Fixes: #79
git-override
Thomas Orozco 8 years ago
parent 6ad9813ed8
commit bb0e1816a1
  1. 12
      CMakeLists.txt

@ -6,14 +6,23 @@ set (tini_VERSION_MAJOR 0)
set (tini_VERSION_MINOR 14)
set (tini_VERSION_PATCH 0)
set (GIT_PREFIX " - git.")
# Build options
option(MINIMAL "Disable argument parsing and verbose output" OFF)
# Set VERSION_GIT to INTERNAL so it does not persist across runs of CMake, just
# like the auto-discovery would.
set(VERSION_GIT "" CACHE INTERNAL "Override the git revision")
if(MINIMAL)
add_definitions(-DTINI_MINIMAL=1)
endif()
# Extract git version and dirty-ness
if(VERSION_GIT)
set(tini_VERSION_GIT "${GIT_PREFIX}${VERSION_GIT}")
else()
execute_process (
COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
@ -28,13 +37,14 @@ execute_process(
)
if("${git_version_check_ret}" EQUAL 0)
set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
set(tini_VERSION_GIT "${GIT_PREFIX}${tini_VERSION_GIT}")
if(NOT "${git_dirty_check_out}" STREQUAL "")
set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
endif()
else()
set(tini_VERSION_GIT "")
endif()
endif()
# Flags
include(CheckCSourceCompiles)

Loading…
Cancel
Save