From 331d9079c515368830be505ef333ca16f3e564ad Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Wed, 20 Feb 2019 17:18:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BD=D0=BE=D0=BC=D0=B5=D1=80?= =?UTF-8?q?=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8,=20=D1=83=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9=20?= =?UTF-8?q?=D0=B2=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20project()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMLibCPackSources.cmake | 2 +- CMLibCommon.cmake | 1 + CMLibCommonLibraryTarget.cmake | 6 ++---- CMLibConfigHPPGenerate.cmake | 3 +-- CMLibProjectVersion.cmake | 28 ++++------------------------ hpp/config.hpp.in | 4 ++-- 6 files changed, 11 insertions(+), 33 deletions(-) diff --git a/CMLibCPackSources.cmake b/CMLibCPackSources.cmake index cec023f..69ce78e 100644 --- a/CMLibCPackSources.cmake +++ b/CMLibCPackSources.cmake @@ -1,4 +1,4 @@ -get_property(CPACK_PACKAGE_VERSION GLOBAL PROPERTY VERSION_STR) +get_property(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_SOURCE_GENERATOR TXZ) set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}") set(CPACK_IGNORE_FILE "cmake/etc/cpack_ignore.txt") diff --git a/CMLibCommon.cmake b/CMLibCommon.cmake index d87d420..61941ed 100644 --- a/CMLibCommon.cmake +++ b/CMLibCommon.cmake @@ -31,6 +31,7 @@ include(CMLibBuildTypes) include(CMLibCodeAnalysisPvsStudio) include(cotire) +include(CMLibBreathe) include(CMLibQtTranslation) include(CMLibToday) include(CMLibConfigHPPGenerate) diff --git a/CMLibCommonLibraryTarget.cmake b/CMLibCommonLibraryTarget.cmake index ae5190a..7109a5e 100644 --- a/CMLibCommonLibraryTarget.cmake +++ b/CMLibCommonLibraryTarget.cmake @@ -9,11 +9,9 @@ function(add_common_library LIBNAME SOURCES) set_target_properties(${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) add_library(${LIBNAME}_shared SHARED $) - get_property(_ver GLOBAL PROPERTY VERSION_STR) - get_property(_sover GLOBAL PROPERTY VERSION_MAJOR) set_target_properties(${LIBNAME}_shared - PROPERTIES VERSION ${_ver} - SOVERSION ${_sover} + PROPERTIES VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} OUTPUT_NAME ${LIBNAME} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) diff --git a/CMLibConfigHPPGenerate.cmake b/CMLibConfigHPPGenerate.cmake index b5f42c3..06f9ac5 100644 --- a/CMLibConfigHPPGenerate.cmake +++ b/CMLibConfigHPPGenerate.cmake @@ -2,8 +2,7 @@ function(cmlib_config_hpp_generate) include(CMLibLargeFiles) cmlib_test_large_files(HAVE_LARGEFILES) - get_property(VERSION_INT GLOBAL PROPERTY VERSION_INT) - get_property(VERSION_STR GLOBAL PROPERTY VERSION_STR) + get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT) get_property(ORGANIZATION_NAME GLOBAL PROPERTY ORGANIZATION_NAME) configure_file(${CMLIB_MODULE_DIR}/hpp/config.hpp.in ${CMAKE_BINARY_DIR}/include/config.hpp) diff --git a/CMLibProjectVersion.cmake b/CMLibProjectVersion.cmake index 245cf14..3ef2204 100644 --- a/CMLibProjectVersion.cmake +++ b/CMLibProjectVersion.cmake @@ -1,30 +1,10 @@ -# read file cmake/etc/version.txt and set global properties -# VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_INT and VERSION_STR - function(set_project_version) - set(_version_file "${CMAKE_SOURCE_DIR}/cmake/etc/version.txt") - if(NOT EXISTS "${_version_file}") - message(FATAL_ERROR "File ${_version_file} doesn't exists") - endif() - file(READ "${_version_file}" _version) - set_property(DIRECTORY - APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS ${_version_file}) - - if(NOT "${_version}" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)\n") - message(FATAL_ERROR "${_version_file} has wrong format") + if(NOT ${PROJECT_VERSION_PATCH} MATCHES "([0-9]+)") + message(FATAL_ERROR "Please set project version in X.Y.Z format") endif() - string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)\n" _ ${_version}) - - set_property(GLOBAL PROPERTY VERSION_MAJOR ${CMAKE_MATCH_1}) - set_property(GLOBAL PROPERTY VERSION_MINOR ${CMAKE_MATCH_2}) - set_property(GLOBAL PROPERTY VERSION_PATCH ${CMAKE_MATCH_3}) math(EXPR _version_int - "(${CMAKE_MATCH_1} << 16) + (${CMAKE_MATCH_2} << 8) + ${CMAKE_MATCH_3}") - set_property(GLOBAL PROPERTY VERSION_INT ${_version_int}) - set_property(GLOBAL - PROPERTY VERSION_STR - "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}") + "(${PROJECT_VERSION_MAJOR} << 16) + (${PROJECT_VERSION_MINOR} << 8) + ${PROJECT_VERSION_PATCH}") + set_property(GLOBAL PROPERTY PROJECT_VERSION_INT ${_version_int}) endfunction() diff --git a/hpp/config.hpp.in b/hpp/config.hpp.in index b457498..4bb9693 100644 --- a/hpp/config.hpp.in +++ b/hpp/config.hpp.in @@ -1,8 +1,8 @@ #ifndef @CMLIB_PROJECT_NAME_CANONICAL@_CONFIG_HPP_ #define @CMLIB_PROJECT_NAME_CANONICAL@_CONFIG_HPP_ -#define @CMLIB_PROJECT_NAME_CANONICAL@_VERSION_STR "@VERSION_STR@" -#define @CMLIB_PROJECT_NAME_CANONICAL@_VERSION_INT @VERSION_INT@ +#define @CMLIB_PROJECT_NAME_CANONICAL@_VERSION_STR "@PROJECT_VERSION@" +#define @CMLIB_PROJECT_NAME_CANONICAL@_VERSION_INT @PROJECT_VERSION_INT@ #define ORGANIZATION_NAME "@ORGANIZATION_NAME@" #define PROJECT_NAME "@CMAKE_PROJECT_NAME@" #define BUILD_TYPE "@CMAKE_BUILD_TYPE@"