mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 02:40:59 +00:00
Option to read VERSION file in cmake #3927
This commit is contained in:
+30
-17
@@ -27,8 +27,6 @@ if(CCACHE_FOUND)
|
|||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(IfcOpenShell VERSION 0.8.0)
|
|
||||||
|
|
||||||
cmake_policy(SET CMP0048 NEW)
|
cmake_policy(SET CMP0048 NEW)
|
||||||
cmake_policy(SET CMP0074 NEW)
|
cmake_policy(SET CMP0074 NEW)
|
||||||
cmake_policy(SET CMP0078 OLD)
|
cmake_policy(SET CMP0078 OLD)
|
||||||
@@ -82,6 +80,17 @@ option(WITH_RELATIONSHIP_VALIDATION "Build IfcConvert with option to validate ge
|
|||||||
|
|
||||||
option(USERSPACE_PYTHON_PREFIX "Installs IfcPython for the current user only instead of system-wide." OFF)
|
option(USERSPACE_PYTHON_PREFIX "Installs IfcPython for the current user only instead of system-wide." OFF)
|
||||||
option(ADD_COMMIT_SHA "Add commit sha and branch in version number, warning results in many rebuilds, requires git" OFF)
|
option(ADD_COMMIT_SHA "Add commit sha and branch in version number, warning results in many rebuilds, requires git" OFF)
|
||||||
|
option(VERSION_OVERRIDE "Override the version defined in IfcParse.h with the file VERSION in the repository root" OFF)
|
||||||
|
|
||||||
|
if (VERSION_OVERRIDE)
|
||||||
|
file(READ "../VERSION" "RELEASE_VERSION_")
|
||||||
|
string(STRIP "${RELEASE_VERSION_}" RELEASE_VERSION)
|
||||||
|
message(STATUS "Detected version '${RELEASE_VERSION}'")
|
||||||
|
else()
|
||||||
|
set(RELEASE_VERSION "0.8.0")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(IfcOpenShell VERSION ${RELEASE_VERSION})
|
||||||
|
|
||||||
if(MINIMAL_BUILD)
|
if(MINIMAL_BUILD)
|
||||||
message(STATUS "Setting options for minimal build")
|
message(STATUS "Setting options for minimal build")
|
||||||
@@ -1097,22 +1106,26 @@ if(ADD_COMMIT_SHA)
|
|||||||
find_package(Git)
|
find_package(Git)
|
||||||
|
|
||||||
if(GIT_FOUND)
|
if(GIT_FOUND)
|
||||||
message("git found: ${GIT_EXECUTABLE} with version ${GIT_VERSION_STRING}")
|
if (VERSION_OVERRIDE)
|
||||||
execute_process(
|
set (git_branch ${RELEASE_VERSION})
|
||||||
COMMAND ${GIT_EXECUTABLE} branch -a --contains HEAD
|
else()
|
||||||
OUTPUT_VARIABLE git_branches
|
message("git found: ${GIT_EXECUTABLE} with version ${GIT_VERSION_STRING}")
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
execute_process(
|
||||||
)
|
COMMAND ${GIT_EXECUTABLE} branch -a --contains HEAD
|
||||||
string(REPLACE "\n" ";" git_branch_list "${git_branches}")
|
OUTPUT_VARIABLE git_branches
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
string(REPLACE "\n" ";" git_branch_list "${git_branches}")
|
||||||
|
|
||||||
foreach(git_branch_candidate IN ITEMS ${git_branch_list})
|
foreach(git_branch_candidate IN ITEMS ${git_branch_list})
|
||||||
string(REPLACE "*" "" git_branch_candidate_temp "${git_branch_candidate}")
|
string(REPLACE "*" "" git_branch_candidate_temp "${git_branch_candidate}")
|
||||||
string(STRIP "${git_branch_candidate_temp}" git_branch_candidate_2)
|
string(STRIP "${git_branch_candidate_temp}" git_branch_candidate_2)
|
||||||
if(NOT git_branch_candidate_2 MATCHES "^HEAD$")
|
if(NOT git_branch_candidate_2 MATCHES "^HEAD$")
|
||||||
string(REPLACE "/" ";" git_branch_candidate_2_list "${git_branch_candidate_2}")
|
string(REPLACE "/" ";" git_branch_candidate_2_list "${git_branch_candidate_2}")
|
||||||
list(GET git_branch_candidate_2_list -1 git_branch)
|
list(GET git_branch_candidate_2_list -1 git_branch)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||||
|
|||||||
Reference in New Issue
Block a user