# HG changeset patch # User Hasan Yavuz ÖZDERYA # Date 2017-05-05 05:13:45 # Node ID b0a44adcd19fe6dc0edcc48fc18a5fd724d9a2c9 # Parent f75372a6d061daa7efa74e164942d95832c84c61 move version information back to cmake file because its needed for package names diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,14 +161,15 @@ else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() -# get revision number from mercurial +# default version +set(VERSION_STRING "0.9.0") +set(VERSION_REVISION "0") + +# get revision number from mercurial and parse version string include(GetVersion) -if (NOT ${HG_VERSION} STREQUAL "") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_STRING=\\\"${HG_VERSION}\\\" ") -endif() -if (NOT ${HG_REVISION} STREQUAL "") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_REVISION=\\\"${HG_REVISION}\\\" ") -endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_STRING=\\\"${VERSION_STRING}\\\" ") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_REVISION=\\\"${VERSION_REVISION}\\\" ") # add make run target add_custom_target(run @@ -228,9 +229,9 @@ include(InstallRequiredSystemLibraries) set(CPACK_PACKAGE_NAME "${PROGRAM_NAME}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Small and simple software for plotting data from serial port") set(CPACK_PACKAGE_CONTACT "Hasan Yavuz Özderya ") -set(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION}) -set(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION}) -set(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION}) +set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) set(CPACK_STRIP_FILES TRUE) set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5widgets5 (>= 5.2.1), libqt5svg5 (>= 5.2.1), libqt5serialport5 (>= 5.2.1), libc6 (>= 2.19)") set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Small and simple software for plotting data from serial port diff --git a/cmake/modules/GetVersion.cmake b/cmake/modules/GetVersion.cmake --- a/cmake/modules/GetVersion.cmake +++ b/cmake/modules/GetVersion.cmake @@ -60,7 +60,17 @@ endif () # extract version information from tag (remove 'v' prefix) if (NOT ${HG_LATEST_TAG} STREQUAL "") string(REPLACE "v" "" HG_VERSION ${HG_LATEST_TAG}) - message("Version: ${HG_VERSION} (${HG_REVISION})") + message("Version from mercurial: ${HG_VERSION} (${HG_REVISION})") + + # replace version string + set(VERSION_STRING ${HG_VERSION}) + set(VERSION_REVISION ${HG_REVISION}) else () - message("Failed to find version information.") + message("Failed to find version information from mercurial.") endif () + +# parse version numbers +string(REPLACE "." ";" VERSION_LIST ${VERSION_STRING}) +list(GET VERSION_LIST 0 VERSION_MAJOR) +list(GET VERSION_LIST 1 VERSION_MINOR) +list(GET VERSION_LIST 2 VERSION_PATCH) diff --git a/src/version.h b/src/version.h --- a/src/version.h +++ b/src/version.h @@ -21,7 +21,8 @@ #define VERSION_H #ifndef VERSION_STRING -#define VERSION_STRING "0.9.0" +#warning VERSION_STRING not defined! +#define VERSION_STRING "0.0.0" #endif #ifndef VERSION_REVISION