diff options
79 files changed, 1363 insertions, 399 deletions
diff --git a/Docs/cmake-completion b/Docs/cmake-completion new file mode 100644 index 0000000..011f3fa --- /dev/null +++ b/Docs/cmake-completion @@ -0,0 +1,190 @@ +# +# bash-completion file for CMake +# Provided by Eric NOULARD - eric.noulard@gmail.com +# +# see http://bash-completion.alioth.debian.org/ +# and http://www.cmake.org +# +# We will try to complete cmake commands options +# at 2 (or may be 3 levels) +# [cmake|cpack|ctest] <level0> <level1> <level2> +# +# level0 is top level cmake/cpack/ctest options +# level1 is the first argument of level0 option +# level2 is the seconf argument of level1 argument +# FIXME: I don't know how to handle level2 +# +# The file has been proposed for inclusion in the bash-completion package +# https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312632&group_id=100114 +# In the meantime, +# 1) If you want to test bash completion for cmake/cpack/ctest +# just source the current file at bash prompt +# . ./cmake-completion +# +# 2) If you want to install it for good copy this file to +# cp cmake-completion /etc/bash_completion.d/cmake +# + +# +# cmake command +# +# have cmake && +_cmake() +{ + local cur prev opts words cword + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + # seems to be only available on bash-completion 1.2 + #_get_comp_words_by_ref cur prev + + # cmake command line option we want to complete + opts=`cmake --help | grep "^ \-.*=\ .*" | cut -d" " -f 3 | cut -d= -f 1 | cut -d[ -f 1` + + # + # Complete the arguments to some of + # the most commonly used commands (Level 1). + # + case "${prev}" in + -E) + local running=$(for x in `cmake -E |& grep "^ " | cut -d" " -f 3`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-command) + local running=$(for x in `cmake --help-command-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-module) + local running=$(for x in `cmake --help-module-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-policy) + local running=$(for x in `cmake --help-policies | grep "^ CMP"`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-property) + local running=$(for x in `cmake --help-property-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-variable) + local running=$(for x in `cmake --help-variable-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + *) + ;; + esac + + # + # Complete the arguments to some of + # the most commonly used commands (Level 2). + # ?? How to do that .. + + # + # Complete the option (Level 0 - right after cmake) + # + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} && +complete -F _cmake -o default cmake + +# +# cpack command +# +#have cpack && +_cpack() +{ + local cur prev opts words cword + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + # seems to be only available on bash-completion 1.2 + #_get_comp_words_by_ref cur prev + + # cpack command line option we want to complete + opts=`cpack --help | grep "^ \-.*=\ .*" | cut -d" " -f 3 | cut -d= -f 1` + opts="${opts} --help -V" + + # + # Complete the arguments to some of + # the most commonly used commands (Level 1). + # + case "${prev}" in + -G) + local running=$(for x in `cpack --help | grep "^ .*=\ .*" | grep -v "^ -" | cut -d" " -f 3`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --config) + COMPREPLY=( $(compgen -f ${cur}) ) + return 0 + ;; + *) + ;; + esac + + # + # Complete the option (Level 0 - right after cmake) + # + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} && +complete -F _cpack -o default cpack + +# +# cmake command +# +# have ctest && +_ctest() +{ + local cur prev opts words cword + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + # seems to be only available on bash-completion 1.2 + #_get_comp_words_by_ref cur prev + + # cmake command line option we want to complete + opts=`ctest --help | grep "\-\-.*" | cut -d" " -f 3 | sed s/,/\\\n/g` + + # + # Complete the arguments to some of + # the most commonly used commands (Level 1). + # + case "${prev}" in + --help-command) + local running=$(for x in `ctest --help-command-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + -R) + local running=$(for x in `ctest -N 2> /dev/null | grep "^ Test" | cut -d: -f 2`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + *) + ;; + esac + + # + # Complete the arguments to some of + # the most commonly used commands (Level 2). + # ?? How to do that .. + + # + # Complete the option (Level 0 - right after cmake) + # + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} && +complete -F _ctest -o default ctest + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh
\ No newline at end of file diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 964a2a9..b94303e 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -28,18 +28,25 @@ IF("${CMAKE_BASE_NAME}" STREQUAL "as") SET(CMAKE_BASE_NAME gas) ENDIF("${CMAKE_BASE_NAME}" STREQUAL "as") -INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL) +# Load compiler-specific information. +SET(_INCLUDED_FILE "") +IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + INCLUDE(Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) +IF(NOT _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL) +ENDIF(NOT _INCLUDED_FILE) IF(CMAKE_SYSTEM_PROCESSOR) - INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) + IF(NOT _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) + ENDIF(NOT _INCLUDED_FILE) ENDIF(CMAKE_SYSTEM_PROCESSOR) -IF(NOT _INCLUDED_FILE) - INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-ASM-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) -ENDIF(NOT _INCLUDED_FILE) -INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) IF(NOT _INCLUDED_FILE) - INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-ASM OPTIONAL) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) ENDIF(NOT _INCLUDED_FILE) # Set default assembler file extensions: diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 9e5bc72..06dd6b8 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -38,9 +38,9 @@ ELSE(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) # we only get here if CMAKE_ASM${ASM_DIALECT}_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE # - # if a compiler was specified by the user but without path, + # if a compiler was specified by the user but without path, # now try to find it with the full path - # if it is found, force it into the cache, + # if it is found, force it into the cache, # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" GET_FILENAME_COMPONENT(_CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH) IF(NOT _CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH) @@ -57,11 +57,30 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION) GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH) ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) -# If we have a gas/as cross compiler, they have usually some prefix, like + +IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + + # Table of per-vendor compiler id flags with expected output. + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS GNU ) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_GNU "--version") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "GNU assembler") + + CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT}) + + IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + MESSAGE(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}") + ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + MESSAGE(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown") + ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + +ENDIF() + + +# If we have a gas/as cross compiler, they have usually some prefix, like # e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas . # The other tools of the toolchain usually have the same prefix # NAME_WE cannot be used since then this test will fail for names lile -# "arm-unknown-nto-qnx6.3.0-gas.exe", where BASENAME would be +# "arm-unknown-nto-qnx6.3.0-gas.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" IF (NOT _CMAKE_TOOLCHAIN_PREFIX) GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME) @@ -86,7 +105,7 @@ SET(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}") SET(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}") # configure variables set in this file for fast reload later on -CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in +CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeASM${ASM_DIALECT}Compiler.cmake IMMEDIATE @ONLY) SET(_CMAKE_ASM_COMPILER) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index ab81215..bf78a5b 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -63,7 +63,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) - SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" + SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID) @@ -247,7 +247,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) # Return the information extracted. SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) - SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" + SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) SET(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang) @@ -261,6 +261,17 @@ ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang) # We try running the compiler with the flag for each vendor and # matching its regular expression in the output. FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) + + IF(NOT CMAKE_${lang}_COMPILER_ID_DIR) + # We get here when this function is called not from within CMAKE_DETERMINE_COMPILER_ID() + # This is done e.g. for detecting the compiler ID for assemblers. + # Compute the directory in which to run the test and Create a clean working directory. + SET(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CompilerId${lang}) + FILE(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR}) + FILE(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}) + ENDIF(NOT CMAKE_${lang}_COMPILER_ID_DIR) + + FOREACH(vendor ${CMAKE_${lang}_COMPILER_ID_VENDORS}) SET(flags ${CMAKE_${lang}_COMPILER_ID_VENDOR_FLAGS_${vendor}}) SET(regex ${CMAKE_${lang}_COMPILER_ID_VENDOR_REGEX_${vendor}}) @@ -272,6 +283,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE result + TIMEOUT 10 ) IF("${output}" MATCHES "${regex}") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log @@ -280,9 +292,15 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) SET(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE) BREAK() ELSE() - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" " - "did not match \"${regex}\":\n${output}") + IF("${result}" MATCHES "timeout") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" " + "terminated after 10 s due to timeout.") + ELSE() + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" " + "did not match \"${regex}\":\n${output}") + ENDIF() ENDIF() ENDFOREACH() ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR) diff --git a/Modules/CMakeParseArguments.cmake b/Modules/CMakeParseArguments.cmake new file mode 100644 index 0000000..7ce4c49 --- /dev/null +++ b/Modules/CMakeParseArguments.cmake @@ -0,0 +1,138 @@ +# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) +# +# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for +# parsing the arguments given to that macro or function. +# It processes the arguments and defines a set of variables which hold the +# values of the respective options. +# +# The <options> argument contains all options for the respective macro, +# i.e. keywords which can be used when calling the macro without any value +# following, like e.g. the OPTIONAL keyword of the install() command. +# +# The <one_value_keywords> argument contains all keywords for this macro +# which are followed by one value, like e.g. DESTINATION keyword of the +# install() command. +# +# The <multi_value_keywords> argument contains all keywords for this macro +# which can be followed by more than one value, like e.g. the TARGETS or +# FILES keywords of the install() command. +# +# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the +# keywords listed in <options>, <one_value_keywords> and +# <multi_value_keywords> a variable composed of the given <prefix> +# followed by "_" and the name of the respective keyword. +# These variables will then hold the respective value from the argument list. +# For the <options> keywords this will be TRUE or FALSE. +# +# All remaining arguments are collected in a variable +# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether +# your macro was called with unrecognized parameters. +# +# As an example here a my_install() macro, which takes similar arguments as the +# real install() command: +# +# function(MY_INSTALL) +# set(options OPTIONAL FAST) +# set(oneValueArgs DESTINATION RENAME) +# set(multiValueArgs TARGETS CONFIGURATIONS) +# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) +# ... +# +# Assume my_install() has been called like this: +# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) +# +# After the cmake_parse_arguments() call the macro will have set the following +# variables: +# MY_INSTALL_OPTIONAL = TRUE +# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() +# MY_INSTALL_DESTINATION = "bin" +# MY_INSTALL_RENAME = "" (was not used) +# MY_INSTALL_TARGETS = "foo;bar" +# MY_INSTALL_CONFIGURATIONS = "" (was not used) +# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" +# +# You can the continue and process these variables. +# +# Keywords terminate lists of values, e.g. if directly after a one_value_keyword +# another recognized keyword follows, this is interpreted as the beginning of +# the new option. +# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in +# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would +# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. + +#============================================================================= +# Copyright 2010 Alexander Neundorf <neundorf@kde.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + + +if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) + return() +endif() +set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) + + +function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) + # first set all result variables to empty/FALSE + foreach(arg_name ${_singleArgNames} ${_multiArgNames}) + set(${prefix}_${arg_name}) + endforeach(arg_name) + + foreach(option ${_optionNames}) + set(${prefix}_${option} FALSE) + endforeach(option) + + set(${prefix}_UNPARSED_ARGUMENTS) + + set(insideValues FALSE) + set(currentArgName) + + # now iterate over all arguments and fill the result variables + foreach(currentArg ${ARGN}) + list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword + + if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) + if(insideValues) + if("${insideValues}" STREQUAL "SINGLE") + set(${prefix}_${currentArgName} ${currentArg}) + set(insideValues FALSE) + elseif("${insideValues}" STREQUAL "MULTI") + list(APPEND ${prefix}_${currentArgName} ${currentArg}) + endif() + else(insideValues) + list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) + endif(insideValues) + else() + if(NOT ${optionIndex} EQUAL -1) + set(${prefix}_${currentArg} TRUE) + set(insideValues FALSE) + elseif(NOT ${singleArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "SINGLE") + elseif(NOT ${multiArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "MULTI") + endif() + endif() + + endforeach(currentArg) + + # propagate the result variables to the caller: + foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) + set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) + endforeach(arg_name) + set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + +endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/Modules/CMakeVS6FindMake.cmake b/Modules/CMakeVS6FindMake.cmake index 6a73905..dccf8c4 100644 --- a/Modules/CMakeVS6FindMake.cmake +++ b/Modules/CMakeVS6FindMake.cmake @@ -22,3 +22,4 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC60 1) +SET(MSVC_VERSION 1200) diff --git a/Modules/CMakeVS71FindMake.cmake b/Modules/CMakeVS71FindMake.cmake index bb03e7a..2381adb 100644 --- a/Modules/CMakeVS71FindMake.cmake +++ b/Modules/CMakeVS71FindMake.cmake @@ -23,3 +23,4 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC71 1) +SET(MSVC_VERSION 1310) diff --git a/Modules/CMakeVS7FindMake.cmake b/Modules/CMakeVS7FindMake.cmake index 99c953e..665158c 100644 --- a/Modules/CMakeVS7FindMake.cmake +++ b/Modules/CMakeVS7FindMake.cmake @@ -22,3 +22,4 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC70 1) +SET(MSVC_VERSION 1300) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 668a62a..7033e31 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -19,9 +19,41 @@ # described below, for more information about component-specific # installations. # -# Before including the CPack module, there are a variety of variables -# that can be set to customize the resulting installers. The most -# commonly-used variables are: +# The CPACK_GENERATOR variable has different meanings in different +# contexts. In your CMakeLists.txt file, CPACK_GENERATOR is a +# *list of generators*: when run with no other arguments, CPack +# will iterate over that list and produce one package for each +# generator. In a CPACK_PROJECT_CONFIG_FILE, though, CPACK_GENERATOR +# is a *string naming a single generator*. If you need per-cpack- +# generator logic to control *other* cpack settings, then you need +# a CPACK_PROJECT_CONFIG_FILE. +# +# The CMake source tree itself contains a CPACK_PROJECT_CONFIG_FILE. +# See the top level file CMakeCPackOptions.cmake.in for an example. +# +# If set, the CPACK_PROJECT_CONFIG_FILE is included automatically +# on a per-generator basis. It only need contain overrides. +# +# Here's how it works: +# - cpack runs +# - it includes CPackConfig.cmake +# - it iterates over the generators listed in that file's +# CPACK_GENERATOR list variable (unless told to use just a +# specific one via -G on the command line...) +# +# - foreach generator, it then +# - sets CPACK_GENERATOR to the one currently being iterated +# - includes the CPACK_PROJECT_CONFIG_FILE +# - produces the package for that generator +# +# This is the key: For each generator listed in CPACK_GENERATOR +# in CPackConfig.cmake, cpack will *reset* CPACK_GENERATOR +# internally to *the one currently being used* and then include +# the CPACK_PROJECT_CONFIG_FILE. +# +# Before including this CPack module in your CMakeLists.txt file, +# there are a variety of variables that can be set to customize +# the resulting installers. The most commonly-used variables are: # # CPACK_PACKAGE_NAME - The name of the package (or application). If # not specified, defaults to the project name. @@ -48,6 +80,11 @@ # CPACK_PACKAGE_INSTALL_DIRECTORY - Installation directory on the # target system, e.g., "CMake 2.5". # +# CPACK_PROJECT_CONFIG_FILE - File included at cpack time, once per +# generator after setting CPACK_GENERATOR to the actual generator +# being used. Allows per-generator setting of CPACK_* variables at +# cpack time. +# # CPACK_RESOURCE_FILE_LICENSE - License file for the project, which # will typically be displayed to the user (often with an explicit # "Accept" button, for graphical installers) prior to installation. diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 86fc272..1a1b168 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -556,7 +556,7 @@ ELSE (_boost_IN_CACHE) # Setting some more suffixes for the library SET (Boost_LIB_PREFIX "") - if ( WIN32 AND Boost_USE_STATIC_LIBS ) + if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) SET (Boost_LIB_PREFIX "lib") endif() diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 0769da7..3b99ae2 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -28,6 +28,8 @@ # # GTK2_DEBUG - Enables verbose debugging of the module # GTK2_SKIP_MARK_AS_ADVANCED - Disable marking cache variables as advanced +# GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to +# search for include files # #================= # Example Usage: @@ -64,6 +66,15 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Version 1.0 (8/12/2010) +# * Add support for detecting new pangommconfig.h header file +# (Thanks to Sune Vuorela & the Debian Project for the patch) +# * Add support for detecting fontconfig.h header +# * Call find_package(Freetype) since it's required +# * Add support for allowing users to add additional library directories +# via the GTK2_ADDITIONAL_SUFFIXES variable (kind of a future-kludge in +# case the GTK developers change versions on any of the directories in the +# future). # Version 0.8 (1/4/2010) # * Get module working under MacOSX fink by adding /sw/include, /sw/lib # to PATHS and the gobject library @@ -131,7 +142,8 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) endif() set(_relatives - # FIXME + # If these ever change, things will break. + ${GTK2_ADDITIONAL_SUFFIXES} glibmm-2.4 glib-2.0 atk-1.0 @@ -390,6 +402,10 @@ endif() # Find all components # +find_package(Freetype) +list(APPEND GTK2_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS}) +list(APPEND GTK2_LIBRARIES ${FREETYPE_LIBRARIES}) + foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) if(_GTK2_component STREQUAL "gtk") _GTK2_FIND_INCLUDE_DIR(GTK2_GLIB_INCLUDE_DIR glib.h) @@ -401,16 +417,21 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_INCLUDE_DIR gdk/gdk.h) _GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG_INCLUDE_DIR gdkconfig.h) - _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true) - _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true) - _GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h) - _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true) - _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true) + + if(UNIX) + _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true) + _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true) + else() + _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true) + _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true) + endif() _GTK2_FIND_INCLUDE_DIR(GTK2_CAIRO_INCLUDE_DIR cairo.h) _GTK2_FIND_LIBRARY (GTK2_CAIRO_LIBRARY cairo false false) + _GTK2_FIND_INCLUDE_DIR(GTK2_FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGO_INCLUDE_DIR pango/pango.h) _GTK2_FIND_LIBRARY (GTK2_PANGO_LIBRARY pango false true) @@ -439,6 +460,7 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true) _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMM_INCLUDE_DIR pangomm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h) _GTK2_FIND_LIBRARY (GTK2_PANGOMM_LIBRARY pangomm true true) _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++_INCLUDE_DIR sigc++/sigc++.h) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index c0cdcb1..d3d7fc2 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -74,8 +74,8 @@ IF(WIN32 AND NOT CYGWIN) ) if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) set( OPENSSL_LIBRARIES - optimized ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} - debug ${SSL_EAY_DEBUG} ${LIB_EAY_DEBUG} + optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG} + optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG} ) else() set( OPENSSL_LIBRARIES ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} ) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 37a55b3..c698480 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -68,89 +68,47 @@ # License text for the above reference.) INCLUDE(FindPackageMessage) - -# Checks a list of strings (typically function/macro parameters) whether it contains a keyword -# (_keyword) and return the value(s) following this keyword in _outputVar. -# If _multipleValues is true, this can be more than one value. -# Then end of the values for a keyword is then determined by checking whether the -# next argument is contained in _allKeywordsList. -FUNCTION(FPHSA_GET_OPTION_VALUE _keyword _outputVar _allArgsList _allKeywordsList _multipleValues) - UNSET(${_outputVar}) - UNSET(_removeIndices) - - SET(_insideValues FALSE) - SET(_counter 0) - FOREACH(_currentArg ${${_allArgsList}}) - IF(NOT _insideValues) # first check that we find the keyword we are currently interested in... - IF("${_currentArg}" STREQUAL "${_keyword}") - SET(_insideValues TRUE) - LIST(APPEND _removeIndices ${_counter}) - ENDIF("${_currentArg}" STREQUAL "${_keyword}") - ELSE(NOT _insideValues) - - LIST(FIND ${_allKeywordsList} "${_currentArg}" _index) # ... then this marks the end of the arguments belonging to this keyword - IF(${_index} EQUAL -1) - LIST(APPEND _result ${_currentArg}) - LIST(APPEND _removeIndices ${_counter}) # collect the indices of the strings we found to remove them from the list afterwards - IF(NOT _multipleValues) - BREAK() - ENDIF(NOT _multipleValues) - ELSE(${_index} EQUAL -1) - SET(_insideValues FALSE) - BREAK() - ENDIF(${_index} EQUAL -1) - ENDIF(NOT _insideValues) - - MATH(EXPR _counter "${_counter} + 1") - - ENDFOREACH(_currentArg ${${_allArgsList}}) - - IF(DEFINED _removeIndices) - LIST(REMOVE_AT ${_allArgsList} ${_removeIndices}) - ENDIF(DEFINED _removeIndices) - - SET(${_outputVar} ${_result} PARENT_SCOPE) - SET(${_allArgsList} ${${_allArgsList}} PARENT_SCOPE) - -ENDFUNCTION(FPHSA_GET_OPTION_VALUE _keyword _outputVar _allArgsList _allKeywordsList _multipleValues) +INCLUDE(CMakeParseArguments) FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1) - SET(_KEYWORDS_FOR_EXTENDED_MODE FAIL_MESSAGE REQUIRED_VARS VERSION_VAR ) +# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in +# new extended or in the "old" mode: + SET(options) # none + SET(oneValueArgs FAIL_MESSAGE VERSION_VAR) + SET(multiValueArgs REQUIRED_VARS) + SET(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) LIST(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) IF(${INDEX} EQUAL -1) - SET(_FAIL_MESSAGE ${_FIRST_ARG}) - SET(_REQUIRED_VARS ${_VAR1} ${ARGN}) - SET(_VERSION_VAR) + SET(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) + SET(FPHSA_REQUIRED_VARS ${_VAR1} ${ARGN}) + SET(FPHSA_VERSION_VAR) ELSE(${INDEX} EQUAL -1) - SET(ALL_ARGS ${_FIRST_ARG} ${_VAR1} ${ARGN}) - FPHSA_GET_OPTION_VALUE("FAIL_MESSAGE" _FAIL_MESSAGE ALL_ARGS _KEYWORDS_FOR_EXTENDED_MODE FALSE) - FPHSA_GET_OPTION_VALUE("REQUIRED_VARS" _REQUIRED_VARS ALL_ARGS _KEYWORDS_FOR_EXTENDED_MODE TRUE) - FPHSA_GET_OPTION_VALUE("VERSION_VAR" _VERSION_VAR ALL_ARGS _KEYWORDS_FOR_EXTENDED_MODE FALSE) + CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${_VAR1} ${ARGN}) - IF(ALL_ARGS) - MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${ALL_ARGS}\"") - ENDIF(ALL_ARGS) + IF(FPHSA_UNPARSED_ARGUMENTS) + MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") + ENDIF(FPHSA_UNPARSED_ARGUMENTS) - IF(NOT _FAIL_MESSAGE) - SET(_FAIL_MESSAGE "DEFAULT_MSG") - ENDIF(NOT _FAIL_MESSAGE) + IF(NOT FPHSA_FAIL_MESSAGE) + SET(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") + ENDIF(NOT FPHSA_FAIL_MESSAGE) ENDIF(${INDEX} EQUAL -1) # now that we collected all arguments, process them - IF("${_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") - SET(_FAIL_MESSAGE "Could NOT find ${_NAME}") - ENDIF("${_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + IF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + SET(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") + ENDIF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") - IF(NOT _REQUIRED_VARS) + IF(NOT FPHSA_REQUIRED_VARS) MESSAGE(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") - ENDIF(NOT _REQUIRED_VARS) + ENDIF(NOT FPHSA_REQUIRED_VARS) - LIST(GET _REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + LIST(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) STRING(TOUPPER ${_NAME} _NAME_UPPER) @@ -160,7 +118,7 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1) SET(DETAILS "") SET(${_NAME_UPPER}_FOUND TRUE) # check if all passed variables are valid - FOREACH(_CURRENT_VAR ${_REQUIRED_VARS}) + FOREACH(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) IF(NOT ${_CURRENT_VAR}) SET(${_NAME_UPPER}_FOUND FALSE) SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") @@ -177,7 +135,7 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1) # if the package was found, check for the version using <NAME>_FIND_VERSION IF (${_NAME_UPPER}_FOUND) - SET(VERSION ${${_VERSION_VAR}} ) + SET(VERSION ${${FPHSA_VERSION_VAR}} ) IF(VERSION) @@ -227,20 +185,20 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1) IF(NOT VERSION_OK) IF (${_NAME}_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + MESSAGE(FATAL_ERROR "${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") ELSE (${_NAME}_FIND_REQUIRED) IF (NOT ${_NAME}_FIND_QUIETLY) - MESSAGE(STATUS "${_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + MESSAGE(STATUS "${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") ENDIF (NOT ${_NAME}_FIND_QUIETLY) ENDIF (${_NAME}_FIND_REQUIRED) ELSE(NOT VERSION_OK) IF (${_NAME}_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + MESSAGE(FATAL_ERROR "${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") ELSE (${_NAME}_FIND_REQUIRED) IF (NOT ${_NAME}_FIND_QUIETLY) - MESSAGE(STATUS "${_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + MESSAGE(STATUS "${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") ENDIF (NOT ${_NAME}_FIND_QUIETLY) ENDIF (${_NAME}_FIND_REQUIRED) ENDIF(NOT VERSION_OK) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 423d5dd..d12f14a 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -105,11 +105,9 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON # PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python. # PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include # in your sources to initialize the static python modules - -GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS - GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) - FUNCTION(PYTHON_ADD_MODULE _NAME ) + GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS + GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS}) diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 17fbeab..9bad3b1 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -2,8 +2,8 @@ # The module defines the following variables: # Subversion_SVN_EXECUTABLE - path to svn command line client # Subversion_VERSION_SVN - version of svn command line client -# SUBVERSION_FOUND - true if the command line client was found -# Subversion_FOUND - same as SUBVERSION_FOUND, kept around for compatibility +# Subversion_FOUND - true if the command line client was found +# SUBVERSION_FOUND - same as Subversion_FOUND, set for compatiblity reasons # # The minimum required version of Subversion can be specified using the # standard syntax, e.g. FIND_PACKAGE(Subversion 1.4) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index ce29ca0..1ac6c2c 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -50,9 +50,14 @@ IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") STRING(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}") STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}") STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}") - STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_TWEAK "${ZLIB_H}") + SET(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}") - SET(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}.${ZLIB_VERSION_TWEAK}") + # only append a TWEAK version if it exists: + SET(ZLIB_VERSION_TWEAK "") + IF( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$") + SET(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}") + SET(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}") + ENDIF( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$") SET(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}") SET(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}") diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index cc0d5fb..90ef59b 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -47,9 +47,9 @@ # MACRO_NAMESPACE "FC_" # SYMBOL_NAMESPACE "FC_" # SYMBOLS mysub mymod:my_sub) -# This creates a "FC.h" header that defines the same FC_*() mangling -# macros as the previous example plus preprocessor symbols FC_mysub -# and FC_mymod_my_sub. +# This creates a "FCMangle.h" header that defines the same FC_*() +# mangling macros as the previous example plus preprocessor symbols +# FC_mysub and FC_mymod_my_sub. # # Another function is provided to verify that the Fortran and C/C++ # compilers work together: diff --git a/Modules/Platform/BlueGeneP-base.cmake b/Modules/Platform/BlueGeneP-base.cmake new file mode 100644 index 0000000..2ca920f --- /dev/null +++ b/Modules/Platform/BlueGeneP-base.cmake @@ -0,0 +1,118 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# +# BlueGeneP base platform file. +# +# NOTE: Do not set your platform to "BlueGeneP-base". This file is included +# by the real platform files. Use one of these two platforms instead: +# +# BlueGeneP-dynamic For dynamically linked builds +# BlueGeneP-static For statically linked builds +# +# This platform file tries its best to adhere to the behavior of the MPI +# compiler wrappers included with the latest BG/P drivers. +# + + +# +# For BGP builds, we're cross compiling, but we don't want to re-root things +# (e.g. with CMAKE_FIND_ROOT_PATH) because users may have libraries anywhere on +# the shared filesystems, and this may lie outside the root. Instead, we set the +# system directories so that the various system BGP CNK library locations are +# searched first. This is not the clearest thing in the world, given IBM's driver +# layout, but this should cover all the standard ones. +# +set(CMAKE_SYSTEM_LIBRARY_PATH + /bgsys/drivers/ppcfloor/comm/default/lib # default comm layer (used by mpi compiler wrappers) + /bgsys/drivers/ppcfloor/comm/sys/lib # DCMF, other lower-level comm libraries + /bgsys/drivers/ppcfloor/runtime/SPI # other low-level stuff + /bgsys/drivers/ppcfloor/gnu-linux/lib # CNK python installation directory + /bgsys/drivers/ppcfloor/gnu-linux/powerpc-bgp-linux/lib # CNK Linux image -- standard runtime libs, pthread, etc. +) + +# +# This adds directories that find commands should specifically ignore for cross compiles. +# Most of these directories are the includeand lib directories for the frontend on BG/P systems. +# Not ignoring these can cause things like FindX11 to find a frontend PPC version mistakenly. +# We use this on BG instead of re-rooting because backend libraries are typically strewn about +# the filesystem, and we can't re-root ALL backend libraries to a single place. +# +set(CMAKE_SYSTEM_IGNORE_PATH + /lib /lib64 /include + /usr/lib /usr/lib64 /usr/include + /usr/local/lib /usr/local/lib64 /usr/local/include + /usr/X11/lib /usr/X11/lib64 /usr/X11/include + /usr/lib/X11 /usr/lib64/X11 /usr/include/X11 + /usr/X11R6/lib /usr/X11R6/lib64 /usr/X11R6/include + /usr/X11R7/lib /usr/X11R7/lib64 /usr/X11R7/include +) + +# +# Indicate that this is a unix-like system +# +set(UNIX 1) + +# +# Library prefixes, suffixes, extra libs. +# +set(CMAKE_LINK_LIBRARY_SUFFIX "") +set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # lib +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") # .a + +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib +set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so +set(CMAKE_EXECUTABLE_SUFFIX "") # .exe +set(CMAKE_DL_LIBS "dl") + +# +# This macro needs to be called for dynamic library support. Unfortunately on BGP, +# We can't support both static and dynamic links in the same platform file. The +# dynamic link platform file needs to call this explicitly to set up dynamic linking. +# +macro(__BlueGeneP_set_dynamic_flags compiler_id lang) + if (${compiler_id} STREQUAL XL) + # Flags for XL compilers if we explicitly detected XL + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") # -pic + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") # -shared + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") # -rpath + set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") + else() + # Assume flags for GNU compilers (if the ID is GNU *or* anything else). + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") # -pic + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") # -shared + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") # -rpath + set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") + endif() + + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty + + set(BGP_${lang}_DEFAULT_EXE_FLAGS + "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + set(CMAKE_${lang}_LINK_EXECUTABLE + "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGP_${lang}_DYNAMIC_EXE_FLAGS} ${BGP_${lang}_DEFAULT_EXE_FLAGS}") +endmacro() + +# +# This macro needs to be called for static builds. Right now it just adds -Wl,-relax +# to the link line. +# +macro(__BlueGeneP_set_static_flags compiler_id lang) + set(BGP_${lang}_DEFAULT_EXE_FLAGS + "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") + set(CMAKE_${lang}_LINK_EXECUTABLE + "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGP_${lang}_DEFAULT_EXE_FLAGS}") +endmacro() diff --git a/Modules/Platform/BlueGeneP-dynamic-GNU-C.cmake b/Modules/Platform/BlueGeneP-dynamic-GNU-C.cmake new file mode 100644 index 0000000..bd4696b --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-GNU-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_dynamic_flags(GNU C) diff --git a/Modules/Platform/BlueGeneP-dynamic-GNU-CXX.cmake b/Modules/Platform/BlueGeneP-dynamic-GNU-CXX.cmake new file mode 100644 index 0000000..9c995dc --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-GNU-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_dynamic_flags(GNU CXX) diff --git a/Modules/Platform/BlueGeneP-dynamic-GNU-Fortran.cmake b/Modules/Platform/BlueGeneP-dynamic-GNU-Fortran.cmake new file mode 100644 index 0000000..19d6be8 --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-GNU-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_dynamic_flags(GNU Fortran) diff --git a/Modules/Platform/BlueGeneP-dynamic-XL-C.cmake b/Modules/Platform/BlueGeneP-dynamic-XL-C.cmake new file mode 100644 index 0000000..2dbbbc0 --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-XL-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_dynamic_flags(XL C) diff --git a/Modules/Platform/BlueGeneP-dynamic-XL-CXX.cmake b/Modules/Platform/BlueGeneP-dynamic-XL-CXX.cmake new file mode 100644 index 0000000..2bc5127 --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-XL-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_dynamic_flags(XL CXX) diff --git a/Modules/Platform/BlueGeneP-dynamic-XL-Fortran.cmake b/Modules/Platform/BlueGeneP-dynamic-XL-Fortran.cmake new file mode 100644 index 0000000..59da63d --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-XL-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_dynamic_flags(XL Fortran) diff --git a/Modules/Platform/BlueGeneP-dynamic.cmake b/Modules/Platform/BlueGeneP-dynamic.cmake new file mode 100644 index 0000000..8f96f2f --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic.cmake @@ -0,0 +1,19 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(Platform/BlueGeneP-base) +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) +set(CMAKE_FIND_LIBRARY_PREFIXES "lib") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") diff --git a/Modules/Platform/BlueGeneP-static-GNU-C.cmake b/Modules/Platform/BlueGeneP-static-GNU-C.cmake new file mode 100644 index 0000000..412a7a3 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-GNU-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_static_flags(GNU C) diff --git a/Modules/Platform/BlueGeneP-static-GNU-CXX.cmake b/Modules/Platform/BlueGeneP-static-GNU-CXX.cmake new file mode 100644 index 0000000..418f0d8 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-GNU-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_static_flags(GNU CXX) diff --git a/Modules/Platform/BlueGeneP-static-GNU-Fortran.cmake b/Modules/Platform/BlueGeneP-static-GNU-Fortran.cmake new file mode 100644 index 0000000..119195b --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-GNU-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_static_flags(GNU Fortran) diff --git a/Modules/Platform/BlueGeneP-static-XL-C.cmake b/Modules/Platform/BlueGeneP-static-XL-C.cmake new file mode 100644 index 0000000..1f20959 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-XL-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_static_flags(XL C) diff --git a/Modules/Platform/BlueGeneP-static-XL-CXX.cmake b/Modules/Platform/BlueGeneP-static-XL-CXX.cmake new file mode 100644 index 0000000..f027a53 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-XL-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_static_flags(XL CXX) diff --git a/Modules/Platform/BlueGeneP-static-XL-Fortran.cmake b/Modules/Platform/BlueGeneP-static-XL-Fortran.cmake new file mode 100644 index 0000000..778d4bd --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-XL-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +__BlueGeneP_set_static_flags(XL Fortran) diff --git a/Modules/Platform/BlueGeneP-static.cmake b/Modules/Platform/BlueGeneP-static.cmake new file mode 100644 index 0000000..c4f5f21 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static.cmake @@ -0,0 +1,19 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin <tgamblin@llnl.gov> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(Platform/BlueGeneP-base) +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) +set(CMAKE_FIND_LIBRARY_PREFIXES "lib") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") diff --git a/Modules/Platform/Windows-icl.cmake b/Modules/Platform/Windows-icl.cmake index c717c7c..9088cc7 100644 --- a/Modules/Platform/Windows-icl.cmake +++ b/Modules/Platform/Windows-icl.cmake @@ -6,6 +6,10 @@ IF(CMAKE_VERBOSE_MAKEFILE) ELSE(CMAKE_VERBOSE_MAKEFILE) SET(CMAKE_CL_NOLOGO "/nologo") ENDIF(CMAKE_VERBOSE_MAKEFILE) + +SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1) +SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) + # create a shared C++ library SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "xilink ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 5981603..8799330 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -164,8 +164,7 @@ int cmCPackArchiveGenerator::InitializeInternal() return this->Superclass::InitializeInternal(); } -int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector<std::string>& files) +int cmCPackArchiveGenerator::PackageFiles() { int res = ARCHIVE_OK; #define CHECK_ARCHIVE_ERROR(res, msg) \ @@ -178,14 +177,15 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, << "\n"); \ } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " - << (toplevel ? toplevel : "(NULL)") << std::endl); + << toplevel << std::endl); + // create a new archive struct archive* a = archive_write_new(); // Set the compress and archive types for the archive SetArchiveType(a, this->Compress, this->Archive); // Open binary stream cmGeneratedFileStream* gf = new cmGeneratedFileStream; - gf->Open(outFileName, false, true); + gf->Open(packageFileNames[0].c_str(), false, true); StreamData data(gf, this); // pass callbacks to archive_write_open to handle stream res = archive_write_open(a, @@ -202,13 +202,13 @@ int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, CHECK_ARCHIVE_ERROR(res, "archive_read_disk_set_standard_lookup:"); std::vector<std::string>::const_iterator fileIt; std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(toplevel); + cmSystemTools::ChangeDirectory(toplevel.c_str()); for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) { // create a new entry for each file struct archive_entry *entry = archive_entry_new(); // Get the relative path to the file - std::string rp = cmSystemTools::RelativePath(toplevel, fileIt->c_str()); + std::string rp = cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str()); // Set the name of the entry to the file name archive_entry_set_pathname(entry, rp.c_str()); res = archive_read_disk_entry_from_file(disk, entry, -1, 0); diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 486db8e..d3409ae 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -37,8 +37,7 @@ public: protected: virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); virtual const char* GetOutputExtension() = 0; CompressType Compress; ArchiveType Archive; diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 247a043..06a0509 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -53,10 +53,8 @@ const char* cmCPackBundleGenerator::GetPackagingInstallPrefix() } //---------------------------------------------------------------------- -int cmCPackBundleGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector<std::string>& files) +int cmCPackBundleGenerator::PackageFiles() { - (void) files; // Get required arguments ... const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME") @@ -167,5 +165,5 @@ int cmCPackBundleGenerator::CompressFiles(const char* outFileName, cmSystemTools::SetPermissions(command_target.str().c_str(), 0777); } - return this->CreateDMG(toplevel, outFileName); + return this->CreateDMG(); } diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index ce05541..82814b0 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -31,8 +31,7 @@ public: protected: virtual int InitializeInternal(); virtual const char* GetPackagingInstallPrefix(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index 853a1be..6c8fc54 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -41,8 +41,7 @@ int cmCPackCygwinBinaryGenerator::InitializeInternal() } //---------------------------------------------------------------------- -int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector<std::string>& files) +int cmCPackCygwinBinaryGenerator::PackageFiles() { std::string packageName = this->GetOption("CPACK_PACKAGE_NAME"); packageName += "-"; @@ -70,12 +69,10 @@ int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName, ofs << manifest << "\n"; } // add the manifest file to the list of all files - std::vector<std::string> filesWithManifest = files; - filesWithManifest.push_back(manifestFile); + files.push_back(manifestFile); // create the bzip2 tar file - return this->Superclass::CompressFiles(outFileName, toplevel, - filesWithManifest); + return this->Superclass::PackageFiles(); } const char* cmCPackCygwinBinaryGenerator::GetOutputExtension() diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.h b/Source/CPack/cmCPackCygwinBinaryGenerator.h index 19b09f0..38f6df1 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.h +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.h @@ -30,8 +30,7 @@ public: virtual ~cmCPackCygwinBinaryGenerator(); protected: virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); virtual const char* GetOutputExtension(); std::string OutputExtension; }; diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index cca8338..f4ae35f 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -48,21 +48,19 @@ int cmCPackCygwinSourceGenerator::InitializeInternal() } //---------------------------------------------------------------------- -int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector<std::string>& files) +int cmCPackCygwinSourceGenerator::PackageFiles() { // Create a tar file of the sources std::string packageDirFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); packageDirFileName += ".tar.bz2"; + packageFileNames[0] = packageDirFileName; std::string output; // skip one parent up to the cmCPackTarBZip2Generator // to create tar.bz2 file with the list of source // files this->Compress = BZIP2; - if ( !this->cmCPackTarBZip2Generator:: - CompressFiles(packageDirFileName.c_str(), - toplevel, files) ) + if ( !this->cmCPackTarBZip2Generator::PackageFiles() ) { return 0; } @@ -135,21 +133,25 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName, patchFile += "/"; patchFile += cmSystemTools::GetFilenameName( this->GetOption("CPACK_CYGWIN_PATCH_FILE")); - std::vector<std::string> outerFiles; + std::string file = cmSystemTools::GetFilenameName(compressOutFile); std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile); sourceTar += "/"; sourceTar += file; + /* reset list of file to be packaged */ + files.clear(); // a source release in cygwin should have the build script used // to build the package, the patch file that is different from the // regular upstream version of the sources, and a bziped tar file // of the original sources - outerFiles.push_back(buildScript); - outerFiles.push_back(patchFile); - outerFiles.push_back(sourceTar); - if ( !this->cmCPackTarBZip2Generator:: - CompressFiles(outerTarFile.c_str(), - tmpDir.c_str(), outerFiles) ) + files.push_back(buildScript); + files.push_back(patchFile); + files.push_back(sourceTar); + /* update the name of the produced package */ + packageFileNames[0] = outerTarFile; + /* update the toplevel dir */ + toplevel = tmpDir; + if ( !this->cmCPackTarBZip2Generator::PackageFiles() ) { return 0; } diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.h b/Source/CPack/cmCPackCygwinSourceGenerator.h index 9817cf9..9d98a9b 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.h +++ b/Source/CPack/cmCPackCygwinSourceGenerator.h @@ -31,8 +31,7 @@ public: protected: const char* GetPackagingInstallPrefix(); virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); virtual const char* GetOutputExtension(); std::string InstallPrefix; std::string OutputExtension; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index a8fed1d..58c6dc3 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -48,9 +48,7 @@ int cmCPackDebGenerator::InitializeInternal() } //---------------------------------------------------------------------- -int cmCPackDebGenerator::CompressFiles(const char* outFileName, - const char* toplevel, - const std::vector<std::string>& files) +int cmCPackDebGenerator::PackageFiles() { this->ReadListFile("CPackDeb.cmake"); const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND"); @@ -141,7 +139,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, // 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 = strlen(toplevel); + size_t topLevelLength = toplevel.length(); std::set<std::string> installDirs; for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) @@ -160,7 +158,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, std::string output; int retVal = -1; int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel, this->GeneratorVerbose, 0); + &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); if ( !res || retVal ) { @@ -196,7 +194,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, //std::string output; //int retVal = -1; res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel, this->GeneratorVerbose, 0); + &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); // debian md5sums entries are like this: // 014f3604694729f3bf19263bac599765 usr/bin/ccmake // thus strip the full path (with the trailing slash) @@ -237,7 +235,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, } } res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel, this->GeneratorVerbose, 0); + &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); if ( !res || retVal ) { @@ -263,7 +261,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, arFiles.push_back(topLevelString + "debian-binary"); arFiles.push_back(topLevelString + "control.tar.gz"); arFiles.push_back(topLevelString + "data.tar.gz"); - res = ar_append(outFileName, arFiles); + res = ar_append(packageFileNames[0].c_str(), arFiles); if ( res!=0 ) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index d229944..4a357d1 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -33,8 +33,7 @@ public: protected: virtual int InitializeInternal(); - virtual int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + virtual int PackageFiles(); virtual const char* GetOutputExtension() { return ".deb"; } }; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 95324cf..e9ce76c 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -104,12 +104,10 @@ const char* cmCPackDragNDropGenerator::GetOutputExtension() } //---------------------------------------------------------------------- -int cmCPackDragNDropGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector<std::string>& files) +int cmCPackDragNDropGenerator::PackageFiles() { - (void) files; - return this->CreateDMG(toplevel, outFileName); + return this->CreateDMG(); } //---------------------------------------------------------------------- @@ -161,8 +159,7 @@ bool cmCPackDragNDropGenerator::RunCommand(cmOStringStream& command, } //---------------------------------------------------------------------- -int cmCPackDragNDropGenerator::CreateDMG(const std::string& toplevel, - const std::string& outFileName) +int cmCPackDragNDropGenerator::CreateDMG() { // Get optional arguments ... const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") @@ -475,7 +472,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& toplevel, final_image_command << cpack_dmg_format; final_image_command << " -imagekey"; final_image_command << " zlib-level=9"; - final_image_command << " -o \"" << outFileName << "\""; + final_image_command << " -o \"" << packageFileNames[0] << "\""; if(!this->RunCommand(final_image_command)) { diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index 43a9617..dcef7fb 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -29,14 +29,12 @@ public: protected: virtual int InitializeInternal(); virtual const char* GetOutputExtension(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); bool CopyFile(cmOStringStream& source, cmOStringStream& target); bool RunCommand(cmOStringStream& command, std::string* output = 0); - virtual int CreateDMG(const std::string& installdir, - const std::string& outdmg); + int CreateDMG(); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 4a4b428..4ae2d1f 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -100,6 +100,7 @@ int cmCPackGenerator::PrepareNames() } std::string destFile = pdir; + this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PREFIX", destFile.c_str()); destFile += "/" + outName; std::string outFile = topDirectory + "/" + outName; this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str()); @@ -330,13 +331,13 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl); cmsys::Glob gl; - std::string toplevel = it->c_str(); + std::string top = it->c_str(); it ++; std::string subdir = it->c_str(); - std::string findExpr = toplevel; + std::string findExpr = top; findExpr += "/*"; cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "- Install directory: " << toplevel << std::endl); + "- Install directory: " << top << std::endl); gl.RecurseOn(); if ( !gl.FindFiles(findExpr) ) { @@ -344,7 +345,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( "Cannot find any files in the installed directory" << std::endl); return 0; } - std::vector<std::string>& files = gl.GetFiles(); + files = gl.GetFiles(); std::vector<std::string>::iterator gfit; std::vector<cmsys::RegularExpression>::iterator regIt; for ( gfit = files.begin(); gfit != files.end(); ++ gfit ) @@ -368,7 +369,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } std::string filePath = tempDir; filePath += "/" + subdir + "/" - + cmSystemTools::RelativePath(toplevel.c_str(), gfit->c_str()); + + cmSystemTools::RelativePath(top.c_str(), gfit->c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile.c_str() << " -> " << filePath.c_str() << std::endl); if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(), @@ -843,7 +844,7 @@ int cmCPackGenerator::DoPackage() } // The files to be installed - std::vector<std::string> files = gl.GetFiles(); + files = gl.GetFiles(); // For component installations, determine which files go into which // components. @@ -866,34 +867,59 @@ int cmCPackGenerator::DoPackage() } } - if ( !this->CompressFiles(tempPackageFileName, - tempDirectory, files) || cmSystemTools::GetErrorOccuredFlag()) + + packageFileNames.clear(); + /* Put at least one file name into the list of + * wanted packageFileNames. The specific generator + * may update this during PackageFiles. + * (either putting several names or updating the provided one) + */ + packageFileNames.push_back(tempPackageFileName); + toplevel = tempDirectory; + if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory" << std::endl); return 0; } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Finalize package" << std::endl); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copy final package: " - << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) - << " to " - << (packageFileName ? packageFileName : "(NULL)") - << std::endl); - if ( !cmSystemTools::CopyFileIfDifferent(tempPackageFileName, - packageFileName) ) + /* + * Copy the generated packages to final destination + * - there may be several of them + * - the initially provided name may have changed + * (because the specific generator did 'normalize' it) + */ + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) [" + <<packageFileNames.size() + <<"]:"<<std::endl); + std::vector<std::string>::iterator it; + /* now copy package one by one */ + for (it=packageFileNames.begin();it!=packageFileNames.end();++it) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the package: " - << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) - << " to " - << (packageFileName ? packageFileName : "(NULL)") - << std::endl); - return 0; + std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); + tempPackageFileName = it->c_str(); + tmpPF += "/"+cmSystemTools::GetFilenameName(*it); + packageFileName = tmpPF.c_str(); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): " + << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) + << " to " + << (packageFileName ? packageFileName : "(NULL)") + << std::endl); + if ( !cmSystemTools::CopyFileIfDifferent(tempPackageFileName, + packageFileName) ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the package: " + << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) + << " to " + << (packageFileName ? packageFileName : "(NULL)") + << std::endl); + return 0; + } + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: " + << packageFileName + << " generated." << std::endl); } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Package " - << (packageFileName ? packageFileName : "(NULL)") - << " generated." << std::endl); return 1; } @@ -984,12 +1010,8 @@ int cmCPackGenerator::SetCMakeRoot() } //---------------------------------------------------------------------- -int cmCPackGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector<std::string>& files) +int cmCPackGenerator::PackageFiles() { - (void)outFileName; - (void)toplevel; - (void)files; return 0; } diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 45188fe..74b780d 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -55,13 +55,22 @@ class cmCPackGenerator : public cmObject public: cmTypeMacro(cmCPackGenerator, cmObject); /** - * If verbose then more informaiton is printed out + * If verbose then more information is printed out */ void SetVerbose(bool val) { this->GeneratorVerbose = val; } /** - * Do the actual processing. Subclass has to override it. - * Return 0 if error. + * Do the actual whole package processing. + * Subclass may redefine it but its usually enough + * to redefine @ref PackageFiles, because in fact + * this method do call: + * - PrepareName + * - clean-up temp dirs + * - InstallProject (with the appropriate method) + * - prepare list of files and/or components to be package + * - PackageFiles + * - Copy produced packages at the expected place + * @return 0 if error. */ virtual int DoPackage(); @@ -94,13 +103,32 @@ public: bool ReadListFile(const char* moduleName); protected: + /** + * Prepare common used names by inspecting + * several CPACK_xxx var values. + */ int PrepareNames(); + + /** + * Install the project using appropriate method. + */ int InstallProject(); + int CleanTemporaryDirectory(); + virtual const char* GetOutputExtension() { return ".cpack"; } virtual const char* GetOutputPostfix() { return 0; } - virtual int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + + /** + * Package the list of files and/or components which + * has been prepared by the beginning of DoPackage. + * @pre @ref toplevel has been filled-in + * @pre the list of file @ref files has been populated + * @pre packageFileNames contains at least 1 entry + * @post packageFileNames may have been updated and contains + * the list of packages generated by the specific generator. + */ + virtual int PackageFiles(); virtual const char* GetInstallPath(); virtual const char* GetPackagingInstallPrefix(); @@ -134,11 +162,42 @@ protected: std::string InstallPath; + /** + * The list of package file names. + * At beginning of DoPackage the (generic) generator will populate + * the list of desired package file names then it will + * call the redefined method PackageFiles which is may + * either use this set of names (usually on entry there should be + * only a single name) or update the vector with the list + * of created package file names. + */ + std::vector<std::string> packageFileNames; + + /** + * The directory where all the files to be packaged reside. + * If the installer support components there will be one + * sub-directory for each component. In those directories + * one will find the file belonging to the specified component. + */ + std::string toplevel; + + /** + * The complete list of files to be packaged. + * This list will be populated by DoPackage before + * PackageFiles is called. + */ + std::vector<std::string> files; + std::string CPackSelf; std::string CMakeSelf; std::string CMakeRoot; std::map<std::string, cmCPackInstallationType> InstallationTypes; + /** + * The set of components. + * If component installation is supported then this map + * contains the component specified in CPACK_COMPONENTS_ALL + */ std::map<std::string, cmCPackComponent> Components; std::map<std::string, cmCPackComponentGroup> ComponentGroups; diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 8329546..f6f9fbc 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -43,11 +43,10 @@ cmCPackNSISGenerator::~cmCPackNSISGenerator() } //---------------------------------------------------------------------- -int cmCPackNSISGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector<std::string>& files) +int cmCPackNSISGenerator::PackageFiles() { - (void)outFileName; // TODO: Fix nsis to force out file name - (void)toplevel; + // TODO: Fix nsis to force out file name + std::string nsisInFileName = this->FindTemplate("NSIS.template.in"); if ( nsisInFileName.size() == 0 ) { @@ -74,7 +73,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, std::vector<std::string>::const_iterator it; for ( it = files.begin(); it != files.end(); ++ it ) { - std::string fileN = cmSystemTools::RelativePath(toplevel, + std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(), it->c_str()); if (!this->Components.empty()) { @@ -88,13 +87,13 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, << str.str().c_str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); std::vector<std::string> dirs; - this->GetListOfSubdirectories(toplevel, dirs); + this->GetListOfSubdirectories(toplevel.c_str(), dirs); std::vector<std::string>::const_iterator sit; cmOStringStream dstr; for ( sit = dirs.begin(); sit != dirs.end(); ++ sit ) { std::string componentName; - std::string fileN = cmSystemTools::RelativePath(toplevel, sit->c_str()); + std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(), sit->c_str()); if ( fileN.empty() ) { continue; diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index dff5b8f..6ad103f 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -37,8 +37,7 @@ protected: virtual int InitializeInternal(); void CreateMenuLinks( cmOStringStream& str, cmOStringStream& deleteStr); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); virtual const char* GetOutputExtension() { return ".exe"; } virtual const char* GetOutputPostfix() { return "win32"; } diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index a3b5759..2d4bb97 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -33,12 +33,10 @@ cmCPackOSXX11Generator::~cmCPackOSXX11Generator() } //---------------------------------------------------------------------- -int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, - const char* toplevel, - const std::vector<std::string>& files) +int cmCPackOSXX11Generator::PackageFiles() { - (void) files; // TODO: Fix api to not need files. - (void) toplevel; // TODO: Use toplevel + // TODO: Use toplevel ? + // It is used! Is this an obsolete comment? const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES"); @@ -144,7 +142,7 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -format UDZO -srcfolder \"" << diskImageDirectory.c_str() - << "\" \"" << outFileName << "\""; + << "\" \"" << packageFileNames[0] << "\""; int retVal = 1; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: " diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index 7fd60b4..b7bd243 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -33,8 +33,7 @@ public: protected: virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); virtual const char* GetPackagingInstallPrefix(); virtual const char* GetOutputExtension() { return ".dmg"; } diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 9333131..ef81da8 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -59,12 +59,10 @@ int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir, } //---------------------------------------------------------------------- -int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, - const char* toplevel, - const std::vector<std::string>& files) +int cmCPackPackageMakerGenerator::PackageFiles() { - (void) files; // TODO: Fix api to not need files. - (void) toplevel; // TODO: Use toplevel + // TODO: Use toplevel + // It is used! Is this an obsolete comment? std::string resDir; // Where this package's resources will go. std::string packageDirFileName @@ -318,7 +316,7 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, cmOStringStream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName - << "\" \"" << outFileName << "\""; + << "\" \"" << packageFileNames[0] << "\""; std::string output; int retVal = 1; int numTries = 4; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 36cd594..2bab947 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -42,8 +42,7 @@ protected: const char* script, const char* name); virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); virtual const char* GetOutputExtension() { return ".dmg"; } virtual const char* GetOutputPostfix() { return "darwin"; } diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index fb85581..01b6b06 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -31,9 +31,7 @@ int cmCPackRPMGenerator::InitializeInternal() } //---------------------------------------------------------------------- -int cmCPackRPMGenerator::CompressFiles(const char* /*outFileName*/, - const char* /*toplevel*/, - const std::vector<std::string>& /*files*/) +int cmCPackRPMGenerator::PackageFiles() { this->ReadListFile("CPackRPM.cmake"); if (!this->IsSet("RPMBUILD_EXECUTABLE")) diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index c607f35..570e45f 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -37,8 +37,7 @@ public: protected: virtual int InitializeInternal(); - virtual int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + virtual int PackageFiles(); virtual const char* GetOutputExtension() { return ".rpm"; } }; diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index a687e0d..184c557 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -52,14 +52,13 @@ int cmCPackSTGZGenerator::InitializeInternal() } //---------------------------------------------------------------------- -int cmCPackSTGZGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector<std::string>& files) +int cmCPackSTGZGenerator::PackageFiles() { - if ( !this->Superclass::CompressFiles(outFileName, toplevel, files) ) + if ( !this->Superclass::PackageFiles() ) { return 0; } - return cmSystemTools::SetPermissions(outFileName, + return cmSystemTools::SetPermissions(packageFileNames[0].c_str(), #if defined( _MSC_VER ) || defined( __MINGW32__ ) S_IREAD | S_IWRITE | S_IEXEC #elif defined( __BORLANDC__ ) diff --git a/Source/CPack/cmCPackSTGZGenerator.h b/Source/CPack/cmCPackSTGZGenerator.h index fc51e4d..ccceec8 100644 --- a/Source/CPack/cmCPackSTGZGenerator.h +++ b/Source/CPack/cmCPackSTGZGenerator.h @@ -32,8 +32,7 @@ public: virtual ~cmCPackSTGZGenerator(); protected: - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector<std::string>& files); + int PackageFiles(); virtual int InitializeInternal(); int GenerateHeader(std::ostream* os); virtual const char* GetOutputExtension() { return ".sh"; } diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 0d15ddc..13a25cb 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -201,8 +201,7 @@ void cmCTestMemCheckHandler::Initialize() this->CustomMaximumPassedTestOutputSize = 0; this->CustomMaximumFailedTestOutputSize = 0; this->MemoryTester = ""; - this->MemoryTesterOptionsParsed.clear(); - this->MemoryTesterOptions = ""; + this->MemoryTesterOptions.clear(); this->MemoryTesterStyle = UNKNOWN; this->MemoryTesterOutputFile = ""; int cc; @@ -249,12 +248,12 @@ void cmCTestMemCheckHandler::GenerateTestCommand( std::vector<cmStdString>::size_type pp; std::string memcheckcommand = ""; memcheckcommand = this->MemoryTester; - for ( pp = 0; pp < this->MemoryTesterOptionsParsed.size(); pp ++ ) + for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ ) { - args.push_back(this->MemoryTesterOptionsParsed[pp]); - memcheckcommand += " "; - memcheckcommand += cmSystemTools::EscapeSpaces( - this->MemoryTesterOptionsParsed[pp].c_str()); + args.push_back(this->MemoryTesterOptions[pp]); + memcheckcommand += " \""; + memcheckcommand += this->MemoryTesterOptions[pp]; + memcheckcommand += "\""; } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: " << memcheckcommand << std::endl); @@ -440,18 +439,21 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() } // Setup the options + std::string memoryTesterOptions; if ( this->CTest->GetCTestConfiguration( "MemoryCheckCommandOptions").size() ) { - this->MemoryTesterOptions = this->CTest->GetCTestConfiguration( + memoryTesterOptions = this->CTest->GetCTestConfiguration( "MemoryCheckCommandOptions"); } else if ( this->CTest->GetCTestConfiguration( "ValgrindCommandOptions").size() ) { - this->MemoryTesterOptions = this->CTest->GetCTestConfiguration( + memoryTesterOptions = this->CTest->GetCTestConfiguration( "ValgrindCommandOptions"); } + this->MemoryTesterOptions + = cmSystemTools::ParseArguments(memoryTesterOptions.c_str()); this->MemoryTesterOutputFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; @@ -459,10 +461,14 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() if ( this->MemoryTester.find("valgrind") != std::string::npos ) { this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; - if ( !this->MemoryTesterOptions.size() ) + if ( this->MemoryTesterOptions.empty() ) { - this->MemoryTesterOptions = "-q --tool=memcheck --leak-check=yes " - "--show-reachable=yes --workaround-gcc296-bugs=yes --num-callers=50"; + this->MemoryTesterOptions.push_back("-q"); + this->MemoryTesterOptions.push_back("--tool=memcheck"); + this->MemoryTesterOptions.push_back("--leak-check=yes"); + this->MemoryTesterOptions.push_back("--show-reachable=yes"); + this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes"); + this->MemoryTesterOptions.push_back("--num-callers=50"); } if ( this->CTest->GetCTestConfiguration( "MemoryCheckSuppressionFile").size() ) @@ -476,17 +482,15 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() "MemoryCheckSuppressionFile").c_str() << std::endl); return false; } - this->MemoryTesterOptions += " --suppressions=" + - cmSystemTools::EscapeSpaces(this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str()) + ""; + std::string suppressions = "--suppressions=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + this->MemoryTesterOptions.push_back(suppressions); } } else if ( this->MemoryTester.find("purify") != std::string::npos ) { this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; - std::string outputFile = - cmSystemTools::EscapeSpaces(this->MemoryTesterOutputFile.c_str()); - + std::string outputFile; #ifdef _WIN32 if( this->CTest->GetCTestConfiguration( "MemoryCheckSuppressionFile").size() ) @@ -500,31 +504,29 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() "MemoryCheckSuppressionFile").c_str() << std::endl); return false; } - this->MemoryTesterOptions += " /FilterFiles=" + - cmSystemTools::EscapeSpaces(this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str()); + std::string filterFiles = "/FilterFiles=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + this->MemoryTesterOptions.push_back(filterFiles); } - this->MemoryTesterOptions += " /SAVETEXTDATA=" + outputFile; + outputFile = "/SAVETEXTDATA="; #else - this->MemoryTesterOptions += " -log-file=" + outputFile; + outputFile = "-log-file="; #endif + outputFile += this->MemoryTesterOutputFile; + this->MemoryTesterOptions.push_back(outputFile); } else if ( this->MemoryTester.find("BC") != std::string::npos ) { this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile; - std::string outputFile = - cmSystemTools::EscapeSpaces(this->MemoryTesterOutputFile.c_str()); std::string dpbdFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.DPbd"; - std::string errorFile = this->CTest->GetBinaryDir() - + "/Testing/Temporary/MemoryChecker.error"; - errorFile = cmSystemTools::EscapeSpaces(errorFile.c_str()); this->BoundsCheckerDPBDFile = dpbdFile; - dpbdFile = cmSystemTools::EscapeSpaces(dpbdFile.c_str()); this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; - this->MemoryTesterOptions += " /B " + dpbdFile; - this->MemoryTesterOptions += " /X " + outputFile; - this->MemoryTesterOptions += " /M "; + this->MemoryTesterOptions.push_back("/B"); + this->MemoryTesterOptions.push_back(dpbdFile); + this->MemoryTesterOptions.push_back("/X"); + this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile); + this->MemoryTesterOptions.push_back("/M"); } else { @@ -534,8 +536,6 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() return false; } - this->MemoryTesterOptionsParsed - = cmSystemTools::ParseArguments(this->MemoryTesterOptions.c_str()); std::vector<cmStdString>::size_type cc; for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) { diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index db426f0..427d471 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -89,8 +89,7 @@ private: std::string BoundsCheckerDPBDFile; std::string BoundsCheckerXMLFile; std::string MemoryTester; - std::vector<cmStdString> MemoryTesterOptionsParsed; - std::string MemoryTesterOptions; + std::vector<cmStdString> MemoryTesterOptions; int MemoryTesterStyle; std::string MemoryTesterOutputFile; int MemoryTesterGlobalResults[NO_MEMORY_FAULT]; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index ce44097..6570d0e 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -471,7 +471,7 @@ void cmCTestRunTest::ComputeArguments() this->TestProperties->Args[1].c_str()); ++j; //skip the executable (it will be actualCommand) } - this->TestCommand + std::string testCommand = cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str()); //Prepends memcheck args to our command string @@ -479,22 +479,24 @@ void cmCTestRunTest::ComputeArguments() for(std::vector<std::string>::iterator i = this->Arguments.begin(); i != this->Arguments.end(); ++i) { - this->TestCommand += " "; - this->TestCommand += cmSystemTools::EscapeSpaces(i->c_str()); + testCommand += " \""; + testCommand += *i; + testCommand += "\""; } for(;j != this->TestProperties->Args.end(); ++j) { - this->TestCommand += " "; - this->TestCommand += cmSystemTools::EscapeSpaces(j->c_str()); + testCommand += " \""; + testCommand += *j; + testCommand += "\""; this->Arguments.push_back(*j); } - this->TestResult.FullCommandLine = this->TestCommand; + this->TestResult.FullCommandLine = testCommand; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl << this->Index << ": " << (this->TestHandler->MemCheck?"MemCheck":"Test") - << " command: " << this->TestCommand + << " command: " << testCommand << std::endl); } diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index e0cb888..66e6b7b 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -89,7 +89,6 @@ private: cmCTestTestHandler::cmCTestTestResult TestResult; int Index; std::string StartTime; - std::string TestCommand; std::string ActualCommand; std::vector<std::string> Arguments; bool StopTimePassed; diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 88874aa..d9e4742 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -47,7 +47,7 @@ struct cmArchiveWrite::Callback }; //---------------------------------------------------------------------------- -cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c): +cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): Stream(os), Archive(archive_write_new()), Disk(archive_read_disk_new()), @@ -63,6 +63,14 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c): return; } break; + case CompressCompress: + if(archive_write_set_compression_compress(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_compress: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; case CompressGZip: if(archive_write_set_compression_gzip(this->Archive) != ARCHIVE_OK) { @@ -79,11 +87,55 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c): return; } break; + case CompressLZMA: + if(archive_write_set_compression_lzma(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_lzma: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case CompressXZ: + if(archive_write_set_compression_xz(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_xz: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; }; - archive_read_disk_set_standard_lookup(this->Disk); - if(archive_write_set_format_pax_restricted(this->Archive) != ARCHIVE_OK) +#if !defined(_WIN32) || defined(__CYGWIN__) + if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK) + { + this->Error = "archive_read_disk_set_standard_lookup: "; + this->Error += archive_error_string(this->Archive); + return;; + } +#endif + switch (t) + { + case TypeZIP: + if(archive_write_set_format_zip(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_format_zip: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case TypeTAR: + if(archive_write_set_format_pax_restricted(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_format_pax_restricted: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + } + + // do not pad the last block!! + if (archive_write_set_bytes_in_last_block(this->Archive, 1)) { - this->Error = "archive_write_set_format_pax_restricted: "; + this->Error = "archive_write_set_bytes_in_last_block: "; this->Error += archive_error_string(this->Archive); return; } @@ -216,24 +268,24 @@ bool cmArchiveWrite::AddData(const char* file, size_t size) size_t nleft = size; while(nleft > 0) { - cmsys_ios::streamsize nnext = static_cast<cmsys_ios::streamsize>( - nleft > sizeof(buffer)? sizeof(buffer) : nleft); - fin.read(buffer, nnext); + typedef cmsys_ios::streamsize ssize_type; + size_t const nnext = nleft > sizeof(buffer)? sizeof(buffer) : nleft; + ssize_type const nnext_s = static_cast<ssize_type>(nnext); + fin.read(buffer, nnext_s); // Some stream libraries (older HPUX) return failure at end of // file on the last read even if some data were read. Check // gcount instead of trusting the stream error status. - if(fin.gcount() != nnext) + if(static_cast<size_t>(fin.gcount()) != nnext) { break; } - if(archive_write_data(this->Archive, buffer, - static_cast<size_t>(nnext)) != nnext) + if(archive_write_data(this->Archive, buffer, nnext) != nnext_s) { this->Error = "archive_write_data: "; this->Error += archive_error_string(this->Archive); return false; } - nleft -= static_cast<size_t>(nnext); + nleft -= nnext; } if(nleft > 0) { diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index 92c0c73..3e3b2f0 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -31,12 +31,22 @@ public: enum Compress { CompressNone, + CompressCompress, CompressGZip, - CompressBZip2 + CompressBZip2, + CompressLZMA, + CompressXZ + }; + + /** Archive Type */ + enum Type + { + TypeTAR, + TypeZIP }; /** Construct with output stream to which to write archive. */ - cmArchiveWrite(std::ostream& os, Compress c = CompressNone); + cmArchiveWrite(std::ostream& os, Compress c = CompressNone, Type = TypeTAR); ~cmArchiveWrite(); /** diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 3a777d5..d12fde0 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -410,10 +410,14 @@ std::string cmCTest::GetCDashVersion() //First query the server. If that fails, fall back to the local setting std::string response; std::string url = "http://"; - url += this->GetCTestConfiguration("DropSite") + "/CDash/api/getversion.php"; - + url += this->GetCTestConfiguration("DropSite"); + + std::string cdashUri = this->GetCTestConfiguration("DropLocation"); + cdashUri = cdashUri.substr(0, cdashUri.find("/submit.php")); + + url += cdashUri + "/api/getversion.php"; int res = cmCTest::HTTPRequest(url, cmCTest::HTTP_GET, response, "", "", 3); - + return res ? this->GetCTestConfiguration("CDashVersion") : response; #else return this->GetCTestConfiguration("CDashVersion"); diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 2ed959f..9617355 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -587,7 +587,39 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "directories for the current system. It is NOT intended " "to be modified by the project, use CMAKE_PREFIX_PATH for this. See also " "CMAKE_SYSTEM_INCLUDE_PATH, CMAKE_SYSTEM_LIBRARY_PATH, " - "CMAKE_SYSTEM_PROGRAM_PATH.", false, + "CMAKE_SYSTEM_PROGRAM_PATH, and CMAKE_SYSTEM_IGNORE_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_SYSTEM_IGNORE_PATH", cmProperty::VARIABLE, + "Path to be ignored by FIND_XXX() commands.", + "Specifies directories to be ignored by searches in FIND_XXX() commands " + "This is useful in cross-compiled environments where some system " + "directories contain incompatible but possibly linkable libraries. For " + "example, on cross-compiled cluster environments, this allows a user to " + "ignore directories containing libraries meant for the front-end " + "machine that modules like FindX11 (and others) would normally search. " + "By default this contains a list of directories containing incompatible " + "binaries for the host system. " + "See also CMAKE_SYSTEM_PREFIX_PATH, CMAKE_SYSTEM_LIBRARY_PATH, " + "CMAKE_SYSTEM_INCLUDE_PATH, and CMAKE_SYSTEM_PROGRAM_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_IGNORE_PATH", cmProperty::VARIABLE, + "Path to be ignored by FIND_XXX() commands.", + "Specifies directories to be ignored by searches in FIND_XXX() commands " + "This is useful in cross-compiled environments where some system " + "directories contain incompatible but possibly linkable libraries. For " + "example, on cross-compiled cluster environments, this allows a user to " + "ignore directories containing libraries meant for the front-end " + "machine that modules like FindX11 (and others) would normally search. " + "By default this is empty; it is intended to be set by the project. " + "Note that CMAKE_IGNORE_PATH takes a list of directory names, NOT a " + "list of prefixes. If you want to ignore paths under prefixes (bin, " + "include, lib, etc.), you'll need to specify them explicitly. " + "See also CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_INCLUDE_PATH, " + "CMAKE_PROGRAM_PATH.", false, "Variables That Change Behavior"); cm->DefineProperty diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index a54ad7a..e1188d5 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -269,6 +269,11 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) } this->ExpandPaths(); + // Filter out ignored paths from the prefix list + std::set<std::string> ignored; + this->GetIgnoredPaths(ignored); + this->FilterPaths(this->SearchPaths, ignored); + // Handle search root stuff. this->RerootPaths(this->SearchPaths); diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index f352172..b7d3e52 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -241,6 +241,63 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) } //---------------------------------------------------------------------------- +void cmFindCommon::FilterPaths(std::vector<std::string>& paths, + const std::set<std::string>& ignore) +{ + // Now filter out anything that's in the ignore set. + std::vector<std::string> unfiltered; + unfiltered.swap(paths); + + for(std::vector<std::string>::iterator pi = unfiltered.begin(); + pi != unfiltered.end(); ++pi) + { + if (ignore.count(*pi) == 0) + { + paths.push_back(*pi); + } + } +} + + +//---------------------------------------------------------------------------- +void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore) +{ + // null-terminated list of paths. + static const char *paths[] = + { "CMAKE_SYSTEM_IGNORE_PATH", "CMAKE_IGNORE_PATH", 0 }; + + // Construct the list of path roots with no trailing slashes. + for(const char **pathName = paths; *pathName; ++pathName) + { + // Get the list of paths to ignore from the variable. + const char* ignorePath = this->Makefile->GetDefinition(*pathName); + if((ignorePath == 0) || (strlen(ignorePath) == 0)) + { + continue; + } + + cmSystemTools::ExpandListArgument(ignorePath, ignore); + } + + for(std::vector<std::string>::iterator i = ignore.begin(); + i != ignore.end(); ++i) + { + cmSystemTools::ConvertToUnixSlashes(*i); + } +} + + +//---------------------------------------------------------------------------- +void cmFindCommon::GetIgnoredPaths(std::set<std::string>& ignore) +{ + std::vector<std::string> ignoreVec; + GetIgnoredPaths(ignoreVec); + ignore.insert(ignoreVec.begin(), ignoreVec.end()); +} + + + +//---------------------------------------------------------------------------- bool cmFindCommon::CheckCommonArgument(std::string const& arg) { if(arg == "NO_DEFAULT_PATH") diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 2ffbd00..a4866ba 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -39,6 +39,14 @@ protected: /** Place a set of search paths under the search roots. */ void RerootPaths(std::vector<std::string>& paths); + /** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_path variables. */ + void GetIgnoredPaths(std::vector<std::string>& ignore); + void GetIgnoredPaths(std::set<std::string>& ignore); + + /** Remove paths in the ignore set from the supplied vector. */ + void FilterPaths(std::vector<std::string>& paths, + const std::set<std::string>& ignore); + /** Add trailing slashes to all search paths. */ void AddTrailingSlashes(std::vector<std::string>& paths); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index bd58f56..eb86014 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -596,6 +596,15 @@ bool cmFindPackageCommand } } + // get igonored paths from vars and reroot them. + std::vector<std::string> ignored; + this->GetIgnoredPaths(ignored); + this->RerootPaths(ignored); + + // Construct a set of ignored paths + this->IgnoredPaths.clear(); + this->IgnoredPaths.insert(ignored.begin(), ignored.end()); + // Find and load the package. bool result = this->HandlePackageMode(); this->AppendSuccessInformation(); @@ -1431,6 +1440,11 @@ bool cmFindPackageCommand::CheckDirectory(std::string const& dir) bool cmFindPackageCommand::FindConfigFile(std::string const& dir, std::string& file) { + if (this->IgnoredPaths.count(dir)) + { + return false; + } + for(std::vector<std::string>::const_iterator ci = this->Configs.begin(); ci != this->Configs.end(); ++ci) { diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 63f4111..53ea4fc 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -136,6 +136,7 @@ private: bool PolicyScope; std::vector<std::string> Names; std::vector<std::string> Configs; + std::set<std::string> IgnoredPaths; }; #endif diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 07c92e5..bac0223 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2810,17 +2810,29 @@ cmLocalGenerator std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) { std::string result; - bool forceOn = cmSystemTools::GetForceUnixPaths(); - if(forceOn && this->WindowsShell) +#if defined(_WIN32) && !defined(__CYGWIN__) + // if there are spaces + std::string temp = str; + if (temp.find(" ") != std::string::npos && + temp.find("\"")==std::string::npos) { - cmSystemTools::SetForceUnixPaths(false); + result = "\""; + result += str; + result += "\""; + return result; } - result = cmSystemTools::EscapeSpaces(str); - if(forceOn && this->WindowsShell) + return str; +#else + for(const char* ch = str; *ch != '\0'; ++ch) { - cmSystemTools::SetForceUnixPaths(true); + if(*ch == ' ') + { + result += '\\'; + } + result += *ch; } return result; +#endif } //---------------------------------------------------------------------------- diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a26452c..271a662 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -191,49 +191,6 @@ std::string cmSystemTools::EscapeQuotes(const char* str) return result; } -std::string cmSystemTools::EscapeSpaces(const char* str) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - bool useDoubleQ = true; -#else - bool useDoubleQ = false; -#endif - if(cmSystemTools::s_ForceUnixPaths) - { - useDoubleQ = false; - } - - if(useDoubleQ) - { - std::string result; - - // if there are spaces - std::string temp = str; - if (temp.find(" ") != std::string::npos && - temp.find("\"")==std::string::npos) - { - result = "\""; - result += str; - result += "\""; - return result; - } - return str; - } - else - { - std::string result = ""; - for(const char* ch = str; *ch != '\0'; ++ch) - { - if(*ch == ' ') - { - result += '\\'; - } - result += *ch; - } - return result; - } -} - void cmSystemTools::Error(const char* m1, const char* m2, const char* m3, const char* m4) { @@ -1732,7 +1689,8 @@ bool cmSystemTools::CreateTar(const char* outFileName, } cmArchiveWrite a(fout, (gzip? cmArchiveWrite::CompressGZip : (bzip2? cmArchiveWrite::CompressBZip2 : - cmArchiveWrite::CompressNone))); + cmArchiveWrite::CompressNone)), + cmArchiveWrite::TypeTAR); a.SetVerbose(verbose); for(std::vector<cmStdString>::const_iterator i = files.begin(); i != files.end(); ++i) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index da5da31..6a9d849 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -46,12 +46,6 @@ public: static void ExpandRegistryValues(std::string& source, KeyWOW64 view = KeyWOW64_Default); - /** - * Platform independent escape spaces, unix uses backslash, - * windows double quotes the string. - */ - static std::string EscapeSpaces(const char* str); - ///! Escape quotes in a string. static std::string EscapeQuotes(const char* str); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 3153235..bcdb193 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -3059,39 +3059,45 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot static int GetCasePathName(const kwsys_stl::string & pathIn, kwsys_stl::string & casePath) { - kwsys_stl::string::size_type iFound = pathIn.rfind('/'); - if (iFound > 1 && iFound != pathIn.npos) + kwsys_stl::vector<kwsys::String> path_components = + SystemTools::SplitString(pathIn.c_str(), '/', true); + if(path_components.empty()) { - // recurse to peel off components - // - if (GetCasePathName(pathIn.substr(0, iFound), casePath) > 0) - { - casePath += '/'; - if (pathIn[1] != '/') - { - WIN32_FIND_DATA findData; - - // append the long component name to the path - // - HANDLE hFind = ::FindFirstFile(pathIn.c_str(), &findData); - if (INVALID_HANDLE_VALUE != hFind) - { - casePath += findData.cFileName; - ::FindClose(hFind); - } - else - { - // if FindFirstFile fails, return the error code - // - casePath = ""; - return 0; - } - } - } + casePath = ""; + return 0; } - else + kwsys_stl::vector<kwsys_stl::string>::size_type idx = 0; + // assume always absolute path, so just take first + casePath = path_components[idx++]; + // If network path, fill casePath with server/share so FindFirstFile + // will work after that. Maybe someday call other APIs to get + // actual case of servers and shares. + if(path_components.size() > 2 && pathIn.size() >= 2 && + pathIn[0] == '/' && pathIn[1] == '/') { - casePath = pathIn; + casePath += path_components[idx++]; + casePath += "/"; + casePath += path_components[idx++]; + } + + for(; idx < path_components.size(); idx++) + { + casePath += "/"; + kwsys_stl::string test_str = casePath; + test_str += path_components[idx]; + + WIN32_FIND_DATA findData; + HANDLE hFind = ::FindFirstFile(test_str.c_str(), &findData); + if (INVALID_HANDLE_VALUE != hFind) + { + casePath += findData.cFileName; + ::FindClose(hFind); + } + else + { + casePath = ""; + return 0; + } } return (int)casePath.size(); } @@ -3104,28 +3110,29 @@ kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p) #ifndef _WIN32 return p; #else + kwsys_stl::string casePath = p; + // make sure drive letter is always upper case + if(casePath.size() > 1 && casePath[1] == ':') + { + casePath[0] = toupper(casePath[0]); + } + // Check to see if actual case has already been called // for this path, and the result is stored in the LongPathMap - SystemToolsTranslationMap::iterator i = - SystemTools::LongPathMap->find(p); + SystemToolsTranslationMap::iterator i = + SystemTools::LongPathMap->find(casePath); if(i != SystemTools::LongPathMap->end()) { return i->second; } - kwsys_stl::string casePath; int len = GetCasePathName(p, casePath); if(len == 0 || len > MAX_PATH+1) { return p; } - // make sure drive letter is always upper case - if(casePath.size() > 1 && casePath[1] == ':') - { - casePath[0] = toupper(casePath[0]); - } (*SystemTools::LongPathMap)[p] = casePath; return casePath; -#endif +#endif } //---------------------------------------------------------------------------- @@ -3143,9 +3150,9 @@ const char* SystemTools::SplitPathRootComponent(const char* p, } c += 2; } - else if(c[0] == '/') + else if(c[0] == '/' || c[0] == '\\') { - // Unix path. + // Unix path (or Windows path w/out drive letter). if(root) { *root = "/"; diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index f654dfa..6acbd29 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2010) SET(KWSYS_DATE_STAMP_MONTH 08) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 15) +SET(KWSYS_DATE_STAMP_DAY 24) diff --git a/Tests/CMakeTests/ModuleNoticesTest.cmake.in b/Tests/CMakeTests/ModuleNoticesTest.cmake.in index 9ad6cfb..8ecebd3 100644 --- a/Tests/CMakeTests/ModuleNoticesTest.cmake.in +++ b/Tests/CMakeTests/ModuleNoticesTest.cmake.in @@ -3,7 +3,7 @@ # match any additional copyright holder notices. set(notice_regex " #============================================================================= -# Copyright (20[0-9][0-9]-)?20[0-9][0-9] Kitware[^\n]+( +# Copyright (20[0-9][0-9]-)?20[0-9][0-9] [^\n]+( # Copyright (20[0-9][0-9]-)?20[0-9][0-9] [^\n]+)* # # Distributed under the OSI-approved BSD License \\(the \"License\"\\); diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 74cc115..a472bea 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -54,6 +54,10 @@ SET(CMAKE_FIND_APPBUNDLE FIRST) # Set the wrong answer for a find to make sure it re-finds. set(VersionedA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-4.0) +# Test that CMAKE_IGNORE_PATH can ignore the purposely bad package +# files in the lib/cmake/zot-3.1 directory. +set(CMAKE_IGNORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-3.1) + # Look for packages with new-style signatures. FIND_PACKAGE(foo NO_MODULE) FIND_PACKAGE(Foo CONFIGS FooConfig.cmake) diff --git a/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake new file mode 100644 index 0000000..bee2f0e --- /dev/null +++ b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake @@ -0,0 +1,4 @@ +# Claim to be any version to test that CMAKE_IGNORE_PATH hides us. +SET(PACKAGE_VERSION 3.1) +SET(PACKAGE_VERSION_COMPATIBLE 1) +SET(PACKAGE_VERSION_EXACT 1) diff --git a/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake new file mode 100644 index 0000000..2fbd525 --- /dev/null +++ b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake @@ -0,0 +1,2 @@ +# Test config file. +message(WARNING "CMAKE_IGNORE_PATH failed to ignore this file!") |