Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into cmake_wheels_option
Browse files Browse the repository at this point in the history
  • Loading branch information
arahlin committed Sep 25, 2024
2 parents d5596c4 + c6fd1b9 commit 6869e54
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions cmake/Spt3gVersion.cmake
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
file(REMOVE ${CMAKE_BINARY_DIR}/cmake/Spt3gConfigVersion.cmake)

# Check VERSION file (sensible in exported source tree)
file(READ ${CMAKE_SOURCE_DIR}/VERSION GIT_VERSION)
string(REGEX REPLACE "\\$Version: (.*)\\$" "\\1" GIT_VERSION "${GIT_VERSION}")
string(REPLACE "$Version$" "" GIT_VERSION "${GIT_VERSION}")
string(STRIP "${GIT_VERSION}" GIT_VERSION)
if (NOT SPT3G_VERSION)
# Check VERSION file (sensible in exported source tree)
file(READ ${CMAKE_SOURCE_DIR}/VERSION GIT_VERSION)
string(REGEX REPLACE "\\$Version: (.*)\\$" "\\1" GIT_VERSION "${GIT_VERSION}")
string(REPLACE "$Version$" "" GIT_VERSION "${GIT_VERSION}")
string(STRIP "${GIT_VERSION}" GIT_VERSION)

if (NOT GIT_VERSION)
find_package(Git QUIET)

if (NOT GIT_EXECUTABLE)
return()
endif()

# Get version string from git
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
ERROR_VARIABLE GIT_VERSION_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (GIT_VERSION_ERROR)
return()
endif()

if (NOT GIT_VERSION)
find_package(Git QUIET)

if (NOT GIT_EXECUTABLE)
return()
endif()

# Get version string from git
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
ERROR_VARIABLE GIT_VERSION_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Extract numerical version, expect tag to be of the form v0.1.2
string(REGEX REPLACE "^v([0-9\\.]+).*" "\\1" VERSION "${GIT_VERSION}")
string(REGEX MATCH "^([0-9\\.]+)$" TEST_VERSION ${VERSION})

if (GIT_VERSION_ERROR)
if (NOT TEST_VERSION)
return()
endif()
endif()

# Extract numerical version, expect tag to be of the form v0.1.2
string(REGEX REPLACE "^v([0-9\\.]+).*" "\\1" VERSION "${GIT_VERSION}")
string(REGEX MATCH "^([0-9\\.]+)$" TEST_VERSION ${VERSION})

if (NOT TEST_VERSION)
return()
set(SPT3G_VERSION ${VERSION})
endif()

set(SPT3G_VERSION ${VERSION})

# Populate the config file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
Expand Down

0 comments on commit 6869e54

Please sign in to comment.