CPack/RPM: CPACK_RPM_SPEC_MORE_DEFINE could be a list

Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
This commit is contained in:
Alex Turbov
2026-04-12 05:54:58 +04:00
parent 9add46e2fb
commit 30aa150c25
5 changed files with 44 additions and 0 deletions
+4
View File
@@ -553,6 +553,10 @@ List of CPack RPM generator specific variables:
set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true")
.. versionadded:: 4.4
If the variable is a list, its string elements will be concatenated using
``\n`` before being substituted into the spec template.
.. variable:: CPACK_RPM_PACKAGE_DEBUG
Toggle CPack RPM generator debug output.
@@ -0,0 +1,4 @@
CPACK_RPM_SPEC_MORE_DEFINE
--------------------------
* The :variable:`CPACK_RPM_SPEC_MORE_DEFINE` could be a list of definitions.
+4
View File
@@ -1284,6 +1284,10 @@ function(cpack_rpm_generate_package)
# CPACK_RPM_SPEC_MORE_DEFINE
# This is a generated spec rpm file spaceholder
if(CPACK_RPM_SPEC_MORE_DEFINE)
list(LENGTH CPACK_RPM_SPEC_MORE_DEFINE _defines_size)
if(_defines_size GREATER 1)
list(JOIN CPACK_RPM_SPEC_MORE_DEFINE "\n" CPACK_RPM_SPEC_MORE_DEFINE)
endif()
if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}")
endif()
@@ -0,0 +1,27 @@
cmake_path(APPEND bin_dir _CPack_Packages/Linux/RPM/SPECS OUTPUT_VARIABLE SPECS)
file(GLOB specs "${SPECS}/*.spec")
if(NOT specs)
return()
endif()
set(_pfx multilene_defines_test)
set(
expected_defines
"%define ${_pfx}_satu 1"
"%define ${_pfx}_dua 2"
"%define ${_pfx}_tiga 3"
)
foreach(spec IN LISTS specs)
file(STRINGS "${spec}" defines REGEX "%define multilene_defines_test_*.")
if(NOT defines STREQUAL expected_defines)
message(
FATAL_ERROR
"Multiline definitions mismatch:\n"
" file: `${spec}`\n"
" expected: `${expected_defines}`\n"
" actual: `${defines}`\n"
)
endif()
endforeach()
@@ -1,5 +1,10 @@
install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
set(_pfx multilene_defines_test)
set(CPACK_RPM_SPEC_MORE_DEFINE "%define ${_pfx}_satu 1")
list(APPEND CPACK_RPM_SPEC_MORE_DEFINE "%define ${_pfx}_dua 2")
list(APPEND CPACK_RPM_SPEC_MORE_DEFINE "%define ${_pfx}_tiga 3")
if(PACKAGING_TYPE STREQUAL "MONOLITHIC")
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_LIST_DIR}/custom.spec.in")
elseif(PACKAGING_TYPE STREQUAL "COMPONENT")