Правки для формирования пакетов

This commit is contained in:
Andrei Astafev 2021-12-09 17:14:28 +03:00
parent 1b47d92e15
commit 79492c8464
4 changed files with 34 additions and 32 deletions

View File

@ -1,10 +1,10 @@
# Создание динамической библиотеки из объектной библиотеки
function(myx_cmake_add_shared_library target)
get_target_property(_target_type ${target} TYPE)
if(NOT _target_type STREQUAL OBJECT_LIBRARY)
get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY)
message(
FATAL_ERROR
"MyxCMake: add_shared_library needs target of type OBJECT_LIBRARY")
"MyxCMake: myx_cmake_add_shared_library needs target of type OBJECT_LIBRARY")
return()
endif()
@ -16,6 +16,8 @@ function(myx_cmake_add_shared_library target)
SOVERSION ${PROJECT_VERSION_MAJOR}
LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${target}-static LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${target}-shared
COMPONENT main
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endfunction()

View File

@ -1,19 +1,20 @@
# Создание статической библиотеки из объектной библиотеки
function(myx_cmake_add_static_library target)
get_target_property(_target_type ${target} TYPE)
if(NOT _target_type STREQUAL OBJECT_LIBRARY)
get_target_property(__target_type ${target} TYPE)
if(NOT __target_type STREQUAL OBJECT_LIBRARY)
message(
FATAL_ERROR
"MyxCMake: add_static_library needs target of type OBJECT_LIBRARY")
"MyxCMake: myx_cmake_add_static_library needs target of type OBJECT_LIBRARY")
return()
endif()
add_library(${target}-static STATIC $<TARGET_OBJECTS:${target}>)
set_target_properties(
${target}-static
PROPERTIES OUTPUT_NAME ${target}
ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${target}-static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
set_target_properties(${target}-static
PROPERTIES
OUTPUT_NAME ${target}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${target}-static
COMPONENT static
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endfunction()

View File

@ -22,14 +22,8 @@ if(MYX_CMAKE_CPACK_DEFAULT_SCHEME)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME main)
endif()
# В списке компонентов обязательно должны быть main, base-dev, libs-dev и doc
list(
APPEND
CPACK_COMPONENTS_ALL
main
base-dev
libs-dev
doc)
# В списке компонентов обязательно должны быть main, dev, static и doc
list(APPEND CPACK_COMPONENTS_ALL main dev static doc)
list(REMOVE_DUPLICATES CPACK_COMPONENTS_ALL)
# Правило формирования имени пакета и файла для компонента main
@ -37,23 +31,28 @@ if(MYX_CMAKE_CPACK_DEFAULT_SCHEME)
set(CPACK_DEBIAN_MAIN_FILE_NAME
${MYX_CMAKE_PROJECT_NAME_LOWER}_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
# Правило формирования имени пакета и файла для компонента base-dev
set(CPACK_DEBIAN_BASE-DEV_PACKAGE_NAME "lib${MYX_CMAKE_PROJECT_NAME_LOWER}-base-dev")
set(CPACK_DEBIAN_BASE-DEV_FILE_NAME
lib${MYX_CMAKE_PROJECT_NAME_LOWER}-base-dev_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
# Правило формирования имени пакета и файла для компонента libs-dev
set(CPACK_DEBIAN_LIBS-DEV_PACKAGE_NAME lib${MYX_CMAKE_PROJECT_NAME_LOWER}-dev)
set(CPACK_DEBIAN_LIBS-DEV_FILE_NAME
# Правило формирования имени пакета и файла для компонента dev
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "lib${MYX_CMAKE_PROJECT_NAME_LOWER}-dev")
set(CPACK_DEBIAN_DEV_FILE_NAME
lib${MYX_CMAKE_PROJECT_NAME_LOWER}-dev_${CPACK_PACKAGE_VERSION}_${CPACK_TARGET_ARCH}.deb)
set(CPACK_DEBIAN_LIBS-DEV_PACKAGE_DEPENDS "lib${MYX_CMAKE_PROJECT_NAME_LOWER}-base-dev")
# Правило формирования имени пакета и файла для компонента 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)
foreach(component ${CPACK_COMPONENTS_ALL})
string(TOLOWER ${component} _cl)
string(TOUPPER ${component} _cu)
# Правила формирования имени пакета и файла для остальных компонентов
if(NOT ${_cl} STREQUAL main AND NOT ${_cl} STREQUAL base-dev AND NOT ${_cl} STREQUAL libs-dev)
if(NOT ${_cl} STREQUAL main AND NOT ${_cl} STREQUAL dev AND NOT ${_cl} STREQUAL static)
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")

View File

@ -6,7 +6,7 @@ function(myx_cmake_generate_pkgconfig target)
cmake_parse_arguments(ARG "${options}" "${oneVA}" "${multiVA}" ${ARGN})
if(NOT ARG_COMPONENT)
set(ARG_COMPONENT "base-dev")
set(ARG_COMPONENT dev)
endif()
get_target_property(_target_type ${target} TYPE)