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()
|
|
|
|
|
|
|
|
|
|
#if(NOT CPACK_SOURCE_IGNORE_FILES)
|
|
|
|
|
# message(FATAL_ERROR "Required variable CPACK_SOURCE_IGNORE_FILES is not defined")
|
|
|
|
|
#endif()
|
|
|
|
|
|
2020-04-10 20:24:38 +00:00
|
|
|
|
# По умолчанию пакет для Debian делится на компоненты
|
|
|
|
|
if(NOT CPACK_DEB_COMPONENT_INSTALL)
|
|
|
|
|
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Если имя компонента по умолчанию не определено, то устанавливается MAIN
|
|
|
|
|
if(NOT CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
|
|
|
|
|
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME MAIN)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# В списке компонентов обязательно должны быть MAIN и DEV
|
|
|
|
|
list(APPEND CPACK_COMPONENTS_ALL MAIN DEV)
|
|
|
|
|
list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL)
|
|
|
|
|
|
|
|
|
|
# Правило формирования имени пакета и файла для компонента MAIN
|
|
|
|
|
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${CMLIB_PROJECT_NAME_LOWER}")
|
2020-04-11 07:12:20 +00:00
|
|
|
|
set(CPACK_DEBIAN_MAIN_FILE_NAME
|
|
|
|
|
"${CMLIB_PROJECT_NAME_LOWER}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb")
|
2020-04-10 20:24:38 +00:00
|
|
|
|
|
|
|
|
|
# Правило формирования имени пакета и файла для остальных компонентов
|
|
|
|
|
foreach(C ${CPACK_COMPONENTS_ALL})
|
|
|
|
|
if(NOT "${C}" STREQUAL "MAIN")
|
|
|
|
|
string(TOLOWER "${C}" cl)
|
|
|
|
|
set(CPACK_DEBIAN_${C}_PACKAGE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${cl}")
|
2020-04-11 07:12:20 +00:00
|
|
|
|
set(CPACK_DEBIAN_${C}_FILE_NAME
|
|
|
|
|
"${CMLIB_PROJECT_NAME_LOWER}-${cl}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb")
|
2020-04-10 20:24:38 +00:00
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
# Если в каталоге ${CMAKE_SOURCE_DIR}/cmake/deb находятся сценарии сопровождающего
|
|
|
|
|
# postinst, preinst, postrm и prerm, то они будут добавлены к пакету.
|
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/preinst")
|
|
|
|
|
list(APPEND CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/preinst")
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/postinst")
|
|
|
|
|
list(APPEND CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/postinst")
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/prerm")
|
|
|
|
|
list(APPEND CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/prerm")
|
|
|
|
|
endif()
|
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb/postrm")
|
|
|
|
|
list(APPEND CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb/postrm")
|
|
|
|
|
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()
|