Skip to content

Commit

Permalink
CMake: use CMAKE_CURRENT_LIST_DIR instead of CMAKE_SOURCE_DIR when
Browse files Browse the repository at this point in the history
retrieving version info. This fixes issue AMReX-Codes#731.
  • Loading branch information
mic84 committed Mar 5, 2020
1 parent 0ab577a commit c54388b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ find_package (Git QUIET)

set( _tmp "" )

if ( EXISTS ${CMAKE_SOURCE_DIR}/.git AND ${GIT_FOUND} )
if ( EXISTS ${CMAKE_CURRENT_LIST_DIR}/.git AND ${GIT_FOUND} )
execute_process ( COMMAND git describe --abbrev=12 --dirty --always --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE _tmp )
string( STRIP ${_tmp} _tmp )
else ()
# Grep first line from file CHANGES if cannot find version from Git
file(STRINGS ${CMAKE_SOURCE_DIR}/CHANGES ALL_VERSIONS REGEX "#")
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/CHANGES ALL_VERSIONS REGEX "#")
list(GET ALL_VERSIONS 0 _tmp)
string(REPLACE "#" "" _tmp "${_tmp}")
string(STRIP "${_tmp}" _tmp )
Expand All @@ -38,6 +38,7 @@ endif ()
set( AMREX_PKG_VERSION "${_pkg_version}" CACHE INTERNAL "" )
unset(_pkg_version)


########################################################################
#
# AMReX project
Expand Down

0 comments on commit c54388b

Please sign in to comment.