Skip to content

Commit

Permalink
Merge branch 'build-without-git' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipFackler committed Jan 29, 2025
2 parents 66840c9 + 34f7d11 commit ce92474
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CMake/SetupPlsm.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(NOT Xolotl_USE_GIT)
return()
endif()

function(find_plsm __result)
list(APPEND CMAKE_PREFIX_PATH ${plsm_DIR})
find_package(plsm QUIET)
Expand Down
24 changes: 23 additions & 1 deletion CMake/VersionFromGit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function(version_from_git)
)

if(DEFINED ARG_GIT_EXECUTABLE)
set( GIT_EXECUTABLE "${ARG_GIT_EXECUTABLE}")
set(GIT_EXECUTABLE "${ARG_GIT_EXECUTABLE}")
else()
# Find Git or bail out
find_package(Git)
Expand Down Expand Up @@ -114,6 +114,28 @@ function(version_from_git)

endfunction(version_from_git)

## Check if it's appropriate to use git
find_package(Git)
if(NOT GIT_FOUND)
## Git not available
set(Xolotl_USE_GIT FALSE CACHE INTERNAL "")
return()
endif()
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --is-inside-work-tree
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE git_result
OUTPUT_VARIABLE git_output
ERROR_VARIABLE git_error
)
if(NOT git_result EQUAL 0)
## Not using Git for source
set(Xolotl_USE_GIT FALSE CACHE INTERNAL "")
return()
endif()

## Follow through
set(Xolotl_USE_GIT TRUE CACHE INTERNAL "")
option(Xolotl_VERSION_LOG "Print details of version from git" OFF)
version_from_git(LOG ${Xolotl_VERSION_LOG})
set(Xolotl_VERSION_EXACT ${VERSION_EXACT})
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.13)

# Fix cmake behavior for CMAKE_CXX_STANDARD with clang on Mac OS X.
# See cmake documentation on CMP0025 policy for details.
Expand All @@ -15,9 +15,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(Xolotl
VERSION ${VERSION}
VERSION 3.0.1
LANGUAGES CXX
)
if(NOT Xolotl_VERSION_EXACT)
set(Xolotl_VERSION_EXACT ${Xolotl_VERSION})
endif()
enable_language(C)

## MPI
Expand Down

0 comments on commit ce92474

Please sign in to comment.