-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do some ridiculous bending-over-backwards to avoid CMake errors in fi…
…nding RandLAPACK version. This change only addresses failures that happened when CMakeCache.txt was edited after it was initially created.
- Loading branch information
1 parent
cf34ca5
commit 3b2887d
Showing
1 changed file
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,53 @@ | ||
set(tmp) | ||
|
||
# Find Git executable | ||
find_package(Git QUIET) | ||
if(GIT_FOUND) | ||
execute_process(COMMAND ${GIT_EXECUTABLE} | ||
--git-dir=${CMAKE_SOURCE_DIR}/.git describe | ||
--tags --match "[0-9]*.[0-9]*.[0-9]*" | ||
OUTPUT_VARIABLE tmp OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_QUIET) | ||
message(STATUS "Git found: ${GIT_EXECUTABLE}") | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git describe --tags --match "[0-9]*.[0-9]*.[0-9]*" | ||
OUTPUT_VARIABLE tmp | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
ERROR_VARIABLE git_error | ||
RESULT_VARIABLE git_result | ||
) | ||
|
||
# Print the result of the Git command | ||
message(STATUS "Git command result: ${git_result}") | ||
message(STATUS "Git command output: ${tmp}") | ||
if(NOT git_result EQUAL 0) | ||
message(WARNING "Git command failed with error: ${git_error}") | ||
set(tmp "0.0.0") | ||
endif() | ||
else() | ||
message(WARNING "Git not found, using fallback version 0.0.0") | ||
set(tmp "0.0.0") | ||
endif() | ||
|
||
# Check if tmp is empty and set a fallback version if necessary | ||
if(NOT tmp) | ||
message(WARNING "Git describe output is empty, using fallback version 0.0.0") | ||
set(tmp "0.0.0") | ||
endif() | ||
|
||
set(RandLAPACK_VERSION ${tmp} CACHE STRING "RandLAPACK version" FORCE) | ||
# Debugging: Print tmp before setting RandLAPACK_VERSION | ||
message(STATUS "tmp before setting RandLAPACK_VERSION: ${tmp}") | ||
|
||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*$)" | ||
"\\1" RandLAPACK_VERSION_MAJOR ${RandLAPACK_VERSION}) | ||
# Set RandLAPACK_VERSION without CACHE option | ||
set(RandLAPACK_VERSION "${tmp}") | ||
message(STATUS "RandLAPACK_VERSION after setting: ${RandLAPACK_VERSION}") | ||
|
||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*$)" | ||
"\\2" RandLAPACK_VERSION_MINOR ${RandLAPACK_VERSION}) | ||
# Ensure RandLAPACK_VERSION is not empty | ||
if(NOT RandLAPACK_VERSION) | ||
message(FATAL_ERROR "RandLAPACK_VERSION is empty") | ||
endif() | ||
|
||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*$)" | ||
"\\3" RandLAPACK_VERSION_PATCH ${RandLAPACK_VERSION}) | ||
# Extract major, minor, and patch versions | ||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" "\\1" RandLAPACK_VERSION_MAJOR "${RandLAPACK_VERSION}") | ||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" "\\2" RandLAPACK_VERSION_MINOR "${RandLAPACK_VERSION}") | ||
string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" "\\3" RandLAPACK_VERSION_PATCH "${RandLAPACK_VERSION}") | ||
|
||
# Print extracted version components | ||
message(STATUS "RandLAPACK_VERSION_MAJOR=${RandLAPACK_VERSION_MAJOR}") | ||
message(STATUS "RandLAPACK_VERSION_MINOR=${RandLAPACK_VERSION_MINOR}") | ||
message(STATUS "RandLAPACK_VERSION_PATCH=${RandLAPACK_VERSION_PATCH}") |