Skip to content

Commit

Permalink
CMake: provide AMReX versioning even when .git is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
mic84 committed Jul 4, 2018
1 parent 2668c5a commit 1e12eef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ if ( EXISTS ${CMAKE_SOURCE_DIR}/.git AND ${GIT_FOUND} )
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE TMP )
string ( STRIP ${TMP} TMP )
else ()
# Grep first line from file CHANGES if AMREX_GIT_VERSION is not
# provided
file(STRINGS ${PROJECT_SOURCE_DIR}/CHANGES ALL_VERSIONS REGEX "#")
list(GET ALL_VERSIONS 0 TMP)
string(REPLACE "#" "" TMP "${TMP}")
string (STRIP "${TMP}" TMP )
set (TMP "${TMP}.0")
endif ()

set ( AMREX_GIT_VERSION "${TMP}" CACHE INTERNAL "" )
Expand Down
10 changes: 6 additions & 4 deletions Src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ if (AMREX_GIT_VERSION)
string (FIND "${AMREX_VERSION}" "-" IDX REVERSE)
string (SUBSTRING "${AMREX_VERSION}" 0 "${IDX}" AMREX_VERSION )
string (REPLACE "-" "." AMREX_VERSION "${AMREX_VERSION}")

write_basic_package_version_file ( ${CMAKE_BINARY_DIR}/AMReXConfigVersion.cmake
VERSION ${AMREX_VERSION}
COMPATIBILITY AnyNewerVersion )
endif ()

write_basic_package_version_file ( ${CMAKE_BINARY_DIR}/AMReXConfigVersion.cmake
VERSION ${AMREX_VERSION}
COMPATIBILITY AnyNewerVersion )



install ( FILES
${CMAKE_BINARY_DIR}/export/AMReXConfig.cmake
${CMAKE_BINARY_DIR}/AMReXConfigVersion.cmake
Expand Down

0 comments on commit 1e12eef

Please sign in to comment.