2021-12-08 11:32:04 +00:00
|
|
|
|
# По умолчанию пакет собирается для дистрибутива unstable
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
# По умолчанию пакет для Debian делится на компоненты
|
|
|
|
|
if(NOT CPACK_DEB_COMPONENT_INSTALL)
|
|
|
|
|
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(MYX_CMAKE_CPACK_DEFAULT_SCHEME)
|
|
|
|
|
# Если имя компонента по умолчанию не определено, то устанавливается MAIN
|
|
|
|
|
if(NOT CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
|
|
|
|
|
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME main)
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-12-09 14:14:28 +00:00
|
|
|
|
# В списке компонентов обязательно должны быть main, dev, static и doc
|
|
|
|
|
list(APPEND CPACK_COMPONENTS_ALL main dev static doc)
|
2021-12-08 11:32:04 +00:00
|
|
|
|
list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL)
|
|
|
|
|
|
|
|
|
|
# Правило формирования имени пакета и файла для компонента main
|
|
|
|
|
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${MYX_CMAKE_PROJECT_NAME_LOWER}")
|
|
|
|
|
set(CPACK_DEBIAN_MAIN_FILE_NAME
|
|
|
|
|
${MYX_CMAKE_PROJECT_NAME_LOWER}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
|
|
|
|
|
|
2021-12-09 14:14:28 +00:00
|
|
|
|
# Правило формирования имени пакета и файла для компонента dev
|
|
|
|
|
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "lib${MYX_CMAKE_PROJECT_NAME_LOWER}-dev")
|
|
|
|
|
set(CPACK_DEBIAN_DEV_FILE_NAME
|
2021-12-08 11:32:04 +00:00
|
|
|
|
lib${MYX_CMAKE_PROJECT_NAME_LOWER}-dev_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
|
|
|
|
|
|
2021-12-09 14:14:28 +00:00
|
|
|
|
# Правило формирования имени пакета и файла для компонента static
|
|
|
|
|
set(CPACK_DEBIAN_STATIC_PACKAGE_NAME "lib${MYX_CMAKE_PROJECT_NAME_LOWER}-static-dev")
|
|
|
|
|
set(CPACK_DEBIAN_STATIC_FILE_NAME
|
|
|
|
|
lib${MYX_CMAKE_PROJECT_NAME_LOWER}-static-dev_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
|
|
|
|
|
|
|
|
|
|
set(CPACK_DEBIAN_STATIC_PACKAGE_DEPENDS "lib${MYX_CMAKE_PROJECT_NAME_LOWER}-dev")
|
|
|
|
|
|
|
|
|
|
# Правило формирования имени пакета и файла для компонента doc
|
|
|
|
|
set(CPACK_DEBIAN_DOC_PACKAGE_NAME "${MYX_CMAKE_PROJECT_NAME_LOWER}-doc")
|
|
|
|
|
set(CPACK_DEBIAN_DOC_FILE_NAME
|
|
|
|
|
${MYX_CMAKE_PROJECT_NAME_LOWER}-doc_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
|
2021-12-08 11:32:04 +00:00
|
|
|
|
|
|
|
|
|
foreach(component ${CPACK_COMPONENTS_ALL})
|
|
|
|
|
string(TOLOWER ${component} _cl)
|
|
|
|
|
string(TOUPPER ${component} _cu)
|
|
|
|
|
# Правила формирования имени пакета и файла для остальных компонентов
|
2021-12-09 14:14:28 +00:00
|
|
|
|
if(NOT ${_cl} STREQUAL main AND NOT ${_cl} STREQUAL dev AND NOT ${_cl} STREQUAL static)
|
2021-12-08 11:32:04 +00:00
|
|
|
|
set(CPACK_DEBIAN_${_cu}_PACKAGE_NAME "${MYX_CMAKE_PROJECT_NAME_LOWER}-${_cl}")
|
|
|
|
|
set(CPACK_DEBIAN_${_cu}_FILE_NAME
|
|
|
|
|
"${MYX_CMAKE_PROJECT_NAME_LOWER}-${_cl}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Если в каталоге ${CMAKE_SOURCE_DIR}/cmake/deb/${_cl} находятся сценарии сопровождающего
|
|
|
|
|
# postinst, preinst, postrm и prerm, то они будут добавлены к пакету.
|
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/preinst")
|
|
|
|
|
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/preinst")
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postinst")
|
|
|
|
|
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postinst")
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/prerm")
|
|
|
|
|
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/prerm")
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postrm")
|
|
|
|
|
list(APPEND CPACK_DEBIAN_${_cu}_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/${_cl}/postrm")
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(UNIX AND NOT TARGET deb)
|
|
|
|
|
add_custom_target(deb WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND cpack -G DEB)
|
|
|
|
|
endif()
|