summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorJoshua A Clayton <stillcompiling@gmail.com>2015-02-19 08:01:14 (GMT)
committerBrad King <brad.king@kitware.com>2015-02-23 15:48:10 (GMT)
commit761562fea6a987bb898f5a349993cf5765dedbea (patch)
tree5dd6d07cae3262f5c16f0d5369a5fec3325e2b20 /Modules
parent8804c3e0e419eb692ba487ffb2a7e36b1f8e728d (diff)
downloadCMake-761562fea6a987bb898f5a349993cf5765dedbea.zip
CMake-761562fea6a987bb898f5a349993cf5765dedbea.tar.gz
CMake-761562fea6a987bb898f5a349993cf5765dedbea.tar.bz2
CPackRPM: Fix CPACK_RPM_PACKAGE_ARCHITECTURE
BuildArch must only be added to a spec file for a "noarch" package or rpmbuild will fail. For all others, the --target argument sets the package architecture. In the process of Fixing rpm architecture, we make it mandatory, adding a default value of native architecture (the same as if no --target argument is present). Update the documentation at the top of the file to make it mandatory.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CPackRPM.cmake21
1 files changed, 15 insertions, 6 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 7516393..932e174 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -54,8 +54,8 @@
#
# The RPM package architecture.
#
-# * Mandatory : NO
-# * Default : -
+# * Mandatory : YES
+# * Default : Native architecture output by "uname -m"
#
# This may be set to "noarch" if you know you are building a noarch package.
#
@@ -619,12 +619,20 @@ endif()
# RPM "Version" from RPM "Release"
string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION})
-# CPACK_RPM_PACKAGE_ARCHITECTURE (optional)
-if(CPACK_RPM_PACKAGE_ARCHITECTURE)
- set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
+# CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory)
+if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
+ execute_process(COMMAND uname "-m"
+ OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+else()
if(CPACK_RPM_PACKAGE_DEBUG)
message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
endif()
+endif()
+
+set(_CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE})
+if(${_CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
+ set(TMP_RPM_BUILDARCH "Buildarch: ${_CPACK_RPM_PACKAGE_ARCHITECTURE}")
else()
set(TMP_RPM_BUILDARCH "")
endif()
@@ -934,7 +942,7 @@ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES)
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS)
file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS)
-#set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
+#set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${_CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
# it seems rpmbuild can't handle spaces in the path
# neither escaping (as below) nor putting quotes around the path seem to help
@@ -1282,6 +1290,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}"
+ --target "${_CPACK_RPM_PACKAGE_ARCHITECTURE}"
"${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