diff --git a/CMLibCPack.cmake b/CMLibCPack.cmake index 0d2297c..01eeef1 100644 --- a/CMLibCPack.cmake +++ b/CMLibCPack.cmake @@ -1,7 +1,7 @@ # Общие настройки для пакета: организация, автор, версия -set(CPACK_PACKAGE_VENDOR ${CMLIB_ORGANIZATION_NAME_LOWER}) -set(CPACK_PACKAGE_NAME ${CMLIB_PROJECT_NAME_LOWER}) -set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_PACKAGE_VENDOR ${CMLIB_ORGANIZATION_NAME_LOWER} CACHE STRING "") +set(CPACK_PACKAGE_NAME ${CMLIB_PROJECT_NAME_LOWER} CACHE STRING "") +set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION} CACHE STRING "") # Параметры для архива исходных текстов if(NOT CPACK_SOURCE_GENERATOR) diff --git a/CMLibCommon.cmake b/CMLibCommon.cmake index 70e78f4..1851fd0 100644 --- a/CMLibCommon.cmake +++ b/CMLibCommon.cmake @@ -5,6 +5,10 @@ if(CMAKE_INSTALL_PREFIX STREQUAL PROJECT_BINARY_DIR) message(FATAL_ERROR "Cannot install into build directory") endif() +if(CMAKE_INSTALL_PREFIX STREQUAL PROJECT_SOURCE_DIR) + message(FATAL_ERROR "Cannot install into source directory") +endif() + include(CMLibDisableInSourceBuild) include(CMakeParseArguments) include(GNUInstallDirs) diff --git a/CMLibGlobalVariables.cmake b/CMLibGlobalVariables.cmake index 8e289e5..6719027 100644 --- a/CMLibGlobalVariables.cmake +++ b/CMLibGlobalVariables.cmake @@ -1,11 +1,26 @@ +if(NOT CMLIB_THEME_NAME) + set(CMLIB_THEME_NAME "default") +endif() + +canonical_string(${CMLIB_ORGANIZATION_NAME} CMLIB_ORGANIZATION_NAME_CANONICAL) canonical_string(${PROJECT_NAME} CMLIB_PROJECT_NAME_CANONICAL) -canonical_string(${ORGANIZATION_NAME} CMLIB_ORGANIZATION_NAME_CANONICAL) +canonical_string(${CMLIB_THEME_NAME} CMLIB_THEME_NAME_CANONICAL) string(TOLOWER ${CMLIB_ORGANIZATION_NAME_CANONICAL} CMLIB_ORGANIZATION_NAME_LOWER) string(TOLOWER ${CMLIB_PROJECT_NAME_CANONICAL} CMLIB_PROJECT_NAME_LOWER) +string(TOLOWER ${CMLIB_THEME_NAME_CANONICAL} CMLIB_THEME_NAME_LOWER) string(TOUPPER ${CMLIB_ORGANIZATION_NAME_CANONICAL} CMLIB_ORGANIZATION_NAME_UPPER) string(TOUPPER ${CMLIB_PROJECT_NAME_CANONICAL} CMLIB_PROJECT_NAME_UPPER) +string(TOUPPER ${CMLIB_THEME_NAME_CANONICAL} CMLIB_THEME_NAME_UPPER) + +option(CMLIB_ADD_THEME_PREFIX "Append theme name to install prefix" OFF) +if(CMLIB_ADD_THEME_PREFIX AND NOT CMLIB_THEME_PREFIX_APPENDED) + if(NOT CMLIB_THEME_NAME_LOWER STREQUAL "default") + set(CMLIB_THEME_PREFIX_APPENDED ON CACHE BOOL "" FORCE) + set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${CMLIB_THEME_NAME}" CACHE PATH "" FORCE) + endif() +endif() # CMLIB_MODULE_DIR foreach(module ${CMAKE_MODULE_PATH}) diff --git a/CMLibLSBInfo.cmake b/CMLibLSBInfo.cmake index 4753357..cf46c14 100644 --- a/CMLibLSBInfo.cmake +++ b/CMLibLSBInfo.cmake @@ -18,12 +18,12 @@ else() find_program(_lsb_release_executable lsb_release) if(_lsb_release_executable) execute_process(COMMAND ${_lsb_release_executable} -si OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${_lsb_release_executable} -sc OUTPUT_VARIABLE LSB_CODENAME - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${_lsb_release_executable} -sr OUTPUT_VARIABLE LSB_RELEASE - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE) endif() endif() diff --git a/CMLibRequiredVariables.cmake b/CMLibRequiredVariables.cmake index 4c4aa3d..0abcf24 100644 --- a/CMLibRequiredVariables.cmake +++ b/CMLibRequiredVariables.cmake @@ -1,19 +1,21 @@ -if(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/etc/Variables.cmake") - message(FATAL_ERROR "Required file cmake/etc/Variables.cmake does not exist") +# +# Обязательные переменные, значения которым необходимо присвоить в файле CMakeLists.txt +# до подключения CMLib, либо передать из командной строки через ключ -D +# +if(NOT CMLIB_ORGANIZATION_NAME) + message(FATAL_ERROR "Required variable CMLIB_ORGANIZATION_NAME is not defined") endif() -include("${CMAKE_SOURCE_DIR}/cmake/etc/Variables.cmake") - -if(NOT ORGANIZATION_NAME) - message(FATAL_ERROR "Required variable ORGANIZATION_NAME is not defined") +if(NOT CMLIB_AUTHOR_NAME) + message(FATAL_ERROR "Required variable CMLIB_AUTHOR_NAME is not defined") endif() -set(CPACK_PACKAGE_VENDOR ${ORGANIZATION_NAME}) - -if(NOT CPACK_PACKAGE_CONTACT) - message(FATAL_ERROR "Required variable CPACK_PACKAGE_CONTACT is not defined") +if(NOT CMLIB_AUTHOR_EMAIL) + message(FATAL_ERROR "Required variable CMLIB_AUTHOR_EMAIL is not defined") endif() +set(CPACK_PACKAGE_CONTACT "${CMLIB_AUTHOR_NAME} <${CMLIB_AUTHOR_EMAIL}>" CACHE STRING "") -if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - message(FATAL_ERROR "Required variable CPACK_PACKAGE_DESCRIPTION_SUMMARY is not defined") +if(NOT CMLIB_DESCRIPTION) + message(FATAL_ERROR "Required variable CMLIB_DESCRIPTION is not defined") endif() +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CMLIB_DESCRIPTION} CACHE STRING "") diff --git a/hpp/cmlib_private_config.hpp.in b/hpp/cmlib_private_config.hpp.in index afc1bd3..d5a3de6 100644 --- a/hpp/cmlib_private_config.hpp.in +++ b/hpp/cmlib_private_config.hpp.in @@ -9,7 +9,7 @@ #if defined (CMLIB_ORGANIZATION_NAME) #error "Duplicate definition of macros CMLIB_ORGANIZATION_NAME" #else -#define CMLIB_ORGANIZATION_NAME "@ORGANIZATION_NAME@" +#define CMLIB_ORGANIZATION_NAME "@CMLIB_ORGANIZATION_NAME@" #endif #if defined (CMLIB_ORGANIZATION_NAME_LOWER) @@ -42,6 +42,42 @@ #define CMLIB_PROJECT_NAME_UPPER "@CMLIB_PROJECT_NAME_UPPER@" #endif +#if defined (CMLIB_THEME_NAME) +#error "Duplicate definition of macros CMLIB_THEME_NAME" +#else +#define CMLIB_THEME_NAME "@CMLIB_THEME_NAME@" +#endif + +#if defined (CMLIB_THEME_NAME_LOWER) +#error "Duplicate definition of macros CMLIB_THEME_NAME_LOWER" +#else +#define CMLIB_THEME_NAME_LOWER "@CMLIB_THEME_NAME_LOWER@" +#endif + +#if defined (CMLIB_THEME_NAME_UPPER) +#error "Duplicate definition of macros CMLIB_THEME_NAME_UPPER" +#else +#define CMLIB_THEME_NAME_UPPER "@CMLIB_THEME_NAME_UPPER@" +#endif + +#if defined (CMLIB_AUTHOR_NAME) +#error "Duplicate definition of macros CMLIB_AUTHOR_NAME" +#else +#define CMLIB_AUTHOR_NAME "@CMLIB_AUTHOR_NAME@" +#endif + +#if defined (CMLIB_AUTHOR_EMAIL) +#error "Duplicate definition of macros CMLIB_AUTHOR_EMAIL" +#else +#define CMLIB_AUTHOR_EMAIL "@CMLIB_AUTHOR_EMAIL@" +#endif + +#if defined (CMLIB_DESCRIPTION) +#error "Duplicate definition of macros CMLIB_DESCRIPTION" +#else +#define CMLIB_DESCRIPTION "@CMLIB_DESCRIPTION@" +#endif + #if defined (CMLIB_BUILD_TYPE) #error "Duplicate definition of macros CMLIB_BUILD_TYPE" #else