diff --git a/CMLibCPack.cmake b/CMLibCPack.cmake index 767219d..5862b35 100644 --- a/CMLibCPack.cmake +++ b/CMLibCPack.cmake @@ -4,9 +4,16 @@ set(CPACK_PACKAGE_NAME ${CMLIB_PROJECT_NAME_LOWER}) set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) # Параметры для архива исходных текстов -set(CPACK_SOURCE_GENERATOR TXZ) +if(NOT CPACK_SOURCE_GENERATOR) + set(CPACK_SOURCE_GENERATOR "TXZ") +endif() set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${CPACK_PACKAGE_VERSION}") +# Типы генераторов для бинарных архивов +if(NOT CPACK_GENERATOR) + set(CPACK_GENERATOR "TXZ" "DEB") +endif() + # Параметры для архива собранного проекта set(CPACK_TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR}) if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") @@ -15,6 +22,35 @@ endif() set(CPACK_PACKAGE_FILE_NAME "${CMLIB_PROJECT_NAME_LOWER}_${CPACK_TARGET_ARCH}_${CPACK_PACKAGE_VERSION}") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${CPACK_PACKAGE_VERSION}") +# Список масок для исключения из архива исходных текстов +set(CPACK_SOURCE_IGNORE_FILES + "${CPACK_SOURCE_IGNORE_FILES}" + "${CMAKE_BINARY_DIR}" + "^${CMAKE_SOURCE_DIR}/.?build.?/" + "^${CMAKE_SOURCE_DIR}/.?output.?/" + "^${CMAKE_SOURCE_DIR}/files/lib" + "^${CMAKE_SOURCE_DIR}/files/log" + "CMakeLists.txt.user.*" + ".*.autosave" + "~$" + "\\\\.swp$") + +option(CMLIB_COMPACT_SOURCE_PACKAGE "Make compact source package" ON) +if(CMLIB_COMPACT_SOURCE_PACKAGE) + # Список масок для исключения из архива исходных текстов для более компактного архива + set(CPACK_SOURCE_IGNORE_FILES + "${CPACK_SOURCE_IGNORE_FILES}" + "/\\\\.git/" + "/\\\\.gitlab-ci/" + "\\\\.clang-tidy$" + "\\\\.cmake-format$" + "\\\\.gitignore$" + "\\\\.gitattributes$" + "\\\\.gitmodules$" + "\\\\.gitlab-ci.yml$") +endif() + + set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/CMLibCPackProject.cmake) # Правила для сборки пакетов для Debian diff --git a/CMLibCPackDeb.cmake b/CMLibCPackDeb.cmake index 9683b23..8d5b33c 100644 --- a/CMLibCPackDeb.cmake +++ b/CMLibCPackDeb.cmake @@ -3,6 +3,18 @@ if(NOT DEBIAN_PACKAGE_TYPE) set(DEBIAN_PACKAGE_TYPE "unstable") endif() +if(NOT CPACK_DEBIAN_PACKAGE_SECTION) + set(CPACK_DEBIAN_PACKAGE_SECTION "misc") +endif() + +if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY) + set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") +endif() + +#if(NOT CPACK_SOURCE_IGNORE_FILES) +# message(FATAL_ERROR "Required variable CPACK_SOURCE_IGNORE_FILES is not defined") +#endif() + # По умолчанию пакет для Debian делится на компоненты if(NOT CPACK_DEB_COMPONENT_INSTALL) set(CPACK_DEB_COMPONENT_INSTALL ON) diff --git a/CMLibRequiredVariables.cmake b/CMLibRequiredVariables.cmake index f938974..6980fb3 100644 --- a/CMLibRequiredVariables.cmake +++ b/CMLibRequiredVariables.cmake @@ -10,10 +10,6 @@ endif() set(CPACK_PACKAGE_VENDOR ${ORGANIZATION_NAME}) -if(NOT CPACK_GENERATOR) - message(FATAL_ERROR "Required variable CPACK_GENERATOR is not defined") -endif() - if(NOT CPACK_PACKAGE_CONTACT) message(FATAL_ERROR "Required variable CPACK_PACKAGE_CONTACT is not defined") endif() @@ -22,14 +18,3 @@ if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) message(FATAL_ERROR "Required variable CPACK_PACKAGE_DESCRIPTION_SUMMARY is not defined") endif() -if(NOT CPACK_DEBIAN_PACKAGE_SECTION) - message(FATAL_ERROR "Required variable CPACK_DEBIAN_PACKAGE_SECTION is not defined") -endif() - -if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY) - message(FATAL_ERROR "Required variable CPACK_DEBIAN_PACKAGE_PRIORITY is not defined") -endif() - -if(NOT CPACK_SOURCE_IGNORE_FILES) - message(FATAL_ERROR "Required variable CPACK_SOURCE_IGNORE_FILES is not defined") -endif()