diff options
59 files changed, 1123 insertions, 233 deletions
diff --git a/Help/release/dev/FindPkgConfig-targets.rst b/Help/release/dev/FindPkgConfig-targets.rst new file mode 100644 index 0000000..b18cb7b --- /dev/null +++ b/Help/release/dev/FindPkgConfig-targets.rst @@ -0,0 +1,5 @@ +FindPkgConfig-targets +--------------------- + +* The :module:`FindPkgConfig` module learned to optionally create imported + targets for the libraries it has found. diff --git a/Help/release/dev/InstallRequiredSystemLibraries-Windows-UCRT.rst b/Help/release/dev/InstallRequiredSystemLibraries-Windows-UCRT.rst new file mode 100644 index 0000000..e52531d --- /dev/null +++ b/Help/release/dev/InstallRequiredSystemLibraries-Windows-UCRT.rst @@ -0,0 +1,6 @@ +InstallRequiredSystemLibraries-Windows-UCRT +------------------------------------------- + +* The :module:`InstallRequiredSystemLibraries` module learned a new + ``CMAKE_INSTALL_UCRT_LIBRARIES`` option to enable app-local deployment + of the Windows Universal CRT libraries with Visual Studio 2015. diff --git a/Help/release/dev/cpack-deb-imporvements.rst b/Help/release/dev/cpack-deb-imporvements.rst new file mode 100644 index 0000000..4fd35b8 --- /dev/null +++ b/Help/release/dev/cpack-deb-imporvements.rst @@ -0,0 +1,27 @@ +cpack-deb-imporvements +---------------------- + +* The :module:`CPackDeb` module learned how to generate ``DEBIAN/shlibs`` + contorl file when package contains shared libraries. + +* The :module:`CPackDeb` module learned how to generate ``DEBIAN/postinst`` and + ``DEBIAN/postrm`` files if the package installs libraries in + ldconfig-controlled locations (e.g. ``/lib/``, ``/usr/lib/``). + +* The :module:`CPackDeb` module learned how to generate dependencies between + Debian packages if multi-component setup is used and + :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables are set. + This breaks compatibility with previous versions. + +* The :module:`CPackDeb` module learned how to set the package release number + (``DebianRevisionNumber`` in package file name). See + :variable:`CPACK_DEBIAN_PACKAGE_RELEASE`. + +* The :module:`CPackDeb` module now generates properly-named Debian packages:: + + <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb + + This breaks compatibility with previous versions. + +* The :module:`CPackDeb` module learned how to set the package architecture + per-component. See :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE`. diff --git a/Help/release/dev/cpack-rpm-adding-dist-to-release-tag.rst b/Help/release/dev/cpack-rpm-adding-dist-to-release-tag.rst new file mode 100644 index 0000000..42599a9 --- /dev/null +++ b/Help/release/dev/cpack-rpm-adding-dist-to-release-tag.rst @@ -0,0 +1,7 @@ +cpack-rpm-adding-dist-to-release-tag +------------------------------------ + +* The :module:`CPackRPM` module learned how to set RPM ``dist`` tag as part of + RPM ``Release:`` tag when enabled (mandatory on some Linux distributions for + e.g. on Fedora). + See :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`. diff --git a/Help/release/dev/cpack-rpm-different-package-names.rst b/Help/release/dev/cpack-rpm-different-package-names.rst new file mode 100644 index 0000000..48679e1 --- /dev/null +++ b/Help/release/dev/cpack-rpm-different-package-names.rst @@ -0,0 +1,9 @@ +cpack-rpm-different-package-names +--------------------------------- + +* The :module:`CPackRPM` module learned how to set user defined package file + names, how to specify that rpmbuild should decide on file name format as + well as handling of multiple rpm packages generated by a single user defined + spec file. + See :variable:`CPACK_RPM_PACKAGE_NAME` and + :variable:`CPACK_RPM_<component>_PACKAGE_NAME`. diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index 59092bd..ef9a2eb 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -31,7 +31,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj # Construct a regex to match linker lines. It must match both the # whole line and just the command (argv[0]). set(linker_regex "^( *|.*[/\\])(${linker}|([^/\\]+-)?ld|collect2)[^/\\]*( |$)") - set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=") + set(linker_exclude_regex "collect2 version |^[A-Za-z0-9_]+=|/ldfe ") set(log "${log} link line regex: [${linker_regex}]\n") string(REGEX REPLACE "\r?\n" ";" output_lines "${text}") foreach(line IN LISTS output_lines) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index b41d926..d93d924 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -50,8 +50,21 @@ # * Mandatory : YES # * Default : :variable:`CPACK_PACKAGE_VERSION` # +# .. variable:: CPACK_DEBIAN_PACKAGE_RELEASE +# +# The Debian package release - Debian revision number. +# +# * Mandatory : YES +# * Default : 1 +# +# This is the numbering of the DEB package itself, i.e. the version of the +# packaging and not the version of the content (see +# :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value +# if the previous packaging was buggy and/or you want to put here a fancy Linux +# distro specific numbering. # # .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE +# CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE # # The Debian package architecture # @@ -331,6 +344,32 @@ # See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps # # +# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS +# +# * Mandatory : NO +# * Default : OFF +# +# Allows to generate shlibs control file automatically. Compatibility is defined by +# CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY variable value. +# +# .. note:: +# +# Libraries are only considered if they have both library name and version +# set. This can be done by setting SOVERSION property with +# :command:`set_target_properties` command. +# +# +# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY +# +# * Mandatory : NO +# * Default : "=" +# +# Defines compatibility policy for auto-generated shlibs control file. +# Possible values: "=", ">=" +# +# See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps +# +# # .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA # CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA # @@ -399,6 +438,10 @@ #============================================================================= # Copyright 2007-2009 Kitware, Inc. # Copyright 2007-2009 Mathieu Malaterre <mathieu.malaterre@gmail.com> +# Copyright 2014-2016 Alexander Smorkalov <alexander.smorkalov@itseez.com> +# Copyright 2014-2016 Roman Donchenko <roman.donchenko@itseez.com> +# Copyright 2014-2016 Roman Kharitonov <roman.kharitonov@itseez.com> +# Copyright 2014-2016 Ilya Lavrenov <ilya.lavrenov@itseez.com> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -423,6 +466,38 @@ if(NOT UNIX) message(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.") endif() +function(get_component_package_name var component) + string(TOUPPER "${component}" component_upcase) + if(CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME) + string(TOLOWER "${CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME}" package_name) + else() + string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${component}" package_name) + endif() + + set("${var}" "${package_name}" PARENT_SCOPE) +endfunction() + +#extract library name and version for given shared object +function(extract_so_info shared_object libname version) + if(READELF_EXECUTABLE) + execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}" + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(result EQUAL 0) + string(REGEX MATCH "\\(SONAME\\)[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}") + set(${libname} "${CMAKE_MATCH_1}" PARENT_SCOPE) + set(${version} "${CMAKE_MATCH_2}" PARENT_SCOPE) + else() + message(WARNING "Error running readelf for \"${shared_object}\"") + endif() + else() + message(FATAL_ERROR "Readelf utility is not available.") + endif() +endfunction() + function(cpack_deb_prepare_package_vars) # CPACK_DEBIAN_PACKAGE_SHLIBDEPS # If specify OFF, only user depends are used @@ -447,6 +522,39 @@ function(cpack_deb_prepare_package_vars) endif() endif() + if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS) + # Generating binary list - Get type of all install files + cmake_policy(PUSH) + # Tell file(GLOB_RECURSE) not to follow directory symlinks + # even if the project does not set this policy to NEW. + cmake_policy(SET CMP0009 NEW) + file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*") + cmake_policy(POP) + + # get file info so that we can determine if file is executable or not + unset(CPACK_DEB_INSTALL_FILES) + foreach(FILE_ IN LISTS FILE_PATHS_) + execute_process(COMMAND file "./${FILE_}" + WORKING_DIRECTORY "${WDIR}" + OUTPUT_VARIABLE INSTALL_FILE_) + list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}") + endforeach() + + # Only dynamically linked ELF files are included + # Extract only file name infront of ":" + foreach(_FILE IN LISTS CPACK_DEB_INSTALL_FILES) + if(_FILE MATCHES "ELF.*dynamically linked") + string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}") + list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}") + set(CONTAINS_EXECUTABLE_FILES_ TRUE) + endif() + if(_FILE MATCHES "ELF.*shared object") + string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}") + list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}") + endif() + endforeach() + endif() + if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) # dpkg-shlibdeps is a Debian utility for generating dependency list find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps) @@ -468,33 +576,6 @@ function(cpack_deb_prepare_package_vars) message("CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>") endif() - # Generating binary list - Get type of all install files - cmake_policy(PUSH) - # Tell file(GLOB_RECURSE) not to follow directory symlinks - # even if the project does not set this policy to NEW. - cmake_policy(SET CMP0009 NEW) - file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*") - cmake_policy(POP) - - # get file info so that we can determine if file is executable or not - unset(CPACK_DEB_INSTALL_FILES) - foreach(FILE_ IN LISTS FILE_PATHS_) - execute_process(COMMAND file "./${FILE_}" - WORKING_DIRECTORY "${WDIR}" - OUTPUT_VARIABLE INSTALL_FILE_) - list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}") - endforeach() - - # Only dynamically linked ELF files are included - # Extract only file name infront of ":" - foreach(_FILE ${CPACK_DEB_INSTALL_FILES}) - if( ${_FILE} MATCHES "ELF.*dynamically linked") - string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}") - list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}") - set(CONTAINS_EXECUTABLE_FILES_ TRUE) - endif() - endforeach() - if(CONTAINS_EXECUTABLE_FILES_) message("CPackDeb: - Generating dependency list") @@ -586,7 +667,9 @@ function(cpack_deb_prepare_package_vars) endif() # Architecture: (mandatory) - if(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) + if(CPACK_DEB_PACKAGE_COMPONENT AND CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE) + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE}") + elseif(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) # There is no such thing as i686 architecture on debian, you should use i386 instead # $ dpkg --print-architecture find_program(DPKG_CMD dpkg) @@ -630,6 +713,22 @@ function(cpack_deb_prepare_package_vars) endif() endif() endforeach() + set(COMPONENT_DEPENDS "") + foreach (_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS}) + get_component_package_name(_PACK_NAME "${_PACK}") + if(COMPONENT_DEPENDS) + set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}") + else() + set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})") + endif() + endforeach() + if(COMPONENT_DEPENDS) + if(CPACK_DEBIAN_PACKAGE_DEPENDS) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}") + else() + set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}") + endif() + endif() endif() # at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set @@ -637,7 +736,7 @@ function(cpack_deb_prepare_package_vars) # Append automatically discovered dependencies . if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "") if (CPACK_DEBIAN_PACKAGE_DEPENDS) - set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}") + set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") else () set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") endif () @@ -718,14 +817,75 @@ function(cpack_deb_prepare_package_vars) set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}") endif() endforeach() + get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name}) + endif() - if(CPACK_DEBIAN_${_local_component_name}_PACKAGE_NAME) - string(TOLOWER "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME) + set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "") + + if (NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY) + set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=") + endif() + + find_program(READELF_EXECUTABLE NAMES readelf) + + if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS) + if(READELF_EXECUTABLE) + foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES) + extract_so_info("${_FILE}" libname soversion) + if(libname AND soversion) + list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST + "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_PACKAGE_VERSION})") + else() + message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.") + endif() + endforeach() + if (CPACK_DEBIAN_PACKAGE_SHLIBS_LIST) + string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}") + endif() else() - string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_DEB_PACKAGE_COMPONENT}" CPACK_DEBIAN_PACKAGE_NAME) + message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.") + endif() + endif() + + # add ldconfig call in default postrm and postint + set(CPACK_ADD_LDCONFIG_CALL 0) + foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES}) + get_filename_component(_DIR ${_FILE} DIRECTORY) + # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning + if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib") + set(CPACK_ADD_LDCONFIG_CALL 1) endif() + endforeach() + + if(CPACK_ADD_LDCONFIG_CALL) + set(CPACK_DEBIAN_GENERATE_POSTINST 1) + set(CPACK_DEBIAN_GENERATE_POSTRM 1) + foreach(f ${PACKAGE_CONTROL_EXTRA}) + get_filename_component(n "${f}" NAME) + if("${n}" STREQUAL "postinst") + set(CPACK_DEBIAN_GENERATE_POSTINST 0) + endif() + if("${n}" STREQUAL "postrm") + set(CPACK_DEBIAN_GENERATE_POSTRM 0) + endif() + endforeach() + else() + set(CPACK_DEBIAN_GENERATE_POSTINST 0) + set(CPACK_DEBIAN_GENERATE_POSTRM 0) + endif() + + if(NOT CPACK_DEBIAN_PACKAGE_RELEASE) + set(CPACK_DEBIAN_PACKAGE_RELEASE 1) endif() + # Patch package file name to be in corrent debian format: + # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb + set(CPACK_OUTPUT_FILE_NAME + "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") + set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}") + get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY) + set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}") + # Print out some debug information if we were asked for that if(CPACK_DEBIAN_PACKAGE_DEBUG) message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'") @@ -755,6 +915,8 @@ function(cpack_deb_prepare_package_vars) #endif() # move variables to parent scope so that they may be used to create debian package + set(GEN_CPACK_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" PARENT_SCOPE) + set(GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TEMPORARY_PACKAGE_FILE_NAME}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_DEBIAN_PACKAGE_SECTION}" PARENT_SCOPE) @@ -773,11 +935,14 @@ function(cpack_deb_prepare_package_vars) set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION "${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE "${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE) set(GEN_WDIR "${WDIR}" PARENT_SCOPE) endfunction() diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 768d64f..aecb7fc 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -54,6 +54,30 @@ # * Mandatory : YES # * Default : CPACK_PACKAGE_NAME # +# .. variable:: CPACK_RPM_FILE_NAME +# CPACK_RPM_<component>_FILE_NAME +# +# Package file name. +# +# * Mandatory : YES +# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces +# replaced by '-' +# +# This may be set to ``RPM-DEFAULT`` to allow rpmbuild tool to generate package +# file name by itself. +# Alternatively provided package file name must end with ".rpm" suffix. +# +# .. note:: +# +# By using user provided spec file, rpm macro extensions such as for +# generating debuginfo packages or by simply using multiple components more +# than one rpm file may be generated, either from a single spec file or from +# multiple spec files (each component execution produces it's own spec file). +# In such cases duplicate file names may occur as a result of this variable +# setting or spec file content structure. Duplicate files get overwritten +# and it is up to the packager to set the variables in a manner that will +# prevent such errors. +# # .. variable:: CPACK_RPM_PACKAGE_VERSION # # The RPM package version. @@ -80,10 +104,27 @@ # # This is the numbering of the RPM package itself, i.e. the version of the # packaging and not the version of the content (see -# CPACK_RPM_PACKAGE_VERSION). One may change the default value if the -# previous packaging was buggy and/or you want to put here a fancy Linux +# :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if +# the previous packaging was buggy and/or you want to put here a fancy Linux # distro specific numbering. # +# .. note:: +# +# This is the string that goes into the RPM ``Release:`` field. Some distros +# (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number. +# ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`. +# +# .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST +# +# The dist tag that is added RPM ``Release:`` field. +# +# * Mandatory : NO +# * Default : OFF +# +# This is the reported ``%{dist}`` tag from the current distribution or empty +# ``%{dist}`` if RPM macro is not set. If this variable is set then RPM +# ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``. +# # .. variable:: CPACK_RPM_PACKAGE_LICENSE # # The RPM package license policy. @@ -1317,7 +1358,11 @@ function(cpack_rpm_generate_package) # This is the case when the packaging is buggy (not) the software :=) # If not set, 1 is a good candidate if(NOT CPACK_RPM_PACKAGE_RELEASE) - set(CPACK_RPM_PACKAGE_RELEASE 1) + set(CPACK_RPM_PACKAGE_RELEASE "1") + endif() + + if(CPACK_RPM_PACKAGE_RELEASE_DIST) + set(CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}%{?dist}") endif() # CPACK_RPM_PACKAGE_LICENSE @@ -1534,8 +1579,6 @@ function(cpack_rpm_generate_package) 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_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 #string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") @@ -1716,6 +1759,28 @@ function(cpack_rpm_generate_package) "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_BINARY_SPECFILE") endif() + cpack_rpm_variable_fallback("CPACK_RPM_FILE_NAME" + "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_FILE_NAME" + "CPACK_RPM_FILE_NAME") + if(NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT") + if(CPACK_RPM_FILE_NAME) + cmake_policy(PUSH) + cmake_policy(SET CMP0010 NEW) + if(NOT CPACK_RPM_FILE_NAME MATCHES ".*\\.rpm") + cmake_policy(POP) + message(FATAL_ERROR "'${CPACK_RPM_FILE_NAME}' is not a valid RPM package file name as it must end with '.rpm'!") + endif() + cmake_policy(POP) + else() + # old file name format for back compatibility + set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") + endif() + # else example: + #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm") + + set(FILE_NAME_DEFINE "%define _rpmfilename ${CPACK_RPM_FILE_NAME}") + endif() + # We should generate a USER spec file template: # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE # - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE @@ -1746,7 +1811,7 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@TMP_RPM_PREFIXES\@ %define _rpmdir \@CPACK_RPM_DIRECTORY\@ -%define _rpmfilename \@CPACK_RPM_FILE_NAME\@ +\@FILE_NAME_DEFINE\@ %define _unpackaged_files_terminate_build 0 %define _topdir \@CPACK_RPM_DIRECTORY\@ \@TMP_RPM_SPEC_INSTALL_POST\@ @@ -1844,6 +1909,24 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT message(FATAL_ERROR "RPM packaging through alien not done (yet)") endif() endif() + + # find generated rpm files and take their names + cmake_policy(PUSH) + # Tell file(GLOB_RECURSE) not to follow directory symlinks + # even if the project does not set this policy to NEW. + cmake_policy(SET CMP0009 NEW) + file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/*.rpm") + cmake_policy(POP) + + if(NOT GENERATED_FILES) + message(FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}") + endif() + + set(GEN_CPACK_OUTPUT_FILES "${GENERATED_FILES}" PARENT_SCOPE) + + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: GEN_CPACK_OUTPUT_FILES = ${GENERATED_FILES}") + endif() endfunction() cpack_rpm_generate_package() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 777003b..67d71d0 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -711,7 +711,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106200) + elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106100) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) @@ -725,6 +725,20 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) + elseif(NOT Boost_VERSION VERSION_LESS 106100 AND Boost_VERSION VERSION_LESS 106200) + set(_Boost_CHRONO_DEPENDENCIES system) + set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) + set(_Boost_COROUTINE_DEPENDENCIES context system) + set(_Boost_FILESYSTEM_DEPENDENCIES system) + set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic) + set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic) + set(_Boost_MPI_DEPENDENCIES serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization) + set(_Boost_RANDOM_DEPENDENCIES system) + set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) + set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) + set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() message(WARNING "Imported targets not available for Boost version ${Boost_VERSION}") set(_Boost_IMPORTED_TARGETS FALSE) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 17a2aeb..f589977 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -46,24 +46,47 @@ # # :: # +# HDF5_FOUND - true if HDF5 was found on the system +# HDF5_VERSION - HDF5 version in format Major.Minor.Release # HDF5_INCLUDE_DIRS - Location of the hdf5 includes # HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) # HDF5_DEFINITIONS - Required compiler definitions for HDF5 -# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings. +# HDF5_LIBRARIES - Required libraries for all requested bindings +# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all +# bindings, if the HL component is enabled +# +# Available components are: C CXX Fortran and HL. For each enabled language +# binding, a corresponding HDF5_${LANG}_LIBRARIES variable will be defined. +# If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will +# also be defined. With all components enabled, the following variables will be defined: +# +# :: +# +# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings # HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings # HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings -# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API +# HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings +# HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings # HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran # bindings. -# HDF5_LIBRARIES - Required libraries for all requested bindings -# HDF5_FOUND - true if HDF5 was found on the system -# HDF5_VERSION - HDF5 version in format Major.Minor.Release -# HDF5_LIBRARY_DIRS - the full set of library directories +# # HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support # HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler # HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler # HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler +# HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler +# which is also the HDF5 wrapper +# HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++ +# compiler which is also +# the HDF5 wrapper +# HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary +# Fortran compiler which +# is also the HDF5 wrapper # HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool +# +# The following variable can be set to guide the search for HDF5 libraries and includes: +# +# HDF5_ROOT #============================================================================= # Copyright 2015 Axel Huebl, Helmholtz-Zentrum Dresden - Rossendorf @@ -85,28 +108,43 @@ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # List of the valid HDF5 components -set( HDF5_VALID_COMPONENTS - C - CXX - Fortran - HL - Fortran_HL -) +set(HDF5_VALID_LANGUAGE_BINDINGS C CXX Fortran) # Validate the list of find components. -if( NOT HDF5_FIND_COMPONENTS ) - set( HDF5_LANGUAGE_BINDINGS "C" ) +set(HDF5_LANGUAGE_BINDINGS) +if(NOT HDF5_FIND_COMPONENTS) + get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) + foreach(__lang IN LISTS __langs) + if(__lang MATCHES "^(C|CXX|Fortran)$") + list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang}) + endif() + endforeach() + set(FIND_HL ON) else() - # add the extra specified components, ensuring that they are valid. - foreach( component ${HDF5_FIND_COMPONENTS} ) - list( FIND HDF5_VALID_COMPONENTS ${component} component_location ) - if( ${component_location} EQUAL -1 ) - message( FATAL_ERROR - "\"${component}\" is not a valid HDF5 component." ) - else() - list( APPEND HDF5_LANGUAGE_BINDINGS ${component} ) - endif() + # add the extra specified components, ensuring that they are valid. + set(FIND_HL OFF) + foreach(component IN LISTS HDF5_FIND_COMPONENTS) + list(FIND HDF5_VALID_LANGUAGE_BINDINGS ${component} component_location) + if(NOT component_location EQUAL -1) + list(APPEND HDF5_LANGUAGE_BINDINGS ${component}) + elseif(component STREQUAL "HL") + set(FIND_HL ON) + elseif(component STREQUAL "Fortran_HL") # only for compatibility + list(APPEND HDF5_LANGUAGE_BINDINGS Fortran) + set(FIND_HL ON) + else() + message(FATAL_ERROR "${component} is not a valid HDF5 component.") + endif() + endforeach() + if(NOT HDF5_LANGUAGE_BINDINGS) + get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) + foreach(__lang IN LISTS __langs) + if(__lang MATCHES "^(C|CXX|Fortran)$") + list(APPEND HDF5_LANGUAGE_BINDINGS ${__lang}) + endif() endforeach() + endif() + list(REMOVE_DUPLICATES HDF5_LANGUAGE_BINDINGS) endif() # Determine whether to search for serial or parallel executable first @@ -260,7 +298,8 @@ macro( _HDF5_parse_compile_line include_paths definitions library_paths - libraries ) + libraries + libraries_hl) # Match the include paths string( REGEX MATCHALL "-I([^\" ]+)" include_path_flags @@ -297,40 +336,57 @@ macro( _HDF5_parse_compile_line # strip the -l from all of the library flags and add to the search list foreach( LIB ${library_name_flags} ) string( REGEX REPLACE "^[, ]-l" "" LIB ${LIB} ) - list( APPEND ${libraries} ${LIB} ) + if(LIB MATCHES ".*_hl") + list(APPEND ${libraries_hl} ${LIB}) + else() + list(APPEND ${libraries} ${LIB}) + endif() endforeach() endmacro() # Try to find HDF5 using an installed hdf5-config.cmake -if( NOT HDF5_FOUND ) - find_package( HDF5 QUIET NO_MODULE ) - if( HDF5_FOUND ) - set( HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR} ) - set( HDF5_LIBRARIES ) - set( HDF5_C_TARGET hdf5 ) - set( HDF5_CXX_TARGET hdf5_cpp ) - set( HDF5_HL_TARGET hdf5_hl ) - set( HDF5_Fortran_TARGET hdf5_fortran ) - set( HDF5_Fortran_HL_TARGET hdf5_hl_fortran ) - foreach( _component ${HDF5_LANGUAGE_BINDINGS} ) - list( FIND HDF5_VALID_COMPONENTS ${_component} _component_location ) - get_target_property( _comp_location ${HDF5_${_component}_TARGET} LOCATION ) - if( _comp_location ) - set( HDF5_${_component}_LIBRARY ${_comp_location} CACHE PATH - "HDF5 ${_component} library" ) - mark_as_advanced( HDF5_${_component}_LIBRARY ) - list( APPEND HDF5_LIBRARIES ${HDF5_${_component}_LIBRARY} ) +if(NOT HDF5_ROOT AND NOT HDF5_FOUND) + find_package(HDF5 QUIET NO_MODULE) + if( HDF5_FOUND) + set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR}) + set(HDF5_LIBRARIES) + set(HDF5_C_TARGET hdf5) + set(HDF5_C_HL_TARGET hdf5_hl) + set(HDF5_CXX_TARGET hdf5_cpp) + set(HDF5_CXX_HL_TARGET hdf5_hl_cpp) + set(HDF5_Fortran_TARGET hdf5_fortran) + set(HDF5_Fortran_HL_TARGET hdf5_hl_fortran) + if(HDF5_USE_STATIC_LIBRARIES) + set(_suffix "-static") + else() + set(_suffix "-shared") + endif() + foreach(_lang ${HDF5_LANGUAGE_BINDINGS}) + get_target_property(_lang_location ${HDF5_${_component}_TARGET}${_suffix} LOCATION) + if( _lang_location ) + set(HDF5_${_lang}_LIBRARY ${_lang_location} CACHE PATH + "HDF5 ${_lang} library" ) + mark_as_advanced(HDF5_${_lang}_LIBRARY) + list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_LIBRARY}) + endif() + if(FIND_HL) + get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION) + if( _lang_location ) + set(HDF5_${_lang}_HL_LIBRARY ${_lang_location} CACHE PATH + "HDF5 ${_lang} HL library" ) + mark_as_advanced(HDF5_${_lang}_LIBRARY) + list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_HL_LIBRARY}) + endif() endif() endforeach() endif() endif() -set(_HDF5_NEED_TO_SEARCH False) -set(HDF5_COMPILER_NO_INTERROGATE True) -get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) -if(__langs) +if(NOT HDF5_ROOT AND NOT HDF5_FOUND) + set(_HDF5_NEED_TO_SEARCH False) + set(HDF5_COMPILER_NO_INTERROGATE True) # Only search for languages we've enabled - foreach(__lang IN LISTS __langs) + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) # First check to see if our regular compiler is one of wrappers if(__lang STREQUAL "C") _HDF5_test_regular_compiler_C( @@ -349,7 +405,9 @@ if(__langs) if(HDF5_${__lang}_COMPILER_NO_INTERROGATE) message(STATUS "HDF5: Using hdf5 compiler wrapper for all ${__lang} compiling") set(HDF5_${__lang}_FOUND True) - set(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE "${CMAKE_${__lang}_COMPILER}" CACHE FILEPATH "HDF5 ${__lang} compiler wrapper") + set(HDF5_${__lang}_COMPILER_EXECUTABLE_NO_INTERROGATE + "${CMAKE_${__lang}_COMPILER}" + CACHE FILEPATH "HDF5 ${__lang} compiler wrapper") set(HDF5_${__lang}_DEFINITIONS) set(HDF5_${__lang}_INCLUDE_DIRS) set(HDF5_${__lang}_LIBRARIES) @@ -357,6 +415,7 @@ if(__langs) mark_as_advanced(HDF5_${__lang}_DEFINITIONS) mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS) mark_as_advanced(HDF5_${__lang}_LIBRARIES) + mark_as_advanced(HDF5_${__lang}_HL_LIBRARIES) else() set(HDF5_COMPILER_NO_INTERROGATE False) # If this language isn't using the wrapper, then try to seed the @@ -380,6 +439,7 @@ if(__langs) HDF5_${__lang}_DEFINITIONS HDF5_${__lang}_LIBRARY_DIRS HDF5_${__lang}_LIBRARY_NAMES + HDF5_${__lang}_HL_LIBRARY_NAMES ) set(HDF5_${__lang}_LIBRARIES) foreach(L IN LISTS HDF5_${__lang}_LIBRARY_NAMES) @@ -390,6 +450,17 @@ if(__langs) list(APPEND HDF5_${__lang}_LIBRARIES ${L}) endif() endforeach() + if(FIND_HL) + set(HDF5_${__lang}_HL_LIBRARIES) + foreach(L IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) + find_library(HDF5_${__lang}_LIBRARY_${L} ${L} ${HDF5_${__lang}_LIBRARY_DIRS}) + if(HDF5_${__lang}_LIBRARY_${L}) + list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${__lang}_LIBRARY_${L}}) + else() + list(APPEND HDF5_${__lang}_HL_LIBRARIES ${L}) + endif() + endforeach() + endif() set(HDF5_${__lang}_FOUND True) mark_as_advanced(HDF5_${__lang}_DEFINITIONS) mark_as_advanced(HDF5_${__lang}_INCLUDE_DIRS) @@ -397,6 +468,7 @@ if(__langs) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_DEFINITIONS) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_INCLUDE_DIRS) _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_LIBRARIES) + _HDF5_remove_duplicates_from_beginning(HDF5_${__lang}_HL_LIBRARIES) else() set(_HDF5_NEED_TO_SEARCH True) endif() @@ -412,6 +484,8 @@ if(__langs) endif() endif() endforeach() +else() + set(_HDF5_NEED_TO_SEARCH True) endif() if(HDF5_COMPILER_NO_INTERROGATE) @@ -424,20 +498,28 @@ elseif(NOT _HDF5_NEED_TO_SEARCH) # to determine necessary include and library flags set(HDF5_INCLUDE_DIRS) set(HDF5_LIBRARIES) - foreach(__lang IN LISTS __langs) + set(HDF5_HL_LIBRARIES) + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) if(HDF5_${__lang}_FOUND) if(NOT HDF5_${__lang}_COMPILER_NO_INTERROGATE) list(APPEND HDF5_DEFINITIONS ${HDF5_${__lang}_DEFINITIONS}) list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIRS}) list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) + if(FIND_HL) + list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) + endif() endif() endif() endforeach() _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS) _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) + _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) set(HDF5_FOUND True) set(HDF5_REQUIRED_VARS HDF5_LIBRARIES) + if(FIND_HL) + list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) + endif() endif() find_program( HDF5_DIFF_EXECUTABLE @@ -450,15 +532,18 @@ mark_as_advanced( HDF5_DIFF_EXECUTABLE ) if( NOT HDF5_FOUND ) # seed the initial lists of libraries to find with items we know we need set(HDF5_C_LIBRARY_NAMES hdf5) - set(HDF5_C_HL_LIBRARY_NAMES hdf5_hl ${HDF5_C_LIBRARY_NAMES_INIT}) + set(HDF5_C_HL_LIBRARY_NAMES hdf5_hl) - set(HDF5_CXX_LIBRARY_NAMES hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT}) - set(HDF5_CXX_HL_LIBRARY_NAMES hdf5_hl_cpp ${HDF5_C_HL_LIBRARY_NAMES_INIT} ${HDF5_CXX_LIBRARY_NAMES_INIT}) + set(HDF5_CXX_LIBRARY_NAMES hdf5_cpp ${HDF5_C_LIBRARY_NAMES}) + set(HDF5_CXX_HL_LIBRARY_NAMES hdf5_hl_cpp ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_CXX_LIBRARY_NAMES}) - set(HDF5_Fortran_LIBRARY_NAMES hdf5_fortran ${HDF5_C_LIBRARY_NAMES_INIT}) - set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5hl_fortran ${HDF5_C_HL_LIBRARY_NAMES_INIT} ${HDF5_Fortran_LIBRARY_NAMES_INIT}) + set(HDF5_Fortran_LIBRARY_NAMES hdf5_fortran ${HDF5_C_LIBRARY_NAMES}) + set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5_hl_fortran ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_Fortran_LIBRARY_NAMES}) - foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} ) + if(HDF5_ROOT) + set(SEARCH_OPTS NO_DEFAULT_PATH) + endif() + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) # find the HDF5 include directories if(LANGUAGE STREQUAL "Fortran") set(HDF5_INCLUDE_FILENAME hdf5.mod) @@ -468,50 +553,88 @@ if( NOT HDF5_FOUND ) set(HDF5_INCLUDE_FILENAME hdf5.h) endif() - find_path(HDF5_${LANGUAGE}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} - HINTS $ENV{HDF5_ROOT} + find_path(HDF5_${__lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} + HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATHS $ENV{HOME}/.local/include PATH_SUFFIXES include Include + ${SEARCH_OPTS} ) mark_as_advanced(HDF5_${LANGUAGE}_INCLUDE_DIR) - list( APPEND HDF5_INCLUDE_DIRS ${HDF5_${LANGUAGE}_INCLUDE_DIR} ) + list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${__lang}_INCLUDE_DIR}) # find the HDF5 libraries - foreach( LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES} ) - if( UNIX AND HDF5_USE_STATIC_LIBRARIES ) + foreach(LIB IN LISTS HDF5_${__lang}_LIBRARY_NAMES) + if(UNIX AND HDF5_USE_STATIC_LIBRARIES) # According to bug 1643 on the CMake bug tracker, this is the # preferred method for searching for a static library. # See https://cmake.org/Bug/view.php?id=1643. We search # first for the full static library name, but fall back to a # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG lib${LIB}d.a lib${LIB}_debug.a ${LIB}d ${LIB}_debug ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} ) + set( THIS_LIBRARY_SEARCH_DEBUG + lib${LIB}d.a lib${LIB}_debug.a ${LIB}d ${LIB}_debug + lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_debug-static ) + set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a ${LIB}-static) else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_debug ) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ) + set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_debug ${LIB}d-shared ${LIB}_debug-shared) + set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) endif() - find_library( HDF5_${LIB}_LIBRARY_DEBUG + find_library(HDF5_${LIB}_LIBRARY_DEBUG NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} - ENV HDF5_ROOT - PATH_SUFFIXES lib Lib ) + HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATH_SUFFIXES lib Lib + ${SEARCH_OPTS} + ) find_library( HDF5_${LIB}_LIBRARY_RELEASE NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} - ENV HDF5_ROOT - PATH_SUFFIXES lib Lib ) + HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATH_SUFFIXES lib Lib + ${SEARCH_OPTS} + ) select_library_configurations( HDF5_${LIB} ) - list(APPEND HDF5_${LANGUAGE}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) - endforeach() - list( APPEND HDF5_LIBRARY_DIRS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} ) + list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) + eNdforeach() # Append the libraries for this language binding to the list of all # required libraries. - list(APPEND HDF5_LIBRARIES ${HDF5_${LANGUAGE}_LIBRARIES}) + list(APPEND HDF5_LIBRARIES ${HDF5_${__lang}_LIBRARIES}) + + if(FIND_HL) + foreach(LIB IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES) + if(UNIX AND HDF5_USE_STATIC_LIBRARIES) + # According to bug 1643 on the CMake bug tracker, this is the + # preferred method for searching for a static library. + # See https://cmake.org/Bug/view.php?id=1643. We search + # first for the full static library name, but fall back to a + # generic search on the name if the static search fails. + set( THIS_LIBRARY_SEARCH_DEBUG + lib${LIB}d.a lib${LIB}_debug.a ${LIB}d ${LIB}_debug + lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_debug-static ) + set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a ${LIB}-static) + else() + set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_debug ${LIB}d-shared ${LIB}_debug-shared) + set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared) + endif() + find_library(HDF5_${LIB}_LIBRARY_DEBUG + NAMES ${THIS_LIBRARY_SEARCH_DEBUG} + HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATH_SUFFIXES lib Lib + ${SEARCH_OPTS} + ) + find_library( HDF5_${LIB}_LIBRARY_RELEASE + NAMES ${THIS_LIBRARY_SEARCH_RELEASE} + HINTS ${HDF5_ROOT} ENV HDF5_ROOT PATH_SUFFIXES lib Lib + ${SEARCH_OPTS} + ) + select_library_configurations( HDF5_${LIB} ) + list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${LIB}_LIBRARY}) + endforeach() + + # Append the libraries for this language binding to the list of all + # required libraries. + list(APPEND HDF5_HL_LIBRARIES ${HDF5_${__lang}_HL_LIBRARIES}) + endif() endforeach() _HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS) - _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARY_DIRS) + _HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES) + _HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES) # If the HDF5 include directory was found, open H5pubconf.h to determine if # HDF5 was compiled with parallel IO support @@ -552,6 +675,9 @@ if( NOT HDF5_FOUND ) set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) endif() set(HDF5_REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS) + if(FIND_HL) + list(APPEND HDF5_REQUIRED_VARS HDF5_HL_LIBRARIES) + endif() endif() find_package_handle_standard_args(HDF5 diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 447c526..644687c 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -16,6 +16,7 @@ # Copyright 2006-2014 Kitware, Inc. # Copyright 2014 Christoph Grüninger <foss@grueninger.de> # Copyright 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de> +# Copyright 2016 Rolf Eike Beer <eike@sf-mail.de> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -119,11 +120,12 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro() # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path) +macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target) set(${_is_req} 0) set(${_is_silent} 0) set(${_no_cmake_path} 0) set(${_no_cmake_environment_path} 0) + set(${_imp_target} 0) if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH) if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH) set(${_no_cmake_path} 1) @@ -147,6 +149,9 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma if (_pkg STREQUAL "NO_CMAKE_ENVIRONMENT_PATH") set(${_no_cmake_environment_path} 1) endif() + if (_pkg STREQUAL "IMPORTED_TARGET") + set(${_imp_target} 1) + endif() endforeach() set(${_result} ${ARGN}) @@ -154,6 +159,7 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma list(REMOVE_ITEM ${_result} "QUIET") list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH") list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH") + list(REMOVE_ITEM ${_result} "IMPORTED_TARGET") endmacro() # Add the content of a variable or an environment variable to a list of @@ -181,8 +187,63 @@ function(_pkgconfig_add_extra_path _extra_paths_var _var) set(${_extra_paths_var} ${${_extra_paths_var}} PARENT_SCOPE) endfunction() +# scan the LDFLAGS returned by pkg-config for library directories and +# libraries, figure out the absolute paths of that libraries in the +# given directories, and create an imported target from them +function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_path) + unset(_libs) + unset(_find_opts) + + # set the options that are used as long as the .pc file does not provide a library + # path to look into + if(_no_cmake_path) + set(_find_opts "NO_CMAKE_PATH") + endif() + if(_no_cmake_environment_path) + set(_find_opts "${_find_opts} NO_CMAKE_ENVIRONMENT_PATH") + endif() + + foreach (flag IN LISTS ${_prefix}_LDFLAGS) + if (flag MATCHES "^-L(.*)") + # only look into the given paths from now on + set(_find_opts "HINTS ${${CMAKE_MATCH_1}} NO_DEFAULT_PATH") + continue() + endif() + if (flag MATCHES "^-l(.*)") + set(_pkg_search "${CMAKE_MATCH_1}") + else() + continue() + endif() + + find_library(pkgcfg_lib_${_prefix}_${_pkg_search} + NAMES ${_pkg_search} + ${_find_opts}) + list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}") + endforeach() + + # only create the target if it is linkable, i.e. no executables + if (NOT TARGET PkgConfig::${_prefix} + AND ( ${_prefix}_INCLUDE_DIRS OR _libs OR ${_prefix}_CFLAGS_OTHER )) + add_library(PkgConfig::${_prefix} INTERFACE IMPORTED) + + unset(_props) + if(${_prefix}_INCLUDE_DIRS) + set_property(TARGET PkgConfig::${_prefix} PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}") + endif() + if(_libs) + set_property(TARGET PkgConfig::${_prefix} PROPERTY + INTERFACE_LINK_LIBRARIES "${_libs}") + endif() + if(${_prefix}_CFLAGS_OTHER) + set_property(TARGET PkgConfig::${_prefix} PROPERTY + INTERFACE_COMPILE_OPTIONS "${${_prefix}_CFLAGS_OTHER}") + endif() + endif() +endfunction() + ### -macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix) +macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) _pkgconfig_unset(${_prefix}_PREFIX) @@ -400,6 +461,10 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS "(^| )-I" --cflags-only-I ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) + + if (_imp_target) + _pkg_create_imp_target("${_prefix}" _no_cmake_path _no_cmake_environment_path) + endif() endif() if(NOT "${_extra_paths}" STREQUAL "") @@ -427,6 +492,7 @@ endmacro() pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] + [IMPORTED_TARGET] <MODULE> [<MODULE>]*) @@ -443,6 +509,9 @@ endmacro() The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments disable this behavior for the cache variables and the environment variables, respectively. + The ``IMPORTED_TARGET`` argument will create an imported target named + PkgConfig::<PREFIX>> that can be passed directly as an argument to + :command:`target_link_libraries`. It sets the following variables: :: @@ -524,8 +593,8 @@ endmacro() macro(pkg_check_modules _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) - _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) - _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" ${_pkg_modules}) + _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) endif() @@ -540,6 +609,7 @@ endmacro() pkg_search_module(<PREFIX> [REQUIRED] [QUIET] [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] + [IMPORTED_TARGET] <MODULE> [<MODULE>]*) Examples @@ -552,7 +622,7 @@ macro(pkg_search_module _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN}) if (NOT ${_pkg_is_silent}) message(STATUS "Checking for one of the modules '${_pkg_modules_alt}'") @@ -561,7 +631,7 @@ macro(pkg_search_module _prefix _module0) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) if(NOT _pkg_modules_found) - _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" "${_pkg_alt}") + _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" "${_pkg_alt}") endif() if (${_prefix}_FOUND) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 2ff9aed..aa84077 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -23,6 +23,11 @@ # Set to TRUE to install only the debug runtime libraries with MSVC # tools even if the release runtime libraries are also available. # +# ``CMAKE_INSTALL_UCRT_LIBRARIES`` +# Set to TRUE to install the Windows Universal CRT libraries for +# app-local deployment. This is meaningful only with MSVC from +# Visual Studio 2015 or higher. +# # ``CMAKE_INSTALL_MFC_LIBRARIES`` # Set to TRUE to install the MSVC MFC runtime libraries. # @@ -171,12 +176,12 @@ if(MSVC) # Find the runtime library redistribution directory. get_filename_component(msvc_install_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${v}.0;InstallDir]" ABSOLUTE) + set(programfilesx86 "ProgramFiles(x86)") find_path(MSVC${v}_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT PATHS "${msvc_install_dir}/../../VC/redist" "${base_dir}/VC/redist" "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist" - set(programfilesx86 "ProgramFiles(x86)") "$ENV{${programfilesx86}}/Microsoft Visual Studio ${v}.0/VC/redist" ) mark_as_advanced(MSVC${v}_REDIST_DIR) @@ -207,6 +212,24 @@ if(MSVC) list(APPEND __install__libs "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll") endif() endif() + + if(CMAKE_INSTALL_UCRT_LIBRARIES AND NOT v VERSION_LESS 14) + # Find the Windows Universal CRT redistribution directory. + get_filename_component(windows_kits_dir + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE) + set(programfilesx86 "ProgramFiles(x86)") + find_path(WINDOWS_KITS_REDIST_DIR NAMES ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll + PATHS + "${windows_kits_dir}/Redist" + "$ENV{ProgramFiles}/Windows Kits/10/Redist" + "$ENV{${programfilesx86}}/Windows Kits/10/Redist" + ) + mark_as_advanced(WINDOWS_KITS_REDIST_DIR) + + # Glob the list of UCRT DLLs. + file(GLOB __ucrt_dlls "${WINDOWS_KITS_REDIST_DIR}/ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll") + list(APPEND __install__libs ${__ucrt_dlls}) + endif() endmacro() if(MSVC10) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ed8d6d9..20a9a8d 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 5) -set(CMake_VERSION_PATCH 20160511) +set(CMake_VERSION_PATCH 20160516) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 0911713..aec06b7 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -60,9 +60,10 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( - std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) - +"-"+packageName + this->GetOutputExtension() - ); + cmsys::SystemTools::LowerCase( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))) + +"-"+packageName + this->GetOutputExtension() + ); localToplevel += "/"+ packageName; /* replace the TEMP DIRECTORY with the component one */ @@ -107,6 +108,9 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, retval = 0; } // add the generated package to package file names list + packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + packageFileName += "/"; + packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"); packageFileNames.push_back(packageFileName); return retval; } @@ -165,17 +169,16 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) return retval; } -int cmCPackDebGenerator::PackageComponentsAllInOne() +//---------------------------------------------------------------------- +int cmCPackDebGenerator::PackageComponentsAllInOne( + const std::string& compInstDirName) { int retval = 1; - std::string compInstDirName; /* Reset package file name list it will be populated during the * component packaging run*/ packageFileNames.clear(); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); - compInstDirName = "ALL_COMPONENTS_IN_ONE"; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging all groups in one package..." "(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)" @@ -187,7 +190,8 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() cmSystemTools::GetParentDirectory(toplevel) ); std::string outputFileName( - std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + cmsys::SystemTools::LowerCase( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))) + this->GetOutputExtension() ); // all GROUP in one vs all COMPONENT in one @@ -201,11 +205,15 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() /* replace the TEMPORARY package file name */ this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", packageFileName.c_str()); - // Tell CPackDeb.cmake the path where the component is. - std::string component_path = "/"; - component_path += compInstDirName; - this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", - component_path.c_str()); + + if(!compInstDirName.empty()) + { + // Tell CPackDeb.cmake the path where the component is. + std::string component_path = "/"; + component_path += compInstDirName; + this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", + component_path.c_str()); + } if (!this->ReadListFile("CPackDeb.cmake")) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -227,20 +235,22 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() } packageFiles = gl.GetFiles(); + int res = createDeb(); if (res != 1) { retval = 0; } // add the generated package to package file names list + packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + packageFileName += "/"; + packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"); packageFileNames.push_back(packageFileName); return retval; } int cmCPackDebGenerator::PackageFiles() { - int retval = -1; - /* Are we in the component packaging case */ if (WantsComponentInstallation()) { // CASE 1 : COMPONENT ALL-IN-ONE package @@ -248,7 +258,7 @@ int cmCPackDebGenerator::PackageFiles() // then the package file is unique and should be open here. if (componentPackageMethod == ONE_PACKAGE) { - return PackageComponentsAllInOne(); + return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE"); } // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // There will be 1 package for each component group @@ -263,27 +273,15 @@ int cmCPackDebGenerator::PackageFiles() // CASE 3 : NON COMPONENT package. else { - if (!this->ReadListFile("CPackDeb.cmake")) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Error while execution CPackDeb.cmake" << std::endl); - retval = 0; - } - else - { - packageFiles = files; - return createDeb(); - } + return PackageComponentsAllInOne(""); } - return retval; } int cmCPackDebGenerator::createDeb() { // debian-binary file - std::string dbfilename; - dbfilename += this->GetOption("GEN_WDIR"); - dbfilename += "/debian-binary"; + const std::string strGenWDIR(this->GetOption("GEN_WDIR")); + const std::string dbfilename = strGenWDIR + "/debian-binary"; { // the scope is needed for cmGeneratedFileStream cmGeneratedFileStream out(dbfilename.c_str()); out << "2.0"; @@ -291,9 +289,7 @@ int cmCPackDebGenerator::createDeb() } // control file - std::string ctlfilename; - ctlfilename = this->GetOption("GEN_WDIR"); - ctlfilename += "/control"; + std::string ctlfilename = strGenWDIR + "/control"; // debian policy enforce lower case for package name // mandatory entries: @@ -405,7 +401,41 @@ int cmCPackDebGenerator::createDeb() out << std::endl; } - const std::string strGenWDIR(this->GetOption("GEN_WDIR")); + const std::string shlibsfilename = strGenWDIR + "/shlibs"; + + const char* debian_pkg_shlibs = this->GetOption( + "GEN_CPACK_DEBIAN_PACKAGE_SHLIBS"); + const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") + && debian_pkg_shlibs && *debian_pkg_shlibs; + if( gen_shibs ) + { + cmGeneratedFileStream out(shlibsfilename.c_str()); + out << debian_pkg_shlibs; + out << std::endl; + } + + const std::string postinst = strGenWDIR + "/postinst"; + const std::string postrm = strGenWDIR + "/postrm"; + if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) + { + cmGeneratedFileStream out(postinst.c_str()); + out << + "#!/bin/sh\n\n" + "set -e\n\n" + "if [ \"$1\" = \"configure\" ]; then\n" + "\tldconfig\n" + "fi\n"; + } + if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) + { + cmGeneratedFileStream out(postrm.c_str()); + out << + "#!/bin/sh\n\n" + "set -e\n\n" + "if [ \"$1\" = \"remove\" ]; then\n" + "\tldconfig\n" + "fi\n"; + } cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip; const char* debian_compression_type = @@ -605,6 +635,54 @@ int cmCPackDebGenerator::createDeb() return 0; } + // adds generated shlibs file + if( gen_shibs ) + { + if( !control_tar.Add(shlibsfilename, strGenWDIR.length(), ".") ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error adding file to tar:" << std::endl + << "#top level directory: " + << strGenWDIR << std::endl + << "#file: \"shlibs\"" << std::endl + << "#error:" << control_tar.GetError() << std::endl); + return 0; + } + } + + // adds LDCONFIG related files + if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) + { + control_tar.SetPermissions(permission755); + if(!control_tar.Add(postinst, strGenWDIR.length(), ".")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error adding file to tar:" << std::endl + << "#top level directory: " + << strGenWDIR << std::endl + << "#file: \"postinst\"" << std::endl + << "#error:" << control_tar.GetError() << std::endl); + return 0; + } + control_tar.SetPermissions(permission644); + } + + if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) + { + control_tar.SetPermissions(permission755); + if(!control_tar.Add(postrm, strGenWDIR.length(), ".")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error adding file to tar:" << std::endl + << "#top level directory: " + << strGenWDIR << std::endl + << "#file: \"postinst\"" << std::endl + << "#error:" << control_tar.GetError() << std::endl); + return 0; + } + control_tar.SetPermissions(permission644); + } + // for the other files, we use // -either the original permission on the files // -either a permission strictly defined by the Debian policies @@ -662,11 +740,12 @@ int cmCPackDebGenerator::createDeb() arFiles.push_back(topLevelString + "data.tar" + compression_suffix); std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); outputFileName += "/"; - outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME"); + outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"); int res = ar_append(outputFileName.c_str(), arFiles); if ( res!=0 ) { - std::string tmpFile = this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME"); + std::string tmpFile = this->GetOption( + "GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME"); tmpFile += "/Deb.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); ofs << "# Problem creating archive using: " << res << std::endl; diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index 3d945dd..439b7ea 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -60,7 +60,7 @@ protected: * Special case of component install where all * components will be put in a single installer. */ - int PackageComponentsAllInOne(); + int PackageComponentsAllInOne(const std::string& compInstDirName); virtual int PackageFiles(); virtual const char* GetOutputExtension() { return ".deb"; } virtual bool SupportsComponentInstallation() const; diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 6349e05..2640404 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -47,6 +47,22 @@ int cmCPackRPMGenerator::InitializeInternal() return this->Superclass::InitializeInternal(); } +void cmCPackRPMGenerator::AddGeneratedPackageNames() +{ + // add the generated packages to package file names list + std::string fileNames(this->GetOption("GEN_CPACK_OUTPUT_FILES")); + const char sep = ';'; + std::string::size_type pos1 = 0; + std::string::size_type pos2 = fileNames.find(sep, pos1+1); + while(pos2 != std::string::npos) + { + packageFileNames.push_back(fileNames.substr(pos1, pos2-pos1)); + pos1 = pos2+1; + pos2 = fileNames.find(sep, pos1+1); + } + packageFileNames.push_back(fileNames.substr(pos1, pos2-pos1)); +} + int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel, std::string packageName) { @@ -85,8 +101,7 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel, "Error while execution CPackRPM.cmake" << std::endl); retval = 0; } - // add the generated package to package file names list - packageFileNames.push_back(packageFileName); + return retval; } @@ -139,20 +154,24 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) retval &= PackageOnePack(initialTopLevel,compIt->first); } } + + if(retval) + { + AddGeneratedPackageNames(); + } + return retval; } -int cmCPackRPMGenerator::PackageComponentsAllInOne() +int cmCPackRPMGenerator::PackageComponentsAllInOne( + const std::string& compInstDirName) { int retval = 1; - std::string compInstDirName; /* Reset package file name list it will be populated during the * component packaging run*/ packageFileNames.clear(); std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); - compInstDirName = "ALL_COMPONENTS_IN_ONE"; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging all groups in one package..." "(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)" @@ -178,27 +197,32 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne() /* replace the TEMPORARY package file name */ this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", packageFileName.c_str()); - // Tell CPackRPM.cmake the path where the component is. - std::string component_path = "/"; - component_path += compInstDirName; - this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH", - component_path.c_str()); - if (!this->ReadListFile("CPackRPM.cmake")) + + if(!compInstDirName.empty()) + { + // Tell CPackRPM.cmake the path where the component is. + std::string component_path = "/"; + component_path += compInstDirName; + this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH", + component_path.c_str()); + } + + if (this->ReadListFile("CPackRPM.cmake")) + { + AddGeneratedPackageNames(); + } + else { cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake" << std::endl); retval = 0; } - // add the generated package to package file names list - packageFileNames.push_back(packageFileName); return retval; } int cmCPackRPMGenerator::PackageFiles() { - int retval = 1; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl); @@ -209,7 +233,7 @@ int cmCPackRPMGenerator::PackageFiles() // then the package file is unique and should be open here. if (componentPackageMethod == ONE_PACKAGE) { - return PackageComponentsAllInOne(); + return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE"); } // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // There will be 1 package for each component group @@ -224,20 +248,8 @@ int cmCPackRPMGenerator::PackageFiles() // CASE 3 : NON COMPONENT package. else { - if (!this->ReadListFile("CPackRPM.cmake")) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Error while execution CPackRPM.cmake" << std::endl); - retval = 0; - } - } - - if (!this->IsSet("RPMBUILD_EXECUTABLE")) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find rpmbuild" << std::endl); - retval = 0; + return PackageComponentsAllInOne(""); } - return retval; } bool cmCPackRPMGenerator::SupportsComponentInstallation() const diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index a4a1ba8..9987cf4 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -65,12 +65,13 @@ protected: * Special case of component install where all * components will be put in a single installer. */ - int PackageComponentsAllInOne(); + int PackageComponentsAllInOne(const std::string& compInstDirName); virtual const char* GetOutputExtension() { return ".rpm"; } virtual bool SupportsComponentInstallation() const; virtual std::string GetComponentInstallDirNameSuffix( const std::string& componentName); + void AddGeneratedPackageNames(); }; #endif diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 9647968..ed0cad7 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -102,6 +102,7 @@ static const char* cmCTestErrorExceptions[] = { ": warning", ": \\(Warning\\)", ": note", + "Note:", "makefile:", "Makefile:", ":[ \\t]+Where:", diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index b78a5df..1e1f040 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -94,6 +94,8 @@ int main(int argc, char** argv) QApplication app(argc, argv); + setlocale(LC_NUMERIC, "C"); + #if defined(CMAKE_ENCODING_UTF8) QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(utf8_codec); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0aa6a99..5b42b1a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -655,7 +655,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // Add the interface library as an item so it can be considered as part // of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore // this for the actual link line. - this->Items.push_back(Item(std::string(), true, tgt)); + this->Items.push_back(Item(std::string(), false, tgt)); } else { diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake index 26ab19e..70d6edf 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") set(expected_count 3) @@ -60,9 +60,9 @@ if(DPKGDEB_EXECUTABLE) "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-application'\n") endif() elseif("${dpkg_package_name}" STREQUAL "mylib-headers") - if(NOT "${dpkg_depends}" STREQUAL "depend-headers") + if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers") set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-headers'\n") + "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n") endif() elseif("${dpkg_package_name}" STREQUAL "mylib-libraries") if(NOT "${dpkg_depends}" STREQUAL "depend-default") diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake index 79e5df2..415d536 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") set(expected_count 3) set(config_verbose -V) @@ -73,9 +73,9 @@ if(DPKGDEB_EXECUTABLE) "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does contains 'depend-default'\n") endif() elseif("${dpkg_package_name}" STREQUAL "mylib-headers") - if(NOT "${dpkg_depends}" STREQUAL "depend-headers") + if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers") set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}" - "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-headers'\n") + "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n") endif() elseif("${dpkg_package_name}" STREQUAL "mylib-libraries") if(NOT "${dpkg_depends}" STREQUAL "depend-default") diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake index 6335029..337cc16 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake index 3d09296..35ca74c 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake @@ -7,7 +7,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake index ff22f8f..d51650c 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake @@ -5,7 +5,7 @@ endif() include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # TODO: currently debian doens't produce lower cased names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake index 79d8f0d..fcfc7ea 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake @@ -9,7 +9,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # requirements # debian now produces lower case names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") set(expected_count 3) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake index 51fa3ad..351bf21 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake @@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # expected results -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb") set(expected_count 3) set(config_verbose -V) diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake index 2175ada..c97ecb0 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake @@ -5,7 +5,7 @@ endif() include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake) # TODO: currently debian doens't produce lower cased names -set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb") +set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2-1_*.deb") set(expected_count 1) set(actual_output) diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index e956f17..fc90d09 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -60,7 +60,7 @@ elseif (CPackGen MATCHES "RPM") set(expected_count 1) endif () elseif (CPackGen MATCHES "DEB") - set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2-1_*.deb") if (${CPackComponentWay} STREQUAL "default") set(expected_count 1) elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") @@ -118,7 +118,7 @@ if(expected_file_mask) message(STATUS "expected_file_mask='${expected_file_mask}'") if(NOT expected_file) - message(FATAL_ERROR "error: expected_file=${expected_file} does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}") + message(FATAL_ERROR "error: expected_file does not exist: CPackComponentsForAll test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}") endif() list(LENGTH expected_file actual_count) diff --git a/Tests/CompileFeatures/cxx_unicode_literals.cpp b/Tests/CompileFeatures/cxx_unicode_literals.cpp index a7b7df0..7794c11 100644 --- a/Tests/CompileFeatures/cxx_unicode_literals.cpp +++ b/Tests/CompileFeatures/cxx_unicode_literals.cpp @@ -1,3 +1,5 @@ +/* clang-format off */ const char16_t lit_16[] = u"\u00DA"; const char32_t lit_32[] = U"\u00DA"; +/* clang-format on */ diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake index aef1086..7bf42f9 100644 --- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake +++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake @@ -9,6 +9,20 @@ function(run_cpack_test TEST_NAME types build) file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + if(EXISTS "${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake") + include("${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake") + + set(FOUND_PREREQUIREMENTS false) + get_test_prerequirements("FOUND_PREREQUIREMENTS" + "${TEST_CONFIG_DIR}/${type}_config.cmake") + + # skip the test if prerequirements are not met + if(NOT FOUND_PREREQUIREMENTS) + message(STATUS "${TEST_NAME} - SKIPPED") + return() + endif() + endif() + # execute cmake set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}") run_cmake(${TEST_NAME}) diff --git a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake index 5adca68..62f2f9c 100644 --- a/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/COMPONENTS_EMPTY_DIR-ExpectedFiles.cmake @@ -1,5 +1,5 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "components_empty_dir*.deb") +set(EXPECTED_FILE_1 "components_empty_dir-test_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake index 2ff679a..4531a34 100644 --- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-ExpectedFiles.cmake @@ -1,9 +1,9 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "deb_extra-*-foo.deb") +set(EXPECTED_FILE_1 "deb_extra-foo_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "deb_extra-*-bar.deb") +set(EXPECTED_FILE_2 "deb_extra-bar_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_2 "^.*/usr/${whitespaces_}.*/usr/bar/${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_3 "deb_extra-*-bas.deb") +set(EXPECTED_FILE_3 "deb_extra-bas_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_3 "^.*/usr/${whitespaces_}.*/usr/bas/${whitespaces_}.*/usr/bas/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake new file mode 100644 index 0000000..a8efb61 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-ExpectedFiles.cmake @@ -0,0 +1,6 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_1 "generate_shlibs_0.1.1-1_*.deb") +# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it +set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake new file mode 100644 index 0000000..b98065a --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var) + find_program(READELF_EXECUTABLE NAMES readelf) + + if(READELF_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake new file mode 100644 index 0000000..8ccb628 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake @@ -0,0 +1,3 @@ +set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$") +set(shlibs_shlibs_permissions_regex "-rw-r--r-- .*") +verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake new file mode 100644 index 0000000..9a9dee3 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-ExpectedFiles.cmake @@ -0,0 +1,6 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_1 "generate_shlibs_ldconfig_0.1.1-1_*.deb") +# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it +set(EXPECTED_FILE_CONTENT_1 "^.*/usr/lib${whitespaces_}.*/usr/lib/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake new file mode 100644 index 0000000..b98065a --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-Prerequirements.cmake @@ -0,0 +1,7 @@ +function(get_test_prerequirements found_var) + find_program(READELF_EXECUTABLE NAMES readelf) + + if(READELF_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake new file mode 100644 index 0000000..d04c641 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake @@ -0,0 +1,7 @@ +set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs_ldconfig \\(>\\= 0\\.1\\.1\\)\n$") +set(shlibs_shlibs_permissions_regex "-rw-r--r-- .*") +set(shlibs_postinst ".*ldconfig.*") +set(shlibs_postinst_permissions_regex "-rwxr-xr-x .*") +set(shlibs_postrm ".*ldconfig.*") +set(shlibs_postrm_permissions_regex "-rwxr-xr-x .*") +verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs;postinst;postrm") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake index c56c670..c182e30 100644 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-ExpectedFiles.cmake @@ -1,14 +1,14 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "5") -set(EXPECTED_FILE_1 "dependencies*-applications.deb") +set(EXPECTED_FILE_1 "dependencies-applications_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$") -set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb") +set(EXPECTED_FILE_2 "dependencies-applications_auto_0.1.1-1_*.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_3 "dependencies-headers_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$") -set(EXPECTED_FILE_4 "dependencies*-libs.deb") +set(EXPECTED_FILE_4 "dependencies-libs_0.1.1-1_*.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_5 "dependencies-libs_auto_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$") diff --git a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake index 1552a36..6dc5906 100644 --- a/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/EMPTY_DIR-ExpectedFiles.cmake @@ -1,5 +1,5 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "empty_dir*.deb") +set(EXPECTED_FILE_1 "empty_dir_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$") diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake index f490130..d05f115 100644 --- a/Tests/RunCMake/CPack/DEB/Helpers.cmake +++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake @@ -1,7 +1,7 @@ set(ALL_FILES_GLOB "*.deb") function(getPackageContent FILE RESULT_VAR) - execute_process(COMMAND ${DPKG_EXECUTABLE} -c ${FILE} + execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}" OUTPUT_VARIABLE package_content_ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -9,8 +9,73 @@ function(getPackageContent FILE RESULT_VAR) set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE) endfunction() +function(getMissingShlibsErrorExtra FILE RESULT_VAR) + execute_process(COMMAND ${DPKG_EXECUTABLE} -x "${FILE}" data_${PREFIX} + ERROR_VARIABLE err_) + + if(err_) + set(error_extra " Extra: Could not unpack package content: '${err}'") + else() + cmake_policy(PUSH) + # Tell file(GLOB_RECURSE) not to follow directory symlinks + # even if the project does not set this policy to NEW. + cmake_policy(SET CMP0009 NEW) + file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/data_${PREFIX}/*") + cmake_policy(POP) + + # get file info so that we can determine if file is executable or not + foreach(FILE_ IN LISTS FILE_PATHS_) + execute_process(COMMAND file "${FILE_}" + WORKING_DIRECTORY "${WDIR}" + OUTPUT_VARIABLE INSTALL_FILE_ + ERROR_VARIABLE err_) + + if(NOT err_) + list(APPEND deb_install_files "${INSTALL_FILE_}") + else() + list(APPEND deb_install_files_errors "'${FILE_}': '${err_}'\n") + endif() + endforeach() + + set(error_extra " Extra: install files '${deb_install_files}'") + + if(deb_install_files_errors) + set(error_extra "${error_extra}; errors \"${deb_install_files_errors}\"") + endif() + + find_program(READELF_EXECUTABLE NAMES readelf) + + if(READELF_EXECUTABLE) + set(error_extra "${error_extra}; readelf \"\n") + + # Only dynamically linked ELF files are included + # Extract only file name infront of ":" + foreach(_FILE IN LISTS deb_install_files) + if(_FILE MATCHES "ELF.*shared object") + string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}") + + execute_process(COMMAND ${READELF_EXECUTABLE} -d "${CMAKE_MATCH_1}" + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE err_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + set(error_extra "${error_extra} name '${CMAKE_MATCH_1}'\n result '${result}'\n output '${output}'\n error '${err_}'\n") + endif() + endforeach() + + set(error_extra "${error_extra}\"") + else() + set(error_extra "${error_extra}; error readelf missing") + endif() + endif() + + set(${RESULT_VAR} "${error_extra}" PARENT_SCOPE) +endfunction() + function(verifyDebControl FILE PREFIX VERIFY_FILES) - execute_process(COMMAND ${DPKG_EXECUTABLE} --control ${FILE} control_${PREFIX} + execute_process(COMMAND ${DPKG_EXECUTABLE} --control "${FILE}" control_${PREFIX} ERROR_VARIABLE err_) if(err_) @@ -19,6 +84,14 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES) endif() foreach(FILE_ IN LISTS VERIFY_FILES) + if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}") + if(FILE_ STREQUAL "shlibs") + getMissingShlibsErrorExtra("${FILE}" error_extra) + endif() + + message(FATAL_ERROR "Expected Debian control file does not exist: '${FILE_}'${error_extra}") + endif() + file(READ "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}" content_) if(NOT content_ MATCHES "${${PREFIX}_${FILE_}}") message(FATAL_ERROR "Unexpected content in for '${PREFIX}_${FILE_}'!" diff --git a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake index 9e4aa7c..648c866 100644 --- a/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/MINIMAL-ExpectedFiles.cmake @@ -1,5 +1,5 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_1 "minimal*.deb") +set(EXPECTED_FILE_1 "minimal_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake index 1f6c11b..40f6730 100644 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-ExpectedFiles.cmake @@ -1,9 +1,9 @@ set(whitespaces_ "[\t\n\r ]*") set(EXPECTED_FILES_COUNT "3") -set(EXPECTED_FILE_1 "per_component*-pkg_1.deb") +set(EXPECTED_FILE_1 "per_component-pkg_1_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_2 "per_component*-pkg_2.deb") +set(EXPECTED_FILE_2 "second_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") -set(EXPECTED_FILE_3 "per_component*-pkg_3.deb") +set(EXPECTED_FILE_3 "per_component-pkg_3_0.1.1-1_*.deb") set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake new file mode 100644 index 0000000..efb0211 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS.cmake @@ -0,0 +1,17 @@ +set(CPACK_PACKAGE_CONTACT "someone") +set(CPACK_DEB_COMPONENT_INSTALL "ON") + +set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON") + +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") +set_target_properties(test_lib PROPERTIES SOVERSION "0.8") + +install(TARGETS test_lib DESTINATION foo COMPONENT libs) + +set(CPACK_PACKAGE_NAME "generate_shlibs") diff --git a/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake new file mode 100644 index 0000000..1f70386 --- /dev/null +++ b/Tests/RunCMake/CPack/DEB_GENERATE_SHLIBS_LDCONFIG.cmake @@ -0,0 +1,18 @@ +set(CPACK_PACKAGE_CONTACT "someone") +set(CPACK_DEB_COMPONENT_INSTALL "ON") + +set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON") +set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") + +set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp" + "int test_lib();\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp" + "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n") +add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp") +set_target_properties(test_lib PROPERTIES SOVERSION "0.8") + +install(TARGETS test_lib LIBRARY DESTINATION lib COMPONENT libs NAMELINK_SKIP) + +set(CPACK_PACKAGE_NAME "generate_shlibs_ldconfig") diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index ea68304..5c86880 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -1,6 +1,9 @@ RunCMake.CPack is a test module that is intended for testing of package generators that can be validated from command line. +TODO: all tests should cover all packaging types (single package, grouped and + component packaging) + ------------- Adding a test ------------- @@ -19,10 +22,29 @@ run_cpack_test(<test_name> "<generator_name>") will be run for all listed generators. Test consists of +- test prerequirements phase (optional) - CMake execution phase - CPack execution phase - verification of generated files +test prerequirements phase (optional): +-------------------------------------- + +In some cases individual tests for certain generator need additional +prerequirements met. + +In such cases '<generator_name>/<test_name>-Prerequirements.cmake' file +containing 'function(get_test_prerequirements found_var)' should be created. +Function should return true if all prerequirements are met. + +If prerequirements are not met test will be skipped outputting +'<test_name> - SKIPPED' string. Note that this doesn't fail the entire test +group. + +TODO: skipped tests should provide expected error string so test should fail + if error string is not found in the output of run test (this would add + 'EXPECTED FAIL' string on success and 'ERROR' on failure). + CMake execution phase: ---------------------- diff --git a/Tests/RunCMake/CPack/RPM/RPM_CUSTOM_NAMES-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/RPM_CUSTOM_NAMES-ExpectedFiles.cmake new file mode 100644 index 0000000..780e57e --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/RPM_CUSTOM_NAMES-ExpectedFiles.cmake @@ -0,0 +1,9 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "3") +set(EXPECTED_FILE_1 "custom_names-pkg_1*.rpm") +set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") +set(EXPECTED_FILE_2 "second*.rpm") +set(EXPECTED_FILE_CONTENT_2 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") +set(EXPECTED_FILE_3 "pkg_3_abc.rpm") +set(EXPECTED_FILE_CONTENT_3 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/RPM_CUSTOM_NAMES-stderr.txt b/Tests/RunCMake/CPack/RPM/RPM_CUSTOM_NAMES-stderr.txt new file mode 100644 index 0000000..d3ba7b0 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/RPM_CUSTOM_NAMES-stderr.txt @@ -0,0 +1,3 @@ +^CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/RPM_CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/custom_names-pkg_1.spec +CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/RPM_CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/second.spec +CPackRPM: Will use GENERATED spec file: .*/Tests/RunCMake/RPM/CPack/RPM_CUSTOM_NAMES-build/_CPack_Packages/.*/RPM/SPECS/custom_names-pkg_3.spec$ diff --git a/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake b/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake new file mode 100644 index 0000000..3b5a347 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/RPM_DIST-ExpectedFiles.cmake @@ -0,0 +1,5 @@ +set(whitespaces_ "[\t\n\r ]*") + +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_1 "rpm_dist*.rpm") +set(EXPECTED_FILE_CONTENT_1 "^/usr/foo${whitespaces_}/usr/foo/CMakeLists.txt$") diff --git a/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake new file mode 100644 index 0000000..7375ecc --- /dev/null +++ b/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake @@ -0,0 +1,11 @@ +execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist} + OUTPUT_VARIABLE DIST_TAG + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(whitespaces_ "[\t\n\r ]*") + +getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_") +if(NOT FILE_INFO_ MATCHES ".*Release${whitespaces_}:${whitespaces_}1${DIST_TAG}") + message(FATAL_ERROR "Unexpected Release in '${FOUND_FILE_1}'; file info: '${FILE_INFO_}'") +endif() diff --git a/Tests/RunCMake/CPack/RPM_CUSTOM_NAMES.cmake b/Tests/RunCMake/CPack/RPM_CUSTOM_NAMES.cmake new file mode 100644 index 0000000..ba53a87 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM_CUSTOM_NAMES.cmake @@ -0,0 +1,11 @@ +set(CPACK_RPM_COMPONENT_INSTALL "ON") + +set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") +set(CPACK_RPM_PKG_2_PACKAGE_NAME "second") +set(CPACK_RPM_PKG_3_FILE_NAME "pkg_3_abc.rpm") + +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_2) +install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_3) + +set(CPACK_PACKAGE_NAME "custom_names") diff --git a/Tests/RunCMake/CPack/RPM_DIST.cmake b/Tests/RunCMake/CPack/RPM_DIST.cmake new file mode 100644 index 0000000..eb2a123 --- /dev/null +++ b/Tests/RunCMake/CPack/RPM_DIST.cmake @@ -0,0 +1,4 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) +set(CPACK_PACKAGE_NAME "rpm_dist") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index ee4112d..759295f 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -10,5 +10,9 @@ run_cpack_test(DEB_EXTRA "DEB" false) run_cpack_test(DEPENDENCIES "RPM;DEB" true) run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true) run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true) +run_cpack_test(RPM_CUSTOM_NAMES "RPM" true) run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false) +run_cpack_test(RPM_DIST "RPM" false) run_cpack_test(INSTALL_SCRIPTS "RPM" false) +run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true) +run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake new file mode 100644 index 0000000..00cbb7b --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.5) + +project(FindPkgConfig_IMPORTED_TARGET C) + +find_package(PkgConfig REQUIRED) +pkg_check_modules(NCURSES IMPORTED_TARGET QUIET ncurses) + +if (NCURSES_FOUND) + set(tgt PkgConfig::NCURSES) + if (NOT TARGET ${tgt}) + message(FATAL_ERROR "FindPkgConfig found ncurses, but did not create an imported target for it") + endif () + set(prop_found FALSE) + foreach (prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_COMPILE_OPTIONS) + get_target_property(value ${tgt} ${prop}) + if (value) + message(STATUS "Found property ${prop} on target: ${value}") + set(prop_found TRUE) + endif () + endforeach () + if (NOT prop_found) + message(FATAL_ERROR "target ${tgt} found, but it has no properties") + endif () +else () + message(STATUS "skipping test; ncurses not found") +endif () diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index 24089e0..e12b52f 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -15,4 +15,5 @@ find_package(PkgConfig) if (PKG_CONFIG_FOUND) run_cmake(FindPkgConfig_GET_VARIABLE) run_cmake(FindPkgConfig_cache_variables) + run_cmake(FindPkgConfig_IMPORTED_TARGET) endif () diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 2737f18..aee92f6 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -364,6 +364,7 @@ endif() set(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") set(CMAKE_INSTALL_MFC_LIBRARIES 1) set(CMAKE_INSTALL_DEBUG_LIBRARIES 1) +set(CMAKE_INSTALL_UCRT_LIBRARIES 1) include(InstallRequiredSystemLibraries) if(CTEST_TEST_CPACK) diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 2737f18..aee92f6 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -364,6 +364,7 @@ endif() set(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install") set(CMAKE_INSTALL_MFC_LIBRARIES 1) set(CMAKE_INSTALL_DEBUG_LIBRARIES 1) +set(CMAKE_INSTALL_UCRT_LIBRARIES 1) include(InstallRequiredSystemLibraries) if(CTEST_TEST_CPACK) diff --git a/Tests/VSXaml/App.xaml.cpp b/Tests/VSXaml/App.xaml.cpp index 2cb2b32..a187ed5 100644 --- a/Tests/VSXaml/App.xaml.cpp +++ b/Tests/VSXaml/App.xaml.cpp @@ -26,8 +26,9 @@ using namespace Windows::UI::Xaml::Navigation; // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 /// <summary> -/// Initializes the singleton application object. This is the first line of authored code -/// executed, and as such is the logical equivalent of main() or WinMain(). +/// Initializes the singleton application object. This is the first line of +/// authored code executed, and as such is the logical equivalent of main() +/// or WinMain(). /// </summary> App::App() { @@ -36,8 +37,9 @@ App::App() } /// <summary> -/// Invoked when the application is launched normally by the end user. Other entry points -/// will be used such as when the application is launched to open a specific file. +/// Invoked when the application is launched normally by the end user. +/// Other entry points will be used such as when the application is +/// launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) @@ -101,9 +103,9 @@ void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEvent } /// <summary> -/// Invoked when application execution is being suspended. Application state is saved -/// without knowing whether the application will be terminated or resumed with the contents -/// of memory still intact. +/// Invoked when application execution is being suspended. Application state +/// is saved without knowing whether the application will be terminated or +/// resumed with the contents of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> |