如何使用cmake构建ddeb软件包?

时间:2019-09-20 16:43:17

标签: c++ cmake debian debug-symbols

我正在尝试使用cmake构建dbgsym软件包,但在任何地方都找不到任何帮助。我见过CPACK_DEBIAN_DEBUGINFO_PACKAGE,但由于我所使用的CMake版本没有此功能,因此无法在CMakeLists.txt中使用它。

我确实有set(CMAKE_BUILD_TYPE Debug)

我希望能够在程序包中包含调试符号。

1 个答案:

答案 0 :(得分:1)

以下CMakeLists.txt创建一个调试符号包。我没有检查它是否可以在gdb中使用。

cmake_minimum_required(VERSION 3.13)

message( STATUS "Build type is " ${CMAKE_BUILD_TYPE} )

project( demonstrator
        DESCRIPTION     "Demonstrator"
        VERSION         1.0.0
        LANGUAGES       CXX )

add_library( my_library SHARED )

target_sources( my_library
    PRIVATE     my_code.cpp )

target_include_directories( my_library
    PUBLIC      include )

set_target_properties ( my_library
    PROPERTIES
    PUBLIC_HEADER   "include/my_code.hpp" )

install(
    TARGETS          my_library
    ARCHIVE
        DESTINATION  lib
        COMPONENT    runtime
    LIBRARY
        DESTINATION  lib
        COMPONENT    runtime
    PUBLIC_HEADER
        DESTINATION  include
        COMPONENT    development
)

set( CPACK_PACKAGE_NAME                ${PROJECT_NAME} )
set( CPACK_PACKAGE_CONTACT             "Contact name" )
set( CPACK_PACKAGE_VERSION             ${PROJECT_VERSION} )
set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Description" )

set( CPACK_GENERATOR                   DEB )
set( CPACK_DEB_COMPONENT_INSTALL       ON )
set( CPACK_DEBIAN_PACKAGE_DEPENDS      "" )
set( CPACK_DEBIAN_RUNTIME_DEBUGINFO_PACKAGE    ON )

include( CPack )

您可能对此ticket regarding a bug in CMake中的调试符号创建感兴趣。