2020-04-10 20:24:38 +00:00
|
|
|
|
# По умолчанию пакет собирается для дистрибутива unstable
|
|
|
|
|
if(NOT DEBIAN_PACKAGE_TYPE)
|
|
|
|
|
set(DEBIAN_PACKAGE_TYPE "unstable")
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-04-18 12:03:41 +00:00
|
|
|
|
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()
|
|
|
|
|
|
2020-04-10 20:24:38 +00:00
|
|
|
|
# По умолчанию пакет для Debian делится на компоненты
|
|
|
|
|
if(NOT CPACK_DEB_COMPONENT_INSTALL)
|
|
|
|
|
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-04-24 17:28:01 +00:00
|
|
|
|
if(CMLIB_CPACK_DEFAULT_SCHEME)
|
|
|
|
|
# Если имя компонента по умолчанию не определено, то устанавливается MAIN
|
|
|
|
|
if(NOT CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
|
|
|
|
|
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME main)
|
2020-04-10 20:24:38 +00:00
|
|
|
|
endif()
|
|
|
|
|
|
2020-04-24 17:28:01 +00:00
|
|
|
|
# В списке компонентов обязательно должны быть main, base-dev, libs-dev и doc
|
|
|
|
|
list(
|
|
|
|
|
APPEND
|
|
|
|
|
CPACK_COMPONENTS_ALL
|
|
|
|
|
main
|
|
|
|
|
base-dev
|
|
|
|
|
libs-dev
|
|
|
|
|
doc)
|
|
|
|
|
list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL)
|
|
|
|
|
|
|
|
|
|
# Правило формирования имени пакета и файла для компонента main
|
|
|
|
|
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${CMLIB_PROJECT_NAME_LOWER}")
|
|
|
|
|
set(CPACK_DEBIAN_MAIN_FILE_NAME
|
|
|
|
|
${CMLIB_PROJECT_NAME_LOWER}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
|
|
|
|
|
|
|
|
|
|
# Правило формирования имени пакета и файла для компонента base-dev
|
2020-04-24 17:51:10 +00:00
|
|
|
|
set(CPACK_DEBIAN_BASE-DEV_PACKAGE_NAME "lib${CMLIB_PROJECT_NAME_LOWER}-base-dev")
|
2020-04-24 17:28:01 +00:00
|
|
|
|
set(CPACK_DEBIAN_BASE-DEV_FILE_NAME
|
2020-04-24 17:51:10 +00:00
|
|
|
|
lib${CMLIB_PROJECT_NAME_LOWER}-base-dev_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
|
2020-04-24 17:28:01 +00:00
|
|
|
|
|
|
|
|
|
# Правило формирования имени пакета и файла для компонента libs-dev
|
2020-04-24 17:51:10 +00:00
|
|
|
|
set(CPACK_DEBIAN_LIBS-DEV_PACKAGE_NAME lib${CMLIB_PROJECT_NAME_LOWER}-dev)
|
2020-04-24 17:28:01 +00:00
|
|
|
|
set(CPACK_DEBIAN_LIBS-DEV_FILE_NAME
|
2020-04-24 17:51:10 +00:00
|
|
|
|
lib${CMLIB_PROJECT_NAME_LOWER}-dev_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
|
2020-04-24 17:28:01 +00:00
|
|
|
|
|
2020-04-24 17:51:10 +00:00
|
|
|
|
set(CPACK_DEBIAN_LIBS-DEV_PACKAGE_DEPENDS "lib${CMLIB_PROJECT_NAME_LOWER}-base-dev")
|
2020-04-24 17:28:01 +00:00
|
|
|
|
|
|
|
|
|
foreach(_C ${CPACK_COMPONENTS_ALL})
|
|
|
|
|
string(TOLOWER ${_C} _cl)
|
|
|
|
|
string(TOUPPER ${_C} _cu)
|
|
|
|
|
# Правила формирования имени пакета и файла для остальных компонентов
|
|
|
|
|
if(NOT ${_cl} STREQUAL main AND NOT ${_cl} STREQUAL base-dev AND NOT ${_cl} STREQUAL libs-dev)
|
|
|
|
|
set(CPACK_DEBIAN_${_cu}_PACKAGE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${_cl}")
|
|
|
|
|
set(CPACK_DEBIAN_${_cu}_FILE_NAME
|
|
|
|
|
"${CMLIB_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()
|
2020-04-10 20:24:38 +00:00
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(UNIX AND NOT TARGET deb)
|
2020-04-11 07:12:20 +00:00
|
|
|
|
add_custom_target(deb WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND cpack -G DEB)
|
2020-04-10 20:24:38 +00:00
|
|
|
|
endif()
|