Add the --target argument to rpmbuild Do not add a BuildArch variable to the spec file for arch specific packages BuildArch causes rpm building to fail except for "noarch" packages --- Modules/CPackRPM.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 43e3fe0..b9d7381 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -615,7 +615,14 @@ endif() string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION}) # CPACK_RPM_PACKAGE_ARCHITECTURE (optional) -if(CPACK_RPM_PACKAGE_ARCHITECTURE) +if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE) + execute_process(COMMAND uname "-m" + WORKING_DIRECTORY "${WDIR}" + OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE) +endif() +set(TMP_CPACK_RPM_TARGET "--target" "${CPACK_RPM_PACKAGE_ARCHITECTURE}") + +if (CPACK_RPM_PACKAGE_ARCHITECTURE STREQUAL "noarch") set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}") if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") @@ -1277,6 +1284,7 @@ if(RPMBUILD_EXECUTABLE) COMMAND "${RPMBUILD_EXECUTABLE}" -bb --define "_topdir ${CPACK_RPM_DIRECTORY}" --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" + ${TMP_CPACK_RPM_TARGET} "${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 -- 2.1.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