summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/CPackRPM.cmake73
-rw-r--r--Tests/RunCMake/CPack/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake14
-rw-r--r--Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake15
-rw-r--r--Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake15
-rw-r--r--Tests/RunCMake/CPack/DEB/Helpers.cmake10
-rw-r--r--Tests/RunCMake/CPack/DEPENDENCIES.cmake18
-rw-r--r--Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake13
-rw-r--r--Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake45
-rw-r--r--Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake22
-rw-r--r--Tests/RunCMake/CPack/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CPack/VerifyResult.cmake2
12 files changed, 228 insertions, 2 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index cb77fb8..7c1db14 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -95,6 +95,7 @@
# * Default : CPACK_PACKAGE_VENDOR if set or "unknown"
#
# .. variable:: CPACK_RPM_PACKAGE_URL
+# CPACK_RPM_<component>_PACKAGE_URL
#
# The projects URL.
#
@@ -123,7 +124,55 @@
# compression whereas older cannot use such RPM. Using this one can enforce
# compression type to be used. Possible value are: lzma, xz, bzip2 and gzip.
#
+# .. variable:: CPACK_RPM_PACKAGE_AUTOREQ
+# CPACK_RPM_<component>_PACKAGE_AUTOREQ
+#
+# RPM spec autoreq field.
+#
+# * Mandatory : NO
+# * Default : -
+#
+# May be used to enable (1, yes) or disable (0, no) automatic shared libraries
+# dependency detection. Dependencies are added to requires list.
+#
+# .. note::
+#
+# By defalut automatic dependency detection is enabled by rpm generator.
+#
+# .. variable:: CPACK_RPM_PACKAGE_AUTOPROV
+# CPACK_RPM_<component>_PACKAGE_AUTOPROV
+#
+# RPM spec autoprov field.
+#
+# * Mandatory : NO
+# * Default : -
+#
+# May be used to enable (1, yes) or disable (0, no) automatic listing of shared
+# libraries that are provided by the package. Shared libraries are added to
+# provides list.
+#
+# .. note::
+#
+# By defalut automatic provides detection is enabled by rpm generator.
+#
+# .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV
+# CPACK_RPM_<component>_PACKAGE_AUTOREQPROV
+#
+# RPM spec autoreqprov field.
+#
+# * Mandatory : NO
+# * Default : -
+#
+# Variable enables/disables autoreq and autoprov at the same time.
+# See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and :variable:`CPACK_RPM_PACKAGE_AUTOPROV`
+# for more details.
+#
+# .. note::
+#
+# By defalut automatic detection feature is enabled by rpm.
+#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES
+# CPACK_RPM_<component>_PACKAGE_REQUIRES
#
# RPM spec requires field.
#
@@ -139,7 +188,25 @@
#
# rpm -qp --requires file.rpm
#
+# .. variable:: CPACK_RPM_PACKAGE_CONFLICTS
+# CPACK_RPM_<component>_PACKAGE_CONFLICTS
+#
+# RPM spec conflicts field.
+#
+# * Mandatory : NO
+# * Default : -
+#
+# May be used to set negative RPM dependencies (conflicts). Note that you must enclose
+# the complete requires string between quotes, for example::
+#
+# set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
+#
+# The conflicting package list of an RPM file could be printed with::
+#
+# rpm -qp --conflicts file.rpm
+#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
+# CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
#
# RPM spec requires(pre) field.
#
@@ -152,6 +219,7 @@
# set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
+# CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
#
# RPM spec requires(post) field.
#
@@ -165,6 +233,7 @@
#
#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
+# CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
#
# RPM spec requires(postun) field.
#
@@ -178,6 +247,7 @@
#
#
# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
+# CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
#
# RPM spec requires(preun) field.
#
@@ -190,6 +260,7 @@
# set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
#
# .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
+# CPACK_RPM_<component>_PACKAGE_SUGGESTS
#
# RPM spec suggest field.
#
@@ -200,6 +271,7 @@
# enclose the complete requires string between quotes.
#
# .. variable:: CPACK_RPM_PACKAGE_PROVIDES
+# CPACK_RPM_<component>_PACKAGE_PROVIDES
#
# RPM spec provides field.
#
@@ -212,6 +284,7 @@
# rpm -qp --provides file.rpm
#
# .. variable:: CPACK_RPM_PACKAGE_OBSOLETES
+# CPACK_RPM_<component>_PACKAGE_OBSOLETES
#
# RPM spec obsoletes field.
#
diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt
index 7905706..46f1367 100644
--- a/Tests/RunCMake/CPack/CMakeLists.txt
+++ b/Tests/RunCMake/CPack/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
-project(${RunCMake_TEST} NONE)
+project(${RunCMake_TEST} CXX)
include(${RunCMake_TEST}.cmake)
# include test generator specifics
diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake
new file mode 100644
index 0000000..c56c670
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake
@@ -0,0 +1,14 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "5")
+set(EXPECTED_FILE_1 "dependencies*-applications.deb")
+set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$")
+set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb")
+set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$")
+set(EXPECTED_FILE_3 "dependencies*-headers.deb")
+set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$")
+set(EXPECTED_FILE_4 "dependencies*-libs.deb")
+# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
+set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$")
+set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb")
+set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$")
diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake
new file mode 100644
index 0000000..44c862d
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake
@@ -0,0 +1,15 @@
+function(checkDepends_ FILE REGEX)
+ set(whitespaces_ "[\t\n\r ]*")
+
+ getPackageInfo("${FILE}" "FILE_INFO_")
+ if(NOT FILE_INFO_ MATCHES "${REGEX}")
+ message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'")
+ endif()
+endfunction()
+
+checkDepends_("${FOUND_FILE_1}" ".*Depends${whitespaces_}:${whitespaces_}depend-application, depend-application-b.*")
+# use wildcard as we are using dependency auto detection
+checkDepends_("${FOUND_FILE_2}" ".*Depends${whitespaces_}:${whitespaces_}.*depend-application, depend-application-b.*")
+checkDepends_("${FOUND_FILE_3}" ".*Depends${whitespaces_}:${whitespaces_}depend-headers.*")
+checkDepends_("${FOUND_FILE_4}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*")
+checkDepends_("${FOUND_FILE_5}" ".*Depends${whitespaces_}:${whitespaces_}depend-default, depend-default-b.*")
diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake
new file mode 100644
index 0000000..9e09428
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-specifics.cmake
@@ -0,0 +1,15 @@
+set(CPACK_PACKAGE_CONTACT "someone")
+set(CPACK_DEB_COMPONENT_INSTALL "ON")
+
+# false by default
+set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS FALSE)
+# FIXME can not be tested as libraries first have to be part of a package in order
+# to determine their dependencies and we can not be certain if there will be any
+set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_SHLIBDEPS TRUE)
+
+set(CPACK_DEBIAN_PACKAGE_DEPENDS "depend-default, depend-default-b")
+set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_DEPENDS "depend-application, depend-application-b")
+set(CPACK_DEBIAN_APPLICATIONS_AUTO_PACKAGE_DEPENDS "depend-application, depend-application-b")
+set(CPACK_DEBIAN_HEADERS_PACKAGE_DEPENDS "depend-headers")
+
+# TODO add other dependency tests once CPackDeb supports them
diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake
index 45c85c3..a204a3c 100644
--- a/Tests/RunCMake/CPack/DEB/Helpers.cmake
+++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake
@@ -26,3 +26,13 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES)
endif()
endforeach()
endfunction()
+
+function(getPackageInfo FILE RESULT_VAR)
+ execute_process(COMMAND ${DPKG_EXECUTABLE} -I ${FILE}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE package_info_
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ set(${RESULT_VAR} "${package_info_}" PARENT_SCOPE)
+endfunction()
diff --git a/Tests/RunCMake/CPack/DEPENDENCIES.cmake b/Tests/RunCMake/CPack/DEPENDENCIES.cmake
new file mode 100644
index 0000000..0aef925
--- /dev/null
+++ b/Tests/RunCMake/CPack/DEPENDENCIES.cmake
@@ -0,0 +1,18 @@
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
+ "int test_lib();")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
+ "#include \"test_lib.hpp\"\nint test_lib() {return 0;}")
+add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
+ "#include \"test_lib.hpp\"\nint main() {return test_lib();}")
+add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
+target_link_libraries(test_prog test_lib)
+
+install(TARGETS test_prog DESTINATION foo COMPONENT applications)
+install(TARGETS test_prog DESTINATION foo_auto COMPONENT applications_auto)
+install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers)
+install(TARGETS test_lib DESTINATION bas COMPONENT libs)
+install(TARGETS test_lib DESTINATION bas_auto COMPONENT libs_auto)
+
+set(CPACK_PACKAGE_NAME "dependencies")
diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake
new file mode 100644
index 0000000..cf85dab
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-ExpectedFiles.cmake
@@ -0,0 +1,13 @@
+set(whitespaces_ "[\t\n\r ]*")
+
+set(EXPECTED_FILES_COUNT "5")
+set(EXPECTED_FILE_1 "dependencies*-applications.rpm")
+set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/test_prog$")
+set(EXPECTED_FILE_2 "dependencies*-applications_auto.rpm")
+set(EXPECTED_FILE_CONTENT_2 "^/usr/foo_auto${whitespaces_}/usr/foo_auto/test_prog$")
+set(EXPECTED_FILE_3 "dependencies*-headers.rpm")
+set(EXPECTED_FILE_CONTENT_3 "^/usr/bar${whitespaces_}/usr/bar/CMakeLists.txt$")
+set(EXPECTED_FILE_4 "dependencies*-libs.rpm")
+set(EXPECTED_FILE_CONTENT_4 "^/usr/bas${whitespaces_}/usr/bas/libtest_lib.so$")
+set(EXPECTED_FILE_5 "dependencies*-libs_auto.rpm")
+set(EXPECTED_FILE_CONTENT_5 "^/usr/bas_auto${whitespaces_}/usr/bas_auto/libtest_lib.so$")
diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake
new file mode 100644
index 0000000..fec8889
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake
@@ -0,0 +1,45 @@
+function(checkDependencies_ FILE TYPE COMPARE_LIST)
+ set(whitespaces_ "[\t\n\r ]*")
+
+ execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE FILE_DEPENDENCIES_
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}")
+
+ foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST)
+ unset(FOUND_)
+
+ foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_)
+ if(COMPARE_ MATCHES "${COMPARE_REGEX_}")
+ set(FOUND_ true)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT FOUND_)
+ message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'")
+ endif()
+ endforeach()
+endfunction()
+
+# TODO add tests for what should not be present in lists
+checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b")
+checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*")
+checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers")
+checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b")
+checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b")
+
+checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b")
+checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b")
+checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers")
+checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b")
+checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b")
+
+checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b")
+checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b")
+checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b")
+checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib")
+checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b")
diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake
new file mode 100644
index 0000000..2cdfece
--- /dev/null
+++ b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-specifics.cmake
@@ -0,0 +1,22 @@
+set(CPACK_RPM_COMPONENT_INSTALL "ON")
+
+# FIXME auto autoprov is not tested at the moment as Ubuntu 15.04 rpmbuild
+# does not use them correctly: https://bugs.launchpad.net/rpm/+bug/1475755
+set(CPACK_RPM_PACKAGE_AUTOREQ "no")
+set(CPACK_RPM_PACKAGE_AUTOPROV "no")
+set(CPACK_RPM_applications_auto_PACKAGE_AUTOREQPROV "yes")
+set(CPACK_RPM_libs_auto_PACKAGE_AUTOREQPROV "yes")
+
+set(CPACK_RPM_PACKAGE_REQUIRES "depend-default, depend-default-b")
+set(CPACK_RPM_applications_PACKAGE_REQUIRES "depend-application, depend-application-b")
+set(CPACK_RPM_applications_auto_PACKAGE_REQUIRES "depend-application, depend-application-b")
+set(CPACK_RPM_headers_PACKAGE_REQUIRES "depend-headers")
+
+set(CPACK_RPM_PACKAGE_CONFLICTS "conflict-default, conflict-default-b")
+set(CPACK_RPM_applications_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
+set(CPACK_RPM_applications_auto_PACKAGE_CONFLICTS "conflict-application, conflict-application-b")
+set(CPACK_RPM_headers_PACKAGE_CONFLICTS "conflict-headers")
+
+set(CPACK_RPM_PACKAGE_PROVIDES "provided-default, provided-default-b")
+set(CPACK_RPM_libs_PACKAGE_PROVIDES "provided-lib")
+set(CPACK_RPM_libs_auto_PACKAGE_PROVIDES "provided-lib_auto, provided-lib_auto-b")
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index 97ef238..3e5714d 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -7,3 +7,4 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake")
run_cpack_test(MINIMAL "RPM;DEB" false)
run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false)
run_cpack_test(DEB_EXTRA "DEB" false)
+run_cpack_test(DEPENDENCIES "RPM;DEB" true)
diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake
index e059d9c..96efa9e 100644
--- a/Tests/RunCMake/CPack/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/VerifyResult.cmake
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+cmake_minimum_required(VERSION ${CMAKE_VERSION} FATAL_ERROR)
include("${config_file}")
include("${src_dir}/${GENERATOR_TYPE}/Helpers.cmake")