Hi,

similar to the previous patch for CPackDeb, the attached patch adds component-specific settings for group and name of an RPM package.

CPACK_RPM_<component>_PACKAGE_GROUP allows setting the group of the component with the main libraries to "Development/Libraries", while "Documentation" can be used for the component with the actual documentation.

CPACK_RPM_<component>_PACKAGE_NAME can set the package name (not the filename) of a component, e.g., "foo" for libraries (instead of "foo-libraries") and "foo-devel" for headers.

Best regards,

Markus Rickert
From ee398c25a01ff28655b8bf5398b6c65067bb98f0 Mon Sep 17 00:00:00 2001
From: Markus Rickert <rick...@fortiss.org>
Date: Sun, 15 Nov 2015 20:22:23 +0100
Subject: [PATCH] [CPackRPM] Configure RPM package group and name per component

---
 Modules/CPackRPM.cmake | 44 ++++++++++++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 16 deletions(-)

diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 1e7b055..9b6fbb6 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -37,6 +37,7 @@
 #  * Default   : CPACK_PACKAGE_DESCRIPTION_SUMMARY
 #
 # .. variable:: CPACK_RPM_PACKAGE_NAME
+#               CPACK_RPM_<component>_PACKAGE_NAME
 #
 #  The RPM package name.
 #
@@ -81,6 +82,7 @@
 #  * Default   : "unknown"
 #
 # .. variable:: CPACK_RPM_PACKAGE_GROUP
+#               CPACK_RPM_<component>_PACKAGE_GROUP
 #
 #  The RPM package group.
 #
@@ -1104,14 +1106,6 @@ function(cpack_rpm_generate_package)
     message(STATUS "alien found, we may be on a Debian based distro.")
   endif()
 
-  # Are we packaging components ?
-  if(CPACK_RPM_PACKAGE_COMPONENT)
-    set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME 
"-${CPACK_RPM_PACKAGE_COMPONENT}")
-    string(TOUPPER ${CPACK_RPM_PACKAGE_COMPONENT} 
CPACK_RPM_PACKAGE_COMPONENT_UPPER)
-  else()
-    set(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "")
-  endif()
-
   set(WDIR 
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}")
 
   #
@@ -1143,10 +1137,19 @@ function(cpack_rpm_generate_package)
   endif()
 
   # CPACK_RPM_PACKAGE_NAME (mandatory)
+
   if(NOT CPACK_RPM_PACKAGE_NAME)
     string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME)
   endif()
 
+  if(CPACK_RPM_PACKAGE_COMPONENT)
+    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME)
+      set(CPACK_RPM_PACKAGE_NAME 
${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME})
+    else()
+      set(CPACK_RPM_PACKAGE_NAME 
${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_COMPONENT})
+    endif()
+  endif()
+
   # CPACK_RPM_PACKAGE_VERSION (mandatory)
   if(NOT CPACK_RPM_PACKAGE_VERSION)
     if(NOT CPACK_PACKAGE_VERSION)
@@ -1206,6 +1209,15 @@ function(cpack_rpm_generate_package)
   endif()
 
   # CPACK_RPM_PACKAGE_GROUP
+
+  #Check for component group first.
+  #If not set, it will use regular package group logic.
+  if(CPACK_RPM_PACKAGE_COMPONENT)
+    if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP)
+      set(CPACK_RPM_PACKAGE_GROUP 
${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP})
+    endif()
+  endif()
+
   if(NOT CPACK_RPM_PACKAGE_GROUP)
     set(CPACK_RPM_PACKAGE_GROUP "unknown")
   endif()
@@ -1613,7 +1625,7 @@ function(cpack_rpm_generate_package)
     )
 
   # The name of the final spec file to be used by rpmbuild
-  set(CPACK_RPM_BINARY_SPECFILE 
"${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec")
+  set(CPACK_RPM_BINARY_SPECFILE 
"${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec")
 
   # Print out some debug information if we were asked for that
   if(CPACK_RPM_PACKAGE_DEBUG)
@@ -1645,7 +1657,7 @@ function(cpack_rpm_generate_package)
       "# -*- rpm-spec -*-
 BuildRoot:      
\@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@
 Summary:        \@CPACK_RPM_PACKAGE_SUMMARY\@
-Name:           
\@CPACK_RPM_PACKAGE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_NAME\@
+Name:           \@CPACK_RPM_PACKAGE_NAME\@
 Version:        \@CPACK_RPM_PACKAGE_VERSION\@
 Release:        \@CPACK_RPM_PACKAGE_RELEASE\@
 License:        \@CPACK_RPM_PACKAGE_LICENSE\@
@@ -1749,15 +1761,15 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" 
$RPM_BUILD_ROOT
               "${CPACK_RPM_BINARY_SPECFILE}"
       WORKING_DIRECTORY 
"${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
       RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT
-      ERROR_FILE 
"${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err"
-      OUTPUT_FILE 
"${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out")
+      ERROR_FILE 
"${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err"
+      OUTPUT_FILE 
"${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out")
     if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT)
-      file(READ 
${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err
 RPMBUILDERR)
-      file(READ 
${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out
 RPMBUILDOUT)
+      file(READ 
${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err RPMBUILDERR)
+      file(READ 
${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out RPMBUILDOUT)
       message("CPackRPM:Debug: You may consult rpmbuild logs in: ")
-      message("CPackRPM:Debug:    - 
${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err")
+      message("CPackRPM:Debug:    - 
${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err")
       message("CPackRPM:Debug: *** ${RPMBUILDERR} ***")
-      message("CPackRPM:Debug:    - 
${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out")
+      message("CPackRPM:Debug:    - 
${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out")
       message("CPackRPM:Debug: *** ${RPMBUILDOUT} ***")
     endif()
   else()
-- 
2.5.0

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to