diff options
40 files changed, 606 insertions, 483 deletions
diff --git a/Help/release/dev/cpack-rpm-refactored-file-listing.rst b/Help/release/dev/cpack-rpm-refactored-file-listing.rst new file mode 100644 index 0000000..b4a5025 --- /dev/null +++ b/Help/release/dev/cpack-rpm-refactored-file-listing.rst @@ -0,0 +1,6 @@ +cpack-rpm-refactored-file-listing +--------------------------------- + +* The :module:`CPackRPM` module learned a new + :variable:`CPACK_RPM_ADDITIONAL_MAN_DIRS` variable to specify + directories containing man pages for the brp-compress RPM macro. diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 8a4fa49..f248a67 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -223,233 +223,260 @@ if(NOT UNIX) message(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.") endif() -# CPACK_DEBIAN_PACKAGE_SHLIBDEPS -# If specify OFF, only user depends are used -if(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) - set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) -endif() +function(cpack_deb_prepare_package_vars) + # CPACK_DEBIAN_PACKAGE_SHLIBDEPS + # If specify OFF, only user depends are used + if(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) + endif() -find_program(FAKEROOT_EXECUTABLE fakeroot) -if(FAKEROOT_EXECUTABLE) - set(CPACK_DEBIAN_FAKEROOT_EXECUTABLE ${FAKEROOT_EXECUTABLE}) -endif() + find_program(FAKEROOT_EXECUTABLE fakeroot) + if(FAKEROOT_EXECUTABLE) + set(CPACK_DEBIAN_FAKEROOT_EXECUTABLE ${FAKEROOT_EXECUTABLE}) + endif() -if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) - # dpkg-shlibdeps is a Debian utility for generating dependency list - find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps) - - # Check version of the dpkg-shlibdeps tool using CPackRPM method - if(SHLIBDEPS_EXECUTABLE) - execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version - OUTPUT_VARIABLE _TMP_VERSION - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX MATCH "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)" - SHLIBDEPS_EXECUTABLE_VERSION - ${_TMP_VERSION}) - set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}") - if(CPACK_DEBIAN_PACKAGE_DEBUG) - message( "CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>") - endif() + if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + # dpkg-shlibdeps is a Debian utility for generating dependency list + find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps) + + # Check version of the dpkg-shlibdeps tool using CPackRPM method + if(SHLIBDEPS_EXECUTABLE) + execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version + OUTPUT_VARIABLE _TMP_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX MATCH "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)" + SHLIBDEPS_EXECUTABLE_VERSION + ${_TMP_VERSION}) + set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}") + if(CPACK_DEBIAN_PACKAGE_DEBUG) + message( "CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>") + endif() - # Generating binary list - Get type of all install files - execute_process(COMMAND find -type f - COMMAND xargs file - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - OUTPUT_VARIABLE CPACK_DEB_INSTALL_FILES) - - # Convert to CMake list - string(REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES}) - - # 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}) + # Generating binary list - Get type of all install files + execute_process(COMMAND find -type f + COMMAND xargs file + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE CPACK_DEB_INSTALL_FILES) + + # Convert to CMake list + string(REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES}) + + # 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}) + endif() + endforeach() + + message( "CPackDeb: - Generating dependency list") + + # Create blank control file for running dpkg-shlibdeps + # There might be some other way to invoke dpkg-shlibdeps without creating this file + # but standard debian package should not have anything that can collide with this file or directory + file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian) + file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "") + + # Execute dpkg-shlibdeps + # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package + # -O : print to STDOUT + execute_process(COMMAND ${SHLIBDEPS_EXECUTABLE} --ignore-missing-info -O ${CPACK_DEB_BINARY_FILES} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE SHLIBDEPS_OUTPUT + RESULT_VARIABLE SHLIBDEPS_RESULT + ERROR_VARIABLE SHLIBDEPS_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + if(CPACK_DEBIAN_PACKAGE_DEBUG) + # dpkg-shlibdeps will throw some warnings if some input files are not binary + message( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}") endif() - endforeach() - - message( "CPackDeb: - Generating dependency list") - - # Create blank control file for running dpkg-shlibdeps - # There might be some other way to invoke dpkg-shlibdeps without creating this file - # but standard debian package should not have anything that can collide with this file or directory - file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian) - file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "") - - # Execute dpkg-shlibdeps - # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package - # -O : print to STDOUT - execute_process(COMMAND ${SHLIBDEPS_EXECUTABLE} --ignore-missing-info -O ${CPACK_DEB_BINARY_FILES} - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - OUTPUT_VARIABLE SHLIBDEPS_OUTPUT - RESULT_VARIABLE SHLIBDEPS_RESULT - ERROR_VARIABLE SHLIBDEPS_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE ) - if(CPACK_DEBIAN_PACKAGE_DEBUG) - # dpkg-shlibdeps will throw some warnings if some input files are not binary - message( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}") - endif() - if (NOT SHLIBDEPS_RESULT EQUAL 0) - message (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: ${SHLIBDEPS_ERROR}") - endif () + if (NOT SHLIBDEPS_RESULT EQUAL 0) + message (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: ${SHLIBDEPS_ERROR}") + endif () - #Get rid of prefix generated by dpkg-shlibdeps - string (REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS ${SHLIBDEPS_OUTPUT}) + #Get rid of prefix generated by dpkg-shlibdeps + string (REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS ${SHLIBDEPS_OUTPUT}) - if(CPACK_DEBIAN_PACKAGE_DEBUG) - message( "CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") - endif() + if(CPACK_DEBIAN_PACKAGE_DEBUG) + message( "CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") + endif() + + # Remove blank control file + # Might not be safe if package actual contain file or directory named debian + file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian") - # Remove blank control file - # Might not be safe if package actual contain file or directory named debian - file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian") + # Append user depend if set + if (CPACK_DEBIAN_PACKAGE_DEPENDS) + set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}") + else () + set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") + endif () - # Append user depend if set - if (CPACK_DEBIAN_PACKAGE_DEPENDS) - set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}") else () - set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") - endif () + if(CPACK_DEBIAN_PACKAGE_DEBUG) + message( "CPackDeb Debug: Using only user-provided depends because dpkg-shlibdeps is not found.") + endif() + endif() else () if(CPACK_DEBIAN_PACKAGE_DEBUG) - message( "CPackDeb Debug: Using only user-provided depends because dpkg-shlibdeps is not found.") + message( "CPackDeb Debug: Using only user-provided depends") endif() endif() -else () - if(CPACK_DEBIAN_PACKAGE_DEBUG) - message( "CPackDeb Debug: Using only user-provided depends") - endif() -endif() - -# Let's define the control file found in debian package: + # Let's define the control file found in debian package: -# Binary package: -# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles + # Binary package: + # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles -# DEBIAN/control -# debian policy enforce lower case for package name -# Package: (mandatory) -if(NOT CPACK_DEBIAN_PACKAGE_NAME) - string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME) -endif() - -# Version: (mandatory) -if(NOT CPACK_DEBIAN_PACKAGE_VERSION) - if(NOT CPACK_PACKAGE_VERSION) - message(FATAL_ERROR "CPackDeb: Debian package requires a package version") + # DEBIAN/control + # debian policy enforce lower case for package name + # Package: (mandatory) + if(NOT CPACK_DEBIAN_PACKAGE_NAME) + string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME) endif() - set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) -endif() -# Architecture: (mandatory) -if(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) - if(NOT DPKG_CMD) - message(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.") - set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) + # Version: (mandatory) + if(NOT CPACK_DEBIAN_PACKAGE_VERSION) + if(NOT CPACK_PACKAGE_VERSION) + message(FATAL_ERROR "CPackDeb: Debian package requires a package version") + endif() + set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) endif() - execute_process(COMMAND "${DPKG_CMD}" --print-architecture - OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -endif() -# have a look at get_property(result GLOBAL PROPERTY ENABLED_FEATURES), -# this returns the successful find_package() calls, maybe this can help -# Depends: -# You should set: DEBIAN_PACKAGE_DEPENDS -# TODO: automate 'objdump -p | grep NEEDED' -if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) - message(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.") -endif() + # Architecture: (mandatory) + if(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) + if(NOT DPKG_CMD) + message(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.") + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) + endif() + execute_process(COMMAND "${DPKG_CMD}" --print-architecture + OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + endif() -# Maintainer: (mandatory) -if(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) - if(NOT CPACK_PACKAGE_CONTACT) - message(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER") + # have a look at get_property(result GLOBAL PROPERTY ENABLED_FEATURES), + # this returns the successful find_package() calls, maybe this can help + # Depends: + # You should set: DEBIAN_PACKAGE_DEPENDS + # TODO: automate 'objdump -p | grep NEEDED' + if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) + message(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.") endif() - set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) -endif() -# Description: (mandatory) -if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) - if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") + # Maintainer: (mandatory) + if(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) + if(NOT CPACK_PACKAGE_CONTACT) + message(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER") + endif() + set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) endif() - set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) -endif() -# Section: (recommended) -if(NOT CPACK_DEBIAN_PACKAGE_SECTION) - set(CPACK_DEBIAN_PACKAGE_SECTION "devel") -endif() + # Description: (mandatory) + if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) + if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) + message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") + endif() + set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + endif() -# Priority: (recommended) -if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY) - set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") -endif() + # Section: (recommended) + if(NOT CPACK_DEBIAN_PACKAGE_SECTION) + set(CPACK_DEBIAN_PACKAGE_SECTION "devel") + endif() -# Compression: (recommended) -if(NOT CPACK_DEBIAN_COMPRESSION_TYPE) - set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip") -endif() + # Priority: (recommended) + if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY) + set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") + endif() + # Compression: (recommended) + if(NOT CPACK_DEBIAN_COMPRESSION_TYPE) + set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip") + endif() -# Recommends: -# You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS - -# Suggests: -# You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS - -# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA -# This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive) -# Typical examples are: -# - conffiles -# - postinst -# - postrm -# - prerm" -# Usage: -# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA -# "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm") - -# Are we packaging components ? -if(CPACK_DEB_PACKAGE_COMPONENT) - set(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "-${CPACK_DEB_PACKAGE_COMPONENT}") - string(TOLOWER "${CPACK_PACKAGE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_NAME}" CPACK_DEBIAN_PACKAGE_NAME) -else() - set(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "") -endif() -set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}") - -# 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}") - message("CPackDeb:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") - message("CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") - message("CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") - message("CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") - message("CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") - message("CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") - message("CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") -endif() + # Recommends: + # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS + + # Suggests: + # You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS + + # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA + # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive) + # Typical examples are: + # - conffiles + # - postinst + # - postrm + # - prerm" + # Usage: + # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA + # "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm") + + # Are we packaging components ? + if(CPACK_DEB_PACKAGE_COMPONENT) + set(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "-${CPACK_DEB_PACKAGE_COMPONENT}") + string(TOLOWER "${CPACK_PACKAGE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_NAME}" CPACK_DEBIAN_PACKAGE_NAME) + else() + set(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "") + endif() -# For debian source packages: -# debian/control -# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles + set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}") -# .dsc -# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles + # 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}") + message("CPackDeb:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") + message("CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") + message("CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") + message("CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") + message("CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") + message("CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") + message("CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") + endif() -# Builds-Depends: -#if(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS) -# set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS -# "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4" -# ) -#endif() + # For debian source packages: + # debian/control + # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles + + # .dsc + # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles + + # Builds-Depends: + #if(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS) + # set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS + # "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4" + # ) + #endif() + + # move variables to parent scope so that they may be used to create debian package + 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) + set(GEN_CPACK_DEBIAN_PACKAGE_PRIORITY "${CPACK_DEBIAN_PACKAGE_PRIORITY}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_DEBIAN_PACKAGE_MAINTAINER}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_FAKEROOT_EXECUTABLE "${CPACK_DEBIAN_FAKEROOT_EXECUTABLE}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_COMPRESSION_TYPE "${CPACK_DEBIAN_COMPRESSION_TYPE}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS "${CPACK_DEBIAN_PACKAGE_RECOMMENDS}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS "${CPACK_DEBIAN_PACKAGE_SUGGESTS}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_DEBIAN_PACKAGE_HOMEPAGE}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS "${CPACK_DEBIAN_PACKAGE_PREDEPENDS}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_ENHANCES "${CPACK_DEBIAN_PACKAGE_ENHANCES}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_BREAKS "${CPACK_DEBIAN_PACKAGE_BREAKS}" PARENT_SCOPE) + 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_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE) + set(GEN_WDIR "${WDIR}" PARENT_SCOPE) +endfunction() + +cpack_deb_prepare_package_vars() diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index b8d518c..fdba90e 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -419,6 +419,33 @@ # May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX # from relocatable RPM prefix paths. # +# .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS +# +# * Mandatory : NO +# * Default : - +# +# May be used to set additional man dirs that could potentially be compressed +# by brp-compress RPM macro. Variable content must be a list of regular +# expressions that point to directories containing man files or to man files +# directly. Note that in order to compress man pages a path must also be +# present in brp-compress RPM script and that brp-compress script must be +# added to RPM configuration by the operating system. +# +# Regular expressions that are added by default were taken from brp-compress +# RPM macro: +# +# - /usr/man/man.* +# - /usr/man/.*/man.* +# - /usr/info.* +# - /usr/share/man/man.* +# - /usr/share/man/.*/man.* +# - /usr/share/info.* +# - /usr/kerberos/man.* +# - /usr/X11R6/man/man.* +# - /usr/lib/perl5/man/man.* +# - /usr/share/doc/.*/man/man.* +# - /usr/lib/.*/man/man.* +# # Packaging of Symbolic Links # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ # @@ -538,6 +565,107 @@ function(cpack_rpm_prepare_relocation_paths) set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE) endfunction() +function(cpack_rpm_prepare_content_list) + # get files list + cmake_policy(PUSH) + cmake_policy(SET CMP0009 NEW) + file(GLOB_RECURSE CPACK_RPM_INSTALL_FILES LIST_DIRECTORIES true RELATIVE "${WDIR}" "${WDIR}/*") + cmake_policy(POP) + set(CPACK_RPM_INSTALL_FILES "/${CPACK_RPM_INSTALL_FILES}") + string(REPLACE ";" ";/" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}") + + # if we are creating a relocatable package, omit parent directories of + # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list" + # which is passed to the find command that generates the content-list + if(CPACK_RPM_PACKAGE_RELOCATABLE) + # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are + # destinct parent paths of other relocation paths and remove the + # final element (so the install-prefix dir itself is not omitted + # from the RPM's content-list) + list(SORT RPM_USED_PACKAGE_PREFIXES) + set(_DISTINCT_PATH "NOT_SET") + foreach(_RPM_RELOCATION_PREFIX ${RPM_USED_PACKAGE_PREFIXES}) + if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*") + set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}") + + string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS " ${_RPM_RELOCATION_PREFIX}") + list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1) + unset(_TMP_LIST) + # Now generate all of the parent dirs of the relocation path + foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS}) + list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}") + string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}") + separate_arguments(_OMIT_DIR) + list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR}) + endforeach() + endif() + endforeach() + endif() + + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") + endif() + + if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) + set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include) + if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION) + message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.") + list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}") + endif() + endif() + + if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}") + endif() + list(APPEND _RPM_DIRS_TO_OMIT ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}) + endif() + + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") + endif() + + list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES ${_RPM_DIRS_TO_OMIT}) + + # add man paths that will be compressed + # (copied from /usr/lib/rpm/brp-compress - script that does the actual + # compressing) + list(APPEND MAN_LOCATIONS "/usr/man/man.*" "/usr/man/.*/man.*" "/usr/info.*" + "/usr/share/man/man.*" "/usr/share/man/.*/man.*" "/usr/share/info.*" + "/usr/kerberos/man.*" "/usr/X11R6/man/man.*" "/usr/lib/perl5/man/man.*" + "/usr/share/doc/.*/man/man.*" "/usr/lib/.*/man/man.*") + + if(CPACK_RPM_ADDITIONAL_MAN_DIRS) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: CPACK_RPM_ADDITIONAL_MAN_DIRS= ${CPACK_RPM_ADDITIONAL_MAN_DIRS}") + endif() + list(APPEND MAN_LOCATIONS ${CPACK_RPM_ADDITIONAL_MAN_DIRS}) + endif() + + foreach(PACK_LOCATION IN LISTS CPACK_RPM_INSTALL_FILES) + foreach(MAN_LOCATION IN LISTS MAN_LOCATIONS) + # man pages are files inside a certain location + if(PACK_LOCATION MATCHES "${MAN_LOCATION}/" + AND NOT IS_DIRECTORY "${WDIR}${PACK_LOCATION}" + AND NOT IS_SYMLINK "${WDIR}${PACK_LOCATION}") + list(FIND CPACK_RPM_INSTALL_FILES "${PACK_LOCATION}" INDEX) + # insert file location that covers compressed man pages + # even if using a wildcard causes duplicates as those are + # handled by RPM and we still keep the same file list + # in spec file - wildcard only represents file type (e.g. .gz) + list(INSERT CPACK_RPM_INSTALL_FILES ${INDEX} "${PACK_LOCATION}*") + # remove file location that doesn't cover compressed man pages + math(EXPR INDEX ${INDEX}+1) + list(REMOVE_AT CPACK_RPM_INSTALL_FILES ${INDEX}) + + break() + endif() + endforeach() + endforeach() + + set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}" PARENT_SCOPE) +endfunction() + function(cpack_rpm_symlink_get_relocation_prefixes LOCATION PACKAGE_PREFIXES RETURN_VARIABLE) foreach(PKG_PREFIX IN LISTS PACKAGE_PREFIXES) string(REGEX MATCH "^${PKG_PREFIX}/.*" FOUND_ "${LOCATION}") @@ -1285,76 +1413,7 @@ function(cpack_rpm_generate_package) #string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") - # if we are creating a relocatable package, omit parent directories of - # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list" - # which is passed to the find command that generates the content-list - if(CPACK_RPM_PACKAGE_RELOCATABLE) - # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are - # destinct parent paths of other relocation paths and remove the - # final element (so the install-prefix dir itself is not omitted - # from the RPM's content-list) - set(SORTED_RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}") - list(SORT SORTED_RPM_USED_PACKAGE_PREFIXES) - set(_DISTINCT_PATH "NOT_SET") - foreach(_RPM_RELOCATION_PREFIX ${SORTED_RPM_USED_PACKAGE_PREFIXES}) - if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*") - set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}") - - string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS ".${_RPM_RELOCATION_PREFIX}") - list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1) - unset(_TMP_LIST) - # Now generate all of the parent dirs of the relocation path - foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS}) - list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}") - string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}") - list(FIND _RPM_DIRS_TO_OMIT "${_OMIT_DIR}" _DUPLICATE_FOUND) - if(_DUPLICATE_FOUND EQUAL -1) - set(_OMIT_DIR "-o -path ${_OMIT_DIR}") - separate_arguments(_OMIT_DIR) - list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR}) - endif() - endforeach() - endif() - endforeach() - endif() - - if (CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") - endif() - - if (NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) - set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include) - if (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION) - message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.") - list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}") - endif() - endif() - - if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST) - if (CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}") - endif() - foreach(_DIR ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}) - list(APPEND _RPM_DIRS_TO_OMIT "-o;-path;.${_DIR}") - endforeach() - endif() - if (CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}") - endif() - - # Use files tree to construct files command (spec file) - # We should not forget to include symlinks (thus -o -type l) - # We should include directory as well (thus -type d) - # but not the main local dir "." (thus -a -not -name ".") - # We must remove the './' due to the local search and escape the - # file name by enclosing it between double quotes (thus the sed) - # Then we must authorize any man pages extension (adding * at the end) - # because rpmbuild may automatically compress those files - execute_process(COMMAND find . -type f -o -type l -o (-type d -a -not ( -name "." ${_RPM_DIRS_TO_OMIT} ) ) - COMMAND sed s:.*/man.*/.*:&*: - COMMAND sed s/\\.\\\(.*\\\)/\"\\1\"/ - WORKING_DIRECTORY "${WDIR}" - OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) + cpack_rpm_prepare_content_list() # In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT> # into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 1802e61..e8e1fb1 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -1585,10 +1585,12 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options COMMENT "Building NVCC intermediate link file ${output_file_relative_path}" ) else() + get_filename_component(output_file_dir "${output_file}" DIRECTORY) add_custom_command( TARGET ${cuda_target} PRE_LINK COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}" COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}" ) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0e96a1b..4394f24 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 2) -set(CMake_VERSION_PATCH 20150420) +set(CMake_VERSION_PATCH 20150421) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 7f06e2d..0439ff6 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -92,7 +92,8 @@ int cmCPackIFWGenerator::PackageFiles() cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate repository" << std::endl); bool res = cmSystemTools::RunSingleCommand( - ifwCmd.c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); + ifwCmd.c_str(), &output, &output, + &retVal, 0, this->GeneratorVerbose, 0); if ( !res || retVal ) { cmGeneratedFileStream ofs(ifwTmpFile.c_str()); @@ -176,7 +177,8 @@ int cmCPackIFWGenerator::PackageFiles() int retVal = 1; cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl); bool res = cmSystemTools::RunSingleCommand( - ifwCmd.c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); + ifwCmd.c_str(), &output, &output, + &retVal, 0, this->GeneratorVerbose, 0); if ( !res || retVal ) { cmGeneratedFileStream ofs(ifwTmpFile.c_str()); diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 99eabf2..b3eb7b2 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -64,7 +64,8 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command) std::string output; int returnValue = 0; - bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output, + bool status = cmSystemTools::RunSingleCommand( + command.c_str(), &output, &output, &returnValue, 0, cmSystemTools::OUTPUT_NONE); cmsys::ofstream logFile(logFileName.c_str(), std::ios::app); diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index fcf4122..18597e8 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -90,7 +90,7 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, } cmsys::Glob gl; - std::string findExpr(this->GetOption("WDIR")); + std::string findExpr(this->GetOption("GEN_WDIR")); findExpr += "/*"; gl.RecurseOn(); if ( !gl.FindFiles(findExpr) ) @@ -217,7 +217,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne() } cmsys::Glob gl; - std::string findExpr(this->GetOption("WDIR")); + std::string findExpr(this->GetOption("GEN_WDIR")); findExpr += "/*"; gl.RecurseOn(); if ( !gl.FindFiles(findExpr) ) @@ -286,7 +286,7 @@ int cmCPackDebGenerator::createDeb() // debian-binary file std::string dbfilename; - dbfilename += this->GetOption("WDIR"); + dbfilename += this->GetOption("GEN_WDIR"); dbfilename += "/debian-binary"; { // the scope is needed for cmGeneratedFileStream cmGeneratedFileStream out(dbfilename.c_str()); @@ -296,44 +296,47 @@ int cmCPackDebGenerator::createDeb() // control file std::string ctlfilename; - ctlfilename = this->GetOption("WDIR"); + ctlfilename = this->GetOption("GEN_WDIR"); ctlfilename += "/control"; // debian policy enforce lower case for package name // mandatory entries: std::string debian_pkg_name = cmsys::SystemTools::LowerCase( - this->GetOption("CPACK_DEBIAN_PACKAGE_NAME") ); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") ); const char* debian_pkg_version = - this->GetOption("CPACK_DEBIAN_PACKAGE_VERSION"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION"); const char* debian_pkg_section = - this->GetOption("CPACK_DEBIAN_PACKAGE_SECTION"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION"); const char* debian_pkg_priority = - this->GetOption("CPACK_DEBIAN_PACKAGE_PRIORITY"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY"); const char* debian_pkg_arch = - this->GetOption("CPACK_DEBIAN_PACKAGE_ARCHITECTURE"); - const char* maintainer = this->GetOption("CPACK_DEBIAN_PACKAGE_MAINTAINER"); - const char* desc = this->GetOption("CPACK_DEBIAN_PACKAGE_DESCRIPTION"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE"); + const char* maintainer = + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER"); + const char* desc = + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION"); // optional entries - const char* debian_pkg_dep = this->GetOption("CPACK_DEBIAN_PACKAGE_DEPENDS"); + const char* debian_pkg_dep = + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS"); const char* debian_pkg_rec = - this->GetOption("CPACK_DEBIAN_PACKAGE_RECOMMENDS"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS"); const char* debian_pkg_sug = - this->GetOption("CPACK_DEBIAN_PACKAGE_SUGGESTS"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS"); const char* debian_pkg_url = - this->GetOption("CPACK_DEBIAN_PACKAGE_HOMEPAGE"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE"); const char* debian_pkg_predep = - this->GetOption("CPACK_DEBIAN_PACKAGE_PREDEPENDS"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS"); const char* debian_pkg_enhances = - this->GetOption("CPACK_DEBIAN_PACKAGE_ENHANCES"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES"); const char* debian_pkg_breaks = - this->GetOption("CPACK_DEBIAN_PACKAGE_BREAKS"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS"); const char* debian_pkg_conflicts = - this->GetOption("CPACK_DEBIAN_PACKAGE_CONFLICTS"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS"); const char* debian_pkg_provides = - this->GetOption("CPACK_DEBIAN_PACKAGE_PROVIDES"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES"); const char* debian_pkg_replaces = - this->GetOption("CPACK_DEBIAN_PACKAGE_REPLACES"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES"); { // the scope is needed for cmGeneratedFileStream cmGeneratedFileStream out(ctlfilename.c_str()); @@ -399,13 +402,10 @@ int cmCPackDebGenerator::createDeb() out << std::endl; } - std::string cmd; - if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) { - cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); - } + std::string cmd(this->GetOption("GEN_CPACK_DEBIAN_FAKEROOT_EXECUTABLE")); const char* debian_compression_type = - this->GetOption("CPACK_DEBIAN_COMPRESSION_TYPE"); + this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE"); if(!debian_compression_type) { debian_compression_type = "gzip"; @@ -440,8 +440,9 @@ int cmCPackDebGenerator::createDeb() // now add all directories which have to be compressed // collect all top level install dirs for that // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would give /usr and /opt - size_t topLevelLength = std::string(this->GetOption("WDIR")).length(); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \"" << this->GetOption("WDIR") + size_t topLevelLength = std::string(this->GetOption("GEN_WDIR")).length(); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \"" + << this->GetOption("GEN_WDIR") << "\", length = " << topLevelLength << std::endl); std::set<std::string> installDirs; @@ -466,8 +467,8 @@ int cmCPackDebGenerator::createDeb() std::string output; int retval = -1; - int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retval, this->GetOption("WDIR"), this->GeneratorVerbose, 0); + int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output, + &retval, this->GetOption("GEN_WDIR"), this->GeneratorVerbose, 0); if ( !res || retval ) { @@ -485,7 +486,7 @@ int cmCPackDebGenerator::createDeb() } std::string md5filename; - md5filename = this->GetOption("WDIR"); + md5filename = this->GetOption("GEN_WDIR"); md5filename += "/md5sums"; { // the scope is needed for cmGeneratedFileStream @@ -505,7 +506,7 @@ int cmCPackDebGenerator::createDeb() cmd += "\""; //std::string output; //int retVal = -1; - res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, + res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output, &retval, toplevel.c_str(), this->GeneratorVerbose, 0); if ( !res || retval ) { @@ -523,14 +524,10 @@ int cmCPackDebGenerator::createDeb() // Do not end the md5sum file with yet another (invalid) } - cmd = ""; - if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) - { - cmd = this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); - } + cmd = this->GetOption("GEN_CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); cmd += cmake_tar + "tar czf control.tar.gz ./control ./md5sums"; const char* controlExtra = - this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); if( controlExtra ) { std::vector<std::string> controlExtraList; @@ -540,7 +537,7 @@ int cmCPackDebGenerator::createDeb() { std::string filenamename = cmsys::SystemTools::GetFilenameName(*i); - std::string localcopy = this->GetOption("WDIR"); + std::string localcopy = this->GetOption("GEN_WDIR"); localcopy += "/"; localcopy += filenamename; // if we can copy the file, it means it does exist, let's add it: @@ -553,8 +550,8 @@ int cmCPackDebGenerator::createDeb() } } } - res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retval, this->GetOption("WDIR"), this->GeneratorVerbose, 0); + res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output, + &retval, this->GetOption("GEN_WDIR"), this->GeneratorVerbose, 0); if ( !res || retval ) { @@ -575,7 +572,7 @@ int cmCPackDebGenerator::createDeb() // since debian packages require BSD ar (most Linux distros and even // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here. std::vector<std::string> arFiles; - std::string topLevelString = this->GetOption("WDIR"); + std::string topLevelString = this->GetOption("GEN_WDIR"); topLevelString += "/"; arFiles.push_back(topLevelString + "debian-binary"); arFiles.push_back(topLevelString + "control.tar.gz"); diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 5da9234..4c400d9 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -197,7 +197,7 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command, bool result = cmSystemTools::RunSingleCommand( command.str().c_str(), - output, + output, output, &exit_code, 0, this->GeneratorVerbose, diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 2b18c41..e254e9a 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -290,7 +290,8 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( << std::endl); std::string output; int retVal = 1; - bool resB = cmSystemTools::RunSingleCommand(it->c_str(), &output, + bool resB = cmSystemTools::RunSingleCommand( + it->c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0); if ( !resB || retVal ) { @@ -668,7 +669,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( int retVal = 1; bool resB = cmSystemTools::RunSingleCommand(buildCommand.c_str(), - &output, + &output, &output, &retVal, installDirectory.c_str(), this->GeneratorVerbose, 0); diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index fe6cc95..2de2bc4 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -324,7 +324,7 @@ int cmCPackNSISGenerator::PackageFiles() << std::endl); std::string output; int retVal = 1; - bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, + bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0); if ( !res || retVal ) { @@ -430,8 +430,8 @@ int cmCPackNSISGenerator::InitializeInternal() << nsisCmd << std::endl); std::string output; int retVal = 1; - bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), - &output, &retVal, 0, this->GeneratorVerbose, 0); + bool resS = cmSystemTools::RunSingleCommand( + nsisCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0); cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)"); cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs"); if ( !resS || retVal || @@ -836,9 +836,9 @@ CreateComponentDescription(cmCPackComponent *component, zipListFileName.c_str()); std::string output; int retVal = -1; - int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &retVal, - dirName.c_str(), - cmSystemTools::OUTPUT_NONE, 0); + int res = cmSystemTools::RunSingleCommand( + cmd.c_str(), &output, &output, + &retVal, dirName.c_str(), cmSystemTools::OUTPUT_NONE, 0); if ( !res || retVal ) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 313e08b..d533af8 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -180,9 +180,9 @@ int cmCPackOSXX11Generator::PackageFiles() bool res = false; while(numTries > 0) { - res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, - &retVal, 0, - this->GeneratorVerbose, 0); + res = cmSystemTools::RunSingleCommand( + dmgCmd.str().c_str(), &output, &output, + &retVal, 0, this->GeneratorVerbose, 0); if ( res && !retVal ) { numTries = -1; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index dfe35c9..880663f 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -378,9 +378,9 @@ int cmCPackPackageMakerGenerator::PackageFiles() bool res = false; while(numTries > 0) { - res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, - &retVal, 0, this->GeneratorVerbose, - 0); + res = cmSystemTools::RunSingleCommand( + dmgCmd.str().c_str(), &output, &output, + &retVal, 0, this->GeneratorVerbose, 0); if ( res && !retVal ) { numTries = -1; @@ -657,8 +657,9 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char *command, cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl); std::string output; int retVal = 1; - bool res = cmSystemTools::RunSingleCommand(command, &output, &retVal, 0, - this->GeneratorVerbose, 0); + bool res = cmSystemTools::RunSingleCommand( + command, &output, &output, + &retVal, 0, this->GeneratorVerbose, 0); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker" << std::endl); if ( !res || retVal ) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 2752270..2207873 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -356,8 +356,8 @@ int main (int argc, char const* const* argv) ++it ) { const char* gen = it->c_str(); - cmMakefile newMF(*globalMF); - cmMakefile* mf = &newMF; + cmMakefile::ScopePushPop raii(globalMF); + cmMakefile* mf = globalMF; cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Specified generator: " << gen << std::endl); if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") ) diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 7f64d57..0a34be8 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -709,7 +709,8 @@ int cmCTestScriptHandler::CheckOutSourceDir() output = ""; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cvs: " << this->CVSCheckOut << std::endl); - res = cmSystemTools::RunSingleCommand(this->CVSCheckOut.c_str(), &output, + res = cmSystemTools::RunSingleCommand( + this->CVSCheckOut.c_str(), &output, &output, &retVal, this->CTestRoot.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); if (!res || retVal != 0) @@ -789,7 +790,8 @@ int cmCTestScriptHandler::PerformExtraUpdates() retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: " << fullCommand << std::endl); - res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output, + res = cmSystemTools::RunSingleCommand( + fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); if (!res || retVal != 0) @@ -910,7 +912,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard() retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: " << command << std::endl); - res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + res = cmSystemTools::RunSingleCommand( + command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); @@ -956,7 +959,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard() retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: " << command << std::endl); - res = cmSystemTools::RunSingleCommand(command.c_str(), &output, + res = cmSystemTools::RunSingleCommand( + command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d778253..95cdf3b 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1334,7 +1334,7 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec) int retVal = 0; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it << std::endl, this->Quiet); - if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, + if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, 0, &retVal, 0, cmSystemTools::OUTPUT_MERGE /*this->Verbose*/) || retVal != 0 ) { diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index 2a06574..2733d76 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -49,7 +49,7 @@ bool cmBuildNameCommand if(this->Makefile->GetDefinition("UNIX")) { buildname = ""; - cmSystemTools::RunSingleCommand("uname -a", &buildname); + cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname); if(!buildname.empty()) { std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) "; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 9e1f44d..72a6a30 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -1163,7 +1163,7 @@ cmExtraEclipseCDT4Generator::GetEclipsePath(const std::string& path) #if defined(__CYGWIN__) std::string cmd = "cygpath -m " + path; std::string out; - if (!cmSystemTools::RunSingleCommand(cmd.c_str(), &out)) + if (!cmSystemTools::RunSingleCommand(cmd.c_str(), &out, &out)) { return path; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 339df1d..774b172 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1737,7 +1737,7 @@ int cmGlobalGenerator::Build( output += cmSystemTools::PrintSingleCommand(cleanCommand); output += "\n"; - if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, + if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, outputPtr, &retVal, 0, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); @@ -1758,7 +1758,7 @@ int cmGlobalGenerator::Build( output += makeCommandStr; output += "\n"; - if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, + if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, outputPtr, &retVal, 0, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 06ba9ca..76f2e14 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1233,7 +1233,7 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const std::string version; std::string command = ninjaCmd() + " --version"; cmSystemTools::RunSingleCommand(command.c_str(), - &version, 0, 0, + &version, 0, 0, 0, cmSystemTools::OUTPUT_NONE); return version; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0fd6be8..d333c1d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -164,8 +164,8 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory { std::string out; std::string::size_type pos; - if(cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, 0, 0, - cmSystemTools::OUTPUT_NONE) && + if(cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, 0, + 0, 0, cmSystemTools::OUTPUT_NONE) && (pos = out.find(".app/"), pos != out.npos)) { versionFile = out.substr(0, pos+5)+"Contents/version.plist"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7beb932..c77a90c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -106,52 +106,6 @@ cmMakefile::cmMakefile(): Internal(new Internals) this->SuppressWatches = false; } -cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) -{ - this->Internal->VarStack.push(mf.Internal->VarStack.top().Closure()); - this->Internal->VarInitStack.push(mf.Internal->VarInitStack.top()); - this->Internal->VarUsageStack.push(mf.Internal->VarUsageStack.top()); - - this->cmStartDirectory = mf.cmStartDirectory; - this->StartOutputDirectory = mf.StartOutputDirectory; - this->cmHomeDirectory = mf.cmHomeDirectory; - this->HomeOutputDirectory = mf.HomeOutputDirectory; - this->cmCurrentListFile = mf.cmCurrentListFile; - this->ProjectName = mf.ProjectName; - this->Targets = mf.Targets; - this->SourceFiles = mf.SourceFiles; - this->Tests = mf.Tests; - this->LinkDirectories = mf.LinkDirectories; - this->SystemIncludeDirectories = mf.SystemIncludeDirectories; - this->ListFiles = mf.ListFiles; - this->OutputFiles = mf.OutputFiles; - this->LinkLibraries = mf.LinkLibraries; - this->InstallGenerators = mf.InstallGenerators; - this->TestGenerators = mf.TestGenerators; - this->IncludeFileRegularExpression = mf.IncludeFileRegularExpression; - this->ComplainFileRegularExpression = mf.ComplainFileRegularExpression; - this->SourceFileExtensions = mf.SourceFileExtensions; - this->HeaderFileExtensions = mf.HeaderFileExtensions; - this->DefineFlags = mf.DefineFlags; - this->DefineFlagsOrig = mf.DefineFlagsOrig; - -#if defined(CMAKE_BUILD_WITH_CMAKE) - this->SourceGroups = mf.SourceGroups; -#endif - - this->LocalGenerator = mf.LocalGenerator; - this->FunctionBlockers = mf.FunctionBlockers; - this->MacrosList = mf.MacrosList; - this->Properties = mf.Properties; - this->WarnUnused = mf.WarnUnused; - this->Initialize(); - this->CheckSystemVars = mf.CheckSystemVars; - this->ListFileStack = mf.ListFileStack; - this->OutputToSource = mf.OutputToSource; - - this->SuppressWatches = mf.SuppressWatches; -} - //---------------------------------------------------------------------------- void cmMakefile::Initialize() { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 55b2cbd..46e9391 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -75,7 +75,6 @@ public: * Construct an empty makefile. */ cmMakefile(); - cmMakefile(const cmMakefile& mf); /** * Destructor. @@ -939,6 +938,8 @@ protected: cmExecutionStatus &status); private: + cmMakefile(const cmMakefile& mf); + cmMakefile& operator=(const cmMakefile& mf); void Initialize(); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index b204788..1572dc1 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -188,7 +188,7 @@ std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf, std::string output; int retVal = 0; - bool result = cmSystemTools::RunSingleCommand(command, &output, + bool result = cmSystemTools::RunSingleCommand(command, &output, &output, &retVal, 0, cmSystemTools::OUTPUT_NONE); if (!result || retVal) @@ -2196,7 +2196,8 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, std::string output; int retVal = 0; - bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + bool result = cmSystemTools::RunSingleCommand(command, &output, &output, + &retVal); if (!result || retVal) { std::cerr << "AUTOGEN: error: process for " << mocFilePath <<" failed:\n" @@ -2265,7 +2266,8 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, } std::string output; int retVal = 0; - bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + bool result = cmSystemTools::RunSingleCommand(command, &output, &output, + &retVal); if (!result || retVal) { std::cerr << "AUTOUIC: error: process for " << ui_output_file << @@ -2355,7 +2357,8 @@ bool cmQtAutoGenerators::GenerateQrc() } std::string output; int retVal = 0; - bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + bool result = cmSystemTools::RunSingleCommand(command, &output, &output, + &retVal); if (!result || retVal) { std::cerr << "AUTORCC: error: process for " << rcc_output_file << diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 20a61a0..e2970e5 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -63,7 +63,7 @@ bool cmSiteNameCommand { std::string host; cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), - &host, 0, 0, cmSystemTools::OUTPUT_NONE); + &host, 0, 0, 0, cmSystemTools::OUTPUT_NONE); // got the hostname if (!host.empty()) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 95d05a6..0e0532d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -659,7 +659,8 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command) bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, - std::string* output , + std::string* captureStdOut, + std::string* captureStdErr, int* retVal , const char* dir , OutputOption outputflag , double timeout ) @@ -671,9 +672,13 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, argv.push_back(a->c_str()); } argv.push_back(0); - if ( output ) + if ( captureStdOut ) { - *output = ""; + *captureStdOut = ""; + } + if (captureStdErr && captureStdErr != captureStdOut) + { + *captureStdErr = ""; } cmsysProcess* cp = cmsysProcess_New(); @@ -693,15 +698,17 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, cmsysProcess_SetTimeout(cp, timeout); cmsysProcess_Execute(cp); - std::vector<char> tempOutput; + std::vector<char> tempStdOut; + std::vector<char> tempStdErr; char* data; int length; int pipe; - if(outputflag != OUTPUT_PASSTHROUGH && (output || outputflag != OUTPUT_NONE)) + if(outputflag != OUTPUT_PASSTHROUGH && + (captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)) { while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0) { - if(output || outputflag != OUTPUT_NONE) + if(captureStdOut || captureStdErr || outputflag != OUTPUT_NONE) { // Translate NULL characters in the output into valid text. // Visual Studio 7 puts these characters in the output of its @@ -714,9 +721,21 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, } } } - if ( output ) + if(pipe == cmsysProcess_Pipe_STDOUT || + (pipe == cmsysProcess_Pipe_STDERR && + captureStdOut == captureStdErr)) + { + if (captureStdOut) + { + tempStdOut.insert(tempStdOut.end(), data, data+length); + } + } + else if(pipe == cmsysProcess_Pipe_STDERR) { - tempOutput.insert(tempOutput.end(), data, data+length); + if (captureStdErr) + { + tempStdErr.insert(tempStdErr.end(), data, data+length); + } } if(outputflag != OUTPUT_NONE) { @@ -740,9 +759,14 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, } cmsysProcess_WaitForExit(cp, 0); - if ( output && tempOutput.begin() != tempOutput.end()) + if ( captureStdOut && tempStdOut.begin() != tempStdOut.end()) + { + captureStdOut->append(&*tempStdOut.begin(), tempStdOut.size()); + } + if ( captureStdErr && captureStdErr != captureStdOut && + tempStdErr.begin() != tempStdErr.end()) { - output->append(&*tempOutput.begin(), tempOutput.size()); + captureStdErr->append(&*tempStdErr.begin(), tempStdErr.size()); } bool result = true; @@ -767,9 +791,9 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, { std::cerr << exception_str << std::endl; } - if ( output ) + if ( captureStdErr ) { - output->append(exception_str, strlen(exception_str)); + captureStdErr->append(exception_str, strlen(exception_str)); } result = false; } @@ -780,9 +804,9 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, { std::cerr << error_str << std::endl; } - if ( output ) + if ( captureStdErr ) { - output->append(error_str, strlen(error_str)); + captureStdErr->append(error_str, strlen(error_str)); } result = false; } @@ -793,9 +817,9 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, { std::cerr << error_str << std::endl; } - if ( output ) + if ( captureStdErr ) { - output->append(error_str, strlen(error_str)); + captureStdErr->append(error_str, strlen(error_str)); } result = false; } @@ -806,7 +830,8 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command, bool cmSystemTools::RunSingleCommand( const char* command, - std::string* output, + std::string* captureStdOut, + std::string* captureStdErr, int *retVal, const char* dir, OutputOption outputflag, @@ -823,8 +848,8 @@ bool cmSystemTools::RunSingleCommand( { return false; } - return cmSystemTools::RunSingleCommand(args, output,retVal, - dir, outputflag, timeout); + return cmSystemTools::RunSingleCommand(args, captureStdOut, captureStdErr, + retVal, dir, outputflag, timeout); } std::string diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 433ef46..6feb6c5 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -223,7 +223,9 @@ public: OUTPUT_NORMAL, OUTPUT_PASSTHROUGH }; - static bool RunSingleCommand(const char* command, std::string* output = 0, + static bool RunSingleCommand(const char* command, + std::string* captureStdOut = 0, + std::string* captureStdErr = 0, int* retVal = 0, const char* dir = 0, OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); @@ -233,7 +235,8 @@ public: * be in comand[1]...command[command.size()] */ static bool RunSingleCommand(std::vector<std::string> const& command, - std::string* output = 0, + std::string* captureStdOut = 0, + std::string* captureStdErr = 0, int* retVal = 0, const char* dir = 0, OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index c9e7a46..3cd92cb 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -224,7 +224,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, } int timeout = 0; bool worked = cmSystemTools::RunSingleCommand(finalCommand.c_str(), - out, &retVal, + out, out, &retVal, 0, cmSystemTools::OUTPUT_NONE, timeout); // set the run var char retChar[1000]; diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 55fc633..f3c6059 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -206,8 +206,9 @@ static int process( const std::string& srcfilename, } // run the command int exit_code = 0; - bool run = cmSystemTools::RunSingleCommand(command, &output, &exit_code, - dir.c_str(), cmSystemTools::OUTPUT_NONE); + bool run = cmSystemTools::RunSingleCommand(command, &output, &output, + &exit_code, dir.c_str(), + cmSystemTools::OUTPUT_NONE); // process the include directives and output everything else std::stringstream ss(output); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index bd38566..12bb8ee 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -267,7 +267,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::vector<std::string> cmd(ai, ae); int retval; if(cmSystemTools::RunSingleCommand( - cmd, 0, &retval, NULL, cmSystemTools::OUTPUT_PASSTHROUGH)) + cmd, 0, 0, &retval, NULL, cmSystemTools::OUTPUT_PASSTHROUGH)) { return retval; } @@ -398,7 +398,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) time(&time_start); clock_start = clock(); int ret =0; - cmSystemTools::RunSingleCommand(command.c_str(), 0, &ret); + cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &ret); clock_finish = clock(); time(&time_finish); @@ -454,7 +454,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::string command = cmWrap('"', cmRange(args).advance(3), '"', " "); int retval = 0; int timeout = 0; - if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, + if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, 0, &retval, directory.c_str(), cmSystemTools::OUTPUT_NORMAL, timeout) ) { return retval; @@ -1347,7 +1347,7 @@ bool cmcmd::RunCommand(const char* comment, int retCode =0; // use rc command to create .res file cmSystemTools::RunSingleCommand(command, - &output, + &output, &output, &retCode, 0, cmSystemTools::OUTPUT_NONE); // always print the output of the command, unless // it is the dumb rc command banner, but if the command diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 279bcd5..26ab223 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -130,7 +130,7 @@ int main () std::vector<std::string> command; cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command); if (!cmSystemTools::RunSingleCommand( - command, 0, 0, it->at("directory").c_str())) + command, 0, 0, 0, it->at("directory").c_str())) { std::cout << "ERROR: Failed to run command \"" << command[0] << "\"" << std::endl; diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt index 1cc34b0..823f6db 100644 --- a/Tests/CPackComponentsForAll/CMakeLists.txt +++ b/Tests/CPackComponentsForAll/CMakeLists.txt @@ -50,6 +50,13 @@ install(FILES mylib.h COMPONENT headers) if("${CPACK_GENERATOR}" MATCHES "RPM") + ############## test man pages + install(FILES mylib + DESTINATION share/man/mylib/man3/mylib.1) + install(FILES mylib + DESTINATION share/man/mylib/man3/mylib.1 RENAME mylib2) + + ############## test symlinks # Package symbolic links install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_one/depth_two/depth_three COMPONENT libraries) install(DIRECTORY DESTINATION ${CMAKE_INSTALL_LIBDIR}/inside_relocatable_two/depth_two/different_relocatable/bar COMPONENT libraries) diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index e747052..d94a477 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -233,7 +233,14 @@ if(CPackGen MATCHES "RPM") /usr/foo/bar/bin/@in@_@path@@with/@and /usr/foo/bar/bin/@in@_@path@@with/@and/@ /usr/foo/bar/bin/@in@_@path@@with/@and/@/@in_path@ -/usr/foo/bar/bin/@in@_@path@@with/@and/@/@in_path@/mylibapp2$") +/usr/foo/bar/bin/@in@_@path@@with/@and/@/@in_path@/mylibapp2 +/usr/foo/bar/share +/usr/foo/bar/share/man +/usr/foo/bar/share/man/mylib +/usr/foo/bar/share/man/mylib/man3 +/usr/foo/bar/share/man/mylib/man3/mylib.1 +/usr/foo/bar/share/man/mylib/man3/mylib.1/mylib +/usr/foo/bar/share/man/mylib/man3/mylib.1/mylib2$") else() message(FATAL_ERROR "error: unexpected rpm package '${check_file}'") endif() diff --git a/Tests/CPackComponentsForAll/mylib b/Tests/CPackComponentsForAll/mylib new file mode 100644 index 0000000..e3bd05c --- /dev/null +++ b/Tests/CPackComponentsForAll/mylib @@ -0,0 +1,17 @@ +.\" Manpage for mylib. +.\" Contact bugs@mylib_author.net.in to correct errors or typos. +.TH mylib 3 "01 May 2015" "1.0" "mylib.so man page" +.SH NAME +mylib \- cpack testing lib +.SH SYNOPSIS +mylib.so +.SH DESCRIPTION +mylib.so test man page. +.SH OPTIONS +Lib does not take any options. +.SH SEE ALSO +mylib(3) +.SH BUGS +No known bugs. +.SH AUTHOR +Someone (author@lib_author.net.in) diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake new file mode 100644 index 0000000..c1e4204 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake @@ -0,0 +1,17 @@ +set(_cache_file "${RunCMake_TEST_BINARY_DIR}/tmp/FOO-cache.cmake") + +if(NOT EXISTS "${_cache_file}") + set(RunCMake_TEST_FAILED "Initial cache not created") + return() +endif() + +file(READ "${_cache_file}" _cache) + +if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) + set(RunCMake_TEST_FAILED "Cannot find FOO argument in cache") + return() +endif() +if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected forced FOO argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake index bf9b12d..5e37eec 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake @@ -1,21 +1,5 @@ include(ExternalProject) -set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp") -set(_cache_file "${_tmp_dir}/FOO-cache.cmake") - -ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}" +ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" CMAKE_CACHE_ARGS "-DFOO:STRING=BAR") - -if(NOT EXISTS "${_cache_file}") - message(FATAL_ERROR "Initial cache not created") -endif() - -file(READ "${_cache_file}" _cache) - -if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) - message(FATAL_ERROR "Cannot find FOO argument in cache") -endif() -if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) - message(FATAL_ERROR "Expected forced FOO argument") -endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake new file mode 100644 index 0000000..ec1cafb --- /dev/null +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake @@ -0,0 +1,17 @@ +set(_cache_file "${RunCMake_TEST_BINARY_DIR}/tmp/FOO-cache.cmake") + +if(NOT EXISTS "${_cache_file}") + set(RunCMake_TEST_FAILED "Initial cache not created") + return() +endif() + +file(READ "${_cache_file}" _cache) + +if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) + set(RunCMake_TEST_FAILED "Cannot find FOO argument in cache") + return() +endif() +if("${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected not forced FOO argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake index c216664..8e98470 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake @@ -1,21 +1,5 @@ include(ExternalProject) -set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp") -set(_cache_file "${_tmp_dir}/FOO-cache.cmake") - -ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}" +ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" CMAKE_CACHE_DEFAULT_ARGS "-DFOO:STRING=BAR") - -if(NOT EXISTS "${_cache_file}") - message(FATAL_ERROR "Initial cache not created") -endif() - -file(READ "${_cache_file}" _cache) - -if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) - message(FATAL_ERROR "Cannot find FOO argument in cache") -endif() -if("${CMAKE_MATCH_0}" MATCHES FORCE) - message(FATAL_ERROR "Expected not forced FOO argument") -endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix-check.cmake new file mode 100644 index 0000000..2a07f27 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix-check.cmake @@ -0,0 +1,26 @@ +set(_cache_file "${RunCMake_TEST_BINARY_DIR}/tmp/FOO-cache.cmake") + +if(NOT EXISTS "${_cache_file}") + set(RunCMake_TEST_FAILED "Initial cache not created") + return() +endif() + +file(READ "${_cache_file}" _cache) + +if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) + set(RunCMake_TEST_FAILED "Cannot find FOO argument in cache") + return() +endif() +if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected forced FOO argument") + return() +endif() + +if(NOT "${_cache}" MATCHES "set\\(BAR \"BAZ\".+\\)") # \(\) + set(RunCMake_TEST_FAILED "Cannot find BAR argument in cache") + return() +endif() +if("${CMAKE_MATCH_0}" MATCHES FORCE) + set(RunCMake_TEST_FAILED "Expected not forced BAR argument") + return() +endif() diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake index 894e183..e7f26ae 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake @@ -1,29 +1,6 @@ include(ExternalProject) -set(_tmp_dir "${CMAKE_CURRENT_BINARY_DIR}/tmp") -set(_cache_file "${_tmp_dir}/FOO-cache.cmake") - -ExternalProject_Add(FOO TMP_DIR "${_tmp_dir}" +ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp" DOWNLOAD_COMMAND "" CMAKE_CACHE_ARGS "-DFOO:STRING=BAR" CMAKE_CACHE_DEFAULT_ARGS "-DBAR:STRING=BAZ") - -if(NOT EXISTS "${_cache_file}") - message(FATAL_ERROR "Initial cache not created") -endif() - -file(READ "${_cache_file}" _cache) - -if(NOT "${_cache}" MATCHES "set\\(FOO \"BAR\".+\\)") # \(\) - message(FATAL_ERROR "Cannot find FOO argument in cache") -endif() -if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE) - message(FATAL_ERROR "Expected forced FOO argument") -endif() - -if(NOT "${_cache}" MATCHES "set\\(BAR \"BAZ\".+\\)") # \(\) - message(FATAL_ERROR "Cannot find BAR argument in cache") -endif() -if("${CMAKE_MATCH_0}" MATCHES FORCE) - message(FATAL_ERROR "Expected not forced BAR argument") -endif() |