Skip to content

Commit

Permalink
Merge pull request #92 from kwryankrattiger/version_detection
Browse files Browse the repository at this point in the history
Version detection updates
  • Loading branch information
burlen authored Dec 14, 2022
2 parents ea67891 + 262032a commit 1eb4475
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions CMake/version.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
set(tmp)
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE}
--git-dir=${CMAKE_SOURCE_DIR}/.git describe --tags
OUTPUT_VARIABLE tmp OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if(NOT tmp)
# Set this to the latest released version.
# This version is used when using release tarballs
set(SENSEI_VERSION "<DEFAULT>" CACHE STRING "SENSEI version")

# Default detection of version
if (SENSEI_VERSION STREQUAL "<DEFAULT>")
# The default version is the current major release
# This is required for computing version in released
# source tarballs.
set(tmp "v4.0.0")

# If inside a git repo, attempt to inspect the tag instead
# of using the hardcoded value
if (EXISTS ${CMAKE_SOURCE_DIR}/.git)
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE}
--git-dir=${CMAKE_SOURCE_DIR}/.git describe --tags
OUTPUT_VARIABLE tmp OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif ()

# Override the CACHE variable for configure with the computed
# version
set(SENSEI_VERSION ${tmp})
endif()
set(SENSEI_VERSION ${tmp} CACHE STRING "SENSEI version" FORCE)

string(REGEX REPLACE "^v([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*$)"
"\\1" SENSEI_VERSION_MAJOR ${SENSEI_VERSION})
Expand Down

0 comments on commit 1eb4475

Please sign in to comment.