File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Get the version from our sub cmakefile
22execute_process (
33 COMMAND ${CMAKE_COMMAND } -P "${CMAKE_CURRENT_LIST_DIR } /gitversion.cmake"
4- ERROR_VARIABLE PROJECT_VERSION
4+ OUTPUT_VARIABLE PROJECT_VERSION
5+ ERROR_VARIABLE PROJECT_VERSION_ERROR
6+ RESULT_VARIABLE PROJECT_VERSION_RESULT
7+ OUTPUT_STRIP_TRAILING_WHITESPACE
58 ERROR_STRIP_TRAILING_WHITESPACE
69)
710
8- # Cleanup output
11+ if (NOT PROJECT_VERSION_RESULT EQUAL 0)
12+ if (PROJECT_VERSION_ERROR)
13+ message (FATAL_ERROR "Version calculation failed: ${PROJECT_VERSION_ERROR} " )
14+ else ()
15+ message (FATAL_ERROR "Version calculation failed with exit code ${PROJECT_VERSION_RESULT} " )
16+ endif ()
17+ endif ()
18+
19+ # Strip CMake's status prefix and surrounding whitespace
20+ string (REGEX REPLACE "^--[ \t ]*" "" PROJECT_VERSION "${PROJECT_VERSION } " )
921string (REGEX REPLACE "^[[:space:]]+|[[:space:]]+$" "" PROJECT_VERSION "${PROJECT_VERSION } " )
10- string (REGEX REPLACE "\n $" "" PROJECT_VERSION "${PROJECT_VERSION } " )
11- message ("${PROJECT_VERSION } " )
22+
23+ if (PROJECT_VERSION STREQUAL "" )
24+ message (FATAL_ERROR "Version calculation returned an empty string" )
25+ endif ()
26+
27+ # Emit plain text so shell captures are clean
28+ execute_process (
29+ COMMAND ${CMAKE_COMMAND } -E echo "${PROJECT_VERSION } "
30+ )
1231
You can’t perform that action at this time.
0 commit comments