summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/CPackRPM.cmake28
-rw-r--r--Tests/CPackComponentsForAll/CMakeLists.txt10
-rw-r--r--Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake11
-rw-r--r--Tests/CPackComponentsForAll/SystemSpecificInformations.cmake164
4 files changed, 206 insertions, 7 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index 026c45a..26209a7 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -194,6 +194,25 @@ IF(NOT RPMBUILD_EXECUTABLE)
MESSAGE(FATAL_ERROR "RPM package requires rpmbuild executable")
ENDIF(NOT RPMBUILD_EXECUTABLE)
+# Display lsb_release output if DEBUG mode enable
+# This will help to diagnose problem with CPackRPM
+# because we will know on which kind of Linux we are
+IF(CPACK_RPM_PACKAGE_DEBUG)
+ find_program(LSB_RELEASE_EXECUTABLE lsb_release)
+ if(LSB_RELEASE_EXECUTABLE)
+ execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a
+ OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX REPLACE "\n" ", "
+ LSB_RELEASE_OUTPUT
+ ${_TMP_LSB_RELEASE_OUTPUT})
+ else (LSB_RELEASE_EXECUTABLE)
+ set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!")
+ endif(LSB_RELEASE_EXECUTABLE)
+ MESSAGE("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}")
+ENDIF(CPACK_RPM_PACKAGE_DEBUG)
+
# We may use RPM version in the future in order
# to shut down warning about space in buildtree
# some recent RPM version should support space in different places.
@@ -621,13 +640,18 @@ IF(RPMBUILD_EXECUTABLE)
--buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
"${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
ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err"
OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out")
- IF(CPACK_RPM_PACKAGE_DEBUG)
+ IF(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT)
+ FILE(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err RPMBUILDERR)
+ FILE(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out RPMBUILDOUT)
MESSAGE("CPackRPM:Debug: You may consult rpmbuild logs in: ")
MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err")
+ MESSAGE("CPackRPM:Debug: *** ${RPMBUILDERR} ***")
MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out")
- ENDIF(CPACK_RPM_PACKAGE_DEBUG)
+ MESSAGE("CPackRPM:Debug: *** ${RPMBUILDERR} ***")
+ ENDIF(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT)
ELSE(RPMBUILD_EXECUTABLE)
IF(ALIEN_EXECUTABLE)
MESSAGE(FATAL_ERROR "RPM packaging through alien not done (yet)")
diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt
index bcec509..ce12b3b 100644
--- a/Tests/CPackComponentsForAll/CMakeLists.txt
+++ b/Tests/CPackComponentsForAll/CMakeLists.txt
@@ -10,6 +10,14 @@
cmake_minimum_required(VERSION 2.8.3.20101130 FATAL_ERROR)
project(CPackComponentsForAll)
+set(LIBDEST "lib")
+include(${CMAKE_SOURCE_DIR}/SystemSpecificInformations.cmake)
+if(DISTRO_ID MATCHES "SUSE")
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
+ set(LIBDEST "lib64")
+ endif("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
+endif(DISTRO_ID MATCHES "SUSE")
+
# Create the mylib library
add_library(mylib mylib.cpp)
@@ -27,7 +35,7 @@ target_link_libraries(mylibapp2 mylib)
# be used to create the installation components.
install(TARGETS mylib
ARCHIVE
- DESTINATION lib
+ DESTINATION ${LIBDEST}
COMPONENT libraries)
install(TARGETS mylibapp
RUNTIME
diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
index 1fac232..ae0ee1a 100644
--- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
+++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
@@ -30,8 +30,8 @@ set(config_type $ENV{CMAKE_CONFIG_TYPE})
set(config_args )
if(config_type)
set(config_args -C ${config_type})
-endif()
-message(" ${config_args}")
+endif(config_type)
+set(config_verbose )
if(CPackGen MATCHES "ZIP")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip")
@@ -51,10 +51,11 @@ if(CPackGen MATCHES "ZIP")
set(expected_count 1)
endif (${CPackComponentWay} STREQUAL "AllGroupsInOne")
elseif (CPackGen MATCHES "RPM")
+ set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm")
if (${CPackComponentWay} STREQUAL "default")
set(expected_count 1)
- endif(${CPackComponentWay} STREQUAL "default")
+ endif (${CPackComponentWay} STREQUAL "default")
if (${CPackComponentWay} STREQUAL "OnePackPerGroup")
set(expected_count 2)
endif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
@@ -77,7 +78,9 @@ if(expected_file_mask)
endif(expected_file)
endif(expected_file_mask)
-execute_process(COMMAND ${CPackCommand} -G ${CPackGen} ${config_args}
+message("config_args = ${config_args}")
+message("config_verbose = ${config_verbose}")
+execute_process(COMMAND ${CPackCommand} ${config_verbose} -G ${CPackGen} ${config_args}
RESULT_VARIABLE CPack_result
OUTPUT_VARIABLE CPack_output
ERROR_VARIABLE CPack_error
diff --git a/Tests/CPackComponentsForAll/SystemSpecificInformations.cmake b/Tests/CPackComponentsForAll/SystemSpecificInformations.cmake
new file mode 100644
index 0000000..8d11400
--- /dev/null
+++ b/Tests/CPackComponentsForAll/SystemSpecificInformations.cmake
@@ -0,0 +1,164 @@
+
+# define a set of string with may-be useful readable name
+# this file is meant to be included in a CMakeLists.txt
+# not as a standalone CMake script
+set(SPECIFIC_COMPILER_NAME "")
+set(SPECIFIC_SYSTEM_VERSION_NAME "")
+set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "")
+
+# In the WIN32 case try to guess a "readable system name"
+if(WIN32)
+ set(SPECIFIC_SYSTEM_PREFERED_PACKAGE "NSIS")
+ # information taken from
+ # http://www.codeguru.com/cpp/w-p/system/systeminformation/article.php/c8973/
+ # Win9x series
+ if(CMAKE_SYSTEM_VERSION MATCHES "4.0")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "Win95")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "4.0")
+ if(CMAKE_SYSTEM_VERSION MATCHES "4.10")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "Win98")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "4.10")
+ if(CMAKE_SYSTEM_VERSION MATCHES "4.90")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "WinME")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "4.90")
+
+ # WinNTyyy series
+ if(CMAKE_SYSTEM_VERSION MATCHES "3.0")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "WinNT351")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "3.0")
+ if(CMAKE_SYSTEM_VERSION MATCHES "4.1")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "WinNT4")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "4.1")
+
+ # Win2000/XP series
+ if(CMAKE_SYSTEM_VERSION MATCHES "5.0")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "Win2000")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "5.0")
+ if(CMAKE_SYSTEM_VERSION MATCHES "5.1")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "WinXP")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "5.1")
+ if(CMAKE_SYSTEM_VERSION MATCHES "5.2")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "Win2003")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "5.2")
+
+ # WinVista/7 series
+ if(CMAKE_SYSTEM_VERSION MATCHES "6.0")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "WinVISTA")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "6.0")
+ if(CMAKE_SYSTEM_VERSION MATCHES "6.1")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "Win7")
+ endif(CMAKE_SYSTEM_VERSION MATCHES "6.1")
+
+ # Compilers
+ # taken from http://predef.sourceforge.net/precomp.html#sec34
+ if(MSVC)
+ set(SPECIFIC_COMPILER_NAME "MSVC-Unknown-${MSVC_VERSION}")
+ if(MSVC_VERSION EQUAL 1200)
+ set(SPECIFIC_COMPILER_NAME "MSVC-6.0")
+ endif(MSVC_VERSION EQUAL 1200)
+ if(MSVC_VERSION EQUAL 1300)
+ set(SPECIFIC_COMPILER_NAME "MSVC-7.0")
+ endif(MSVC_VERSION EQUAL 1300)
+ if(MSVC_VERSION EQUAL 1310)
+ set(SPECIFIC_COMPILER_NAME "MSVC-7.1-2003") #Visual Studio 2003
+ endif(MSVC_VERSION EQUAL 1310)
+ if(MSVC_VERSION EQUAL 1400)
+ set(SPECIFIC_COMPILER_NAME "MSVC-8.0-2005") #Visual Studio 2005
+ endif(MSVC_VERSION EQUAL 1400)
+ if(MSVC_VERSION EQUAL 1500)
+ set(SPECIFIC_COMPILER_NAME "MSVC-9.0-2008") #Visual Studio 2008
+ endif(MSVC_VERSION EQUAL 1500)
+ if(MSVC_VERSION EQUAL 1600)
+ set(SPECIFIC_COMPILER_NAME "MSVC-10.0-2010") #Visual Studio 2010
+ endif(MSVC_VERSION EQUAL 1600)
+ endif(MSVC)
+ if(MINGW)
+ set(SPECIFIC_COMPILER_NAME "MinGW")
+ endif(MINGW)
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "${SPECIFIC_SYSTEM_VERSION_NAME}-x86_64")
+ endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+endif(WIN32)
+
+# In the Linux case try to guess the distro name/type
+# using either lsb_release program or fallback
+# to the content of the /etc/issue file
+if(UNIX)
+ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ set(SPECIFIC_SYSTEM_VERSION_NAME "${CMAKE_SYSTEM_NAME}")
+ set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "TGZ")
+ find_program(LSB_RELEASE_EXECUTABLE lsb_release)
+ if(LSB_RELEASE_EXECUTABLE)
+ execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -i
+ OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "Distributor ID:(.*)" DISTRO_ID ${_TMP_LSB_RELEASE_OUTPUT})
+ string(STRIP "${CMAKE_MATCH_1}" DISTRO_ID)
+ # replace potential space with underscore
+ string(REPLACE " " "_" DISTRO_ID "${DISTRO_ID}")
+ execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -r
+ OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "Release:(.*)" DISTRO_RELEASE ${_TMP_LSB_RELEASE_OUTPUT})
+ string(STRIP "${CMAKE_MATCH_1}" DISTRO_RELEASE)
+ execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -c
+ OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "Codename:(.*)" DISTRO_CODENAME ${_TMP_LSB_RELEASE_OUTPUT})
+ string(STRIP "${CMAKE_MATCH_1}" DISTRO_CODENAME)
+ elseif (EXISTS "/etc/issue")
+ set(LINUX_NAME "")
+ file(READ "/etc/issue" LINUX_ISSUE)
+ # Fedora case
+ if(LINUX_ISSUE MATCHES "Fedora")
+ string(REGEX MATCH "release ([0-9]+)" FEDORA "${LINUX_ISSUE}")
+ set(DISTRO_ID "Fedora")
+ set(DISTRO_RELEASE "${CMAKE_MATCH_1}")
+ # FIXME can we find that in /etc/issue
+ set(DISTRO_CODENAME "")
+ endif(LINUX_ISSUE MATCHES "Fedora")
+ # Ubuntu case
+ if(LINUX_ISSUE MATCHES "Ubuntu")
+ string(REGEX MATCH "buntu ([0-9]+\\.[0-9]+)" UBUNTU "${LINUX_ISSUE}")
+ set(DISTRO_ID "Ubuntu")
+ set(DISTRO_RELEASE "${CMAKE_MATCH_1}")
+ # FIXME can we find that in /etc/issue
+ set(DISTRO_CODENAME "")
+ endif(LINUX_ISSUE MATCHES "Ubuntu")
+ # Debian case
+ if(LINUX_ISSUE MATCHES "Debian")
+ string(REGEX MATCH "Debian .*ux ([0-9]+\\.[0-9]+)"
+ DEBIAN "${LINUX_ISSUE}")
+ set(DISTRO_ID "Debian")
+ set(DISTRO_RELEASE "${CMAKE_MATCH_1}")
+ set(DISTRO_CODENAME "")
+ endif(LINUX_ISSUE MATCHES "Debian")
+ # Open SuSE case
+ if(LINUX_ISSUE MATCHES "SUSE")
+ string(REGEX MATCH "SUSE ([0-9]+\\.[0-9]+)" SUSE "${LINUX_ISSUE}")
+ set(DISTRO_ID "SUSE")
+ set(DISTRO_RELEASE "${CMAKE_MATCH_1}")
+ set(DISTRO_CODENAME "")
+ endif(LINUX_ISSUE MATCHES "SUSE")
+ # Mandriva case
+ # TODO
+ endif(LSB_RELEASE_EXECUTABLE)
+ # Now mangle some names
+ set(LINUX_NAME "${DISTRO_ID}_${DISTRO_RELEASE}")
+ if(DISTRO_ID MATCHES "Fedora|Mandriva|SUSE|OpenSUSE")
+ set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "RPM")
+ endif(DISTRO_ID MATCHES "Fedora|Mandriva|SUSE|OpenSUSE")
+ if(DISTRO_ID MATCHES "Debian|Ubuntu")
+ set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "DEB")
+ endif(DISTRO_ID MATCHES "Debian|Ubuntu")
+ if(LINUX_NAME)
+ set(SPECIFIC_SYSTEM_VERSION_NAME "${CMAKE_SYSTEM_NAME}-${LINUX_NAME}")
+ endif(LINUX_NAME)
+ endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ set(SPECIFIC_SYSTEM_VERSION_NAME
+ "${SPECIFIC_SYSTEM_VERSION_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
+ set(SPECIFIC_COMPILER_NAME "")
+endif(UNIX)