From d699559081ff610f905f512b3a923bd9cabc19f0 Mon Sep 17 00:00:00 2001 From: Andreas Schuh Date: Thu, 20 Mar 2014 20:21:30 +0000 Subject: [PATCH] Fix architecture used for RPM packages and DEB/RPM package file names. --- CMakeLists.txt | 26 +++++++++++++++++++++----- cmake/package.cmake.in | 31 +++++++------------------------ 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34dc4b4..93d3a73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -366,15 +366,31 @@ if (BUILD_PACKAGING) set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_LIST_DIR}/cmake/README_runtime.txt") endif () - # system name used for binary package file name + # system/architecture if (WINDOWS) if (CMAKE_CL_64) set (CPACK_SYSTEM_NAME "win64") else () set (CPACK_SYSTEM_NAME "win32") endif () + set (CPACK_PACKAGE_ARCHITECTURE) else () string (TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME) + execute_process ( + COMMAND dpkg --print-architecture + RESULT_VARIABLE RV + OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE + ) + if (RV EQUAL 0) + string (STRIP "${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_ARCHITECTURE) + else () + execute_process (COMMAND uname -m OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE) + if (CPACK_PACKAGE_ARCHITECTURE MATCHES "x86_64") + set (CPACK_PACKAGE_ARCHITECTURE amd64) + else () + set (CPACK_PACKAGE_ARCHITECTURE i386) + endif () + endif () endif () # source package settings @@ -383,10 +399,10 @@ if (BUILD_PACKAGING) set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;\\\\.swp$;\\\\.#;/#;\\\\.*~;cscope\\\\.*;/[Bb]uild[.+-_a-zA-Z0-9]*/") # default binary package settings - set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY TRUE) - set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}") - if (CMAKE_SYSTEM_PROCESSOR) - set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CMAKE_SYSTEM_PROCESSOR}") + set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY TRUE) + set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}") + if (CPACK_PACKAGE_ARCHITECTURE) + set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_ARCHITECTURE}") endif () # generator specific configuration file diff --git a/cmake/package.cmake.in b/cmake/package.cmake.in index f0b9fd0..aaec792 100644 --- a/cmake/package.cmake.in +++ b/cmake/package.cmake.in @@ -27,40 +27,23 @@ elseif (CPACK_GENERATOR MATCHES "DEB") else () set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}0") endif () - set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_${CPACK_PACKAGE_VERSION}-1_${CMAKE_SYSTEM_PROCESSOR}") - - execute_process ( - COMMAND dpkg --print-architecture - RESULT_VARIABLE RV - OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE - ) - if (NOT RV EQUAL 0) - set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) - endif () + set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_${CPACK_PACKAGE_VERSION}-1_${CPACK_PACKAGE_ARCHITECTURE}") set (CPACK_DEBIAN_PACKAGE_DEPENDS) - set (CPACK_DEBIAN_PACKAGE_SECTION "devel") - set (CPACK_DEBIAN_PACKAGE_PRIORITY "optional") - set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_RPM_PACKAGE_URL}") - set (CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}") + set (CPACK_DEBIAN_PACKAGE_SECTION "devel") + set (CPACK_DEBIAN_PACKAGE_PRIORITY "optional") + set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_RPM_PACKAGE_URL}") + set (CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}") + set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_PACKAGE_ARCHITECTURE}") # ------------------------------------------------------------------------------ # RPM package elseif (CPACK_GENERATOR MATCHES "RPM") - execute_process ( - COMMAND dpkg --print-architecture - RESULT_VARIABLE RV - OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE - ) - if (NOT RV EQUAL 0) - set (CPACK_RPM_PACKAGE_ARCHITECTURE i386) - endif () - set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}") if (DEVEL) set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-devel") endif () - set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_VERSION}-1_${CMAKE_SYSTEM_PROCESSOR}") + set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_VERSION}-1.${CPACK_PACKAGE_ARCHITECTURE}") endif ()