Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake/cpack component debuginfo rpm package doesn't appear

Tags:

c++

cmake

rpm

cpack

CentOS6.9 / cmake 3.6.1

On my project I'm trying to create several components, than build runtime, devel and debuginfo packages for them, but I was unable to produce more than one rpm for each component. I created small project to show the problem:

./include/Box.hpp

namespace room {

class Box {
public:
    Box(int volume);
    int get_volume() const;
private:
    int m_volume;
};

}

./source/Box.cpp

#include "Box.hpp"

namespace room {

Box::Box(int volume)
    : m_volume(volume)
{
}

int Box::get_volume() const
{
    return this->m_volume;
}

}

./source/app.cpp

#include "Box.hpp"

int main() {
    room::Box box(5);
    return box.get_volume();
}

./CMakeLists.txt

cmake_minimum_required(VERSION 3.6)

project (home)

set(CMAKE_INSTALL_PREFIX "/usr/local")
set(CMAKE_BUILD_TYPE "RelWithDebInfo")

include_directories("include")
file(GLOB SRC_FILES "source/*.cpp")
file(GLOB HDR_FILES "include/*.hpp")

add_executable(${PROJECT_NAME} ${SRC_FILES})
install(FILES ${HDR_FILES} DESTINATION "include" COMPONENT devel)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "bin" COMPONENT devel)

set(CPACK_COMPONENTS_ALL devel)

set(CPACK_RPM_PACKAGE_DEBUG 1)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_DEVEL_FILE_NAME "${PROJECT_NAME}-devel.rpm")

set(CPACK_RPM_DEVEL_DEBUGINFO_PACKAGE ON)
set(CPACK_RPM_DEVEL_DEBUGINFO_FILE_NAME "${PROJECT_NAME}-devel-debuginfo.rpm")
include(CPack)

console:

$ mkdir BUILD && cd BUILD && cmake3 .. && make -j5 && make package

But after this actions I see only one 'devel' rpm and no rpm with debuginfo. I looked at documentation and couldn't find any idea where I am wrong. Could someone clarify it to me? Thank you for any suggestions.

like image 905
J. Ode Avatar asked Mar 01 '18 01:03

J. Ode


Video Answer


1 Answers

Summary

Your example is generally working, you probably just need to update your CMake version.

The Details

I couldn't reproduce your problem with my Ubuntu 14.04.5 LTS and CMake 3.10.2. There is a ./BUILD/home-devel-debuginfo.rpm generated.

So three things I've noticed with your given example:

  1. The CPACK_RPM_DEBUGINFO_PACKAGE was introduced in CMake Version 3.7. So the first line of your CMakeLists.txt should be:

    cmake_minimum_required(VERSION 3.7)
    

    For some more details on updating your CMake to the latest version on Linux see "ccmake using cmake version 3.10".

    If you want to find which CMake version is the minimum to support a certain feature - since this is not part of CMake's official documentation - please see "Finding which CMake version a feature was introduced in".

  2. The documentation says the variable CPACK_BUILD_SOURCE_DIRS is mandatory. And if I add the following line, I get rid of a lot of rpm generation warnings:

    set(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR}")
    
  3. There was a dependency of packaging debuginfo to the elfutils package. So I had to do:

    sudo apt-get install elfutils
    
like image 162
Florian Avatar answered Sep 19 '22 08:09

Florian