diff options
77 files changed, 1433 insertions, 540 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/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 d936190..1a1b168 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -63,7 +63,7 @@ # Currently this module searches for the following version numbers: # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, -# 1.40, 1.40.0, 1.41, 1.41.0 +# 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories @@ -297,6 +297,7 @@ else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} + "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") @@ -555,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/FindCUDA.cmake b/Modules/FindCUDA.cmake index 81d082a..d9b9d54 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -497,29 +497,6 @@ endif() # Always set this convenience variable set(CUDA_VERSION_STRING "${CUDA_VERSION}") -# Here we need to determine if the version we found is acceptable. We will -# assume that is unless CUDA_FIND_VERSION_EXACT or CUDA_FIND_VERSION is -# specified. The presence of either of these options checks the version -# string and signals if the version is acceptable or not. -set(_cuda_version_acceptable TRUE) -# -if(CUDA_FIND_VERSION_EXACT AND NOT CUDA_VERSION VERSION_EQUAL CUDA_FIND_VERSION) - set(_cuda_version_acceptable FALSE) -endif() -# -if(CUDA_FIND_VERSION AND CUDA_VERSION VERSION_LESS CUDA_FIND_VERSION) - set(_cuda_version_acceptable FALSE) -endif() -# -if(NOT _cuda_version_acceptable) - set(_cuda_error_message "Requested CUDA version ${CUDA_FIND_VERSION}, but found unacceptable version ${CUDA_VERSION}") - if(CUDA_FIND_REQUIRED) - message("${_cuda_error_message}") - elseif(NOT CUDA_FIND_QUIETLY) - message("${_cuda_error_message}") - endif() -endif() - # CUDA_TOOLKIT_INCLUDE find_path(CUDA_TOOLKIT_INCLUDE device_functions.h # Header included in toolkit @@ -687,12 +664,14 @@ set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CUDA DEFAULT_MSG - CUDA_TOOLKIT_ROOT_DIR - CUDA_NVCC_EXECUTABLE - CUDA_INCLUDE_DIRS - CUDA_CUDART_LIBRARY - _cuda_version_acceptable +find_package_handle_standard_args(CUDA + REQUIRED_VARS + CUDA_TOOLKIT_ROOT_DIR + CUDA_NVCC_EXECUTABLE + CUDA_INCLUDE_DIRS + CUDA_CUDART_LIBRARY + VERSION_VAR + CUDA_VERSION ) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index f0f4a7b..55b5639 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -6,6 +6,10 @@ # FLEX_VERSION - the version of flex # FLEX_LIBRARIES - The flex libraries # +# The minimum required version of flex can be specified using the +# standard syntax, e.g. FIND_PACKAGE(FLEX 2.5.13) +# +# # If flex is found on the system, the module provides the macro: # FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>]) # which creates a custom command to generate the <FlexOutput> file from @@ -136,6 +140,7 @@ IF(FLEX_EXECUTABLE) ENDIF(FLEX_EXECUTABLE) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLEX DEFAULT_MSG FLEX_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLEX REQUIRED_VARS FLEX_EXECUTABLE + VERSION_VAR FLEX_VERSION) # FindFLEX.cmake ends here 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/FindJava.cmake b/Modules/FindJava.cmake index eeb4778..1599433 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -13,6 +13,9 @@ # Java_VERSION_TWEAK = The tweak version of the package found (after '_') # Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) # +# The minimum required version of Java can be specified using the +# standard CMake syntax, e.g. FIND_PACKAGE(Java 1.5) +# # NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to be # identical. For example some java version may return: # Java_VERSION_STRING = 1.5.0_17 @@ -83,7 +86,6 @@ FIND_PROGRAM(Java_JAVA_EXECUTABLE ) IF(Java_JAVA_EXECUTABLE) - set(_java_version_acceptable TRUE) EXECUTE_PROCESS(COMMAND ${Java_JAVA_EXECUTABLE} -version RESULT_VARIABLE res OUTPUT_VARIABLE var @@ -114,7 +116,6 @@ IF(Java_JAVA_EXECUTABLE) ELSE() IF(NOT Java_FIND_QUIETLY) message(WARNING "regex not supported: ${var}. Please report") - set(_java_version_acceptable FALSE) ENDIF(NOT Java_FIND_QUIETLY) ENDIF() STRING( REGEX REPLACE "([0-9]+).*" "\\1" Java_VERSION_MAJOR "${Java_VERSION_STRING}" ) @@ -134,17 +135,6 @@ IF(Java_JAVA_EXECUTABLE) ENDIF(NOT Java_FIND_QUIETLY) ENDIF() - # check version if requested: - if( Java_FIND_VERSION ) - if("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}") - set(_java_version_acceptable FALSE) - endif("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}") - if( Java_FIND_VERSION_EXACT ) - if("${Java_VERSION}" VERSION_GREATER "${Java_FIND_VERSION}") - set(_java_version_acceptable FALSE) - endif("${Java_VERSION}" VERSION_GREATER "${Java_FIND_VERSION}") - endif( Java_FIND_VERSION_EXACT ) - endif( Java_FIND_VERSION ) ENDIF(Java_JAVA_EXECUTABLE) @@ -165,17 +155,15 @@ if(Java_FIND_COMPONENTS) foreach(component ${Java_FIND_COMPONENTS}) # User just want to execute some Java byte-compiled if(component STREQUAL "Runtime") - find_package_handle_standard_args(Java DEFAULT_MSG - Java_JAVA_EXECUTABLE - _java_version_acceptable - ) + find_package_handle_standard_args(Java + REQUIRED_VARS Java_JAVA_EXECUTABLE + VERSION_VAR Java_VERSION + ) elseif(component STREQUAL "Development") - find_package_handle_standard_args(Java DEFAULT_MSG - Java_JAVA_EXECUTABLE - Java_JAR_EXECUTABLE - Java_JAVAC_EXECUTABLE - _java_version_acceptable - ) + find_package_handle_standard_args(Java + REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE + VERSION_VAR Java_VERSION + ) else() message(FATAL_ERROR "Comp: ${component} is not handled") endif() @@ -183,12 +171,10 @@ if(Java_FIND_COMPONENTS) endforeach(component) else() # Check for everything - find_package_handle_standard_args(Java DEFAULT_MSG - Java_JAVA_EXECUTABLE - Java_JAR_EXECUTABLE - Java_JAVAC_EXECUTABLE - _java_version_acceptable - ) + find_package_handle_standard_args(Java + REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE + VERSION_VAR Java_VERSION + ) endif() diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 1f6b7d0..37a55b3 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -214,7 +214,7 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1) ENDIF (${_NAME}_FIND_VERSION) IF(VERSION_OK) - SET(DETAILS "${DETAILS}[v${${VERSION}}]") + SET(DETAILS "${DETAILS}[v${VERSION}]") ELSE(VERSION_OK) SET(${_NAME_UPPER}_FOUND FALSE) ENDIF(VERSION_OK) diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake index eb4a904..d9b0e2b 100644 --- a/Modules/FindPerlLibs.cmake +++ b/Modules/FindPerlLibs.cmake @@ -8,6 +8,9 @@ # PERL_LIBRARY = path to libperl # PERL_EXECUTABLE = full path to the perl binary # +# The minimum required version of Perl can be specified using the +# standard syntax, e.g. FIND_PACKAGE(PerlLibs 6.0) +# # The following variables are also available if needed # (introduced after CMake 2.6.4) # @@ -227,8 +230,9 @@ endif (PERL_EXECUTABLE) # handle the QUIETLY and REQUIRED arguments and set PERLLIBS_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PerlLibs DEFAULT_MSG PERL_LIBRARY PERL_INCLUDE_PATH) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PerlLibs REQUIRED_VARS PERL_LIBRARY PERL_INCLUDE_PATH + VERSION_VAR PERL_VERSION) # Introduced after CMake 2.6.4 to bring module into compliance set(PERL_INCLUDE_DIR ${PERL_INCLUDE_PATH}) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 2d1a125..2e78d85 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -1,7 +1,10 @@ # - Find Ruby # This module finds if Ruby is installed and determines where the include files -# and libraries are. Ruby 1.8 and 1.9 are supported. The minimum required version -# specified in the find_package() command is honored. +# and libraries are. Ruby 1.8 and 1.9 are supported. +# +# The minimum required version of Ruby can be specified using the +# standard syntax, e.g. FIND_PACKAGE(Ruby 1.8) +# # It also determines what the name of the library is. This # code sets the following variables: # @@ -154,22 +157,6 @@ SET(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}") SET(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}") SET(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}") -# Now we know which version we found -IF(Ruby_FIND_VERSION) - IF(${RUBY_VERSION} VERSION_LESS ${Ruby_FIND_VERSION}) - # force running ruby the next time again - SET(RUBY_VERSION_MAJOR "" CACHE PATH "The Ruby major version" FORCE) - IF(Ruby_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Ruby version ${Ruby_FIND_VERSION} required, but only version ${RUBY_VERSION} found.") - ELSE(Ruby_FIND_REQUIRED) - IF(NOT Ruby_FIND_QUIETLY) - MESSAGE(STATUS "Ruby version ${Ruby_FIND_VERSION} required, but only version ${RUBY_VERSION} found.") - ENDIF(NOT Ruby_FIND_QUIETLY) - RETURN() - ENDIF(Ruby_FIND_REQUIRED) - ENDIF(${RUBY_VERSION} VERSION_LESS ${Ruby_FIND_VERSION}) -ENDIF(Ruby_FIND_VERSION) - FIND_PATH(RUBY_INCLUDE_DIR NAMES ruby.h HINTS @@ -240,7 +227,8 @@ IF(_RUBY_DEBUG_OUTPUT) MESSAGE(STATUS "--------------------") ENDIF(_RUBY_DEBUG_OUTPUT) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby DEFAULT_MSG ${_RUBY_REQUIRED_VARS}) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_RUBY_REQUIRED_VARS} + VERSION_VAR RUBY_VERSION ) MARK_AS_ADVANCED( RUBY_EXECUTABLE diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index b8c3b28..68a913d 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -5,6 +5,9 @@ # SWIG_EXECUTABLE - the path to the swig executable # SWIG_VERSION - the version number of the swig executable # +# The minimum required version of SWIG can be specified using the +# standard syntax, e.g. FIND_PACKAGE(SWIG 1.1) +# # All information is collected from the SWIG_EXECUTABLE so the # version to be found can be changed from the command line by # means of setting SWIG_EXECUTABLE @@ -23,8 +26,6 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -SET(SWIG_FOUND FALSE) - FIND_PROGRAM(SWIG_EXECUTABLE swig) IF(SWIG_EXECUTABLE) @@ -45,7 +46,6 @@ IF(SWIG_EXECUTABLE) SET(SWIG_DIR SWIG_DIR-NOTFOUND) FIND_PATH(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output}) IF(SWIG_DIR) - SET(SWIG_FOUND 1) SET(SWIG_USE_FILE ${CMAKE_ROOT}/Modules/UseSWIG.cmake) EXECUTE_PROCESS(COMMAND ${SWIG_EXECUTABLE} -version OUTPUT_VARIABLE SWIG_version_output @@ -62,12 +62,6 @@ IF(SWIG_EXECUTABLE) ENDIF(SWIG_swiglib_result) ENDIF(SWIG_EXECUTABLE) -IF(NOT SWIG_FOUND) - IF(NOT SWIG_FIND_QUIETLY) - IF(SWIG_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "SWIG was not found. Please specify Swig executable location") - ELSE(SWIG_FIND_REQUIRED) - MESSAGE(STATUS "SWIG was not found. Please specify Swig executable location") - ENDIF(SWIG_FIND_REQUIRED) - ENDIF(NOT SWIG_FIND_QUIETLY) -ENDIF(NOT SWIG_FOUND) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR + VERSION_VAR SWIG_VERSION ) diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake index a9ddf27..b0b6b2f 100644 --- a/Modules/FindSquish.cmake +++ b/Modules/FindSquish.cmake @@ -4,9 +4,6 @@ # # ---- Variables and Macros # SQUISH_FOUND If false, don't try to use Squish -# SQUISH_VERSION_MAJOR The major version of Squish found -# SQUISH_VERSION_MINOR The minor version of Squish found -# SQUISH_VERSION_PATCH The patch version of Squish found # # SQUISH_INSTALL_DIR The Squish installation directory (containing bin, lib, etc) # SQUISH_SERVER_EXECUTABLE The squishserver executable diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 91c2ba1..17fbeab 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -2,7 +2,12 @@ # 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 - true if the command line client was found +# Subversion_FOUND - same as SUBVERSION_FOUND, kept around for compatibility +# +# The minimum required version of Subversion can be specified using the +# standard syntax, e.g. FIND_PACKAGE(Subversion 1.4) +# # If the command line client executable is found the macro # Subversion_WC_INFO(<dir> <var-prefix>) # is defined to extract information of a subversion working copy at @@ -17,12 +22,12 @@ # <var-prefix>_WC_INFO - output of command `svn info <dir>' # Example usage: # FIND_PACKAGE(Subversion) -# IF(Subversion_FOUND) +# IF(SUBVERSION_FOUND) # Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project) # MESSAGE("Current revision is ${Project_WC_REVISION}") # Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project) # MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}") -# ENDIF(Subversion_FOUND) +# ENDIF(SUBVERSION_FOUND) #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -38,16 +43,18 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -SET(Subversion_FOUND FALSE) -SET(Subversion_SVN_FOUND FALSE) - FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn DOC "subversion command line client") MARK_AS_ADVANCED(Subversion_SVN_EXECUTABLE) IF(Subversion_SVN_EXECUTABLE) - SET(Subversion_SVN_FOUND TRUE) - SET(Subversion_FOUND TRUE) + + EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version + OUTPUT_VARIABLE Subversion_VERSION_SVN + OUTPUT_STRIP_TRAILING_WHITESPACE) + + STRING(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" + "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") MACRO(Subversion_WC_INFO dir prefix) # the subversion commands should be executed with the C locale, otherwise @@ -55,11 +62,6 @@ IF(Subversion_SVN_EXECUTABLE) SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") SET(ENV{LC_ALL} C) - EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version - WORKING_DIRECTORY ${dir} - OUTPUT_VARIABLE Subversion_VERSION_SVN - OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir} OUTPUT_VARIABLE ${prefix}_WC_INFO ERROR_VARIABLE Subversion_svn_info_error @@ -70,8 +72,6 @@ IF(Subversion_SVN_EXECUTABLE) MESSAGE(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}") ELSE(NOT ${Subversion_svn_info_result} EQUAL 0) - STRING(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" - "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") STRING(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" "\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}") STRING(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*" @@ -110,4 +110,9 @@ IF(Subversion_SVN_EXECUTABLE) ENDIF(Subversion_SVN_EXECUTABLE) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion DEFAULT_MSG Subversion_SVN_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion REQUIRED_VARS Subversion_SVN_EXECUTABLE + VERSION_VAR Subversion_VERSION_SVN ) + +# for compatibility +SET(Subversion_FOUND ${SUBVERSION_FOUND}) +SET(Subversion_SVN_FOUND ${SUBVERSION_FOUND}) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index eb02ba8..ce29ca0 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -62,21 +62,8 @@ ENDIF() # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_INCLUDE_DIR ZLIB_LIBRARY) - -# handle the VERSION provided in find_package() command -if(ZLIB_FIND_VERSION) - if(ZLIB_FIND_VERSION_EXACT AND NOT ${ZLIB_VERSION_STRING} VERSION_EQUAL ${ZLIB_FIND_VERSION}) - message(FATAL_ERROR "ZLIB version found (${ZLIB_VERSION_STRING}) does not match the required one (${ZLIB_FIND_VERSION}), aborting.") - elseif(${ZLIB_VERSION_STRING} VERSION_LESS ${ZLIB_FIND_VERSION}) - if(ZLIB_FIND_REQUIRED) - message(FATAL_ERROR "ZLIB version found (${ZLIB_VERSION_STRING}) is less then the minimum required (${ZLIB_FIND_VERSION}), aborting.") - else(ZLIB_FIND_REQUIRED) - message("ZLIB version found (${ZLIB_VERSION_STRING}) is less then the minimum required (${ZLIB_FIND_VERSION}), continue without ZLIB support.") - set(ZLIB_FOUND FALSE) - endif(ZLIB_FIND_REQUIRED) - endif() -endif(ZLIB_FIND_VERSION) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_INCLUDE_DIR ZLIB_LIBRARY + VERSION_VAR ZLIB_VERSION_STRING) IF(ZLIB_FOUND) SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) 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-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index b7d4431..79b2f80 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -49,6 +49,13 @@ set(CMAKE_CREATE_WIN32_EXE "-mwindows") set(CMAKE_GNULD_IMAGE_VERSION "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>") +# Check if GNU ld is too old to support @FILE syntax. +set(__WINDOWS_GNU_LD_RESPONSE 1) +execute_process(COMMAND ld -v OUTPUT_VARIABLE _help ERROR_VARIABLE _help) +if("${_help}" MATCHES "GNU ld .* 2\\.1[1-6]") + set(__WINDOWS_GNU_LD_RESPONSE 0) +endif() + macro(__windows_compiler_gnu lang) if(MSYS OR MINGW) @@ -68,7 +75,7 @@ macro(__windows_compiler_gnu lang) endif() set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on Windows - set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1) + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Wl,@") # Binary link rules. 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/CMakeLists.txt b/Source/CMakeLists.txt index b098da1..71284b2 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -112,6 +112,7 @@ ENDIF(CMAKE_USE_ELF_PARSER) # SET(SRCS cmStandardIncludes.cxx + cmArchiveWrite.cxx cmBootstrapCommands.cxx cmCacheManager.cxx cmCacheManager.h diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index a52d05e..8799330 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -22,9 +22,7 @@ #include <errno.h> #include <cmsys/SystemTools.hxx> -#include <cmlibarchive/libarchive/archive.h> -#include <cmlibarchive/libarchive/archive_entry.h> - +#include <cm_libarchive.h> //---------------------------------------------------------------------- cmCPackArchiveGenerator::cmCPackArchiveGenerator(CompressType t, @@ -166,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) \ @@ -180,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, @@ -204,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/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx new file mode 100644 index 0000000..88874aa --- /dev/null +++ b/Source/cmArchiveWrite.cxx @@ -0,0 +1,247 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2010 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cmArchiveWrite.h" + +#include "cmSystemTools.h" +#include <cmsys/ios/iostream> +#include <cmsys/Directory.hxx> +#include <cm_libarchive.h> + +//---------------------------------------------------------------------------- +class cmArchiveWrite::Entry +{ + struct archive_entry* Object; +public: + Entry(): Object(archive_entry_new()) {} + ~Entry() { archive_entry_free(this->Object); } + operator struct archive_entry*() { return this->Object; } +}; + +//---------------------------------------------------------------------------- +struct cmArchiveWrite::Callback +{ + // archive_write_callback + static __LA_SSIZE_T Write(struct archive*, void *cd, + const void *b, size_t n) + { + cmArchiveWrite* self = static_cast<cmArchiveWrite*>(cd); + if(self->Stream.write(static_cast<const char*>(b), + static_cast<cmsys_ios::streamsize>(n))) + { + return static_cast<__LA_SSIZE_T>(n); + } + else + { + return static_cast<__LA_SSIZE_T>(-1); + } + } +}; + +//---------------------------------------------------------------------------- +cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c): + Stream(os), + Archive(archive_write_new()), + Disk(archive_read_disk_new()), + Verbose(false) +{ + switch (c) + { + case CompressNone: + if(archive_write_set_compression_none(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_none: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case CompressGZip: + if(archive_write_set_compression_gzip(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_gzip: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case CompressBZip2: + if(archive_write_set_compression_bzip2(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_bzip2: "; + 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) + { + this->Error = "archive_write_set_format_pax_restricted: "; + this->Error += archive_error_string(this->Archive); + return; + } + + if(archive_write_open( + this->Archive, this, 0, + reinterpret_cast<archive_write_callback*>(&Callback::Write), + 0) != ARCHIVE_OK) + { + this->Error = "archive_write_open: "; + this->Error += archive_error_string(this->Archive); + return; + } +} + +//---------------------------------------------------------------------------- +cmArchiveWrite::~cmArchiveWrite() +{ + archive_read_finish(this->Disk); + archive_write_finish(this->Archive); +} + +//---------------------------------------------------------------------------- +bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix) +{ + if(this->Okay()) + { + if(!path.empty() && path[path.size()-1] == '/') + { + path.erase(path.size()-1); + } + this->AddPath(path.c_str(), skip, prefix); + } + return this->Okay(); +} + +//---------------------------------------------------------------------------- +bool cmArchiveWrite::AddPath(const char* path, + size_t skip, const char* prefix) +{ + if(!this->AddFile(path, skip, prefix)) + { + return false; + } + if(!cmSystemTools::FileIsDirectory(path)) + { + return true; + } + cmsys::Directory d; + if(d.Load(path)) + { + std::string next = path; + next += "/"; + std::string::size_type end = next.size(); + unsigned long n = d.GetNumberOfFiles(); + for(unsigned long i = 0; i < n; ++i) + { + const char* file = d.GetFile(i); + if(strcmp(file, ".") != 0 && strcmp(file, "..") != 0) + { + next.erase(end); + next += file; + if(!this->AddPath(next.c_str(), skip, prefix)) + { + return false; + } + } + } + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmArchiveWrite::AddFile(const char* file, + size_t skip, const char* prefix) +{ + // Skip the file if we have no name for it. This may happen on a + // top-level directory, which does not need to be included anyway. + if(skip >= strlen(file)) + { + return true; + } + const char* out = file + skip; + + // Meta-data. + std::string dest = prefix? prefix : ""; + dest += out; + if(this->Verbose) + { + std::cout << dest << "\n"; + } + Entry e; + archive_entry_copy_sourcepath(e, file); + archive_entry_set_pathname(e, dest.c_str()); + if(archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK) + { + this->Error = "archive_read_disk_entry_from_file: "; + this->Error += archive_error_string(this->Disk); + return false; + } + if(archive_write_header(this->Archive, e) != ARCHIVE_OK) + { + this->Error = "archive_write_header: "; + this->Error += archive_error_string(this->Archive); + return false; + } + + // Content. + if(size_t size = static_cast<size_t>(archive_entry_size(e))) + { + return this->AddData(file, size); + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmArchiveWrite::AddData(const char* file, size_t size) +{ + std::ifstream fin(file, std::ios::in | cmsys_ios_binary); + if(!fin) + { + this->Error = "Error opening \""; + this->Error += file; + this->Error += "\": "; + this->Error += cmSystemTools::GetLastSystemError(); + return false; + } + + char buffer[16384]; + 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); + // 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) + { + break; + } + if(archive_write_data(this->Archive, buffer, + static_cast<size_t>(nnext)) != nnext) + { + this->Error = "archive_write_data: "; + this->Error += archive_error_string(this->Archive); + return false; + } + nleft -= static_cast<size_t>(nnext); + } + if(nleft > 0) + { + this->Error = "Error reading \""; + this->Error += file; + this->Error += "\": "; + this->Error += cmSystemTools::GetLastSystemError(); + return false; + } + return true; +} diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h new file mode 100644 index 0000000..92c0c73 --- /dev/null +++ b/Source/cmArchiveWrite.h @@ -0,0 +1,84 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2010 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef cmArchiveWrite_h +#define cmArchiveWrite_h + +#include "cmStandardIncludes.h" + +#if !defined(CMAKE_BUILD_WITH_CMAKE) +# error "cmArchiveWrite not allowed during bootstrap build!" +#endif + +/** \class cmArchiveWrite + * \brief Wrapper around libarchive for writing. + * + */ +class cmArchiveWrite +{ + typedef void (cmArchiveWrite::* safe_bool)(); + void safe_bool_true() {} +public: + /** Compression type. */ + enum Compress + { + CompressNone, + CompressGZip, + CompressBZip2 + }; + + /** Construct with output stream to which to write archive. */ + cmArchiveWrite(std::ostream& os, Compress c = CompressNone); + ~cmArchiveWrite(); + + /** + * Add a path (file or directory) to the archive. Directories are + * added recursively. The "path" must be readable on disk, either + * full path or relative to current working directory. The "skip" + * value indicates how many leading bytes from the input path to + * skip. The remaining part of the input path is appended to the + * "prefix" value to construct the final name in the archive. + */ + bool Add(std::string path, size_t skip = 0, const char* prefix = 0); + + /** Returns true if there has been no error. */ + operator safe_bool() const + { return this->Okay()? &cmArchiveWrite::safe_bool_true : 0; } + + /** Returns true if there has been an error. */ + bool operator!() const { return !this->Okay(); } + + /** Return the error string; empty if none. */ + std::string GetError() const { return this->Error; } + + // TODO: More general callback instead of hard-coding calls to + // std::cout. + void SetVerbose(bool v) { this->Verbose = v; } + +private: + bool Okay() const { return this->Error.empty(); } + bool AddPath(const char* path, size_t skip, const char* prefix); + bool AddFile(const char* file, size_t skip, const char* prefix); + bool AddData(const char* file, size_t size); + + struct Callback; + friend struct Callback; + + class Entry; + + std::ostream& Stream; + struct archive* Archive; + struct archive* Disk; + bool Verbose; + std::string Error; +}; + +#endif 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/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 0badbba..a26452c 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -23,8 +23,8 @@ #include <cmsys/Directory.hxx> #include <cmsys/System.h> #if defined(CMAKE_BUILD_WITH_CMAKE) -#include <cmlibarchive/libarchive/archive.h> -#include <cmlibarchive/libarchive/archive_entry.h> +# include "cmArchiveWrite.h" +# include <cm_libarchive.h> # include <cmsys/Terminal.h> #endif #include <cmsys/stl/algorithm> @@ -1719,142 +1719,40 @@ bool cmSystemTools::CreateTar(const char* outFileName, bool gzip, bool bzip2, bool verbose) { #if defined(CMAKE_BUILD_WITH_CMAKE) - - // Create a macro to handle return from libarchive - // functions -#define CHECK_ARCHIVE_ERROR(res, msg)\ - if(res != ARCHIVE_OK)\ - {\ - cmSystemTools::Error(msg, \ - archive_error_string(a));\ - return false;\ - } - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - // recursively expand all directories in files so that we have a list - // of files - std::vector<std::string> expandedFiles; + std::ofstream fout(outFileName, std::ios::out | cmsys_ios_binary); + if(!fout) + { + std::string e = "Cannot open output file \""; + e += outFileName; + e += "\": "; + e += cmSystemTools::GetLastSystemError(); + cmSystemTools::Error(e.c_str()); + return false; + } + cmArchiveWrite a(fout, (gzip? cmArchiveWrite::CompressGZip : + (bzip2? cmArchiveWrite::CompressBZip2 : + cmArchiveWrite::CompressNone))); + a.SetVerbose(verbose); for(std::vector<cmStdString>::const_iterator i = files.begin(); i != files.end(); ++i) { - if(cmSystemTools::FileIsDirectory(i->c_str())) + std::string path = *i; + if(cmSystemTools::FileIsFullPath(path.c_str())) { - cmsys::Glob gl; - std::string findExpr = *i; - if ( findExpr[findExpr.size()-1] != '/' ) - { - findExpr +="/"; - } - findExpr += "*"; - gl.RecurseOn(); - if ( gl.FindFiles(findExpr) ) - { - std::vector<std::string> dirfiles = gl.GetFiles(); - std::copy(dirfiles.begin(), dirfiles.end(), - std::back_inserter(expandedFiles)); - } + // Get the relative path to the file. + path = cmSystemTools::RelativePath(cwd.c_str(), path.c_str()); } - else + if(!a.Add(path)) { - if(!cmSystemTools::FileIsFullPath(i->c_str())) - { - std::string fullp = cwd + "/" + *i; - expandedFiles.push_back(fullp); - } - else - { - expandedFiles.push_back(*i); - } + break; } } - int res; - // create a new archive - struct archive* a = archive_write_new(); if(!a) { - cmSystemTools::Error("Unable to use create archive"); + cmSystemTools::Error(a.GetError().c_str()); return false; } - - if(gzip) - { - res = archive_write_set_compression_gzip(a); - CHECK_ARCHIVE_ERROR(res, "Can not set gzip:"); - } - if(bzip2) - { - res = archive_write_set_compression_bzip2(a); - CHECK_ARCHIVE_ERROR(res, "Can not set bzip2:"); - } - if(!bzip2 && !gzip) - { - res = archive_write_set_compression_none(a); - CHECK_ARCHIVE_ERROR(res, "Can not set none:"); - } - res = archive_write_set_format_pax_restricted(a); - CHECK_ARCHIVE_ERROR(res, "Can not set tar format:"); - res = archive_write_open_file(a, outFileName); - CHECK_ARCHIVE_ERROR(res, "write open:"); - // create a new disk struct - struct archive* disk = archive_read_disk_new(); - archive_read_disk_set_standard_lookup(disk); - std::vector<std::string>::const_iterator fileIt; - for ( fileIt = expandedFiles.begin(); - fileIt != expandedFiles.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(cwd.c_str(), - fileIt->c_str()); - if(verbose) - { - std::cout << rp << "\n"; - } - // Set the name of the entry to the file name - archive_entry_set_pathname(entry, rp.c_str()); - archive_read_disk_entry_from_file(disk, entry, -1, 0); - CHECK_ARCHIVE_ERROR(res, "read disk entry:"); - - // write entry header - res = archive_write_header(a, entry); - CHECK_ARCHIVE_ERROR(res, "write header: "); - if(archive_entry_size(entry) > 0) - { - // now copy contents of file into archive a - FILE* file = fopen(fileIt->c_str(), "rb"); - if(!file) - { - cmSystemTools::Error("Problem with fopen(): ", - fileIt->c_str()); - return false; - } - char buff[16384]; - size_t len = fread(buff, 1, sizeof(buff), file); - while (len > 0) - { - size_t wlen = archive_write_data(a, buff, len); - if(wlen != len) - { - cmOStringStream error; - error << "Problem with archive_write_data\n" - << "Tried to write [" << len << "] bytes.\n" - << "archive_write_data wrote [" << wlen << "] bytes.\n"; - cmSystemTools::Error(error.str().c_str(), - archive_error_string(a) - ); - return false; - } - len = fread(buff, 1, sizeof(buff), file); - } - // close the file and free the entry - fclose(file); - } - archive_entry_free(entry); - } - archive_write_close(a); - archive_write_finish(a); - archive_read_finish(disk); return true; #else (void)outFileName; 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 3b5f67d..7aee779 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 06) +SET(KWSYS_DATE_STAMP_DAY 17) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0743c5a..5383bda 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1520,36 +1520,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) - IF(NOT DEFINED CTEST_RUN_CTestSubmitLargeOutput) - SET(CTEST_RUN_CTestSubmitLargeOutput OFF) - - IF (CMAKE_TESTS_CDASH_SERVER AND "${server}" STREQUAL "localhost") - SET(CTEST_RUN_CTestSubmitLargeOutput ON) - ENDIF (CMAKE_TESTS_CDASH_SERVER AND "${server}" STREQUAL "localhost") - ENDIF(NOT DEFINED CTEST_RUN_CTestSubmitLargeOutput) - - IF(CTEST_RUN_CTestSubmitLargeOutput) - CONFIGURE_FILE( - "${CMake_SOURCE_DIR}/Tests/CTestSubmitLargeOutput/test.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/test.cmake" - @ONLY ESCAPE_QUOTES - ) - ADD_TEST(CTestSubmitLargeOutput ${CMAKE_CTEST_COMMAND} - -S "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/test.cmake" -V - --output-log "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/testOutput.log" - ) - - # This test only passes if it fails to submit properly... - # - SET_TESTS_PROPERTIES(CTestSubmitLargeOutput PROPERTIES - PASS_REGULAR_EXPRESSION "Errors occurred during submission") - - # Give this test plenty of time to run on slower machines: - # - SET_TESTS_PROPERTIES(CTestSubmitLargeOutput PROPERTIES - TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - ENDIF(CTEST_RUN_CTestSubmitLargeOutput) - IF (CMAKE_RUN_LONG_TESTS AND TEST_KDE4_STABLE_BRANCH) IF(UNIX) IF(NOT QT4_FOUND) diff --git a/Tests/CTestSubmitLargeOutput/CMakeLists.txt b/Tests/CTestSubmitLargeOutput/CMakeLists.txt deleted file mode 100644 index 6c30e7a..0000000 --- a/Tests/CTestSubmitLargeOutput/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(SubmitLargeOutput NONE) - -include(CTest) - -add_test(GenerateRandomOutput ${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_SOURCE_DIR}/GenerateRandomOutput.cmake - ) diff --git a/Tests/CTestSubmitLargeOutput/CTestConfig.cmake b/Tests/CTestSubmitLargeOutput/CTestConfig.cmake deleted file mode 100644 index ffd6efc..0000000 --- a/Tests/CTestSubmitLargeOutput/CTestConfig.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(CTEST_PROJECT_NAME "SubmitLargeOutput") -set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") -set(CTEST_DROP_METHOD "http") -set(CTEST_DROP_SITE "www.cdash.org") -set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") -set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake b/Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake deleted file mode 100644 index c7f4f29..0000000 --- a/Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# -# This script generates random lines of output. -# -# By default, it generates 100M of output (a million lines of 100 bytes each), -# but you can override that by passing in -D line_count and/or -D line_size... -# - -# Default values: -# -if(NOT DEFINED line_count) - set(line_count 1000000) -endif() - -if(NOT DEFINED line_size) - set(line_size 100) -endif() - -if(NOT DEFINED random_seed) - set(random_seed 1987) -endif() - -# Use RANDOM_SEED once before the loop: -# -string(RANDOM LENGTH ${line_size} RANDOM_SEED ${random_seed} s) - -# Emit line_count lines of random output: -# -foreach(i RANGE 1 ${line_count}) - string(RANDOM LENGTH ${line_size} s) - message(${s}) -endforeach() diff --git a/Tests/CTestSubmitLargeOutput/test.cmake.in b/Tests/CTestSubmitLargeOutput/test.cmake.in deleted file mode 100644 index 17a7c7d..0000000 --- a/Tests/CTestSubmitLargeOutput/test.cmake.in +++ /dev/null @@ -1,27 +0,0 @@ -SET(CTEST_SITE "@SITE@") -SET(CTEST_BUILD_NAME "LargeOutput-@BUILDNAME@") -SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") - -SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestSubmitLargeOutput") -SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestSubmitLargeOutput/build") -SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") - -CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -CTEST_START(Experimental) -CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_READ_CUSTOM_FILES("${CTEST_BINARY_DIRECTORY}") -CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - -SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 1000000000) -SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000000) -SET(CTEST_TEST_TIMEOUT @CMAKE_LONG_TEST_TIMEOUT@) - -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - -set(CTEST_DROP_METHOD "@protocol@") -set(CTEST_DROP_SITE "@server@") -set(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") - -CTEST_SUBMIT(RETURN_VALUE res) 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!") diff --git a/Utilities/cmThirdParty.h.in b/Utilities/cmThirdParty.h.in index 6cdd47c..daf8114 100644 --- a/Utilities/cmThirdParty.h.in +++ b/Utilities/cmThirdParty.h.in @@ -16,6 +16,7 @@ #cmakedefine CMAKE_USE_SYSTEM_CURL #cmakedefine CMAKE_USE_SYSTEM_EXPAT #cmakedefine CMAKE_USE_SYSTEM_ZLIB +#cmakedefine CMAKE_USE_SYSTEM_LIBARCHIVE #cmakedefine CTEST_USE_XMLRPC #endif diff --git a/Utilities/cm_libarchive.h b/Utilities/cm_libarchive.h new file mode 100644 index 0000000..1469bae --- /dev/null +++ b/Utilities/cm_libarchive.h @@ -0,0 +1,25 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2010 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef __cm_libarchive_h +#define __cm_libarchive_h + +/* Use the libarchive configured for CMake. */ +#include "cmThirdParty.h" +#ifdef CMAKE_USE_SYSTEM_LIBARCHIVE +# include <archive.h> +# include <archive_entry.h> +#else +# include <cmlibarchive/libarchive/archive.h> +# include <cmlibarchive/libarchive/archive_entry.h> +#endif + +#endif |