summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorDomen Vrankar <domen.vrankar@gmail.com>2015-01-20 23:29:46 (GMT)
committerBrad King <brad.king@kitware.com>2015-01-29 15:48:58 (GMT)
commit3ec025472735c22cb90b09bc171190005dd28bb1 (patch)
treeef09aed4a19e40b892c3228fb0f2aa3051c22423 /Tests
parent8c4b7c567bbb47ed9555da2bd50b672304ccb858 (diff)
downloadCMake-3ec025472735c22cb90b09bc171190005dd28bb1.zip
CMake-3ec025472735c22cb90b09bc171190005dd28bb1.tar.gz
CMake-3ec025472735c22cb90b09bc171190005dd28bb1.tar.bz2
CPackRPM: Allow multiple path relocation prefixes for one package
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CPackComponentsForAll/CMakeLists.txt6
-rw-r--r--Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in16
-rw-r--r--Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake30
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CPackRPM/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING-stderr.txt1
-rw-r--r--Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake7
-rw-r--r--Tests/RunCMake/CPackRPM/RunCMakeTest.cmake17
8 files changed, 79 insertions, 9 deletions
diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt
index ff40e30..b55594e 100644
--- a/Tests/CPackComponentsForAll/CMakeLists.txt
+++ b/Tests/CPackComponentsForAll/CMakeLists.txt
@@ -110,6 +110,12 @@ set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full)
set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)
+# set CPACK_RPM_RELOCATION_PATHS here as GNUInstallDirs script
+# can not be used in CPack scripts due to CMAKE_SIZEOF_VOID_P
+# variable not being set
+set(CPACK_RPM_RELOCATION_PATHS "${CMAKE_INSTALL_INCLUDEDIR}"
+ "${CMAKE_INSTALL_LIBDIR}" "${CMAKE_INSTALL_BINDIR}")
+
# We may use the CPack specific config file in order
# to tailor CPack behavior on a CPack generator specific way
# (Behavior would be different for RPM or TGZ or DEB ...)
diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
index 8c01b32..de0ee46 100644
--- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
+++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
@@ -6,15 +6,17 @@ if(CPACK_GENERATOR MATCHES "ZIP")
endif()
if(CPACK_GENERATOR MATCHES "RPM")
- set(CPACK_RPM_COMPONENT_INSTALL "ON")
- set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries")
+ set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
- # test package summary override
- set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
- set(CPACK_RPM_libraries_PACKAGE_SUMMARY "libraries summary")
+ set(CPACK_RPM_COMPONENT_INSTALL "ON")
+ set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries")
- # test package description override
- set(CPACK_RPM_libraries_PACKAGE_DESCRIPTION "libraries description")
+ # test package summary override
+ set(CPACK_RPM_PACKAGE_SUMMARY "default summary")
+ set(CPACK_RPM_libraries_PACKAGE_SUMMARY "libraries summary")
+
+ # test package description override
+ set(CPACK_RPM_libraries_PACKAGE_DESCRIPTION "libraries description")
endif()
if(CPACK_GENERATOR MATCHES "DEB")
diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
index 4d56218..68d846f 100644
--- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
+++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
@@ -140,6 +140,12 @@ if(CPackGen MATCHES "RPM")
"C/C\\+\\+ header files for use with MyLib")
if(${CPackComponentWay} STREQUAL "IgnoreGroup")
+ # set gnu install prefixes to what they are set during rpm creation
+ # CMAKE_SIZEOF_VOID_P is not set here but lib is prefix of lib64 so
+ # relocation path test won't fail on OSes with lib64 library location
+ include(GNUInstallDirs)
+ set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
+
foreach(check_file ${expected_file})
string(REGEX MATCH ".*libraries.*" check_file_libraries_match ${check_file})
string(REGEX MATCH ".*headers.*" check_file_headers_match ${check_file})
@@ -154,15 +160,23 @@ if(CPackGen MATCHES "RPM")
if(check_file_libraries_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_libraries_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*${CPACK_RPM_libraries_PACKAGE_DESCRIPTION}.*")
+ set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+ set(spec_regex "*libraries*")
elseif(check_file_headers_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*${CPACK_COMPONENT_HEADERS_DESCRIPTION}.*")
+ set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
+ set(spec_regex "*headers*")
elseif(check_file_applications_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*${CPACK_COMPONENT_APPLICATIONS_DESCRIPTION}.*")
+ set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
+ set(spec_regex "*applications*")
elseif(check_file_Unspecified_match)
set(check_file_match_expected_summary ".*${CPACK_RPM_PACKAGE_SUMMARY}.*")
set(check_file_match_expected_description ".*DESCRIPTION.*")
+ set(check_file_match_expected_relocation_path "Relocations : ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
+ set(spec_regex "*Unspecified*")
else()
message(FATAL_ERROR "error: unexpected rpm package '${check_file}'")
endif()
@@ -170,13 +184,25 @@ if(CPackGen MATCHES "RPM")
string(REGEX MATCH ${check_file_match_expected_summary} check_file_match_summary ${check_file_content})
if(NOT check_file_match_summary)
- message(FATAL_ERROR "error: '${check_file}' rpm package summary does not match expected value - regex '${check_file_match_expected_summary}'")
+ message(FATAL_ERROR "error: '${check_file}' rpm package summary does not match expected value - regex '${check_file_match_expected_summary}'; RPM output: '${check_file_content}'")
endif()
string(REGEX MATCH ${check_file_match_expected_description} check_file_match_description ${check_file_content})
if(NOT check_file_match_description)
- message(FATAL_ERROR "error: '${check_file}' rpm package description does not match expected value - regex '${check_file_match_expected_description}'")
+ message(FATAL_ERROR "error: '${check_file}' rpm package description does not match expected value - regex '${check_file_match_expected_description}'; RPM output: '${check_file_content}'")
+ endif()
+
+ string(REGEX MATCH ${check_file_match_expected_relocation_path} check_file_match_relocation_path ${check_file_content})
+
+ if(NOT check_file_match_relocation_path)
+ file(GLOB_RECURSE spec_file "${CPackComponentsForAll_BINARY_DIR}/${spec_regex}.spec")
+
+ if(spec_file)
+ file(READ ${spec_file} spec_file_content)
+ endif()
+
+ message(FATAL_ERROR "error: '${check_file}' rpm package relocation path does not match expected value - regex '${check_file_match_expected_relocation_path}'; RPM output: '${check_file_content}'; generated spec file: '${spec_file_content}'")
endif()
endforeach()
elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index b5e41d9..15a24de 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -173,3 +173,7 @@ add_RunCMake_test(CommandLine)
add_RunCMake_test(install)
add_RunCMake_test(CPackInstallProperties)
add_RunCMake_test(ExternalProject)
+
+if(RPMBUILD)
+ add_RunCMake_test(CPackRPM)
+endif()
diff --git a/Tests/RunCMake/CPackRPM/CMakeLists.txt b/Tests/RunCMake/CPackRPM/CMakeLists.txt
new file mode 100644
index 0000000..b7d170b
--- /dev/null
+++ b/Tests/RunCMake/CPackRPM/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
+
+set(CPACK_GENERATOR "RPM")
+include(CPack)
diff --git a/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING-stderr.txt b/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING-stderr.txt
new file mode 100644
index 0000000..3b63d5b
--- /dev/null
+++ b/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING-stderr.txt
@@ -0,0 +1 @@
+CPackRPM:Warning: Path /not_relocatable/CMakeLists.txt is not on one of the.*relocatable paths! Package will be partially relocatable.
diff --git a/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake b/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake
new file mode 100644
index 0000000..3ace6a8
--- /dev/null
+++ b/Tests/RunCMake/CPackRPM/CPackRPM_PARTIALLY_RELOCATABLE_WARNING.cmake
@@ -0,0 +1,7 @@
+install(FILES CMakeLists.txt DESTINATION /not_relocatable COMPONENT static)
+install(FILES CMakeLists.txt DESTINATION relocatable COMPONENT relocatable)
+
+set(CPACK_PACKAGE_RELOCATABLE TRUE)
+set(CPACK_PACKAGING_INSTALL_PREFIX "/opt")
+
+set(CPACK_RPM_COMPONENT_INSTALL ON)
diff --git a/Tests/RunCMake/CPackRPM/RunCMakeTest.cmake b/Tests/RunCMake/CPackRPM/RunCMakeTest.cmake
new file mode 100644
index 0000000..1935e32
--- /dev/null
+++ b/Tests/RunCMake/CPackRPM/RunCMakeTest.cmake
@@ -0,0 +1,17 @@
+include(RunCMake)
+
+function(run_cpack_rpm_test TEST_NAME)
+ set(RunCMake_TEST_NO_CLEAN TRUE)
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build")
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" -D RunCMake_TEST=${TEST_NAME} "${RunCMake_SOURCE_DIR}"
+ WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
+ OUTPUT_QUIET
+ ERROR_QUIET
+ )
+ run_cmake_command(${TEST_NAME} ${CMAKE_CPACK_COMMAND})
+endfunction()
+
+run_cpack_rpm_test(CPackRPM_PARTIALLY_RELOCATABLE_WARNING)