2017-10-12 153 views
0

目前我正在使用以下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) 
+0

可能的重複[在cmake:Linux中使用CPack生成兩個不同的包](https://stackoverflow.com/questions/28671524/generate-two-different-package-using-cpack-in-cmake-linux) –

回答

0

第二二進制包被稱爲「子包」。您只需添加幾行到您的spec文件(或spec.in)。請參閱:

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

你不手動創建-devel子包。除非您指定「BuildArch:noarch」,否則它將自動創建。

+0

我已經按照該教程創建了一個子包,並且通過手動執行rpmbuild創建了兩個RPM。 (在這個更清晰的問題中我解釋了同樣的問題:https://stackoverflow.com/questions/46727419/how-to-build-subpackages-defined-in-spec-files-using-cpack)。我想用CPACK來做同樣的事情,因爲上面的CMake文件是一個包中使用的文件。 – ThanksBye

相關問題