fix cmake PACKAGE_VERSION to behave same way as in autotools

This commit is contained in:
zdenop 2019-01-29 20:01:55 +01:00
parent 394839cdd7
commit fd881e4486
2 changed files with 8 additions and 2 deletions

View File

@ -45,6 +45,13 @@ file(STRINGS "VERSION" VERSION_PLAIN)
string(REGEX REPLACE "^([^.]*)\\..*" "\\1" VERSION_MAJOR ${VERSION_PLAIN})
string(REGEX REPLACE "^[^.]*\\.([^.]*)\\..*" "\\1" VERSION_MINOR ${VERSION_PLAIN})
string(REGEX REPLACE "^[^.]*\\.[^.]*\\.([0-9]*).*" "\\1" VERSION_PATCH ${VERSION_PLAIN})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
execute_process(COMMAND git describe --abbrev=4
OUTPUT_VARIABLE GIT_REV)
string(REGEX REPLACE "\n$" "" PACKAGE_VERSION "${GIT_REV}")
elseif()
set(PACKAGE_VERSION ${VERSION_PLAIN})
endif()
# Provide also same macro names as autoconf (see configure.ac).
set(GENERIC_MAJOR_VERSION ${VERSION_MAJOR})

View File

@ -119,10 +119,9 @@ set(types_list
)
check_types(types_list)
set(PACKAGE_VERSION "${VERSION_PLAIN}")
file(APPEND ${AUTOCONFIG_SRC} "
/* Version number */
#cmakedefine PACKAGE_VERSION \"${VERSION_PLAIN}\"
#cmakedefine PACKAGE_VERSION \"${PACKAGE_VERSION}\"
")
test_big_endian(WORDS_BIGENDIAN)