1

At the moment I'm building an RPM called firstrpm using the following CMakeLists.txt file. I extended the spec file to have a subpackage with the %package directive, and now I would like to extend the CMakeLists to make two rpms (say firstrpm and secondrpm). How can I extend it to be able to make also the second RPM, with a different package name, with a single build?

set(CPACK_PACKAGE_RELEASE_VERSION ${PROJECT_VERSION_RELEASE})
set(CPACK_PACKAGE_MINOR_VERSION ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_SERVICE_PACK ${PROJECT_VERSION_SERVICE_PACK})
set(CPACK_PACKAGE_BUILD ${PROJECT_VERSION_BUILD})
set(CPACK_SPEC_FILE_DIR ${CMAKE_CURRENT_BINARY_DIR})    
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "firstrpm")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_RELEASE_VERSION}.${CPACK_PACKAGE_MINOR_VERSION}.${CPACK_PACKAGE_SERVICE_PACK}-${CPACK_PACKAGE_BUILD}.${CMAKE_SYSTEM_PROCESSOR}")

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${CPACK_PACKAGE_NAME}.spec.in" "${CPACK_SPEC_FILE_DIR}/${CPACK_PACKAGE_NAME}.spec" @ONLY IMMEDIATE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${CPACK_PACKAGE_NAME}-devel.spec.in" "${CPACK_SPEC_FILE_DIR}/${CPACK_PACKAGE_NAME}-devel.spec" @ONLY IMMEDIATE)
set(CPACK_RPM_USER_BINARY_SPECFILE "${CPACK_SPEC_FILE_DIR}/${CPACK_PACKAGE_NAME}.spec")

set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CMAKE_BINARY_DIR}/_CPack_Packages/Linux/RPM/RPMS/${CMAKE_SYSTEM_PROCESSOR}/${CPACK_PACKAGE_FILE_NAME}.rpm")
include(CPack)
Karl Alexius
  • 313
  • 1
  • 6
  • 15
  • Possible duplicate of [Generate two different package using CPack in cmake : Linux](https://stackoverflow.com/questions/28671524/generate-two-different-package-using-cpack-in-cmake-linux) – Chris Maes Oct 12 '17 at 13:53

1 Answers1

0

Second binary package from one source package is called "subpackage". You add just a few more lines to your spec file (or spec.in). See:

http://ftp.rpm.org/max-rpm/s1-rpm-subpack-spec-file-changes.html

And you do not manually create -devel subpackage. It will be automatically created unless you specify "BuildArch: noarch".

msuchy
  • 5,162
  • 1
  • 14
  • 26
  • I have already followed that tutorial to create a subpackage and the two RPMs are created by manually doing rpmbuild. (explanation in this clearer question I made for the same problem : https://stackoverflow.com/questions/46727419/how-to-build-subpackages-defined-in-spec-files-using-cpack). I would like to do the same using CPACK, given that the CMake file above is the one used with one package. – Karl Alexius Oct 13 '17 at 12:15