CPack/RPM: Setting 'CPACK_RPM_<component>_USER_FILELIST' prevents debuginfo RPM from being generated
I am see a problem in a large project where setting any value in a CPACK_RPM_<component>_USER_FILELIST
is resulting in many files being omitted from the debuginfo RPM. In trying to reproduce on a much smaller scale, I am see this error. Maybe they are related. This needs to work I believe first before I can to reproduce the large scale error in a small example (or fixing this may fix the other). Ran with nightly build CMake dated 2021-04-12.
I have the following files:
CMakeLists.txt:
cmake_minimum_required(VERSION 3.17.3)
project(main VERSION 1.0.0)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif ()
set(CMAKE_CXX_STANDARD 11)
# Create some empty directories
foreach (emptyDir outbox tmpbox)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/common/${emptyDir})
endforeach ()
add_executable(main
src/main.cpp)
set(FOO_SRCS
src/foo/bar.cpp
src/foo/foo.cpp)
add_library(foo
SHARED ${FOO_SRCS})
target_link_libraries(main
foo)
include(GNUInstallDirs)
install(DIRECTORY
src/foo
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/foo
COMPONENT main
FILES_MATCHING
PATTERN "*.h")
install(FILES
LICENSE.txt
README.txt
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT devel)
install(TARGETS foo
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/foo
COMPONENT devel
NAMELINK_COMPONENT devel)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/common
DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}
COMPONENT common)
set(CPACK_BUILD_SOURCE_DIRS ${PROJECT_SOURCE_DIR}/src)
set(CPACK_COMPONENTS_ALL common devel main)
set(CPACK_GENERATOR RPM)
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
set(CPACK_RPM_COMPONENT_INSTALL ON)
# TODO - FIXME! Enabling this results in:
# CPackRPM:Warning: debuginfo package was requested but will not be generated
# as no source files were found!
#set(CPACK_RPM_DEVEL_USER_FILELIST
# "%attr(644,root,root) /usr/share/doc/main/README.txt")
set(CPACK_RPM_DEBUGINFO_PACKAGE ON)
set(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE ON)
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
set(CPACK_RPM_MAIN_COMPONENT ${PROJECT_NAME})
set(CPACK_RPM_PACKAGE_RELEASE 1)
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
include(CPack)
LICENSE.txt
TODO Added LICENSE text
README.txt
TODO Added README text
src/main.cpp:
#include "foo/bar.h"
#include "foo/foo.h"
int main()
{
bar();
foo();
}
foo/bar.h:
#ifndef BAR_H
#define BAR_H
void bar();
#endif // BAR_H
foo/bar.cpp:
#include "bar.h"
#include <cstdlib>
void bar()
{
system("g++ --version");
}
foo/foo.h:
#ifndef FOO_H
#define FOO_H
void foo();
#endif // FOO_H
foo/foo.cpp:
#include "foo.h"
#include <cstdlib>
void foo()
{
system("cmake3 --version");
}
Without setting CPACK_RPM_DEVEL_USER_FILELIST
:
build]$ rm -rf ./* && /home/gmajszak/Downloads/cmake-3.20.20210412-g6f769e2-linux-x86_64/bin/cmake .. && make package
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
...
[100%] Built target main
Run CPack packaging tool...
CPack: Create package using RPM
CPack: Install projects
CPack: - Run preinstall target for: main
CPack: - Install project: main []
CPack: - Install component: common
CPack: - Install component: devel
CPack: - Install component: main
CPack: Create package
CPackRPM: Will use GENERATED spec file: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/_CPack_Packages/Linux/RPM/SPECS/main-common.spec
CPackRPM: Will use GENERATED spec file: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/_CPack_Packages/Linux/RPM/SPECS/main-devel.spec
CPackRPM: Will use GENERATED spec file: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/_CPack_Packages/Linux/RPM/SPECS/main.spec
CPack: - package: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/main-1.0.0-1.el7.x86_64.rpm generated.
CPack: - package: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/main-common-1.0.0-1.el7.x86_64.rpm generated.
CPack: - package: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/main-debuginfo-1.0.0-1.el7.x86_64.rpm generated.
CPack: - package: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/main-devel-1.0.0-1.el7.x86_64.rpm generated.
With setting CPACK_RPM_DEVEL_USER_FILELIST
:
build]$ rm -rf ./* && /home/gmajszak/Downloads/cmake-3.20.20210412-g6f769e2-linux-x86_64/bin/cmake .. && make package
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
...
[100%] Built target main
Run CPack packaging tool...
CPack: Create package using RPM
CPack: Install projects
CPack: - Run preinstall target for: main
CPack: - Install project: main []
CPack: - Install component: common
CPack: - Install component: devel
CPack: - Install component: main
CPack: Create package
CPackRPM: Will use GENERATED spec file: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/_CPack_Packages/Linux/RPM/SPECS/main-common.spec
CPackRPM: Will use GENERATED spec file: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/_CPack_Packages/Linux/RPM/SPECS/main-devel.spec
CMake Warning (dev) at /home/gmajszak/Downloads/cmake-3.20.20210412-g6f769e2-linux-x86_64/share/cmake-3.20/Modules/Internal/CPack/CPackRPM.cmake:1467 (message):
CPackRPM:Warning: debuginfo package was requested but will not be generated
as no source files were found!
Call Stack (most recent call first):
/home/gmajszak/Downloads/cmake-3.20.20210412-g6f769e2-linux-x86_64/share/cmake-3.20/Modules/Internal/CPack/CPackRPM.cmake:1943 (cpack_rpm_generate_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CPackRPM: Will use GENERATED spec file: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/_CPack_Packages/Linux/RPM/SPECS/main.spec
CPack: - package: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/main-1.0.0-1.el7.x86_64.rpm generated.
CPack: - package: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/main-common-1.0.0-1.el7.x86_64.rpm generated.
CPack: - package: /home/gmajszak/GeneralTest_source_dir_path_must_be_longer_than_debuginfo_sources_dir_path/build/main-devel-1.0.0-1.el7.x86_64.rpm generated.
So why would specifying a CPACK_RPM_<component>_USER_FILELIST
cause debuginfo RPM not to be generated?
Thanks,
Greg