目前我正在使用以下CMakeLists.txt文件構建一個名爲firstrpm的RPM。我擴展了spec文件,使其具有%package
指令的子包,現在我想擴展CMakeLists來創建兩個rpms(比如說firstrpm和secondrpm)。我怎樣才能擴展它,以便能夠製作第二個具有不同軟件包名稱和單個構建的RPM?來自一個源包如何在一個版本中創建兩個不同的RPM?
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)
可能的重複[在cmake:Linux中使用CPack生成兩個不同的包](https://stackoverflow.com/questions/28671524/generate-two-different-package-using-cpack-in-cmake-linux) –