diff --git a/CMakeLists.txt b/CMakeLists.txt index 05e07e44930..0e1b60ce704 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 "" ) diff --git a/Src/CMakeLists.txt b/Src/CMakeLists.txt index 8dd612246ad..383bf2b1f12 100644 --- a/Src/CMakeLists.txt +++ b/Src/CMakeLists.txt @@ -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