瀏覽代碼

Merge branch 'target-include-directories' into ninja-generator

David Cole 13 年之前
父節點
當前提交
bada88e8e4
共有 100 個文件被更改,包括 2501 次插入762 次删除
  1. 5 0
      CTestCustom.cmake.in
  2. 10 0
      Docs/cmake-completion
  3. 206 0
      Modules/CMakeAddFortranSubdirectory.cmake
  4. 2 0
      Modules/CMakeAddFortranSubdirectory/build_mingw.cmake.in
  5. 9 0
      Modules/CMakeAddFortranSubdirectory/config_mingw.cmake.in
  6. 8 6
      Modules/CMakeCXXInformation.cmake
  7. 4 4
      Modules/CMakeDetermineFortranCompiler.cmake
  8. 129 0
      Modules/CMakeExpandImportedTargets.cmake
  9. 8 0
      Modules/CMakeFortranInformation.cmake
  10. 76 68
      Modules/CPack.cmake
  11. 12 0
      Modules/CPackBundle.cmake
  12. 58 1
      Modules/CPackComponent.cmake
  13. 70 0
      Modules/CPackDMG.cmake
  14. 38 0
      Modules/CPackDeb.cmake
  15. 42 0
      Modules/CPackNSIS.cmake
  16. 34 0
      Modules/CPackPackageMaker.cmake
  17. 81 34
      Modules/CPackRPM.cmake
  18. 2 0
      Modules/CheckCCompilerFlag.cmake
  19. 6 1
      Modules/CheckCSourceCompiles.cmake
  20. 9 4
      Modules/CheckCSourceRuns.cmake
  21. 3 0
      Modules/CheckCXXCompilerFlag.cmake
  22. 6 1
      Modules/CheckCXXSourceCompiles.cmake
  23. 11 6
      Modules/CheckCXXSourceRuns.cmake
  24. 8 3
      Modules/CheckFortranFunctionExists.cmake
  25. 9 4
      Modules/CheckFunctionExists.cmake
  26. 5 5
      Modules/CheckIncludeFiles.cmake
  27. 65 0
      Modules/CheckLanguage.cmake
  28. 11 6
      Modules/CheckLibraryExists.cmake
  29. 6 1
      Modules/CheckPrototypeDefinition.cmake
  30. 6 1
      Modules/CheckSymbolExists.cmake
  31. 6 1
      Modules/CheckTypeSize.cmake
  32. 10 5
      Modules/CheckVariableExists.cmake
  33. 1 1
      Modules/FeatureSummary.cmake
  34. 5 6
      Modules/FindALSA.cmake
  35. 94 110
      Modules/FindBLAS.cmake
  36. 1 1
      Modules/FindCUDA.cmake
  37. 26 2
      Modules/FindFreetype.cmake
  38. 16 18
      Modules/FindGLUT.cmake
  39. 43 5
      Modules/FindGettext.cmake
  40. 1 1
      Modules/FindImageMagick.cmake
  41. 60 31
      Modules/FindLAPACK.cmake
  42. 3 2
      Modules/FindLibArchive.cmake
  43. 15 3
      Modules/FindLibXslt.cmake
  44. 133 72
      Modules/FindOpenMP.cmake
  45. 36 3
      Modules/FindPerl.cmake
  46. 25 45
      Modules/FindPerlLibs.cmake
  47. 16 5
      Modules/FindPkgConfig.cmake
  48. 4 1
      Modules/FindQt3.cmake
  49. 3 2
      Modules/FindQt4.cmake
  50. 26 31
      Modules/FindRuby.cmake
  51. 3 7
      Modules/FindSDL.cmake
  52. 3 4
      Modules/FindSDL_image.cmake
  53. 3 4
      Modules/FindSDL_mixer.cmake
  54. 3 4
      Modules/FindSDL_net.cmake
  55. 3 3
      Modules/FindSDL_sound.cmake
  56. 3 4
      Modules/FindSDL_ttf.cmake
  57. 15 3
      Modules/FindX11.cmake
  58. 1 1
      Modules/GenerateExportHeader.cmake
  59. 2 2
      Modules/NSIS.template.in
  60. 7 1
      Modules/Qt4Macros.cmake
  61. 38 18
      Modules/UseJava.cmake
  62. 2 0
      Source/CMakeLists.txt
  63. 9 2
      Source/CPack/cmCPackArchiveGenerator.cxx
  64. 16 0
      Source/CPack/cmCPackDocumentMacros.cxx
  65. 21 0
      Source/CPack/cmCPackDocumentMacros.h
  66. 32 0
      Source/CPack/cmCPackDocumentVariables.cxx
  67. 21 0
      Source/CPack/cmCPackDocumentVariables.h
  68. 5 0
      Source/CPack/cmCPackGenerator.cxx
  69. 3 3
      Source/CPack/cmCPackNSISGenerator.cxx
  70. 88 6
      Source/CPack/cpack.cxx
  71. 1 1
      Source/CTest/cmCTestCoverageHandler.cxx
  72. 1 0
      Source/CursesDialog/ccmake.cxx
  73. 5 6
      Source/CursesDialog/cmCursesMainForm.cxx
  74. 2 2
      Source/QtDialog/CMakeLists.txt
  75. 1 0
      Source/QtDialog/CMakeSetup.cxx
  76. 1 2
      Source/QtDialog/CMakeSetupDialog.cxx
  77. 12 1
      Source/QtDialog/QCMake.cxx
  78. 4 1
      Source/QtDialog/QCMake.h
  79. 6 2
      Source/cmBootstrapCommands.cxx
  80. 11 0
      Source/cmCommand.h
  81. 0 4
      Source/cmCommands.cxx
  82. 13 1
      Source/cmComputeLinkInformation.cxx
  83. 1 0
      Source/cmComputeLinkInformation.h
  84. 9 4
      Source/cmCoreTryCompile.cxx
  85. 13 1
      Source/cmDepends.cxx
  86. 422 49
      Source/cmDocumentation.cxx
  87. 70 0
      Source/cmDocumentation.h
  88. 6 5
      Source/cmExtraCodeBlocksGenerator.cxx
  89. 7 3
      Source/cmExtraEclipseCDT4Generator.cxx
  90. 14 4
      Source/cmFindLibraryCommand.cxx
  91. 9 0
      Source/cmFindPackageCommand.cxx
  92. 11 0
      Source/cmFunctionCommand.cxx
  93. 20 19
      Source/cmGlobalGenerator.cxx
  94. 1 1
      Source/cmGlobalXCodeGenerator.cxx
  95. 15 7
      Source/cmIncludeDirectoryCommand.h
  96. 26 26
      Source/cmLocalGenerator.cxx
  97. 3 3
      Source/cmLocalGenerator.h
  98. 15 22
      Source/cmLocalUnixMakefileGenerator3.cxx
  99. 60 45
      Source/cmLocalVisualStudio6Generator.cxx
  100. 1 1
      Source/cmLocalVisualStudio6Generator.h

+ 5 - 0
CTestCustom.cmake.in

@@ -1,3 +1,7 @@
+SET(CTEST_CUSTOM_ERROR_MATCH
+  ${CTEST_CUSTOM_ERROR_MATCH}
+  "ERROR:")
+
 SET(CTEST_CUSTOM_WARNING_EXCEPTION
   ${CTEST_CUSTOM_WARNING_EXCEPTION}
   "xtree.[0-9]+. : warning C4702: unreachable code"
@@ -44,6 +48,7 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION
   "cc-3968 CC: WARNING File.*" # "implicit" truncation by static_cast
   "ld: warning: directory not found for option .-(F|L)"
   "warning.*This version of Mac OS X is unsupported"
+  "clang.*: warning: argument unused during compilation: .-g"
 
   # Ignore clang's summary warning, assuming prior text has matched some
   # other warning expression:

+ 10 - 0
Docs/cmake-completion

@@ -130,6 +130,16 @@ _cpack()
             COMPREPLY=( $(compgen -f ${cur}) )
             return 0
             ;;
+        --help-variable)
+            local running=$(for x in `cpack --help-variable-list | grep -v "cpack version" `; do echo ${x} ; done )
+            COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
+            return 0
+            ;;
+        --help-command)
+            local running=$(for x in `cpack --help-command-list | grep -v "cpack version" `; do echo ${x} ; done )
+            COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
+            return 0
+            ;;
         *)
             ;;
     esac

+ 206 - 0
Modules/CMakeAddFortranSubdirectory.cmake

@@ -0,0 +1,206 @@
+# - Use MinGW gfortran from VS if a fortran compiler is not found.
+# The 'add_fortran_subdirectory' function adds a subdirectory
+# to a project that contains a fortran only sub-project. The module
+# will check the current compiler and see if it can support fortran.
+# If no fortran compiler is found and the compiler is MSVC, then
+# this module will find the MinGW gfortran.  It will then use
+# an external project to build with the MinGW tools.  It will also
+# create imported targets for the libraries created.  This will only
+# work if the fortran code is built into a dll, so BUILD_SHARED_LIBS
+# is turned on in the project.  In addition the CMAKE_GNUtoMS option
+# is set to on, so that the MS .lib files are created.
+# Usage is as follows:
+#  cmake_add_fortran_subdirectory(
+#   <subdir>                # name of subdirectory
+#   PROJECT <project_name>  # project name in subdir top CMakeLists.txt
+#   ARCHIVE_DIR <dir>       # dir where project places .lib files
+#   RUNTIME_DIR <dir>       # dir where project places .dll files
+#   LIBRARIES <lib>...      # names of library targets to import
+#   LINK_LIBRARIES          # link interface libraries for LIBRARIES
+#    [LINK_LIBS <lib> <dep>...]...
+#   CMAKE_COMMAND_LINE ...  # extra command line flags to pass to cmake
+#   NO_EXTERNAL_INSTALL     # skip installation of external project
+#   )
+# Relative paths in ARCHIVE_DIR and RUNTIME_DIR are interpreted with respect
+# to the build directory corresponding to the source directory in which the
+# function is invoked.
+#
+# Limitations:
+#
+# NO_EXTERNAL_INSTALL is required for forward compatibility with a
+# future version that supports installation of the external project
+# binaries during "make install".
+
+#=============================================================================
+# Copyright 2011-2012 Kitware, Inc.
+#
+# 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.)
+
+
+set(_MS_MINGW_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
+include(CheckLanguage)
+include(ExternalProject)
+include(CMakeParseArguments)
+
+function(_setup_mingw_config_and_build source_dir build_dir)
+  # Look for a MinGW gfortran.
+  find_program(MINGW_GFORTRAN
+    NAMES gfortran
+    PATHS
+      c:/MinGW/bin
+      "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MinGW;InstallLocation]/bin"
+    )
+  if(NOT MINGW_GFORTRAN)
+    message(FATAL_ERROR
+      "gfortran not found, please install MinGW with the gfortran option."
+      "Or set the cache variable MINGW_GFORTRAN to the full path. "
+      " This is required to build")
+  endif()
+
+  # Validate the MinGW gfortran we found.
+  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+    set(_mingw_target "Target:.*64.*mingw")
+  else()
+    set(_mingw_target "Target:.*mingw32")
+  endif()
+  execute_process(COMMAND "${MINGW_GFORTRAN}" -v
+    ERROR_VARIABLE out ERROR_STRIP_TRAILING_WHITESPACE)
+  if(NOT "${out}" MATCHES "${_mingw_target}")
+    string(REPLACE "\n" "\n  " out "  ${out}")
+    message(FATAL_ERROR
+      "MINGW_GFORTRAN is set to\n"
+      "  ${MINGW_GFORTRAN}\n"
+      "which is not a MinGW gfortran for this architecture.  "
+      "The output from -v does not match \"${_mingw_target}\":\n"
+      "${out}\n"
+      "Set MINGW_GFORTRAN to a proper MinGW gfortran for this architecture."
+      )
+  endif()
+
+  # Configure scripts to run MinGW tools with the proper PATH.
+  get_filename_component(MINGW_PATH ${MINGW_GFORTRAN} PATH)
+  file(TO_NATIVE_PATH "${MINGW_PATH}" MINGW_PATH)
+  string(REPLACE "\\" "\\\\" MINGW_PATH "${MINGW_PATH}")
+  configure_file(
+    ${_MS_MINGW_SOURCE_DIR}/CMakeAddFortranSubdirectory/config_mingw.cmake.in
+    ${build_dir}/config_mingw.cmake
+    @ONLY)
+  configure_file(
+    ${_MS_MINGW_SOURCE_DIR}/CMakeAddFortranSubdirectory/build_mingw.cmake.in
+    ${build_dir}/build_mingw.cmake
+    @ONLY)
+endfunction()
+
+function(_add_fortran_library_link_interface library depend_library)
+  set_target_properties(${library} PROPERTIES
+    IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG "${depend_library}")
+endfunction()
+
+
+function(cmake_add_fortran_subdirectory subdir)
+  # Parse arguments to function
+  set(options NO_EXTERNAL_INSTALL)
+  set(oneValueArgs PROJECT ARCHIVE_DIR RUNTIME_DIR)
+  set(multiValueArgs LIBRARIES LINK_LIBRARIES CMAKE_COMMAND_LINE)
+  cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+  if(NOT ARGS_NO_EXTERNAL_INSTALL)
+    message(FATAL_ERROR
+      "Option NO_EXTERNAL_INSTALL is required (for forward compatibility) "
+      "but was not given."
+      )
+  endif()
+
+  # if we are not using MSVC without fortran support
+  # then just use the usual add_subdirectory to build
+  # the fortran library
+  check_language(Fortran)
+  if(NOT (MSVC AND (NOT CMAKE_Fortran_COMPILER)))
+    add_subdirectory(${subdir})
+    return()
+  endif()
+
+  # if we have MSVC without Intel fortran then setup
+  # external projects to build with mingw fortran
+
+  set(source_dir "${CMAKE_CURRENT_SOURCE_DIR}/${subdir}")
+  set(project_name "${ARGS_PROJECT}")
+  set(library_dir "${ARGS_ARCHIVE_DIR}")
+  set(binary_dir "${ARGS_RUNTIME_DIR}")
+  set(libraries ${ARGS_LIBRARIES})
+  # use the same directory that add_subdirectory would have used
+  set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${subdir}")
+  foreach(dir_var library_dir binary_dir)
+    if(NOT IS_ABSOLUTE "${${dir_var}}")
+      get_filename_component(${dir_var}
+        "${CMAKE_CURRENT_BINARY_DIR}/${${dir_var}}" ABSOLUTE)
+    endif()
+  endforeach()
+  # create build and configure wrapper scripts
+  _setup_mingw_config_and_build("${source_dir}" "${build_dir}")
+  # create the external project
+  externalproject_add(${project_name}_build
+    SOURCE_DIR ${source_dir}
+    BINARY_DIR ${build_dir}
+    CONFIGURE_COMMAND ${CMAKE_COMMAND}
+    -P ${build_dir}/config_mingw.cmake
+    BUILD_COMMAND ${CMAKE_COMMAND}
+    -P ${build_dir}/build_mingw.cmake
+    INSTALL_COMMAND ""
+    )
+  # make the external project always run make with each build
+  externalproject_add_step(${project_name}_build forcebuild
+    COMMAND ${CMAKE_COMMAND}
+    -E remove
+    ${CMAKE_CURRENT_BUILD_DIR}/${project_name}-prefix/src/${project_name}-stamp/${project_name}-build
+    DEPENDEES configure
+    DEPENDERS build
+    ALWAYS 1
+    )
+  # create imported targets for all libraries
+  foreach(lib ${libraries})
+    add_library(${lib} SHARED IMPORTED GLOBAL)
+    set_property(TARGET ${lib} APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
+    set_target_properties(${lib} PROPERTIES
+      IMPORTED_IMPLIB_NOCONFIG   "${library_dir}/lib${lib}.lib"
+      IMPORTED_LOCATION_NOCONFIG "${binary_dir}/lib${lib}.dll"
+      )
+    add_dependencies(${lib} ${project_name}_build)
+  endforeach()
+
+  # now setup link libraries for targets
+  set(start FALSE)
+  set(target)
+  foreach(lib ${ARGS_LINK_LIBRARIES})
+    if("${lib}" STREQUAL "LINK_LIBS")
+      set(start TRUE)
+    else()
+      if(start)
+        if(DEFINED target)
+          # process current target and target_libs
+          _add_fortran_library_link_interface(${target} "${target_libs}")
+          # zero out target and target_libs
+          set(target)
+          set(target_libs)
+        endif()
+        # save the current target and set start to FALSE
+        set(target ${lib})
+        set(start FALSE)
+      else()
+        # append the lib to target_libs
+        list(APPEND target_libs "${lib}")
+      endif()
+    endif()
+  endforeach()
+  # process anything that is left in target and target_libs
+  if(DEFINED target)
+    _add_fortran_library_link_interface(${target} "${target_libs}")
+  endif()
+endfunction()

+ 2 - 0
Modules/CMakeAddFortranSubdirectory/build_mingw.cmake.in

@@ -0,0 +1,2 @@
+set(ENV{PATH} "@MINGW_PATH@\;$ENV{PATH}")
+execute_process(COMMAND "@CMAKE_COMMAND@" --build . )

+ 9 - 0
Modules/CMakeAddFortranSubdirectory/config_mingw.cmake.in

@@ -0,0 +1,9 @@
+set(ENV{PATH} "@MINGW_PATH@\;$ENV{PATH}")
+set(CMAKE_COMMAND_LINE "@ARGS_CMAKE_COMMAND_LINE@")
+execute_process(
+  COMMAND "@CMAKE_COMMAND@" "-GMinGW Makefiles"
+  -DCMAKE_Fortran_COMPILER:PATH=@MINGW_GFORTRAN@
+  -DBUILD_SHARED_LIBS=ON
+  -DCMAKE_GNUtoMS=ON
+  ${CMAKE_COMMAND_LINE}
+  "@source_dir@")

+ 8 - 6
Modules/CMakeCXXInformation.cmake

@@ -93,12 +93,6 @@ IF(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
 ENDIF()
 
 
-# for most systems a module is the same as a shared library
-# so unless the variable CMAKE_MODULE_EXISTS is set just
-# copy the values from the LIBRARY variables
-IF(NOT CMAKE_MODULE_EXISTS)
-  SET(CMAKE_SHARED_MODULE_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
-ENDIF(NOT CMAKE_MODULE_EXISTS)
 # Create a set of shared library variable specific to C++
 # For 90% of the systems, these are the same flags as the C versions
 # so if these are not set just copy the flags from the c version
@@ -158,6 +152,14 @@ IF(NOT CMAKE_INCLUDE_FLAG_SEP_CXX)
   SET(CMAKE_INCLUDE_FLAG_SEP_CXX ${CMAKE_INCLUDE_FLAG_SEP_C})
 ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_CXX)
 
+# for most systems a module is the same as a shared library
+# so unless the variable CMAKE_MODULE_EXISTS is set just
+# copy the values from the LIBRARY variables
+IF(NOT CMAKE_MODULE_EXISTS)
+  SET(CMAKE_SHARED_MODULE_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
+  SET(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS})
+ENDIF(NOT CMAKE_MODULE_EXISTS)
+
 # repeat for modules
 IF(NOT CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS)
   SET(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})

+ 4 - 4
Modules/CMakeDetermineFortranCompiler.cmake

@@ -50,7 +50,7 @@ IF(NOT CMAKE_Fortran_COMPILER)
     #  fort77: native F77 compiler under HP-UX (and some older Crays)
     #  frt: Fujitsu F77 compiler
     #  pathf90/pathf95/pathf2003: PathScale Fortran compiler
-    #  pgf77/pgf90/pgf95: Portland Group F77/F90/F95 compilers
+    #  pgf77/pgf90/pgf95/pgfortran: Portland Group F77/F90/F95 compilers
     #  xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
     #  lf95: Lahey-Fujitsu F95 compiler
     #  fl32: Microsoft Fortran 77 "PowerStation" compiler
@@ -64,8 +64,8 @@ IF(NOT CMAKE_Fortran_COMPILER)
     #  then 77 or older compilers, gnu is always last in the group,
     #  so if you paid for a compiler it is picked by default.
     SET(CMAKE_Fortran_COMPILER_LIST
-      ifort ifc af95 af90 efc f95 pathf2003 pathf95 pgf95 lf95 xlf95 fort
-      gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77
+      ifort ifc af95 af90 efc f95 pathf2003 pathf95 pgf95 pgfortran lf95 xlf95
+      fort gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77
       frt pgf77 xlf fl32 af77 g77 f77
       )
 
@@ -73,7 +73,7 @@ IF(NOT CMAKE_Fortran_COMPILER)
     SET(_Fortran_COMPILER_NAMES_GNU       gfortran gfortran-4 g95 g77)
     SET(_Fortran_COMPILER_NAMES_Intel     ifort ifc efc)
     SET(_Fortran_COMPILER_NAMES_Absoft    af95 af90 af77)
-    SET(_Fortran_COMPILER_NAMES_PGI       pgf95 pgf90 pgf77)
+    SET(_Fortran_COMPILER_NAMES_PGI       pgf95 pgfortran pgf90 pgf77)
     SET(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90)
     SET(_Fortran_COMPILER_NAMES_XL        xlf)
     SET(_Fortran_COMPILER_NAMES_VisualAge xlf95 xlf90 xlf)

+ 129 - 0
Modules/CMakeExpandImportedTargets.cmake

@@ -0,0 +1,129 @@
+# CMAKE_EXPAND_IMPORTED_TARGETS(<var> LIBRARIES lib1 lib2...libN
+#                                     [CONFIGURATION <config>] )
+#
+# CMAKE_EXPAND_IMPORTED_TARGETS() takes a list of libraries and replaces
+# all imported targets contained in this list with their actual file paths
+# of the referenced libraries on disk, including the libraries from their
+# link interfaces.
+# If a CONFIGURATION is given, it uses the respective configuration of the
+# imported targets if it exists. If no CONFIGURATION is given, it uses
+# the first configuration from ${CMAKE_CONFIGURATION_TYPES} if set, otherwise
+# ${CMAKE_BUILD_TYPE}.
+# This macro is used by all Check*.cmake files which use
+# TRY_COMPILE() or TRY_RUN() and support CMAKE_REQUIRED_LIBRARIES , so that
+# these checks support imported targets in CMAKE_REQUIRED_LIBRARIES:
+#    cmake_expand_imported_targets(expandedLibs LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
+#                                               CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}" )
+
+
+#=============================================================================
+# Copyright 2012 Kitware, Inc.
+# Copyright 2009-2012 Alexander Neundorf <[email protected]>
+#
+# 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(CMakeParseArguments)
+
+function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT )
+
+   set(options )
+   set(oneValueArgs CONFIGURATION )
+   set(multiValueArgs LIBRARIES )
+
+   cmake_parse_arguments(CEIT "${options}" "${oneValueArgs}" "${multiValueArgs}"  ${ARGN})
+
+   if(CEIT_UNPARSED_ARGUMENTS)
+      message(FATAL_ERROR "Unknown keywords given to CMAKE_EXPAND_IMPORTED_TARGETS(): \"${CEIT_UNPARSED_ARGUMENTS}\"")
+   endif()
+
+   if(NOT CEIT_CONFIGURATION)
+      if(CMAKE_CONFIGURATION_TYPES)
+         list(GET CMAKE_CONFIGURATION_TYPES 0 CEIT_CONFIGURATION)
+      else()
+         set(CEIT_CONFIGURATION ${CMAKE_BUILD_TYPE})
+      endif()
+   endif()
+
+   # handle imported library targets
+
+   set(_CCSR_REQ_LIBS ${CEIT_LIBRARIES})
+
+   set(_CHECK_FOR_IMPORTED_TARGETS TRUE)
+   set(_CCSR_LOOP_COUNTER 0)
+   while(_CHECK_FOR_IMPORTED_TARGETS)
+      math(EXPR _CCSR_LOOP_COUNTER "${_CCSR_LOOP_COUNTER} + 1 ")
+      set(_CCSR_NEW_REQ_LIBS )
+      set(_CHECK_FOR_IMPORTED_TARGETS FALSE)
+      foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS})
+         get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS)
+         if (_importedConfigs)
+#            message(STATUS "Detected imported target ${_CURRENT_LIB}")
+            # Ok, so this is an imported target.
+            # First we get the imported configurations.
+            # Then we get the location of the actual library on disk of the first configuration.
+            # then we'll get its link interface libraries property,
+            # iterate through it and replace all imported targets we find there
+            # with there actual location.
+
+            # guard against infinite loop: abort after 100 iterations ( 100 is arbitrary chosen)
+            if ("${_CCSR_LOOP_COUNTER}" LESS 100)
+               set(_CHECK_FOR_IMPORTED_TARGETS TRUE)
+#                else ("${_CCSR_LOOP_COUNTER}" LESS 1)
+#                   message(STATUS "********* aborting loop, counter : ${_CCSR_LOOP_COUNTER}")
+            endif ("${_CCSR_LOOP_COUNTER}" LESS 100)
+
+            # if one of the imported configurations equals ${CMAKE_TRY_COMPILE_CONFIGURATION},
+            # use it, otherwise simply use the first one:
+            list(FIND _importedConfigs "${CEIT_CONFIGURATION}" _configIndexToUse)
+            if("${_configIndexToUse}" EQUAL -1)
+              set(_configIndexToUse 0)
+            endif("${_configIndexToUse}" EQUAL -1)
+            list(GET _importedConfigs ${_configIndexToUse} _importedConfigToUse)
+
+            get_target_property(_importedLocation "${_CURRENT_LIB}" IMPORTED_LOCATION_${_importedConfigToUse})
+            get_target_property(_linkInterfaceLibs "${_CURRENT_LIB}" IMPORTED_LINK_INTERFACE_LIBRARIES_${_importedConfigToUse} )
+
+            list(APPEND _CCSR_NEW_REQ_LIBS  "${_importedLocation}")
+#            message(STATUS "Appending lib ${_CURRENT_LIB} as ${_importedLocation}")
+            if(_linkInterfaceLibs)
+               foreach(_currentLinkInterfaceLib ${_linkInterfaceLibs})
+#                  message(STATUS "Appending link interface lib ${_currentLinkInterfaceLib}")
+                  if(_currentLinkInterfaceLib)
+                     list(APPEND _CCSR_NEW_REQ_LIBS "${_currentLinkInterfaceLib}" )
+                  endif(_currentLinkInterfaceLib)
+               endforeach(_currentLinkInterfaceLib "${_linkInterfaceLibs}")
+            endif(_linkInterfaceLibs)
+         else(_importedConfigs)
+            # "Normal" libraries are just used as they are.
+            list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" )
+#            message(STATUS "Appending lib directly: ${_CURRENT_LIB}")
+         endif(_importedConfigs)
+      endforeach(_CURRENT_LIB ${_CCSR_REQ_LIBS})
+
+      set(_CCSR_REQ_LIBS ${_CCSR_NEW_REQ_LIBS} )
+   endwhile(_CHECK_FOR_IMPORTED_TARGETS)
+
+   # Finally we iterate once more over all libraries. This loop only removes
+   # all remaining imported target names (there shouldn't be any left anyway).
+   set(_CCSR_NEW_REQ_LIBS )
+   foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS})
+      get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS)
+      if (NOT _importedConfigs)
+         list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" )
+#         message(STATUS "final: appending ${_CURRENT_LIB}")
+      else (NOT _importedConfigs)
+#             message(STATUS "final: skipping ${_CURRENT_LIB}")
+      endif (NOT _importedConfigs)
+   endforeach(_CURRENT_LIB ${_CCSR_REQ_LIBS})
+#   message(STATUS "setting -${_RESULT}- to -${_CCSR_NEW_REQ_LIBS}-")
+   set(${_RESULT} "${_CCSR_NEW_REQ_LIBS}" PARENT_SCOPE)
+
+endfunction()

+ 8 - 0
Modules/CMakeFortranInformation.cmake

@@ -109,6 +109,14 @@ IF(NOT DEFINED CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG)
   SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG})
 ENDIF()
 
+# for most systems a module is the same as a shared library
+# so unless the variable CMAKE_MODULE_EXISTS is set just
+# copy the values from the LIBRARY variables
+IF(NOT CMAKE_MODULE_EXISTS)
+  SET(CMAKE_SHARED_MODULE_Fortran_FLAGS ${CMAKE_SHARED_LIBRARY_Fortran_FLAGS})
+  SET(CMAKE_SHARED_MODULE_CREATE_Fortran_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS})
+ENDIF(NOT CMAKE_MODULE_EXISTS)
+
 # repeat for modules
 IF(NOT DEFINED CMAKE_SHARED_MODULE_CREATE_Fortran_FLAGS)
   SET(CMAKE_SHARED_MODULE_CREATE_Fortran_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})

+ 76 - 68
Modules/CPack.cmake

@@ -1,5 +1,7 @@
-# - Build binary and source package installers
-#
+##section Variables common to all CPack generators
+##end
+##module
+# - Build binary and source package installers.
 # The CPack module generates binary and source installers in a variety
 # of formats using the cpack program. Inclusion of the CPack module
 # adds two new targets to the resulting makefiles, package and
@@ -29,16 +31,16 @@
 # 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...)
+#  - 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
+#  - 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
@@ -48,174 +50,180 @@
 # 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:
+##end
 #
+##variable
 #   CPACK_PACKAGE_NAME - The name of the package (or application). If
 #   not specified, defaults to the project name.
+##end
 #
-#   CPACK_PACKAGE_VENDOR - The name of the package vendor (e.g.,
+##variable
+#   CPACK_PACKAGE_VENDOR - The name of the package vendor. (e.g.,
 #   "Kitware").
+##end
 #
+##variable
 #   CPACK_PACKAGE_VERSION_MAJOR - Package major Version
+##end
 #
+##variable
 #   CPACK_PACKAGE_VERSION_MINOR - Package minor Version
+##end
 #
+##variable
 #   CPACK_PACKAGE_VERSION_PATCH - Package patch Version
+##end
 #
+##variable
 #   CPACK_PACKAGE_DESCRIPTION_FILE - A text file used to describe the
 #   project. Used, for example, the introduction screen of a
 #   CPack-generated Windows installer to describe the project.
+##end
 #
+##variable
 #   CPACK_PACKAGE_DESCRIPTION_SUMMARY - Short description of the
 #   project (only a few words).
+##end
 #
+##variable
 #   CPACK_PACKAGE_FILE_NAME - The name of the package file to generate,
 #   not including the extension. For example, cmake-2.6.1-Linux-i686.
+##end
 #
+##variable
 #   CPACK_PACKAGE_INSTALL_DIRECTORY - Installation directory on the
 #   target system, e.g., "CMake 2.5".
+##end
 #
+##variable
 #   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.
+##end
 #
+##variable
 #   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.
+##end
 #
+##variable
 #   CPACK_RESOURCE_FILE_README - ReadMe file for the project, which
 #   typically describes in some detail
+##end
 #
+##variable
 #   CPACK_RESOURCE_FILE_WELCOME - Welcome file for the project, which
 #   welcomes users to this installer. Typically used in the graphical
 #   installers on Windows and Mac OS X.
+##end
 #
+##variable
 #   CPACK_MONOLITHIC_INSTALL - Disables the component-based 
 #   installation mechanism, so that all components are always installed.
+##end
 #
+##variable
 #   CPACK_GENERATOR - List of CPack generators to use. If not
 #   specified, CPack will create a set of options (e.g.,
 #   CPACK_BINARY_NSIS) allowing the user to enable/disable individual
 #   generators.
+##end
 #
+##variable
 #   CPACK_OUTPUT_CONFIG_FILE - The name of the CPack configuration file
 #   for binary installers that will be generated by the CPack
 #   module. Defaults to CPackConfig.cmake.
+##end
 #
+##variable
 #   CPACK_PACKAGE_EXECUTABLES - Lists each of the executables along
 #   with a text label, to be used to create Start Menu shortcuts on
 #   Windows. For example, setting this to the list ccmake;CMake will
 #   create a shortcut named "CMake" that will execute the installed
 #   executable ccmake.
+##end
 #
+##variable
 #   CPACK_STRIP_FILES - List of files to be stripped. Starting with
 #   CMake 2.6.0 CPACK_STRIP_FILES will be a boolean variable which
 #   enables stripping of all files (a list of files evaluates to TRUE
 #   in CMake, so this change is compatible).
+##end
 #
 # The following CPack variables are specific to source packages, and 
 # will not affect binary packages:
 #
+##variable
 #   CPACK_SOURCE_PACKAGE_FILE_NAME - The name of the source package,
 #   e.g., cmake-2.6.1
+##end
 #
+##variable
 #   CPACK_SOURCE_STRIP_FILES - List of files in the source tree that
 #   will be stripped. Starting with CMake 2.6.0
 #   CPACK_SOURCE_STRIP_FILES will be a boolean variable which enables
 #   stripping of all files (a list of files evaluates to TRUE in CMake,
 #   so this change is compatible).
+##end
 #
+##variable
 #   CPACK_SOURCE_GENERATOR - List of generators used for the source
 #   packages. As with CPACK_GENERATOR, if this is not specified then
 #   CPack will create a set of options (e.g., CPACK_SOURCE_ZIP)
 #   allowing users to select which packages will be generated.
+##end
 #
+##variable
 #   CPACK_SOURCE_OUTPUT_CONFIG_FILE - The name of the CPack
 #   configuration file for source installers that will be generated by
 #   the CPack module. Defaults to CPackSourceConfig.cmake.
+##end
 #
+##variable
 #   CPACK_SOURCE_IGNORE_FILES - Pattern of files in the source tree
 #   that won't be packaged when building a source package. This is a
 #   list of patterns, e.g., /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*
-#
-# The following variables are specific to the DragNDrop installers
-# built on Mac OS X:
-#
-#   CPACK_DMG_VOLUME_NAME - The volume name of the generated disk
-#   image. Defaults to CPACK_PACKAGE_FILE_NAME.
-#
-#   CPACK_DMG_FORMAT - The disk image format. Common values are UDRO
-#   (UDIF read-only), UDZO (UDIF zlib-compressed) or UDBZ (UDIF
-#   bzip2-compressed). Refer to hdiutil(1) for more information on
-#   other available formats.
-#
-#   CPACK_DMG_DS_STORE - Path to a custom .DS_Store file which e.g.
-#   can be used to specify the Finder window position/geometry and
-#   layout (such as hidden toolbars, placement of the icons etc.).
-#   This file has to be generated by the Finder (either manually or
-#   through OSA-script) using a normal folder from which the .DS_Store
-#   file can then be extracted.
-#
-#   CPACK_DMG_BACKGROUND_IMAGE - Path to an image file which is to be
-#   used as the background for the Finder Window when the disk image
-#   is opened.  By default no background image is set. The background
-#   image is applied after applying the custom .DS_Store file.
-#
-#   CPACK_COMMAND_HDIUTIL - Path to the hdiutil(1) command used to
-#   operate on disk image files on Mac OS X. This variable can be used
-#   to override the automatically detected command (or specify its
-#   location if the auto-detection fails to find it.)
-#
-#   CPACK_COMMAND_SETFILE - Path to the SetFile(1) command used to set
-#   extended attributes on files and directories on Mac OS X. This
-#   variable can be used to override the automatically detected
-#   command (or specify its location if the auto-detection fails to
-#   find it.)
-#
-#   CPACK_COMMAND_REZ - Path to the Rez(1) command used to compile
-#   resources on Mac OS X. This variable can be used to override the
-#   automatically detected command (or specify its location if the
-#   auto-detection fails to find it.)
-#
-# The following variable is specific to installers build on Mac OS X
-# using PackageMaker:
-#
-#   CPACK_OSX_PACKAGE_VERSION - The version of Mac OS X that the
-#   resulting PackageMaker archive should be compatible
-#   with. Different versions of Mac OS X support different
-#   features. For example, CPack can only build component-based
-#   installers for Mac OS X 10.4 or newer, and can only build
-#   installers that download component son-the-fly for Mac OS X 10.5
-#   or newer. If left blank, this value will be set to the minimum
-#   version of Mac OS X that supports the requested features. Set this
-#   variable to some value (e.g., 10.4) only if you want to guarantee
-#   that your installer will work on that version of Mac OS X, and
-#   don't mind missing extra features available in the installer
-#   shipping with later versions of Mac OS X.
+##end
 #
 # The following variables are for advanced uses of CPack:
 #
+##variable
 #   CPACK_CMAKE_GENERATOR - What CMake generator should be used if the
 #   project is CMake project. Defaults to the value of CMAKE_GENERATOR;
 #   few users will want to change this setting.
+##end
 #
+##variable
 #   CPACK_INSTALL_CMAKE_PROJECTS - List of four values that specify
 #   what project to install. The four values are: Build directory,
 #   Project Name, Project Component, Directory. If omitted, CPack will
 #   build an installer that installers everything.
+##end
 #
+##variable
 #   CPACK_SYSTEM_NAME - System name, defaults to the value of
 #   ${CMAKE_SYSTEM_NAME}.
+##end
 #
+##variable
 #   CPACK_PACKAGE_VERSION - Package full version, used internally. By
 #   default, this is built from CPACK_PACKAGE_VERSION_MAJOR,
 #   CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH.
+##end
 #
+##variable
 #   CPACK_TOPLEVEL_TAG - Directory for the installed files.
+##end
 #
+##variable
 #   CPACK_INSTALL_COMMANDS - Extra commands to install components.
+##end
 #
+##variable
 #   CPACK_INSTALLED_DIRECTORIES - Extra directories to install.
+##end
 #
 
 #=============================================================================
@@ -259,7 +267,7 @@ MACRO(cpack_set_if_not_set name value)
   ENDIF(NOT DEFINED "${name}")
 ENDMACRO(cpack_set_if_not_set)
 
-# Macro to encode variables for the configuration file
+# cpack_encode_variables - Macro to encode variables for the configuration file
 # find any variable that starts with CPACK and create a variable
 # _CPACK_OTHER_VARIABLES_ that contains SET commands for
 # each cpack variable.  _CPACK_OTHER_VARIABLES_ is then

+ 12 - 0
Modules/CPackBundle.cmake

@@ -1,25 +1,37 @@
+##section Variables specific to CPack Bundle generator
+##end
+##module
 # - CPack Bundle generator (Mac OS X) specific options
 #
 # Installers built on Mac OS X using the Bundle generator use the
 # aforementioned DragNDrop variables, plus the following Bundle-specific
 # parameters:
+##end
 #
+##variable
 #   CPACK_BUNDLE_NAME - The name of the generated bundle.  This
 #   appears in the OSX finder as the bundle name.  Required.
+##end
 #
+##variable
 #   CPACK_BUNDLE_PLIST - Path to an OSX plist file that will be used
 #   as the Info.plist for the generated bundle.  This assumes that
 #   the caller has generated or specified their own Info.plist file.
 #   Required.
+##end
 #
+##variable
 #   CPACK_BUNDLE_ICON - Path to an OSX icns file that will be used as
 #   the icon for the generated bundle.  This is the icon that appears
 #   in the OSX finder for the bundle, and in the OSX dock when the
 #   bundle is opened.  Required.
+##end
 #
+##variable
 #   CPACK_BUNDLE_STARTUP_SCRIPT - Path to an executable or script that
 #   will be run whenever an end-user double-clicks the generated bundle
 #   in the OSX Finder.  Optional.
+##end
 
 #=============================================================================
 # Copyright 2006-2009 Kitware, Inc.

+ 58 - 1
Modules/CPackComponent.cmake

@@ -1,3 +1,6 @@
+##section Variables concerning CPack Components
+##end
+##module
 # - Build binary and source package installers
 #
 # The CPackComponent module is the module which handles
@@ -20,7 +23,54 @@
 # components are identified by the COMPONENT argument of CMake's
 # INSTALL commands, and should be further described by the following
 # CPack commands:
-#
+##end
+#
+##variable
+#  CPACK_COMPONENTS_ALL - The list of component to install.
+#
+#  The default value of this variable is computed by CPack
+#  and contains all components defined by the project. The
+#  user may set it to only include the specified components.
+##end
+#
+##variable
+#  CPACK_<GENNAME>_COMPONENT_INSTALL - Enable/Disable component install for
+#  CPack generator <GENNAME>.
+#
+#  Each CPack Generator (RPM, DEB, ARCHIVE, NSIS, DMG, etc...) has a legacy
+#  default behavior. e.g. RPM builds monolithic whereas NSIS builds component.
+#  One can change the default behavior by setting this variable to 0/1 or OFF/ON.
+##end
+##variable
+#  CPACK_COMPONENTS_GROUPING - Specify how components are grouped for multi-package
+#  component-aware CPack generators.
+#
+#  Some generators like RPM or ARCHIVE family (TGZ, ZIP, ...) generates several
+#  packages files when asked for component packaging. They group the component
+#  differently depending on the value of this variable:
+#     - ONE_PER_GROUP (default): creates one package file per component group
+#     - ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) component
+#     - IGNORE : creates one package per component, i.e. IGNORE component group
+#  One can specify different grouping for different CPack generator by using
+#  a CPACK_PROJECT_CONFIG_FILE.
+##end
+##variable
+#  CPACK_COMPONENT_<compName>_DISPLAY_NAME - The name to be displayed for a component.
+##end
+##variable
+#  CPACK_COMPONENT_<compName>_DESCRIPTION - The description of a component.
+##end
+##variable
+#  CPACK_COMPONENT_<compName>_GROUP - The group of a component.
+##end
+##variable
+#  CPACK_COMPONENT_<compName>_DEPENDS - The dependencies (list of components)
+#  on which this component depends.
+##end
+##variable
+#  CPACK_COMPONENT_<compName>_REQUIRED - True is this component is required.
+##end
+##macro
 #   cpack_add_component - Describes a CPack installation component
 #   named by the COMPONENT argument to a CMake INSTALL command.
 #
@@ -90,7 +140,9 @@
 #   create a file with some name based on CPACK_PACKAGE_FILE_NAME and
 #   the name of the component. See cpack_configure_downloads for more
 #   information.
+##end
 #
+##macro
 #   cpack_add_component_group - Describes a group of related CPack
 #   installation components.
 #
@@ -134,7 +186,9 @@
 #
 #   BOLD_TITLE indicates that the group title should appear in bold,
 #   to call the user's attention to the group.
+##end
 #
+##macro
 #   cpack_add_install_type - Add a new installation type containing a
 #   set of predefined component selections to the graphical installer.
 #
@@ -153,7 +207,9 @@
 #   DISPLAY_NAME is the displayed name of the install type, which will
 #   typically show up in a drop-down box within a graphical
 #   installer. This value can be any string.
+##end
 #
+##macro
 #   cpack_configure_downloads - Configure CPack to download selected
 #   components on-the-fly as part of the installation process.
 #
@@ -203,6 +259,7 @@
 #   that can be called from Windows' Add/Remove Programs dialog (via the
 #   "Modify" button) to change the set of installed components. NO_ADD_REMOVE
 #   turns off this behavior. This option is ignored on Mac OS X.
+##endmacro
 
 #=============================================================================
 # Copyright 2006-2009 Kitware, Inc.

+ 70 - 0
Modules/CPackDMG.cmake

@@ -0,0 +1,70 @@
+##section Variables specific to CPack DragNDrop generator
+##end
+##module
+# - DragNDrop CPack generator (Mac OS X).
+# The following variables are specific to the DragNDrop installers
+# built on Mac OS X:
+##end
+#
+##variable
+#   CPACK_DMG_VOLUME_NAME - The volume name of the generated disk
+#   image. Defaults to CPACK_PACKAGE_FILE_NAME.
+##end
+#
+##variable
+#   CPACK_DMG_FORMAT - The disk image format. Common values are UDRO
+#   (UDIF read-only), UDZO (UDIF zlib-compressed) or UDBZ (UDIF
+#   bzip2-compressed). Refer to hdiutil(1) for more information on
+#   other available formats.
+##end
+#
+##variable
+#   CPACK_DMG_DS_STORE - Path to a custom .DS_Store file which e.g.
+#   can be used to specify the Finder window position/geometry and
+#   layout (such as hidden toolbars, placement of the icons etc.).
+#   This file has to be generated by the Finder (either manually or
+#   through OSA-script) using a normal folder from which the .DS_Store
+#   file can then be extracted.
+##end
+#
+##variable
+#   CPACK_DMG_BACKGROUND_IMAGE - Path to an image file which is to be
+#   used as the background for the Finder Window when the disk image
+#   is opened.  By default no background image is set. The background
+#   image is applied after applying the custom .DS_Store file.
+##end
+#
+##variable
+#   CPACK_COMMAND_HDIUTIL - Path to the hdiutil(1) command used to
+#   operate on disk image files on Mac OS X. This variable can be used
+#   to override the automatically detected command (or specify its
+#   location if the auto-detection fails to find it.)
+##end
+#
+##variable
+#   CPACK_COMMAND_SETFILE - Path to the SetFile(1) command used to set
+#   extended attributes on files and directories on Mac OS X. This
+#   variable can be used to override the automatically detected
+#   command (or specify its location if the auto-detection fails to
+#   find it.)
+##end
+#
+##variable
+#   CPACK_COMMAND_REZ - Path to the Rez(1) command used to compile
+#   resources on Mac OS X. This variable can be used to override the
+#   automatically detected command (or specify its location if the
+#   auto-detection fails to find it.)
+##end
+
+#=============================================================================
+# Copyright 2006-2012 Kitware, Inc.
+#
+# 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.)

+ 38 - 0
Modules/CPackDeb.cmake

@@ -1,3 +1,6 @@
+##section Variables specific to CPack Debian (DEB) generator
+##end
+##module
 # - The builtin (binary) CPack Deb generator (Unix only)
 # CPackDeb may be used to create Deb package using CPack.
 # CPackDeb is a CPack generator thus it uses the CPACK_XXX variables
@@ -11,43 +14,63 @@
 # the wiki:
 #  http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
 # However as a handy reminder here comes the list of specific variables:
+##end
 #
+##variable
 # CPACK_DEBIAN_PACKAGE_NAME
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_NAME (lower case)
 #     The debian package summary
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_VERSION
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_VERSION
 #     The debian package version
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_ARCHITECTURE
 #     Mandatory : YES
 #     Default   : Output of dpkg --print-architecture (or i386 if dpkg is not found)
 #     The debian package architecture
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_DEPENDS
 #     Mandatory : NO
 #     Default   : -
 #     May be used to set deb dependencies.
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_MAINTAINER
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_CONTACT
 #     The debian package maintainer
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_DESCRIPTION
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_DESCRIPTION_SUMMARY
 #     The debian package description
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_SECTION
 #     Mandatory : YES
 #     Default   : 'devel'
 #     The debian package section
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_PRIORITY
 #     Mandatory : YES
 #     Default   : 'optional'
 #     The debian package priority
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_HOMEPAGE
 #     Mandatory : NO
 #     Default   : -
 #     The URL of the web site for this package
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_SHLIBDEPS
 #     Mandatory : NO
 #     Default   : OFF
@@ -57,11 +80,15 @@
 #     if you use this feature, because if you don't dpkg-shlibdeps
 #     may fail to find your own shared libs.
 #     See http://www.cmake.org/Wiki/CMake_RPATH_handling.
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_DEBUG
 #     Mandatory : NO
 #     Default   : -
 #     May be set when invoking cpack in order to trace debug information
 #     during CPackDeb run.
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_PREDEPENDS
 #     Mandatory : NO
 #     Default   : -
@@ -69,12 +96,16 @@
 #     This field is like Depends, except that it also forces dpkg to complete installation of
 #     the packages named before even starting the installation of the package which declares
 #     the pre-dependency.
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_ENHANCES
 #     Mandatory : NO
 #     Default   : -
 #     see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
 #     This field is similar to Suggests but works in the opposite direction.
 #     It is used to declare that a package can enhance the functionality of another package.
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_BREAKS
 #     Mandatory : NO
 #     Default   : -
@@ -82,23 +113,30 @@
 #     When one binary package declares that it breaks another, dpkg will refuse to allow the
 #     package which declares Breaks be installed unless the broken package is deconfigured first,
 #     and it will refuse to allow the broken package to be reconfigured.
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_CONFLICTS
 #     Mandatory : NO
 #     Default   : -
 #     see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
 #     When one binary package declares a conflict with another using a Conflicts field,
 #     dpkg will refuse to allow them to be installed on the system at the same time.
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_PROVIDES
 #     Mandatory : NO
 #     Default   : -
 #     see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
 #     A virtual package is one which appears in the Provides control field of another package.
+##end
+##variable
 # CPACK_DEBIAN_PACKAGE_REPLACES
 #     Mandatory : NO
 #     Default   : -
 #     see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
 #     Packages can declare in their control file that they should overwrite
 #     files in certain other packages, or completely replace other packages.
+##end
 
 #=============================================================================
 # Copyright 2007-2009 Kitware, Inc.

+ 42 - 0
Modules/CPackNSIS.cmake

@@ -1,70 +1,112 @@
+##section Variables specific to CPack NSIS generator
+##end
+##module
 # - CPack NSIS generator specific options
 #
 # The following variables are specific to the graphical installers built
 # on Windows using the Nullsoft Installation System.
+##end
 #
+##variable
 #   CPACK_PACKAGE_INSTALL_REGISTRY_KEY - Registry key used when
 #   installing this project.
+##end
 #
+##variable
 #   CPACK_NSIS_INSTALL_ROOT - The default installation directory presented
 #   to the end user by the NSIS installer is under this root dir. The full
 #   directory presented to the end user is:
 #   ${CPACK_NSIS_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY}
+##end
 #
+##variable
 #   CPACK_NSIS_MUI_ICON - The icon file (.ico) for the generated
 #   install program.
+##end
 #
+##variable
 #   CPACK_NSIS_MUI_UNIICON - The icon file (.ico) for the generated
 #   uninstall program.
+##end
 #
+##variable
 #   CPACK_PACKAGE_ICON - A branding image that will be displayed inside
 #   the installer.
+##end
 #
+##variable
 #   CPACK_NSIS_EXTRA_INSTALL_COMMANDS - Extra NSIS commands that will
 #   be added to the install Section.
+##end
 #
+##variable
 #   CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS - Extra NSIS commands that will
 #   be added to the uninstall Section.
+##end
 #
+##variable
 #   CPACK_NSIS_COMPRESSOR - The arguments that will be passed to the
 #   NSIS SetCompressor command.
+##end
 #
+##variable
 #   CPACK_NSIS_MODIFY_PATH - If this is set to "ON", then an extra page
 #   will appear in the installer that will allow the user to choose
 #   whether the program directory should be added to the system PATH
 #   variable.
+##end
 #
+##variable
 #   CPACK_NSIS_DISPLAY_NAME - The display name string that appears in
 #   the Windows Add/Remove Program control panel
+##end
 #
+##variable
 #   CPACK_NSIS_PACKAGE_NAME - The title displayed at the top of the
 #   installer.
+##end
 #
+##variable
 #   CPACK_NSIS_INSTALLED_ICON_NAME - A path to the executable that
 #   contains the installer icon.
+##end
 #
+##variable
 #   CPACK_NSIS_HELP_LINK - URL to a web site providing assistance in
 #   installing your application.
+##end
 #
+##variable
 #   CPACK_NSIS_URL_INFO_ABOUT - URL to a web site providing more
 #   information about your application.
+##end
 #
+##variable
 #   CPACK_NSIS_CONTACT - Contact information for questions and comments
 #   about the installation process.
+##end
 #
+##variable
 #   CPACK_NSIS_CREATE_ICONS_EXTRA - Additional NSIS commands for
 #   creating start menu shortcuts.
+##end
 #
+##variable
 #   CPACK_NSIS_DELETE_ICONS_EXTRA -Additional NSIS commands to
 #   uninstall start menu shortcuts.
+##end
 #
+##variable
 #   CPACK_NSIS_EXECUTABLES_DIRECTORY - Creating NSIS start menu links
 #   assumes that they are in 'bin' unless this variable is set.
 #   For example, you would set this to 'exec' if your executables are
 #   in an exec directory.
+##end
 #
+##variable
 #   CPACK_NSIS_MUI_FINISHPAGE_RUN - Specify an executable to add an option
 #   to run on the finish page of the NSIS installer.
+##end
 
 #=============================================================================
 # Copyright 2006-2009 Kitware, Inc.

+ 34 - 0
Modules/CPackPackageMaker.cmake

@@ -0,0 +1,34 @@
+##section Variables specific to CPack PackageMaker generator
+##end
+##module
+# - PackageMaker CPack generator (Mac OS X).
+# The following variable is specific to installers build on Mac OS X
+# using PackageMaker:
+#
+##variable
+#   CPACK_OSX_PACKAGE_VERSION - The version of Mac OS X that the
+#   resulting PackageMaker archive should be compatible
+#   with. Different versions of Mac OS X support different
+#   features. For example, CPack can only build component-based
+#   installers for Mac OS X 10.4 or newer, and can only build
+#   installers that download component son-the-fly for Mac OS X 10.5
+#   or newer. If left blank, this value will be set to the minimum
+#   version of Mac OS X that supports the requested features. Set this
+#   variable to some value (e.g., 10.4) only if you want to guarantee
+#   that your installer will work on that version of Mac OS X, and
+#   don't mind missing extra features available in the installer
+#   shipping with later versions of Mac OS X.
+##end
+
+#=============================================================================
+# Copyright 2006-2012 Kitware, Inc.
+#
+# 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.)

+ 81 - 34
Modules/CPackRPM.cmake

@@ -1,3 +1,6 @@
+##section Variables specific to CPack RPM generator
+##end
+##module
 # - The builtin (binary) CPack RPM generator (Unix only)
 # CPackRPM may be used to create RPM package using CPack.
 # CPackRPM is a CPack generator thus it uses the CPACK_XXX variables
@@ -15,52 +18,67 @@
 # You'll find a detailed usage of CPackRPM on the wiki:
 #  http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
 # However as a handy reminder here comes the list of specific variables:
+##end
 #
-#  CPACK_RPM_PACKAGE_SUMMARY
+##variable
+#  CPACK_RPM_PACKAGE_SUMMARY - The RPM package summary.
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_DESCRIPTION_SUMMARY
-#     The RPM package summary
-#  CPACK_RPM_PACKAGE_NAME
+##end
+##variable
+#  CPACK_RPM_PACKAGE_NAME - The RPM package name.
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_NAME
-#     The RPM package name
-#  CPACK_RPM_PACKAGE_VERSION
+##end
+##variable
+#  CPACK_RPM_PACKAGE_VERSION - The RPM package version.
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_VERSION
-#     The RPM package version
-#  CPACK_RPM_PACKAGE_ARCHITECTURE
+##end
+##variable
+#  CPACK_RPM_PACKAGE_ARCHITECTURE - The RPM package architecture.
 #     Mandatory : NO
 #     Default   : -
-#     The RPM package architecture. This may be set to "noarch" if you
+#     This may be set to "noarch" if you
 #     know you are building a noarch package.
-#  CPACK_RPM_PACKAGE_RELEASE
+##end
+##variable
+#  CPACK_RPM_PACKAGE_RELEASE - The RPM package release.
 #     Mandatory : YES
 #     Default   : 1
-#     The RPM package release. This is the numbering of the RPM package
+#     This is the numbering of the RPM package
 #     itself, i.e. the version of the packaging and not the version of the
 #     content (see CPACK_RPM_PACKAGE_VERSION). One may change the default
 #     value if the previous packaging was buggy and/or you want to put here
 #     a fancy Linux distro specific numbering.
-#  CPACK_RPM_PACKAGE_LICENSE
+##end
+##variable
+#  CPACK_RPM_PACKAGE_LICENSE - The RPM package license policy.
 #     Mandatory : YES
 #     Default   : "unknown"
-#     The RPM package license policy.
-#  CPACK_RPM_PACKAGE_GROUP
+##end
+##variable
+#  CPACK_RPM_PACKAGE_GROUP - The RPM package group.
 #     Mandatory : YES
 #     Default   : "unknown"
-#     The RPM package group.
-#  CPACK_RPM_PACKAGE_VENDOR
+##end
+##variable
+#  CPACK_RPM_PACKAGE_VENDOR - The RPM package vendor.
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_VENDOR if set or "unknown"
-#     The RPM package vendor.
-#  CPACK_RPM_PACKAGE_URL
+##end
+##variable
+#  CPACK_RPM_PACKAGE_URL - The projects URL.
 #     Mandatory : NO
 #     Default   : -
-#     The projects URL.
-#  CPACK_RPM_PACKAGE_DESCRIPTION
+##end
+##variable
+#  CPACK_RPM_PACKAGE_DESCRIPTION - RPM package description.
 #     Mandatory : YES
 #     Default   : CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package description available"
-#  CPACK_RPM_COMPRESSION_TYPE
+##end
+##variable
+#  CPACK_RPM_COMPRESSION_TYPE - RPM compression type.
 #     Mandatory : NO
 #     Default   : -
 #     May be used to override RPM compression type to be used
@@ -68,7 +86,9 @@
 #     to lzma or xz compression whereas older cannot use such RPM.
 #     Using this one can enforce compression type to be used.
 #     Possible value are: lzma, xz, bzip2 and gzip.
-#  CPACK_RPM_PACKAGE_REQUIRES
+##end
+##variable
+#  CPACK_RPM_PACKAGE_REQUIRES - RPM spec requires field.
 #     Mandatory : NO
 #     Default   : -
 #     May be used to set RPM dependencies (requires).
@@ -77,22 +97,30 @@
 #     set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
 #     The required package list of an RPM file could be printed with
 #     rpm -qp --requires file.rpm
-#  CPACK_RPM_PACKAGE_SUGGESTS
+##end
+##variable
+#  CPACK_RPM_PACKAGE_SUGGESTS - RPM spec suggest field.
 #     Mandatory : NO
 #     Default   : -
 #     May be used to set weak RPM dependencies (suggests).
 #     Note that you must enclose the complete requires string between quotes.
-#  CPACK_RPM_PACKAGE_PROVIDES
+##end
+##variable
+#  CPACK_RPM_PACKAGE_PROVIDES - RPM spec provides field.
 #     Mandatory : NO
 #     Default   : -
 #     May be used to set RPM dependencies (provides).
 #     The provided package list of an RPM file could be printed with
 #     rpm -qp --provides file.rpm
-#  CPACK_RPM_PACKAGE_OBSOLETES
+##end
+##variable
+#  CPACK_RPM_PACKAGE_OBSOLETES - RPM spec obsoletes field.
 #     Mandatory : NO
 #     Default   : -
 #     May be used to set RPM packages that are obsoleted by this one.
-#  CPACK_RPM_PACKAGE_RELOCATABLE
+##end
+##variable
+#  CPACK_RPM_PACKAGE_RELOCATABLE - build a relocatable RPM.
 #     Mandatory : NO
 #     Default   : CPACK_PACKAGE_RELOCATABLE
 #     If this variable is set to TRUE or ON CPackRPM will try
@@ -103,7 +131,9 @@
 #     If CPACK_SET_DESTDIR is set then you will get a warning message
 #     but if there is file installed with absolute path you'll get
 #     unexpected behavior.
-#  CPACK_RPM_SPEC_INSTALL_POST [deprecated]
+##end
+##variable
+#  CPACK_RPM_SPEC_INSTALL_POST - [deprecated].
 #     Mandatory : NO
 #     Default   : -
 #     This way of specifying post-install script is deprecated use
@@ -111,23 +141,31 @@
 #     May be used to set an RPM post-install command inside the spec file.
 #     For example setting it to "/bin/true" may be used to prevent
 #     rpmbuild to strip binaries.
-#  CPACK_RPM_SPEC_MORE_DEFINE
+##end
+##variable
+#  CPACK_RPM_SPEC_MORE_DEFINE - RPM extended spec definitions lines.
 #     Mandatory : NO
 #     Default   : -
 #     May be used to add any %define lines to the generated spec file.
-#  CPACK_RPM_PACKAGE_DEBUG
+##end
+##variable
+#  CPACK_RPM_PACKAGE_DEBUG - Toggle CPackRPM debug output.
 #     Mandatory : NO
 #     Default   : -
 #     May be set when invoking cpack in order to trace debug information
 #     during CPack RPM run. For example you may launch CPack like this
 #     cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
-#  CPACK_RPM_USER_BINARY_SPECFILE
+##end
+##variable
+#  CPACK_RPM_USER_BINARY_SPECFILE - A user provided spec file.
 #     Mandatory : NO
 #     Default   : -
 #     May be set by the user in order to specify a USER binary spec file
 #     to be used by CPackRPM instead of generating the file.
 #     The specified file will be processed by CONFIGURE_FILE( @ONLY).
-#  CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
+##end
+##variable
+#  CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE - Spec file template.
 #     Mandatory : NO
 #     Default   : -
 #     If set CPack will generate a template for USER specified binary
@@ -135,6 +173,8 @@
 #     cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM
 #     The user may then use this file in order to hand-craft is own
 #     binary spec file which may be used with CPACK_RPM_USER_BINARY_SPECFILE.
+##end
+##variable
 #  CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
 #  CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
 #     Mandatory : NO
@@ -143,11 +183,13 @@
 #     The refered script file(s) will be read and directly
 #     put after the %pre or %preun section
 #     If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for
-#     each component can be overriden with
+#     each component can be overridden with
 #     CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE and
 #     CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE
 #     One may verify which scriptlet has been included with
 #      rpm -qp --scripts  package.rpm
+##end
+##variable
 #  CPACK_RPM_POST_INSTALL_SCRIPT_FILE
 #  CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
 #     Mandatory : NO
@@ -156,26 +198,31 @@
 #     The refered script file(s) will be read and directly
 #     put after the %post or %postun section
 #     If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for
-#     each component can be overriden with
+#     each component can be overridden with
 #     CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE and
 #     CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE
 #     One may verify which scriptlet has been included with
 #      rpm -qp --scripts  package.rpm
+##end
+##variable
 #  CPACK_RPM_USER_FILELIST
 #  CPACK_RPM_<COMPONENT>_USER_FILELIST
 #     Mandatory : NO
 #     Default   : -
-#     May be used to explicitely specify %(<directive>) file line
+#     May be used to explicitly specify %(<directive>) file line
 #     in the spec file. Like %config(noreplace) or any other directive
 #     that be found in the %files section. Since CPackRPM is generating
 #     the list of files (and directories) the user specified files of
 #     the CPACK_RPM_<COMPONENT>_USER_FILELIST list will be removed from the generated list.
-#  CPACK_RPM_CHANGELOG_FILE
+##end
+##variable
+#  CPACK_RPM_CHANGELOG_FILE - RPM changelog file.
 #     Mandatory : NO
 #     Default   : -
 #     May be used to embed a changelog in the spec file.
 #     The refered file will be read and directly put after the %changelog
 #     section.
+##end
 
 #=============================================================================
 # Copyright 2007-2009 Kitware, Inc.

+ 2 - 0
Modules/CheckCCompilerFlag.cmake

@@ -9,6 +9,7 @@
 #=============================================================================
 # Copyright 2006-2011 Kitware, Inc.
 # Copyright 2006 Alexander Neundorf <[email protected]>
+# Copyright 2011 Matthias Kretz <[email protected]>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -35,6 +36,7 @@ MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
      FAIL_REGEX "[Uu]nknown option"                         # HP
      FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
      FAIL_REGEX "command option .* is not recognized"       # XL
+     FAIL_REGEX "WARNING: unknown flag:"                    # Open64
      )
    SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
 ENDMACRO (CHECK_C_COMPILER_FLAG)

+ 6 - 1
Modules/CheckCSourceCompiles.cmake

@@ -24,6 +24,9 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 MACRO(CHECK_C_SOURCE_COMPILES SOURCE VAR)
   IF("${VAR}" MATCHES "^${VAR}$")
     SET(_FAIL_REGEX)
@@ -40,8 +43,10 @@ MACRO(CHECK_C_SOURCE_COMPILES SOURCE VAR)
     SET(MACRO_CHECK_FUNCTION_DEFINITIONS
       "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
     IF(CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     ELSE(CMAKE_REQUIRED_LIBRARIES)
       SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
     ENDIF(CMAKE_REQUIRED_LIBRARIES)

+ 9 - 4
Modules/CheckCSourceRuns.cmake

@@ -24,13 +24,18 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 MACRO(CHECK_C_SOURCE_RUNS SOURCE VAR)
   IF("${VAR}" MATCHES "^${VAR}$")
-    SET(MACRO_CHECK_FUNCTION_DEFINITIONS 
+    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
       "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
     IF(CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     ELSE(CMAKE_REQUIRED_LIBRARIES)
       SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
     ENDIF(CMAKE_REQUIRED_LIBRARIES)
@@ -61,7 +66,7 @@ MACRO(CHECK_C_SOURCE_RUNS SOURCE VAR)
     IF("${${VAR}_EXITCODE}" EQUAL 0)
       SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
       MESSAGE(STATUS "Performing Test ${VAR} - Success")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
         "${OUTPUT}\n"
         "Return value: ${${VAR}}\n"
@@ -74,7 +79,7 @@ MACRO(CHECK_C_SOURCE_RUNS SOURCE VAR)
       ENDIF(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN")
 
       MESSAGE(STATUS "Performing Test ${VAR} - Failed")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
         "${OUTPUT}\n"
         "Return value: ${${VAR}_EXITCODE}\n"

+ 3 - 0
Modules/CheckCXXCompilerFlag.cmake

@@ -9,6 +9,7 @@
 #=============================================================================
 # Copyright 2006-2010 Kitware, Inc.
 # Copyright 2006 Alexander Neundorf <[email protected]>
+# Copyright 2011 Matthias Kretz <[email protected]>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -27,6 +28,7 @@ MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
    SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
    CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
      # Some compilers do not fail with a bad flag
+     FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU
      FAIL_REGEX "unrecognized .*option"                     # GNU
      FAIL_REGEX "unknown .*option"                          # Clang
      FAIL_REGEX "ignoring unknown option"                   # MSVC
@@ -36,6 +38,7 @@ MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
      FAIL_REGEX "command option .* is not recognized"       # XL
      FAIL_REGEX "not supported in this configuration; ignored"       # AIX
      FAIL_REGEX "File with unknown suffix passed to linker" # PGI
+     FAIL_REGEX "WARNING: unknown flag:"                    # Open64
      )
    SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
 ENDMACRO (CHECK_CXX_COMPILER_FLAG)

+ 6 - 1
Modules/CheckCXXSourceCompiles.cmake

@@ -24,6 +24,9 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 MACRO(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
   IF("${VAR}" MATCHES "^${VAR}$")
     SET(_FAIL_REGEX)
@@ -41,8 +44,10 @@ MACRO(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
     SET(MACRO_CHECK_FUNCTION_DEFINITIONS
       "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
     IF(CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     ELSE(CMAKE_REQUIRED_LIBRARIES)
       SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES)
     ENDIF(CMAKE_REQUIRED_LIBRARIES)

+ 11 - 6
Modules/CheckCXXSourceRuns.cmake

@@ -24,13 +24,18 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 MACRO(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
   IF("${VAR}" MATCHES "^${VAR}$")
-    SET(MACRO_CHECK_FUNCTION_DEFINITIONS 
+    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
       "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
     IF(CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     ELSE(CMAKE_REQUIRED_LIBRARIES)
       SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES)
     ENDIF(CMAKE_REQUIRED_LIBRARIES)
@@ -62,9 +67,9 @@ MACRO(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
     IF("${${VAR}_EXITCODE}" EQUAL 0)
       SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
       MESSAGE(STATUS "Performing Test ${VAR} - Success")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n"
-        "${OUTPUT}\n" 
+        "${OUTPUT}\n"
         "Return value: ${${VAR}}\n"
         "Source file was:\n${SOURCE}\n")
     ELSE("${${VAR}_EXITCODE}" EQUAL 0)
@@ -75,9 +80,9 @@ MACRO(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
       ENDIF(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES  "FAILED_TO_RUN")
 
       MESSAGE(STATUS "Performing Test ${VAR} - Failed")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n"
-        "${OUTPUT}\n"  
+        "${OUTPUT}\n"
         "Return value: ${${VAR}_EXITCODE}\n"
         "Source file was:\n${SOURCE}\n")
     ENDIF("${${VAR}_EXITCODE}" EQUAL 0)

+ 8 - 3
Modules/CheckFortranFunctionExists.cmake

@@ -22,12 +22,17 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
   if(NOT DEFINED ${VARIABLE})
     message(STATUS "Looking for Fortran ${FUNCTION}")
     if(CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      cmake_expand_imported_targets(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     else(CMAKE_REQUIRED_LIBRARIES)
       set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
     endif(CMAKE_REQUIRED_LIBRARIES)
@@ -50,13 +55,13 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
     if(${VARIABLE})
       set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}")
       message(STATUS "Looking for Fortran ${FUNCTION} - found")
-      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n"
         "${OUTPUT}\n\n")
     else(${VARIABLE})
       message(STATUS "Looking for Fortran ${FUNCTION} - not found")
       set(${VARIABLE} "" CACHE INTERNAL "Have Fortran function ${FUNCTION}")
-      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n"
         "${OUTPUT}\n\n")
     endif(${VARIABLE})

+ 9 - 4
Modules/CheckFunctionExists.cmake

@@ -27,14 +27,19 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 MACRO(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
   IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
-    SET(MACRO_CHECK_FUNCTION_DEFINITIONS 
+    SET(MACRO_CHECK_FUNCTION_DEFINITIONS
       "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
     MESSAGE(STATUS "Looking for ${FUNCTION}")
     IF(CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     ELSE(CMAKE_REQUIRED_LIBRARIES)
       SET(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES)
     ENDIF(CMAKE_REQUIRED_LIBRARIES)
@@ -55,13 +60,13 @@ MACRO(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
     IF(${VARIABLE})
       SET(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
       MESSAGE(STATUS "Looking for ${FUNCTION} - found")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the function ${FUNCTION} exists passed with the following output:\n"
         "${OUTPUT}\n\n")
     ELSE(${VARIABLE})
       MESSAGE(STATUS "Looking for ${FUNCTION} - not found")
       SET(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the function ${FUNCTION} exists failed with the following output:\n"
         "${OUTPUT}\n\n")
     ENDIF(${VARIABLE})

+ 5 - 5
Modules/CheckIncludeFiles.cmake

@@ -44,7 +44,7 @@ MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
     CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
       "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c" @ONLY IMMEDIATE)
 
-    MESSAGE(STATUS "Looking for include files ${VARIABLE}")
+    MESSAGE(STATUS "Looking for include files ${INCLUDE}")
     TRY_COMPILE(${VARIABLE}
       ${CMAKE_BINARY_DIR}
       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c
@@ -54,15 +54,15 @@ MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
       "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}"
       OUTPUT_VARIABLE OUTPUT)
     IF(${VARIABLE})
-      MESSAGE(STATUS "Looking for include files ${VARIABLE} - found")
-      SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${VARIABLE}")
+      MESSAGE(STATUS "Looking for include files ${INCLUDE} - found")
+      SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
       FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
         "Determining if files ${INCLUDE} "
         "exist passed with the following output:\n"
         "${OUTPUT}\n\n")
     ELSE(${VARIABLE})
-      MESSAGE(STATUS "Looking for include files ${VARIABLE} - not found.")
-      SET(${VARIABLE} "" CACHE INTERNAL "Have includes ${VARIABLE}")
+      MESSAGE(STATUS "Looking for include files ${INCLUDE} - not found.")
+      SET(${VARIABLE} "" CACHE INTERNAL "Have includes ${INCLUDE}")
       FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
         "Determining if files ${INCLUDE} "
         "exist failed with the following output:\n"

+ 65 - 0
Modules/CheckLanguage.cmake

@@ -0,0 +1,65 @@
+# - Check if a language can be enabled
+# Usage:
+#  check_language(<lang>)
+# where <lang> is a language that may be passed to enable_language()
+# such as "Fortran".  If CMAKE_<lang>_COMPILER is already defined the
+# check does nothing.  Otherwise it tries enabling the language in a
+# test project.  The result is cached in CMAKE_<lang>_COMPILER as the
+# compiler that was found, or NOTFOUND if the language cannot be enabled.
+#
+# Example:
+#  check_language(Fortran)
+#  if(CMAKE_Fortran_COMPILER)
+#    enable_language(Fortran)
+#  else()
+#    message(STATUS "No Fortran support")
+#  endif()
+
+#=============================================================================
+# Copyright 2009-2012 Kitware, Inc.
+#
+# 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.)
+
+macro(check_language lang)
+  if(NOT DEFINED CMAKE_${lang}_COMPILER)
+    set(_desc "Looking for a ${lang} compiler")
+    message(STATUS ${_desc})
+    file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang})
+    file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt"
+      "cmake_minimum_required(VERSION 2.8)
+project(Check${lang} ${lang})
+file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
+  \"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\"
+  )
+")
+    execute_process(
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}
+      COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR}
+      OUTPUT_VARIABLE output
+      ERROR_VARIABLE output
+      RESULT_VARIABLE result
+      )
+    include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/result.cmake OPTIONAL)
+    if(CMAKE_${lang}_COMPILER AND "${result}" STREQUAL "0")
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+        "${_desc} passed with the following output:\n"
+        "${output}\n")
+    else()
+      set(CMAKE_${lang}_COMPILER NOTFOUND)
+      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+        "${_desc} failed with the following output:\n"
+        "${output}\n")
+    endif()
+    message(STATUS "${_desc} - ${CMAKE_${lang}_COMPILER}")
+    set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE FILEPATH "${lang} compiler")
+    mark_as_advanced(CMAKE_${lang}_COMPILER)
+  endif()
+endmacro()

+ 11 - 6
Modules/CheckLibraryExists.cmake

@@ -26,21 +26,26 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 MACRO(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
   IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
-    SET(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION 
+    SET(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
       "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
     MESSAGE(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
     SET(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
     IF(CMAKE_REQUIRED_LIBRARIES)
-      SET(CHECK_LIBRARY_EXISTS_LIBRARIES 
-        ${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
+      # this one translates potentially used imported library targets to their files on disk
+      CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
+      SET(CHECK_LIBRARY_EXISTS_LIBRARIES
+        ${CHECK_LIBRARY_EXISTS_LIBRARIES} ${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES})
     ENDIF(CMAKE_REQUIRED_LIBRARIES)
     TRY_COMPILE(${VARIABLE}
       ${CMAKE_BINARY_DIR}
       ${CMAKE_ROOT}/Modules/CheckFunctionExists.c
       COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
-      CMAKE_FLAGS 
+      CMAKE_FLAGS
       -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
       -DLINK_DIRECTORIES:STRING=${LOCATION}
       "-DLINK_LIBRARIES:STRING=${CHECK_LIBRARY_EXISTS_LIBRARIES}"
@@ -49,14 +54,14 @@ MACRO(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
     IF(${VARIABLE})
       MESSAGE(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
       SET(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
         "passed with the following output:\n"
         "${OUTPUT}\n\n")
     ELSE(${VARIABLE})
       MESSAGE(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
       SET(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
         "failed with the following output:\n"
         "${OUTPUT}\n\n")

+ 6 - 1
Modules/CheckPrototypeDefinition.cmake

@@ -34,8 +34,11 @@
 #  License text for the above reference.)
 #
 
+include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
 get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
 
+
 function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
 
   if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
@@ -43,8 +46,10 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB
 
     set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
     if (CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      cmake_expand_imported_targets(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       set(CHECK_PROTOTYPE_DEFINITION_LIBS
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     else(CMAKE_REQUIRED_LIBRARIES)
       set(CHECK_PROTOTYPE_DEFINITION_LIBS)
     endif(CMAKE_REQUIRED_LIBRARIES)

+ 6 - 1
Modules/CheckSymbolExists.cmake

@@ -35,6 +35,9 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 MACRO(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
   _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
 ENDMACRO(CHECK_SYMBOL_EXISTS)
@@ -44,8 +47,10 @@ MACRO(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
     SET(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
     SET(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
     IF(CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       SET(CHECK_SYMBOL_EXISTS_LIBS
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     ELSE(CMAKE_REQUIRED_LIBRARIES)
       SET(CHECK_SYMBOL_EXISTS_LIBS)
     ENDIF(CMAKE_REQUIRED_LIBRARIES)

+ 6 - 1
Modules/CheckTypeSize.cmake

@@ -47,6 +47,7 @@
 #  License text for the above reference.)
 
 include(CheckIncludeFile)
+include("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
 
 cmake_policy(PUSH)
 cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
@@ -76,6 +77,10 @@ function(__check_type_size_impl type var map builtin)
   endforeach()
 
   # Perform the check.
+
+  # this one translates potentially used imported library targets to their files on disk
+  cmake_expand_imported_targets(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
+
   set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c)
   set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin)
   configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY)
@@ -84,7 +89,7 @@ function(__check_type_size_impl type var map builtin)
     CMAKE_FLAGS
       "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}"
       "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}"
-      "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}"
+      "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}"
     OUTPUT_VARIABLE output
     COPY_FILE ${bin}
     )

+ 10 - 5
Modules/CheckVariableExists.cmake

@@ -1,6 +1,6 @@
 # - Check if the variable exists.
 #  CHECK_VARIABLE_EXISTS(VAR VARIABLE)
-#  
+#
 #  VAR      - the name of the variable
 #  VARIABLE - variable to store the result
 #
@@ -26,14 +26,19 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/CMakeExpandImportedTargets.cmake")
+
+
 MACRO(CHECK_VARIABLE_EXISTS VAR VARIABLE)
   IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
-    SET(MACRO_CHECK_VARIABLE_DEFINITIONS 
+    SET(MACRO_CHECK_VARIABLE_DEFINITIONS
       "-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}")
     MESSAGE(STATUS "Looking for ${VAR}")
     IF(CMAKE_REQUIRED_LIBRARIES)
+      # this one translates potentially used imported library targets to their files on disk
+      CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES  LIBRARIES  ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
       SET(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES
-        "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
+        "-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
     ELSE(CMAKE_REQUIRED_LIBRARIES)
       SET(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES)
     ENDIF(CMAKE_REQUIRED_LIBRARIES)
@@ -47,13 +52,13 @@ MACRO(CHECK_VARIABLE_EXISTS VAR VARIABLE)
     IF(${VARIABLE})
       SET(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}")
       MESSAGE(STATUS "Looking for ${VAR} - found")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the variable ${VAR} exists passed with the following output:\n"
         "${OUTPUT}\n\n")
     ELSE(${VARIABLE})
       SET(${VARIABLE} "" CACHE INTERNAL "Have variable ${VAR}")
       MESSAGE(STATUS "Looking for ${VAR} - not found")
-      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log 
+      FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the variable ${VAR} exists failed with the following output:\n"
         "${OUTPUT}\n\n")
     ENDIF(${VARIABLE})

+ 1 - 1
Modules/FeatureSummary.cmake

@@ -125,7 +125,7 @@
 #
 #   set_package_properties(LibXml2 PROPERTIES TYPE RECOMMENDED
 #                                             PURPOSE "Enables HTML-import in MyWordProcessor")
-# ...
+#   ...
 #   set_package_properties(LibXml2 PROPERTIES TYPE OPTIONAL
 #                                             PURPOSE "Enables odt-export in MyWordProcessor")
 #

+ 5 - 6
Modules/FindALSA.cmake

@@ -12,8 +12,8 @@
 #
 
 #=============================================================================
-# Copyright 2009 Kitware, Inc.
-# Copyright 2009 Philip Lowman <[email protected]>
+# Copyright 2009-2011 Kitware, Inc.
+# Copyright 2009-2011 Philip Lowman <[email protected]>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -25,8 +25,7 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
-find_path(ALSA_INCLUDE_DIR NAMES asoundlib.h
-          PATH_SUFFIXES alsa
+find_path(ALSA_INCLUDE_DIR NAMES alsa/asoundlib.h
           DOC "The ALSA (asound) include directory"
 )
 
@@ -34,8 +33,8 @@ find_library(ALSA_LIBRARY NAMES asound
           DOC "The ALSA (asound) library"
 )
 
-if(ALSA_INCLUDE_DIR AND EXISTS "${ALSA_INCLUDE_DIR}/version.h")
-  file(STRINGS "${ALSA_INCLUDE_DIR}/version.h" alsa_version_str REGEX "^#define[\t ]+SND_LIB_VERSION_STR[\t ]+\".*\"")
+if(ALSA_INCLUDE_DIR AND EXISTS "${ALSA_INCLUDE_DIR}/alsa/version.h")
+  file(STRINGS "${ALSA_INCLUDE_DIR}/alsa/version.h" alsa_version_str REGEX "^#define[\t ]+SND_LIB_VERSION_STR[\t ]+\".*\"")
 
   string(REGEX REPLACE "^.*SND_LIB_VERSION_STR[\t ]+\"([^\"]*)\".*$" "\\1" ALSA_VERSION_STRING "${alsa_version_str}")
   unset(alsa_version_str)

+ 94 - 110
Modules/FindBLAS.cmake

@@ -23,6 +23,7 @@
 ##########
 ### List of vendors (BLA_VENDOR) valid in this module
 ##  Goto,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model),
+##  Intel10_64lp_seq (intel mkl v10 64 bit,sequential code, lp64 model),
 ##  Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,ACML_GPU,Apple, NAS, Generic
 # C/CXX should be enabled to use Intel mkl
 
@@ -85,6 +86,7 @@ if (NOT _libdir)
     set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH)
   endif ()
 endif ()
+
 foreach(_library ${_list})
   set(_combined_name ${_combined_name}_${_library})
 
@@ -115,7 +117,7 @@ foreach(_library ${_list})
 endforeach(_library ${_list})
 if(_libraries_work)
   # Test this combination of libraries.
-  set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threads})
+  set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread})
 #  message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
   if (_CHECK_FORTRAN)
     check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
@@ -460,117 +462,99 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
   else(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
     find_package(Threads REQUIRED)
   endif(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
-  if (WIN32)
+
+  set(BLAS_SEARCH_LIBS "")
+
   if(BLA_F95)
-    if(NOT BLAS95_LIBRARIES)
-    check_fortran_libraries(
-    BLAS95_LIBRARIES
-    BLAS
-    sgemm
-    ""
-    "mkl_blas95;mkl_intel_c;mkl_intel_thread;mkl_core;libguide40"
-    ""
-    )
-    endif(NOT BLAS95_LIBRARIES)
-  else(BLA_F95)
-    if(NOT BLAS_LIBRARIES)
-    check_fortran_libraries(
-    BLAS_LIBRARIES
-    BLAS
-    SGEMM
-    ""
-    "mkl_c_dll;mkl_intel_thread_dll;mkl_core_dll;libguide40"
-    ""
-    )
-    endif(NOT BLAS_LIBRARIES)
-  endif(BLA_F95)
-  else(WIN32)
-  if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
-    if(BLA_F95)
-      if(NOT BLAS95_LIBRARIES)
-      check_fortran_libraries(
-      BLAS95_LIBRARIES
-      BLAS
-      sgemm
-      ""
-      "mkl_blas95;mkl_intel;mkl_intel_thread;mkl_core;guide"
-      "${CMAKE_THREAD_LIBS_INIT};${LM}"
-      )
-      endif(NOT BLAS95_LIBRARIES)
-    else(BLA_F95)
-    if(NOT BLAS_LIBRARIES)
-      check_fortran_libraries(
-      BLAS_LIBRARIES
-      BLAS
-      sgemm
-      ""
-      "mkl_intel;mkl_intel_thread;mkl_core;guide"
-      "${CMAKE_THREAD_LIBS_INIT}"
-      "${LM}"
-      )
-      endif(NOT BLAS_LIBRARIES)
-    endif(BLA_F95)
-  endif (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
-  if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
-   if(BLA_F95)
-    if(NOT BLAS95_LIBRARIES)
-      check_fortran_libraries(
-      BLAS95_LIBRARIES
-      BLAS
-      sgemm
-      ""
-      "mkl_blas95;mkl_intel_lp64;mkl_intel_thread;mkl_core;guide"
-      "${CMAKE_THREAD_LIBS_INIT};${LM}"
-      )
-    endif(NOT BLAS95_LIBRARIES)
-   else(BLA_F95)
-     if(NOT BLAS_LIBRARIES)
+    set(BLAS_mkl_SEARCH_SYMBOL SGEMM)
+    set(_LIBRARIES BLAS95_LIBRARIES)
+    if (WIN32)
+      list(APPEND BLAS_SEARCH_LIBS
+        "mkl_blas95 mkl_intel_c mkl_intel_thread mkl_core libguide40")
+    else (WIN32)
+      if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
+        list(APPEND BLAS_SEARCH_LIBS
+          "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide")
+      endif ()
+      if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
+        # old version
+        list(APPEND BLAS_SEARCH_LIBS
+          "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide")
+
+        # mkl >= 10.3
+        if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
+          list(APPEND BLAS_SEARCH_LIBS
+            "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core")
+          set(LM "${LM};-lgomp")
+        else ()
+          list(APPEND BLAS_SEARCH_LIBS
+            "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
+        endif ()
+      endif ()
+    endif (WIN32)
+    if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
+      list(APPEND BLAS_SEARCH_LIBS
+        "mkl_blas95_lp64 mkl_intel_lp64 mkl_sequential mkl_core")
+    endif ()
+  else (BLA_F95)
+    set(BLAS_mkl_SEARCH_SYMBOL sgemm)
+    set(_LIBRARIES BLAS_LIBRARIES)
+    if (WIN32)
+      list(APPEND BLAS_SEARCH_LIBS
+        "mkl_c_dll mkl_intel_thread_dll mkl_core_dll libguide40")
+    else (WIN32)
+      if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
+        list(APPEND BLAS_SEARCH_LIBS
+          "mkl_intel mkl_intel_thread mkl_core guide")
+      endif ()
+      if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
+
+        # old version
+        list(APPEND BLAS_SEARCH_LIBS
+          "mkl_intel_lp64 mkl_intel_thread mkl_core guide")
+
+        # mkl >= 10.3
+        if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
+          list(APPEND BLAS_SEARCH_LIBS
+            "mkl_intel_lp64 mkl_gnu_thread mkl_core")
+          set(LM "${LM};-lgomp")
+        else ()
+          list(APPEND BLAS_SEARCH_LIBS
+            "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
+        endif ()
+      endif ()
+
+      #older vesions of intel mkl libs
+      if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All")
+        list(APPEND BLAS_SEARCH_LIBS
+          "mkl")
+        list(APPEND BLAS_SEARCH_LIBS
+          "mkl_ia32")
+        list(APPEND BLAS_SEARCH_LIBS
+          "mkl_em64t")
+      endif ()
+    endif (WIN32)
+    if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
+      list(APPEND BLAS_SEARCH_LIBS
+        "mkl_intel_lp64 mkl_sequential mkl_core")
+    endif ()
+  endif (BLA_F95)
+
+  foreach (IT ${BLAS_SEARCH_LIBS})
+    string(REPLACE " " ";" SEARCH_LIBS ${IT})
+    if (${_LIBRARIES})
+    else ()
       check_fortran_libraries(
-      BLAS_LIBRARIES
-      BLAS
-      sgemm
-      ""
-      "mkl_intel_lp64;mkl_intel_thread;mkl_core;guide"
-      "${CMAKE_THREAD_LIBS_INIT};${LM}"
-      )
-     endif(NOT BLAS_LIBRARIES)
-   endif(BLA_F95)
-  endif (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
-  endif (WIN32)
-  #older vesions of intel mkl libs
-  # BLAS in intel mkl library? (shared)
-  if(NOT BLAS_LIBRARIES)
-    check_fortran_libraries(
-    BLAS_LIBRARIES
-    BLAS
-    sgemm
-    ""
-    "mkl;guide"
-    "${CMAKE_THREAD_LIBS_INIT};${LM}"
-    )
-  endif(NOT BLAS_LIBRARIES)
-  #BLAS in intel mkl library? (static, 32bit)
-  if(NOT BLAS_LIBRARIES)
-    check_fortran_libraries(
-    BLAS_LIBRARIES
-    BLAS
-    sgemm
-    ""
-    "mkl_ia32;guide"
-    "${CMAKE_THREAD_LIBS_INIT};${LM}"
-    )
-  endif(NOT BLAS_LIBRARIES)
-  #BLAS in intel mkl library? (static, em64t 64bit)
-  if(NOT BLAS_LIBRARIES)
-    check_fortran_libraries(
-    BLAS_LIBRARIES
-    BLAS
-    sgemm
-    ""
-    "mkl_em64t;guide"
-    "${CMAKE_THREAD_LIBS_INIT};${LM}"
-    )
-  endif(NOT BLAS_LIBRARIES)
+        ${_LIBRARIES}
+        BLAS
+        ${BLAS_mkl_SEARCH_SYMBOL}
+        ""
+        "${SEARCH_LIBS}"
+        "${CMAKE_THREAD_LIBS_INIT};${LM}"
+        )
+    endif ()
+  endforeach ()
+
  endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
 endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
 

+ 1 - 1
Modules/FindCUDA.cmake

@@ -906,7 +906,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
     message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS: '${format}'.  Use OBJ or PTX.")
   endif()
 
-  # Set up all the command line flags here, so that they can be overriden on a per target basis.
+  # Set up all the command line flags here, so that they can be overridden on a per target basis.
 
   set(nvcc_flags "")
 

+ 26 - 2
Modules/FindFreetype.cmake

@@ -3,6 +3,7 @@
 #  FREETYPE_LIBRARIES, the library to link against
 #  FREETYPE_FOUND, if false, do not try to link to FREETYPE
 #  FREETYPE_INCLUDE_DIRS, where to find headers.
+#  FREETYPE_VERSION_STRING, the version of freetype found (since CMake 2.8.8)
 #  This is the concatenation of the paths:
 #  FREETYPE_INCLUDE_DIR_ft2build
 #  FREETYPE_INCLUDE_DIR_freetype2
@@ -77,10 +78,33 @@ IF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
 ENDIF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
 SET(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}")
 
+IF(FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
+    FILE(STRINGS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h" freetype_version_str
+         REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
+
+    UNSET(FREETYPE_VERSION_STRING)
+    FOREACH(VPART MAJOR MINOR PATCH)
+        FOREACH(VLINE ${freetype_version_str})
+            IF(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}")
+                STRING(REGEX REPLACE "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$" "\\1"
+                       FREETYPE_VERSION_PART "${VLINE}")
+                IF(FREETYPE_VERSION_STRING)
+                    SET(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}")
+                ELSE(FREETYPE_VERSION_STRING)
+                    SET(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}")
+                ENDIF(FREETYPE_VERSION_STRING)
+                UNSET(FREETYPE_VERSION_PART)
+            ENDIF()
+        ENDFOREACH(VLINE)
+    ENDFOREACH(VPART)
+ENDIF(FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h")
+
+
 # handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if
 # all listed variables are TRUE
 INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype  DEFAULT_MSG  FREETYPE_LIBRARY  FREETYPE_INCLUDE_DIRS)
-
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype
+                                  REQUIRED_VARS FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS
+                                  VERSION_VAR FREETYPE_VERSION_STRING)
 
 MARK_AS_ADVANCED(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)

+ 16 - 18
Modules/FindGLUT.cmake

@@ -64,25 +64,23 @@ ELSE (WIN32)
   
 ENDIF (WIN32)
 
-SET( GLUT_FOUND "NO" )
-IF(GLUT_INCLUDE_DIR)
-  IF(GLUT_glut_LIBRARY)
-    # Is -lXi and -lXmu required on all platforms that have it?
-    # If not, we need some way to figure out what platform we are on.
-    SET( GLUT_LIBRARIES
-      ${GLUT_glut_LIBRARY}
-      ${GLUT_Xmu_LIBRARY}
-      ${GLUT_Xi_LIBRARY} 
-      ${GLUT_cocoa_LIBRARY}
-      )
-    SET( GLUT_FOUND "YES" )
-    
-    #The following deprecated settings are for backwards compatibility with CMake1.4
-    SET (GLUT_LIBRARY ${GLUT_LIBRARIES})
-    SET (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR})
+INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_glut_LIBRARY GLUT_INCLUDE_DIR)
+
+IF (GLUT_FOUND)
+  # Is -lXi and -lXmu required on all platforms that have it?
+  # If not, we need some way to figure out what platform we are on.
+  SET( GLUT_LIBRARIES
+    ${GLUT_glut_LIBRARY}
+    ${GLUT_Xmu_LIBRARY}
+    ${GLUT_Xi_LIBRARY}
+    ${GLUT_cocoa_LIBRARY}
+    )
     
-  ENDIF(GLUT_glut_LIBRARY)
-ENDIF(GLUT_INCLUDE_DIR)
+  #The following deprecated settings are for backwards compatibility with CMake1.4
+  SET (GLUT_LIBRARY ${GLUT_LIBRARIES})
+  SET (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR})
+ENDIF(GLUT_FOUND)
 
 MARK_AS_ADVANCED(
   GLUT_INCLUDE_DIR

+ 43 - 5
Modules/FindGettext.cmake

@@ -61,6 +61,17 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext
 
 INCLUDE(CMakeParseArguments)
 
+FUNCTION(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name)
+   SET(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}")
+   GET_PROPERTY(currentCounter GLOBAL PROPERTY "${propertyName}")
+   IF(NOT currentCounter)
+      SET(currentCounter 1)
+   ENDIF()
+   SET(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE)
+   MATH(EXPR currentCounter "${currentCounter} + 1")
+   SET_PROPERTY(GLOBAL PROPERTY ${propertyName} ${currentCounter} )
+ENDFUNCTION()
+
 MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg)
    # make it a real variable, so we can modify it here
    SET(_firstPoFile "${_firstPoFileArg}")
@@ -94,7 +105,15 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg)
 
    ENDFOREACH (_currentPoFile )
 
-   ADD_CUSTOM_TARGET(translations ${_addToAll} DEPENDS ${_gmoFiles})
+   IF(NOT TARGET translations)
+      ADD_CUSTOM_TARGET(translations)
+   ENDIF()
+
+  _GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName)
+
+   ADD_CUSTOM_TARGET(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles})
+
+   ADD_DEPENDENCIES(translations ${uniqueTargetName})
 
 ENDMACRO(GETTEXT_CREATE_TRANSLATIONS )
 
@@ -133,11 +152,20 @@ FUNCTION(GETTEXT_PROCESS_POT_FILE _potFile)
       LIST(APPEND _gmoFiles ${_gmoFile})
    ENDFOREACH (_lang )
 
+  IF(NOT TARGET potfiles)
+     ADD_CUSTOM_TARGET(potfiles)
+  ENDIF()
+
+  _GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName)
+
    IF(_parsedArguments_ALL)
-      ADD_CUSTOM_TARGET(potfiles ALL DEPENDS ${_gmoFiles})
+      ADD_CUSTOM_TARGET(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
    ELSE(_parsedArguments_ALL)
-      ADD_CUSTOM_TARGET(potfiles DEPENDS ${_gmoFiles})
+      ADD_CUSTOM_TARGET(${uniqueTargetName} DEPENDS ${_gmoFiles})
    ENDIF(_parsedArguments_ALL)
+
+   ADD_DEPENDENCIES(potfiles ${uniqueTargetName})
+
 ENDFUNCTION(GETTEXT_PROCESS_POT_FILE)
 
 
@@ -165,11 +193,21 @@ FUNCTION(GETTEXT_PROCESS_PO_FILES _lang)
       LIST(APPEND _gmoFiles ${_gmoFile})
    ENDFOREACH(_current_PO_FILE)
 
+
+  IF(NOT TARGET pofiles)
+     ADD_CUSTOM_TARGET(pofiles)
+  ENDIF()
+
+  _GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName)
+
    IF(_parsedArguments_ALL)
-      ADD_CUSTOM_TARGET(pofiles ALL DEPENDS ${_gmoFiles})
+      ADD_CUSTOM_TARGET(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
    ELSE(_parsedArguments_ALL)
-      ADD_CUSTOM_TARGET(pofiles DEPENDS ${_gmoFiles})
+      ADD_CUSTOM_TARGET(${uniqueTargetName} DEPENDS ${_gmoFiles})
    ENDIF(_parsedArguments_ALL)
+
+   ADD_DEPENDENCIES(pofiles ${uniqueTargetName})
+
 ENDFUNCTION(GETTEXT_PROCESS_PO_FILES)
 
 IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE )

+ 1 - 1
Modules/FindImageMagick.cmake

@@ -169,7 +169,7 @@ FOREACH(component ${ImageMagick_FIND_COMPONENTS}
         LIST(APPEND ImageMagick_REQUIRED_VARS ImageMagick_${component}_EXECUTABLE)
       ENDIF(is_requested GREATER -1)
     ELSEIF(ImageMagick_${component}_EXECUTABLE)
-      # if no components were requested explicitely put all (default) executables
+      # if no components were requested explicitly put all (default) executables
       # in the list
       LIST(APPEND ImageMagick_DEFAULT_EXECUTABLES "${ImageMagick_${component}_EXECUTABLE}")
     ENDIF(ImageMagick_FIND_COMPONENTS)

+ 60 - 31
Modules/FindLAPACK.cmake

@@ -219,40 +219,69 @@ if (BLA_VENDOR STREQUAL "Generic" OR
   endif ( NOT LAPACK_LIBRARIES )
 endif ()
 #intel lapack
- if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
+if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
+  if (NOT WIN32)
+    set(LM "-lm")
+  endif ()
   if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
-   if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
+    if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
       find_PACKAGE(Threads)
-   else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
-       find_package(Threads REQUIRED)
-   endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
-   if (BLA_F95)
-    if(NOT LAPACK95_LIBRARIES)
-     check_lapack_libraries(
-     LAPACK95_LIBRARIES
-     LAPACK
-     cheev
-     ""
-     "mkl_lapack95"
-     "${BLAS95_LIBRARIES}"
-     "${CMAKE_THREAD_LIBS_INIT}"
-     )
-    endif(NOT LAPACK95_LIBRARIES)
-   else(BLA_F95)
-    if(NOT LAPACK_LIBRARIES)
-     check_lapack_libraries(
-     LAPACK_LIBRARIES
-     LAPACK
-     cheev
-     ""
-     "mkl_lapack"
-     "${BLAS_LIBRARIES}"
-     "${CMAKE_THREAD_LIBS_INIT}"
-     )
-    endif(NOT LAPACK_LIBRARIES)
-   endif(BLA_F95)
+    else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
+      find_package(Threads REQUIRED)
+    endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
+    if (BLA_F95)
+      if(NOT LAPACK95_LIBRARIES)
+        # old
+        check_lapack_libraries(
+          LAPACK95_LIBRARIES
+          LAPACK
+          cheev
+          ""
+          "mkl_lapack95"
+          "${BLAS95_LIBRARIES}"
+          "${CMAKE_THREAD_LIBS_INIT};${LM}"
+          )
+      endif(NOT LAPACK95_LIBRARIES)
+      if(NOT LAPACK95_LIBRARIES)
+        # new >= 10.3
+        check_lapack_libraries(
+          LAPACK95_LIBRARIES
+          LAPACK
+          CHEEV
+          ""
+          "mkl_intel_lp64"
+          "${BLAS95_LIBRARIES}"
+          "${CMAKE_THREAD_LIBS_INIT};${LM}"
+          )
+      endif(NOT LAPACK95_LIBRARIES)
+    else(BLA_F95)
+      if(NOT LAPACK_LIBRARIES)
+        # old
+        check_lapack_libraries(
+          LAPACK_LIBRARIES
+          LAPACK
+          cheev
+          ""
+          "mkl_lapack"
+          "${BLAS_LIBRARIES}"
+          "${CMAKE_THREAD_LIBS_INIT};${LM}"
+          )
+      endif(NOT LAPACK_LIBRARIES)
+      if(NOT LAPACK_LIBRARIES)
+        # new >= 10.3
+        check_lapack_libraries(
+          LAPACK_LIBRARIES
+          LAPACK
+          cheev
+          ""
+          "mkl_gf_lp64"
+          "${BLAS_LIBRARIES}"
+          "${CMAKE_THREAD_LIBS_INIT};${LM}"
+          )
+      endif(NOT LAPACK_LIBRARIES)
+    endif(BLA_F95)
   endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
- endif(BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
+endif(BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
 else(BLAS_FOUND)
   message(STATUS "LAPACK requires BLAS")
 endif(BLAS_FOUND)

+ 3 - 2
Modules/FindLibArchive.cmake

@@ -54,8 +54,9 @@ endif()
 #  itself includes this FindLibArchive when built with an older CMake that does
 #  not provide it.  The older CMake also does not have CMAKE_CURRENT_LIST_DIR.)
 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
-find_package_handle_standard_args(LibArchive DEFAULT_MSG
-  LibArchive_LIBRARY LibArchive_INCLUDE_DIR
+find_package_handle_standard_args(LibArchive
+                                  REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR
+                                  VERSION_VAR LibArchive_VERSION
   )
 set(LibArchive_FOUND ${LIBARCHIVE_FOUND})
 unset(LIBARCHIVE_FOUND)

+ 15 - 3
Modules/FindLibXslt.cmake

@@ -5,6 +5,7 @@
 #  LIBXSLT_INCLUDE_DIR - the LibXslt include directory
 #  LIBXSLT_LIBRARIES - Link these to LibXslt
 #  LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt
+#  LIBXSLT_VERSION_STRING - version of LibXslt found (since CMake 2.8.8)
 # Additionally, the following two variables are set (but not required for using xslt):
 #  LIBXSLT_EXSLT_LIBRARIES - Link to these if you need to link against the exslt library
 #  LIBXSLT_XSLTPROC_EXECUTABLE - Contains the full path to the xsltproc executable if found
@@ -51,10 +52,21 @@ SET(LIBXSLT_EXSLT_LIBRARIES ${LIBXSLT_EXSLT_LIBRARY} )
 
 FIND_PROGRAM(LIBXSLT_XSLTPROC_EXECUTABLE xsltproc)
 
-# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if
-# all listed variables are TRUE
+IF(PC_LIBXSLT_VERSION)
+    SET(LIBXSLT_VERSION_STRING ${PC_LIBXSLT_VERSION})
+ELSEIF(LIBXSLT_INCLUDE_DIR AND EXISTS "${LIBXSLT_INCLUDE_DIR}/libxslt/xsltconfig.h")
+    FILE(STRINGS "${LIBXSLT_INCLUDE_DIR}/libxslt/xsltconfig.h" libxslt_version_str
+         REGEX "^#define[\t ]+LIBXSLT_DOTTED_VERSION[\t ]+\".*\"")
+
+    STRING(REGEX REPLACE "^#define[\t ]+LIBXSLT_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1"
+           LIBXSLT_VERSION_STRING "${libxslt_version_str}")
+    UNSET(libxslt_version_str)
+ENDIF()
+
 INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt DEFAULT_MSG LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt
+                                  REQUIRED_VARS LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR
+                                  VERSION_VAR LIBXSLT_VERSION_STRING)
 
 MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR
                  LIBXSLT_LIBRARIES

+ 133 - 72
Modules/FindOpenMP.cmake

@@ -1,7 +1,7 @@
 # - Finds OpenMP support
 # This module can be used to detect OpenMP support in a compiler.
 # If the compiler supports OpenMP, the flags required to compile with
-# openmp support are set.  
+# openmp support are set.
 #
 # The following variables are set:
 #   OpenMP_C_FLAGS - flags to add to the C compiler for OpenMP support
@@ -13,6 +13,7 @@
 #=============================================================================
 # Copyright 2009 Kitware, Inc.
 # Copyright 2008-2009 André Rigland Brodtkorb <[email protected]>
+# Copyright 2012 Rolf Eike Beer <[email protected]>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -24,31 +25,59 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
-include(CheckCSourceCompiles)
-include(CheckCXXSourceCompiles)
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-
-set(OpenMP_C_FLAG_CANDIDATES
-  #Gnu
-  "-fopenmp"
-  #Microsoft Visual Studio
-  "/openmp"
-  #Intel windows
-  "-Qopenmp" 
-  #Intel
-  "-openmp" 
-  #Empty, if compiler automatically accepts openmp
-  " "
-  #Sun
-  "-xopenmp"
-  #HP
-  "+Oopenmp"
-  #IBM XL C/c++
-  "-qsmp"
-  #Portland Group
-  "-mp"
-)
-set(OpenMP_CXX_FLAG_CANDIDATES ${OpenMP_C_FLAG_CANDIDATES})
+get_property(_ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
+list(FIND _ENABLED_LANGUAGES "C" _HAVE_LANGUAGE_C)
+list(FIND _ENABLED_LANGUAGES "CXX" _HAVE_LANGUAGE_CXX)
+unset(_ENABLED_LANGUAGES)
+
+set(_OPENMP_REQUIRED_VARS)
+
+function(_OPENMP_FLAG_CANDIDATES LANG)
+  set(OpenMP_FLAG_CANDIDATES
+    #GNU
+    "-fopenmp"
+    #Microsoft Visual Studio
+    "/openmp"
+    #Intel windows
+    "-Qopenmp"
+    #PathScale, Intel
+    "-openmp"
+    #Empty, if compiler automatically accepts openmp
+    " "
+    #Sun
+    "-xopenmp"
+    #HP
+    "+Oopenmp"
+    #IBM XL C/c++
+    "-qsmp"
+    #Portland Group, MIPSpro
+    "-mp"
+  )
+
+  set(OMP_FLAG_GNU "-fopenmp")
+  set(OMP_FLAG_HP "+Oopenmp")
+  if(WIN32)
+    set(OMP_FLAG_Intel "-Qopenmp")
+  else()
+    set(OMP_FLAG_Intel "-openmp")
+  endif()
+  set(OMP_FLAG_MIPSpro "-mp")
+  set(OMP_FLAG_MSVC "/openmp")
+  set(OMP_FLAG_PathScale "-openmp")
+  set(OMP_FLAG_PGI "-mp")
+  set(OMP_FLAG_SunPro "-xopenmp")
+  set(OMP_FLAG_XL "-qsmp")
+
+  # Move the flag that matches the compiler to the head of the list,
+  # this is faster and doesn't clutter the output that much. If that
+  # flag doesn't work we will still try all.
+  if(OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID})
+    list(REMOVE_ITEM OpenMP_FLAG_CANDIDATES "${OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID}}")
+    list(INSERT OpenMP_FLAG_CANDIDATES 0 "${OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID}}")
+  endif()
+
+  set(OpenMP_${LANG}_FLAG_CANDIDATES "${OpenMP_FLAG_CANDIDATES}" PARENT_SCOPE)
+endfunction(_OPENMP_FLAG_CANDIDATES)
 
 # sample openmp source code to test
 set(OpenMP_C_TEST_SOURCE 
@@ -62,53 +91,85 @@ int main() {
 #endif
 }
 ")
-# use the same source for CXX as C for now
-set(OpenMP_CXX_TEST_SOURCE ${OpenMP_C_TEST_SOURCE})
-# if these are set then do not try to find them again,
-# by avoiding any try_compiles for the flags
-if(DEFINED OpenMP_C_FLAGS AND DEFINED OpenMP_CXX_FLAGS)
-  set(OpenMP_C_FLAG_CANDIDATES)
-  set(OpenMP_CXX_FLAG_CANDIDATES)
-endif(DEFINED OpenMP_C_FLAGS AND DEFINED OpenMP_CXX_FLAGS)
 
 # check c compiler
-foreach(FLAG ${OpenMP_C_FLAG_CANDIDATES})
-  set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
-  set(CMAKE_REQUIRED_FLAGS "${FLAG}")
-  unset(OpenMP_FLAG_DETECTED CACHE)
-  message(STATUS "Try OpenMP C flag = [${FLAG}]")
-  check_c_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
-  set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
-  if(OpenMP_FLAG_DETECTED)
-    set(OpenMP_C_FLAGS_INTERNAL "${FLAG}")
-    break()
-  endif(OpenMP_FLAG_DETECTED) 
-endforeach(FLAG ${OpenMP_C_FLAG_CANDIDATES})
+if(NOT _HAVE_LANGUAGE_C EQUAL -1)
+  # if these are set then do not try to find them again,
+  # by avoiding any try_compiles for the flags
+  if(OpenMP_C_FLAGS)
+    unset(OpenMP_C_FLAG_CANDIDATES)
+  else()
+    _OPENMP_FLAG_CANDIDATES("C")
+    include(CheckCSourceCompiles)
+  endif()
+
+  foreach(FLAG ${OpenMP_C_FLAG_CANDIDATES})
+    set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+    set(CMAKE_REQUIRED_FLAGS "${FLAG}")
+    unset(OpenMP_FLAG_DETECTED CACHE)
+    message(STATUS "Try OpenMP C flag = [${FLAG}]")
+    check_c_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
+    set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
+    if(OpenMP_FLAG_DETECTED)
+      set(OpenMP_C_FLAGS_INTERNAL "${FLAG}")
+      break()
+    endif(OpenMP_FLAG_DETECTED)
+  endforeach(FLAG ${OpenMP_C_FLAG_CANDIDATES})
+
+  set(OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}"
+    CACHE STRING "C compiler flags for OpenMP parallization")
+
+  list(APPEND _OPENMP_REQUIRED_VARS OpenMP_C_FLAGS)
+  unset(OpenMP_C_FLAG_CANDIDATES)
+endif()
 
 # check cxx compiler
-foreach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES})
-  set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
-  set(CMAKE_REQUIRED_FLAGS "${FLAG}")
-  unset(OpenMP_FLAG_DETECTED CACHE)
-  message(STATUS "Try OpenMP CXX flag = [${FLAG}]")
-  check_cxx_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
-  set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
-  if(OpenMP_FLAG_DETECTED)
-    set(OpenMP_CXX_FLAGS_INTERNAL "${FLAG}")
-    break()
-  endif(OpenMP_FLAG_DETECTED)
-endforeach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES})
-
-set(OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}"
-  CACHE STRING "C compiler flags for OpenMP parallization")
-
-set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS_INTERNAL}"
-  CACHE STRING "C++ compiler flags for OpenMP parallization")
-# handle the standard arguments for find_package
-find_package_handle_standard_args(OpenMP DEFAULT_MSG 
-  OpenMP_C_FLAGS OpenMP_CXX_FLAGS )
-
-mark_as_advanced(
-  OpenMP_C_FLAGS
-  OpenMP_CXX_FLAGS
-)
+if(NOT _HAVE_LANGUAGE_CXX EQUAL -1)
+  # if these are set then do not try to find them again,
+  # by avoiding any try_compiles for the flags
+  if(OpenMP_CXX_FLAGS)
+    unset(OpenMP_CXX_FLAG_CANDIDATES)
+  else()
+    _OPENMP_FLAG_CANDIDATES("CXX")
+    include(CheckCXXSourceCompiles)
+
+    # use the same source for CXX as C for now
+    set(OpenMP_CXX_TEST_SOURCE ${OpenMP_C_TEST_SOURCE})
+  endif()
+
+  foreach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES})
+    set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+    set(CMAKE_REQUIRED_FLAGS "${FLAG}")
+    unset(OpenMP_FLAG_DETECTED CACHE)
+    message(STATUS "Try OpenMP CXX flag = [${FLAG}]")
+    check_cxx_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
+    set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
+    if(OpenMP_FLAG_DETECTED)
+      set(OpenMP_CXX_FLAGS_INTERNAL "${FLAG}")
+      break()
+    endif(OpenMP_FLAG_DETECTED)
+  endforeach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES})
+
+  set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS_INTERNAL}"
+    CACHE STRING "C++ compiler flags for OpenMP parallization")
+
+  list(APPEND _OPENMP_REQUIRED_VARS OpenMP_CXX_FLAGS)
+  unset(OpenMP_CXX_FLAG_CANDIDATES)
+  unset(OpenMP_CXX_TEST_SOURCE)
+endif()
+
+unset(_HAVE_LANGUAGE_C)
+unset(_HAVE_LANGUAGE_CXX)
+
+if(_OPENMP_REQUIRED_VARS)
+  include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+  find_package_handle_standard_args(OpenMP
+                                    REQUIRED_VARS ${_OPENMP_REQUIRED_VARS})
+
+  mark_as_advanced(${_OPENMP_REQUIRED_VARS})
+
+  unset(_OPENMP_REQUIRED_VARS)
+else()
+  message(SEND_ERROR "FindOpenMP requires C or CXX language to be enabled")
+endif()

+ 36 - 3
Modules/FindPerl.cmake

@@ -1,8 +1,9 @@
 # - Find perl
 # this module looks for Perl
 #
-#  PERL_EXECUTABLE - the full path to perl
-#  PERL_FOUND      - If false, don't attempt to use perl.
+#  PERL_EXECUTABLE     - the full path to perl
+#  PERL_FOUND          - If false, don't attempt to use perl.
+#  PERL_VERSION_STRING - version of perl found (since CMake 2.8.8)
 
 #=============================================================================
 # Copyright 2001-2009 Kitware, Inc.
@@ -39,12 +40,44 @@ FIND_PROGRAM(PERL_EXECUTABLE
   PATHS ${PERL_POSSIBLE_BIN_PATHS}
   )
 
+IF(PERL_EXECUTABLE)
+  ### PERL_VERSION
+  EXECUTE_PROCESS(
+    COMMAND
+      ${PERL_EXECUTABLE} -V:version
+      OUTPUT_VARIABLE
+        PERL_VERSION_OUTPUT_VARIABLE
+      RESULT_VARIABLE
+        PERL_VERSION_RESULT_VARIABLE
+      ERROR_QUIET
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+  IF(NOT PERL_VERSION_RESULT_VARIABLE AND NOT PERL_VERSION_OUTPUT_VARIABLE MATCHES "^version='UNKNOWN'")
+    STRING(REGEX REPLACE "version='([^']+)'.*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE})
+  ELSE()
+    EXECUTE_PROCESS(
+      COMMAND ${PERL_EXECUTABLE} -v
+      OUTPUT_VARIABLE PERL_VERSION_OUTPUT_VARIABLE
+      RESULT_VARIABLE PERL_VERSION_RESULT_VARIABLE
+      ERROR_QUIET
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    IF(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl.*[ \\(]v([0-9\\._]+)[ \\)]")
+      STRING(REGEX REPLACE ".*This is perl.*[ \\(]v([0-9\\._]+)[ \\)].*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE})
+    ELSEIF(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl, version ([0-9\\._]+) +")
+      STRING(REGEX REPLACE ".*This is perl, version ([0-9\\._]+) +.*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE})
+    ENDIF()
+  ENDIF()
+ENDIF(PERL_EXECUTABLE)
+
 # Deprecated settings for compatibility with CMake1.4
 SET(PERL ${PERL_EXECUTABLE})
 
 # handle the QUIETLY and REQUIRED arguments and set PERL_FOUND to TRUE if 
 # all listed variables are TRUE
 INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl DEFAULT_MSG PERL_EXECUTABLE)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl
+                                  REQUIRED_VARS PERL_EXECUTABLE
+                                  VERSION_VAR PERL_VERSION_STRING)
 
 MARK_AS_ADVANCED(PERL_EXECUTABLE)

+ 25 - 45
Modules/FindPerlLibs.cmake

@@ -55,19 +55,6 @@ if (PERL_EXECUTABLE)
     string(REGEX REPLACE "prefix='([^']+)'.*" "\\1" PERL_PREFIX ${PERL_PREFIX_OUTPUT_VARIABLE})
   endif (NOT PERL_PREFIX_RESULT_VARIABLE)
 
-  ### PERL_VERSION
-  execute_process(
-    COMMAND
-      ${PERL_EXECUTABLE} -V:version
-      OUTPUT_VARIABLE
-        PERL_VERSION_OUTPUT_VARIABLE
-      RESULT_VARIABLE
-        PERL_VERSION_RESULT_VARIABLE
-  )
-  if (NOT PERL_VERSION_RESULT_VARIABLE)
-    string(REGEX REPLACE "version='([^']+)'.*" "\\1" PERL_VERSION ${PERL_VERSION_OUTPUT_VARIABLE})
-  endif (NOT PERL_VERSION_RESULT_VARIABLE)
-
   ### PERL_ARCHNAME
   execute_process(
     COMMAND
@@ -107,6 +94,7 @@ if (PERL_EXECUTABLE)
   )
   if (NOT PERL_SITESEARCH_RESULT_VARIABLE)
     string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_SITESEARCH ${PERL_SITESEARCH_OUTPUT_VARIABLE})
+    file(TO_CMAKE_PATH "${PERL_SITESEARCH}" PERL_SITESEARCH)
   endif (NOT PERL_SITESEARCH_RESULT_VARIABLE)
 
   ### PERL_SITELIB
@@ -120,6 +108,7 @@ if (PERL_EXECUTABLE)
   )
   if (NOT PERL_SITELIB_RESULT_VARIABLE)
     string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_SITELIB ${PERL_SITELIB_OUTPUT_VARIABLE})
+    file(TO_CMAKE_PATH "${PERL_SITELIB}" PERL_SITELIB)
   endif (NOT PERL_SITELIB_RESULT_VARIABLE)
 
   ### PERL_VENDORARCH
@@ -133,6 +122,7 @@ if (PERL_EXECUTABLE)
     )
   if (NOT PERL_VENDORARCH_RESULT_VARIABLE)
     string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_VENDORARCH ${PERL_VENDORARCH_OUTPUT_VARIABLE})
+    file(TO_CMAKE_PATH "${PERL_VENDORARCH}" PERL_VENDORARCH)
   endif (NOT PERL_VENDORARCH_RESULT_VARIABLE)
 
   ### PERL_VENDORLIB
@@ -146,6 +136,7 @@ if (PERL_EXECUTABLE)
   )
   if (NOT PERL_VENDORLIB_RESULT_VARIABLE)
     string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_VENDORLIB ${PERL_VENDORLIB_OUTPUT_VARIABLE})
+    file(TO_CMAKE_PATH "${PERL_VENDORLIB}" PERL_VENDORLIB)
   endif (NOT PERL_VENDORLIB_RESULT_VARIABLE)
 
   macro(perl_adjust_darwin_lib_variable varname)
@@ -186,6 +177,7 @@ if (PERL_EXECUTABLE)
   if (NOT PERL_ARCHLIB_RESULT_VARIABLE)
     string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_ARCHLIB ${PERL_ARCHLIB_OUTPUT_VARIABLE})
     perl_adjust_darwin_lib_variable( ARCHLIB )
+    file(TO_CMAKE_PATH "${PERL_ARCHLIB}" PERL_ARCHLIB)
   endif (NOT PERL_ARCHLIB_RESULT_VARIABLE)
 
   ### PERL_PRIVLIB
@@ -200,28 +192,10 @@ if (PERL_EXECUTABLE)
   if (NOT PERL_PRIVLIB_RESULT_VARIABLE)
     string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_PRIVLIB ${PERL_PRIVLIB_OUTPUT_VARIABLE})
     perl_adjust_darwin_lib_variable( PRIVLIB )
+    file(TO_CMAKE_PATH "${PERL_PRIVLIB}" PERL_PRIVLIB)
   endif (NOT PERL_PRIVLIB_RESULT_VARIABLE)
 
-
-  ### PERL_POSSIBLE_INCLUDE_PATHS
-  set(PERL_POSSIBLE_INCLUDE_PATHS
-    ${PERL_ARCHLIB}/CORE
-    /usr/lib/perl5/${PERL_VERSION}/${PERL_ARCHNAME}/CORE
-    /usr/lib/perl/${PERL_VERSION}/${PERL_ARCHNAME}/CORE
-    /usr/lib/perl5/${PERL_VERSION}/CORE
-    /usr/lib/perl/${PERL_VERSION}/CORE
-    )
-
-  ### PERL_POSSIBLE_LIB_PATHS
-  set(PERL_POSSIBLE_LIB_PATHS
-    ${PERL_ARCHLIB}/CORE
-    /usr/lib/perl5/${PERL_VERSION}/${PERL_ARCHNAME}/CORE
-    /usr/lib/perl/${PERL_VERSION}/${PERL_ARCHNAME}/CORE
-    /usr/lib/perl5/${PERL_VERSION}/CORE
-    /usr/lib/perl/${PERL_VERSION}/CORE
-  )
-
-  ### PERL_POSSIBLE_LIBRARY_NAME
+  ### PERL_POSSIBLE_LIBRARY_NAMES
   execute_process(
     COMMAND
       ${PERL_EXECUTABLE} -V:libperl
@@ -231,10 +205,9 @@ if (PERL_EXECUTABLE)
       PERL_LIBRARY_RESULT_VARIABLE
   )
   if (NOT PERL_LIBRARY_RESULT_VARIABLE)
-    foreach(_perl_lib_path ${PERL_POSSIBLE_LIB_PATHS})
-      string(REGEX REPLACE "libperl='([^']+)'" "\\1" PERL_LIBRARY_OUTPUT_VARIABLE ${PERL_LIBRARY_OUTPUT_VARIABLE})
-      set(PERL_POSSIBLE_LIBRARY_NAME ${PERL_POSSIBLE_LIBRARY_NAME} "${_perl_lib_path}/${PERL_LIBRARY_OUTPUT_VARIABLE}")
-    endforeach(_perl_lib_path ${PERL_POSSIBLE_LIB_PATHS})
+    string(REGEX REPLACE "libperl='([^']+)'.*" "\\1" PERL_POSSIBLE_LIBRARY_NAMES ${PERL_LIBRARY_OUTPUT_VARIABLE})
+  else (NOT PERL_LIBRARY_RESULT_VARIABLE)
+    set(PERL_POSSIBLE_LIBRARY_NAMES perl${PERL_VERSION_STRING} perl)
   endif (NOT PERL_LIBRARY_RESULT_VARIABLE)
 
   ### PERL_INCLUDE_PATH
@@ -242,17 +215,23 @@ if (PERL_EXECUTABLE)
     NAMES
       perl.h
     PATHS
-      ${PERL_POSSIBLE_INCLUDE_PATHS}
+      ${PERL_ARCHLIB}/CORE
+      /usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
+      /usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
+      /usr/lib/perl5/${PERL_VERSION_STRING}/CORE
+      /usr/lib/perl/${PERL_VERSION_STRING}/CORE
   )
-  
+
   ### PERL_LIBRARY
   find_library(PERL_LIBRARY
     NAMES
-      ${PERL_POSSIBLE_LIBRARY_NAME}
-      perl${PERL_VERSION}
-      perl
+      ${PERL_POSSIBLE_LIBRARY_NAMES}
     PATHS
-      ${PERL_POSSIBLE_LIB_PATHS}
+      ${PERL_ARCHLIB}/CORE
+      /usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
+      /usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
+      /usr/lib/perl5/${PERL_VERSION_STRING}/CORE
+      /usr/lib/perl/${PERL_VERSION_STRING}/CORE
   )
 
 endif (PERL_EXECUTABLE)
@@ -261,15 +240,16 @@ endif (PERL_EXECUTABLE)
 # all listed variables are TRUE
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 find_package_handle_standard_args(PerlLibs REQUIRED_VARS PERL_LIBRARY PERL_INCLUDE_PATH
-                                           VERSION_VAR PERL_VERSION)
+                                           VERSION_VAR PERL_VERSION_STRING)
 
 # Introduced after CMake 2.6.4 to bring module into compliance
 set(PERL_INCLUDE_DIR  ${PERL_INCLUDE_PATH})
 set(PERL_INCLUDE_DIRS ${PERL_INCLUDE_PATH})
 set(PERL_LIBRARIES    ${PERL_LIBRARY})
+# For backward compatibility with CMake before 2.8.8
+set(PERL_VERSION ${PERL_VERSION_STRING})
 
 mark_as_advanced(
   PERL_INCLUDE_PATH
-  PERL_EXECUTABLE
   PERL_LIBRARY
 )

+ 16 - 5
Modules/FindPkgConfig.cmake

@@ -13,14 +13,17 @@
 # When the 'QUIET' argument is set, no status messages will be printed.
 #
 # It sets the following variables:
-#   PKG_CONFIG_FOUND         ... true if pkg-config works on the system
-#   PKG_CONFIG_EXECUTABLE    ... pathname of the pkg-config program
-#   <PREFIX>_FOUND           ... set to 1 if module(s) exist
+#   PKG_CONFIG_FOUND          ... true if pkg-config works on the system
+#   PKG_CONFIG_EXECUTABLE     ... pathname of the pkg-config program
+#   PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found
+#                                 (since CMake 2.8.8)
+#   PKG_CONFIG_FOUND          ... if pkg-config executable was found
 #
 # For the following variables two sets of values exist; first one is the
 # common one and has the given PREFIX. The second set contains flags
 # which are given out when pkgconfig was called with the '--static'
 # option.
+#   <XPREFIX>_FOUND          ... set to 1 if module(s) exist
 #   <XPREFIX>_LIBRARIES      ... only the libraries (w/o the '-l')
 #   <XPREFIX>_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
 #   <XPREFIX>_LDFLAGS        ... all required linker flags
@@ -89,9 +92,17 @@ set(PKG_CONFIG_VERSION 1)
 find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
 mark_as_advanced(PKG_CONFIG_EXECUTABLE)
 
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-find_package_handle_standard_args(PkgConfig DEFAULT_MSG PKG_CONFIG_EXECUTABLE)
+if (PKG_CONFIG_EXECUTABLE)
+  execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --version
+    OUTPUT_VARIABLE PKG_CONFIG_VERSION_STRING
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif (PKG_CONFIG_EXECUTABLE)
 
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(PkgConfig
+                                  REQUIRED_VARS PKG_CONFIG_EXECUTABLE
+                                  VERSION_VAR PKG_CONFIG_VERSION_STRING)
 
 # Unsets the given variables
 macro(_pkgconfig_unset var)

+ 4 - 1
Modules/FindQt3.cmake

@@ -183,11 +183,14 @@ ENDIF(QT_UIC_EXECUTABLE)
 
 IF (WIN32)
   FIND_LIBRARY(QT_QTMAIN_LIBRARY qtmain
+    HINTS
+    $ENV{QTDIR}/lib
     "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/lib"
     "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/lib"
     "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/lib"
+    PATHS
     "$ENV{ProgramFiles}/qt/lib"
-    $ENV{QTDIR}/lib "C:/Program Files/qt/lib"
+    "C:/Program Files/qt/lib"
     DOC "This Library is only needed by and included with Qt3 on MSWindows. It should be NOTFOUND, undefined or IGNORE otherwise."
     )
 ENDIF (WIN32)

+ 3 - 2
Modules/FindQt4.cmake

@@ -588,8 +588,9 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION)
     SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE)
     SET(QT_QTCORE_FOUND 1)
   ELSE()
-    MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}")
-    MESSAGE("Warning: But QtCore couldn't be found.  Qt must NOT be installed correctly, or it wasn't found for cross compiling.")
+    MESSAGE(WARNING "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as \"${QT_LIBRARY_DIR_TMP}\" "
+                    "but QtCore could not be found there.  "
+                    "Qt is NOT installed correctly for the target build environment.")
     IF(Qt4_FIND_REQUIRED)
       MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
     ENDIF(Qt4_FIND_REQUIRED)

+ 26 - 31
Modules/FindRuby.cmake

@@ -61,49 +61,44 @@ FIND_PROGRAM(RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES})
 
 
 IF(RUBY_EXECUTABLE  AND NOT  RUBY_VERSION_MAJOR)
-  # query the ruby version
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['MAJOR']"
-      OUTPUT_VARIABLE RUBY_VERSION_MAJOR)
+  FUNCTION(_RUBY_CONFIG_VAR RBVAR OUTVAR)
+    EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']"
+      RESULT_VARIABLE _RUBY_SUCCESS
+      OUTPUT_VARIABLE _RUBY_OUTPUT
+      ERROR_QUIET)
+    IF(_RUBY_SUCCESS OR NOT _RUBY_OUTPUT)
+      EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']"
+        RESULT_VARIABLE _RUBY_SUCCESS
+        OUTPUT_VARIABLE _RUBY_OUTPUT
+        ERROR_QUIET)
+    ENDIF(_RUBY_SUCCESS OR NOT _RUBY_OUTPUT)
+    SET(${OUTVAR} "${_RUBY_OUTPUT}" PARENT_SCOPE)
+  ENDFUNCTION(_RUBY_CONFIG_VAR)
 
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['MINOR']"
-      OUTPUT_VARIABLE RUBY_VERSION_MINOR)
 
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['TEENY']"
-      OUTPUT_VARIABLE RUBY_VERSION_PATCH)
+  # query the ruby version
+   _RUBY_CONFIG_VAR("MAJOR" RUBY_VERSION_MAJOR)
+   _RUBY_CONFIG_VAR("MINOR" RUBY_VERSION_MINOR)
+   _RUBY_CONFIG_VAR("TEENY" RUBY_VERSION_PATCH)
 
    # query the different directories
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['archdir']"
-      OUTPUT_VARIABLE RUBY_ARCH_DIR)
-
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['arch']"
-      OUTPUT_VARIABLE RUBY_ARCH)
-
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['rubyhdrdir']"
-      OUTPUT_VARIABLE RUBY_HDR_DIR)
-
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['libdir']"
-      OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_DIR)
-
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['rubylibdir']"
-      OUTPUT_VARIABLE RUBY_RUBY_LIB_DIR)
+   _RUBY_CONFIG_VAR("archdir" RUBY_ARCH_DIR)
+   _RUBY_CONFIG_VAR("arch" RUBY_ARCH)
+   _RUBY_CONFIG_VAR("rubyhdrdir" RUBY_HDR_DIR)
+   _RUBY_CONFIG_VAR("libdir" RUBY_POSSIBLE_LIB_DIR)
+   _RUBY_CONFIG_VAR("rubylibdir" RUBY_RUBY_LIB_DIR)
 
    # site_ruby
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitearchdir']"
-      OUTPUT_VARIABLE RUBY_SITEARCH_DIR)
-
-   EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitelibdir']"
-      OUTPUT_VARIABLE RUBY_SITELIB_DIR)
+   _RUBY_CONFIG_VAR("sitearchdir" RUBY_SITEARCH_DIR)
+   _RUBY_CONFIG_VAR("sitelibdir" RUBY_SITELIB_DIR)
 
    # vendor_ruby available ?
    EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r vendor-specific -e "print 'true'"
       OUTPUT_VARIABLE RUBY_HAS_VENDOR_RUBY  ERROR_QUIET)
 
    IF(RUBY_HAS_VENDOR_RUBY)
-      EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorlibdir']"
-         OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)
-
-      EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorarchdir']"
-         OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)
+      _RUBY_CONFIG_VAR("vendorlibdir" RUBY_VENDORLIB_DIR)
+      _RUBY_CONFIG_VAR("vendorarchdir" RUBY_VENDORARCH_DIR)
    ENDIF(RUBY_HAS_VENDOR_RUBY)
 
    # save the results in the cache so we don't have to run ruby the next time again

+ 3 - 7
Modules/FindSDL.cmake

@@ -81,7 +81,6 @@ FIND_PATH(SDL_INCLUDE_DIR SDL.h
   /opt/csw # Blastwave
   /opt
 )
-#MESSAGE("SDL_INCLUDE_DIR is ${SDL_INCLUDE_DIR}")
 
 # SDL-1.1 is the name used by FreeBSD ports...
 # don't confuse it for the version number.
@@ -97,8 +96,6 @@ FIND_LIBRARY(SDL_LIBRARY_TEMP
   /opt
 )
 
-#MESSAGE("SDL_LIBRARY_TEMP is ${SDL_LIBRARY_TEMP}")
-
 IF(NOT SDL_BUILDING_LIBRARY)
   IF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework")
     # Non-OS X framework versions expect you to also dynamically link to 
@@ -134,7 +131,6 @@ IF(MINGW)
   SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
 ENDIF(MINGW)
 
-SET(SDL_FOUND "NO")
 IF(SDL_LIBRARY_TEMP)
   # For SDLmain
   IF(NOT SDL_BUILDING_LIBRARY)
@@ -169,9 +165,9 @@ IF(SDL_LIBRARY_TEMP)
   SET(SDL_LIBRARY ${SDL_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
   # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
   SET(SDL_LIBRARY_TEMP "${SDL_LIBRARY_TEMP}" CACHE INTERNAL "")
-
-  SET(SDL_FOUND "YES")
 ENDIF(SDL_LIBRARY_TEMP)
 
-#MESSAGE("SDL_LIBRARY is ${SDL_LIBRARY}")
+INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL
+                                  REQUIRED_VARS SDL_LIBRARY SDL_INCLUDE_DIR)

+ 3 - 4
Modules/FindSDL_image.cmake

@@ -68,8 +68,7 @@ FIND_LIBRARY(SDLIMAGE_LIBRARY
   /opt
 )
 
-SET(SDLIMAGE_FOUND "NO")
-IF(SDLIMAGE_LIBRARY AND SDLIMAGE_INCLUDE_DIR)
-  SET(SDLIMAGE_FOUND "YES")
-ENDIF(SDLIMAGE_LIBRARY AND SDLIMAGE_INCLUDE_DIR)
+INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDLIMAGE
+                                  REQUIRED_VARS SDLIMAGE_LIBRARY SDLIMAGE_INCLUDE_DIR)

+ 3 - 4
Modules/FindSDL_mixer.cmake

@@ -68,8 +68,7 @@ FIND_LIBRARY(SDLMIXER_LIBRARY
   /opt
 )
 
-SET(SDLMIXER_FOUND "NO")
-IF(SDLMIXER_LIBRARY AND SDLMIXER_INCLUDE_DIR)
-  SET(SDLMIXER_FOUND "YES")
-ENDIF(SDLMIXER_LIBRARY AND SDLMIXER_INCLUDE_DIR)
+INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDLMIXER
+                                  REQUIRED_VARS SDLMIXER_LIBRARY SDLMIXER_INCLUDE_DIR)

+ 3 - 4
Modules/FindSDL_net.cmake

@@ -67,8 +67,7 @@ FIND_LIBRARY(SDLNET_LIBRARY
   /opt
 )
 
-SET(SDLNET_FOUND "NO")
-IF(SDLNET_LIBRARY AND SDLNET_INCLUDE_DIR)
-  SET(SDLNET_FOUND "YES")
-ENDIF(SDLNET_LIBRARY AND SDLNET_INCLUDE_DIR)
+INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDLNET
+                                  REQUIRED_VARS SDLNET_LIBRARY SDLNET_INCLUDE_DIR)

+ 3 - 3
Modules/FindSDL_sound.cmake

@@ -114,7 +114,6 @@ FIND_LIBRARY(SDL_SOUND_LIBRARY
   /opt/lib
   )
 
-SET(SDL_SOUND_FOUND "NO")
 IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
 
   # CMake is giving me problems using TRY_COMPILE with the CMAKE_FLAGS
@@ -414,8 +413,9 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
    ENDIF(NOT MY_RESULT)
 
    SET(SDL_SOUND_LIBRARIES "${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARIES_TMP}" CACHE INTERNAL "SDL_sound and dependent libraries")
-   SET(SDL_SOUND_FOUND "YES")
  ENDIF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
 
- # MESSAGE("SDL_SOUND_LIBRARIES is ${SDL_SOUND_LIBRARIES}")
+INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_SOUND
+                                  REQUIRED_VARS SDL_SOUND_LIBRARIES SDL_SOUND_INCLUDE_DIR)

+ 3 - 4
Modules/FindSDL_ttf.cmake

@@ -68,8 +68,7 @@ FIND_LIBRARY(SDLTTF_LIBRARY
     PATH_SUFFIXES lib64 lib
 )
 
-SET(SDLTTF_FOUND "NO")
-IF(SDLTTF_LIBRARY AND SDLTTF_INCLUDE_DIR)
-  SET(SDLTTF_FOUND "YES")
-ENDIF(SDLTTF_LIBRARY AND SDLTTF_INCLUDE_DIR)
+INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDLTTF
+                                  REQUIRED_VARS SDLTTF_LIBRARY SDLTTF_INCLUDE_DIR)

+ 15 - 3
Modules/FindX11.cmake

@@ -20,7 +20,7 @@
 #                X11_XShm_INCLUDE_PATH,         (in X11_Xext_LIB),  X11_XShm_FOUND
 #                X11_Xshape_INCLUDE_PATH,       (in X11_Xext_LIB),  X11_Xshape_FOUND
 #                X11_xf86misc_INCLUDE_PATH,     X11_Xxf86misc_LIB,  X11_xf86misc_FOUND
-#                X11_xf86vmode_INCLUDE_PATH,                        X11_xf86vmode_FOUND
+#                X11_xf86vmode_INCLUDE_PATH,    X11_Xxf86vm_LIB     X11_xf86vmode_FOUND
 #                X11_Xfixes_INCLUDE_PATH,       X11_Xfixes_LIB,     X11_Xfixes_FOUND
 #                X11_Xft_INCLUDE_PATH,          X11_Xft_LIB,        X11_Xft_FOUND
 #                X11_Xi_INCLUDE_PATH,           X11_Xi_LIB,         X11_Xi_FOUND
@@ -29,6 +29,7 @@
 #                X11_Xkb_INCLUDE_PATH,                              X11_Xkb_FOUND
 #                X11_Xkblib_INCLUDE_PATH,                           X11_Xkb_FOUND
 #                X11_Xkbfile_INCLUDE_PATH,      X11_Xkbfile_LIB,    X11_Xkbfile_FOUND
+#                X11_Xmu_INCLUDE_PATH,          X11_Xmu_LIB,        X11_Xmu_FOUND
 #                X11_Xpm_INCLUDE_PATH,          X11_Xpm_LIB,        X11_Xpm_FOUND
 #                X11_XTest_INCLUDE_PATH,        X11_XTest_LIB,      X11_XTest_FOUND
 #                X11_Xrandr_INCLUDE_PATH,       X11_Xrandr_LIB,     X11_Xrandr_FOUND
@@ -103,6 +104,7 @@ IF (UNIX)
   FIND_PATH(X11_Xkb_INCLUDE_PATH X11/extensions/XKB.h                ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_Xkblib_INCLUDE_PATH X11/XKBlib.h                     ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_Xkbfile_INCLUDE_PATH X11/extensions/XKBfile.h        ${X11_INC_SEARCH_PATH})
+  FIND_PATH(X11_Xmu_INCLUDE_PATH X11/Xmu/Xmu.h                       ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_Xpm_INCLUDE_PATH X11/xpm.h                           ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_XTest_INCLUDE_PATH X11/extensions/XTest.h            ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_XShm_INCLUDE_PATH X11/extensions/XShm.h              ${X11_INC_SEARCH_PATH})
@@ -134,6 +136,7 @@ IF (UNIX)
   FIND_LIBRARY(X11_Xinerama_LIB Xinerama     ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xinput_LIB Xi             ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xkbfile_LIB xkbfile       ${X11_LIB_SEARCH_PATH})
+  FIND_LIBRARY(X11_Xmu_LIB Xmu               ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xpm_LIB Xpm               ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xrandr_LIB Xrandr         ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xrender_LIB Xrender       ${X11_LIB_SEARCH_PATH})
@@ -143,6 +146,7 @@ IF (UNIX)
   FIND_LIBRARY(X11_XTest_LIB Xtst            ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xv_LIB Xv                 ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xxf86misc_LIB Xxf86misc   ${X11_LIB_SEARCH_PATH})
+  FIND_LIBRARY(X11_Xxf86vm_LIB Xxf86vm       ${X11_LIB_SEARCH_PATH})
 
   SET(X11_LIBRARY_DIR "")
   IF(X11_X11_LIB)
@@ -267,10 +271,10 @@ IF (UNIX)
      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_xf86misc_INCLUDE_PATH})
   ENDIF (X11_xf86misc_INCLUDE_PATH  AND X11_Xxf86misc_LIB)
 
-  IF (X11_xf86vmode_INCLUDE_PATH)
+  IF (X11_xf86vmode_INCLUDE_PATH AND X11_Xxf86vm_LIB)
      SET(X11_xf86vmode_FOUND TRUE)
      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_xf86vmode_INCLUDE_PATH})
-  ENDIF (X11_xf86vmode_INCLUDE_PATH)
+  ENDIF (X11_xf86vmode_INCLUDE_PATH AND X11_Xxf86vm_LIB)
 
   IF (X11_Xcursor_INCLUDE_PATH AND X11_Xcursor_LIB)
      SET(X11_Xcursor_FOUND TRUE)
@@ -297,6 +301,11 @@ IF (UNIX)
      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xkbfile_INCLUDE_PATH} )
   ENDIF (X11_Xkbfile_INCLUDE_PATH AND X11_Xkbfile_LIB AND X11_Xlib_INCLUDE_PATH)
 
+  IF (X11_Xmu_INCLUDE_PATH AND X11_Xmu_LIB)
+     SET(X11_Xmu_FOUND TRUE)
+     SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xmu_INCLUDE_PATH})
+  ENDIF (X11_Xmu_INCLUDE_PATH AND X11_Xmu_LIB)
+
   IF (X11_Xinput_INCLUDE_PATH AND X11_Xinput_LIB)
      SET(X11_Xinput_FOUND TRUE)
      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinput_INCLUDE_PATH})
@@ -435,6 +444,7 @@ IF (UNIX)
     X11_XRes_INCLUDE_PATH
     X11_Xxf86misc_LIB
     X11_xf86misc_INCLUDE_PATH
+    X11_Xxf86vm_LIB
     X11_xf86vmode_INCLUDE_PATH
     X11_Xi_LIB
     X11_Xi_INCLUDE_PATH
@@ -456,6 +466,8 @@ IF (UNIX)
     X11_Xkblib_INCLUDE_PATH
     X11_Xkbfile_INCLUDE_PATH
     X11_Xkbfile_LIB
+    X11_Xmu_INCLUDE_PATH
+    X11_Xmu_LIB
     X11_Xscreensaver_INCLUDE_PATH
     X11_Xscreensaver_LIB
     X11_Xpm_INCLUDE_PATH

+ 1 - 1
Modules/GenerateExportHeader.cmake

@@ -173,7 +173,7 @@ macro(_test_compiler_hidden_visibility)
         _gcc_version "${_gcc_version_info}")
     endif()
 
-    if(${_gcc_version} VERSION_LESS "4.2")
+    if("${_gcc_version}" VERSION_LESS "4.2")
       set(GCC_TOO_OLD TRUE)
       message(WARNING "GCC version older than 4.2")
     endif()

+ 2 - 2
Modules/NSIS.template.in

@@ -922,12 +922,12 @@ Function .onInit
   Pop $0
   UserInfo::GetAccountType
   Pop $1
-  StrCmp $1 "Admin" 0 +3
+  StrCmp $1 "Admin" 0 +4
     SetShellVarContext all
     ;MessageBox MB_OK 'User "$0" is in the Admin group'
     StrCpy $SV_ALLUSERS "AllUsers"
     Goto done
-  StrCmp $1 "Power" 0 +3
+  StrCmp $1 "Power" 0 +4
     SetShellVarContext all
     ;MessageBox MB_OK 'User "$0" is in the Power Users group'
     StrCpy $SV_ALLUSERS "AllUsers"

+ 7 - 1
Modules/Qt4Macros.cmake

@@ -393,7 +393,13 @@ MACRO(QT4_CREATE_TRANSLATION _qm_files)
        FOREACH(_pro_src ${_my_sources})
          SET(_pro_srcs "${_pro_srcs} \"${_pro_src}\"")
        ENDFOREACH(_pro_src ${_my_sources})
-       FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}")
+       SET(_pro_includes)
+       GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES)
+       FOREACH(_pro_include ${_inc_DIRS})
+         GET_FILENAME_COMPONENT(_abs_include "${_pro_include}" ABSOLUTE)
+         SET(_pro_includes "${_pro_includes} \"${_abs_include}\"")
+       ENDFOREACH(_pro_include ${CMAKE_CXX_INCLUDE_PATH})
+       FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}\nINCLUDEPATH = ${_pro_includes}\n")
      ENDIF(_my_sources)
      ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
         COMMAND ${QT_LUPDATE_EXECUTABLE}

+ 38 - 18
Modules/UseJava.cmake

@@ -25,6 +25,15 @@
 #       set(CMAKE_JAVA_TARGET_OUTPUT_NAME shibboleet.jar)
 #       add_jar(foobar foobar.java)
 #
+#   To use a different output directory than CMAKE_CURRENT_BINARY_DIR
+#   you can set it with:
+#
+#       set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin)
+#
+#   To define an entry point in your jar you can set it with:
+#
+#       set(CMAKE_JAVA_JAR_ENTRY_POINT com/examples/MyProject/Main)
+#
 #   To add a VERSION to the target output name you can set it using
 #   CMAKE_JAVA_TARGET_VERSION. This will create a jar file with the name
 #   shibboleet-1.0.0.jar and will create a symlink shibboleet.jar
@@ -112,7 +121,7 @@
 #                [VERSION TRUE|FALSE]
 #               )
 #
-# Create jave documentation based on files or packages. For more
+# Create java documentation based on files or packages. For more
 # details please read the javadoc manpage.
 #
 # There are two main signatures for create_javadoc. The first
@@ -198,10 +207,19 @@ set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake)
 function(add_jar _TARGET_NAME)
     set(_JAVA_SOURCE_FILES ${ARGN})
 
+    if (NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
+      set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
+    endif(NOT DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
+
+    if (CMAKE_JAVA_JAR_ENTRY_POINT)
+      set(_ENTRY_POINT_OPTION e)
+      set(_ENTRY_POINT_VALUE ${CMAKE_JAVA_JAR_ENTRY_POINT})
+    endif (CMAKE_JAVA_JAR_ENTRY_POINT)
+
     if (LIBRARY_OUTPUT_PATH)
         set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
     else (LIBRARY_OUTPUT_PATH)
-        set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
+        set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR})
     endif (LIBRARY_OUTPUT_PATH)
 
     set(CMAKE_JAVA_INCLUDE_PATH
@@ -221,7 +239,7 @@ function(add_jar _TARGET_NAME)
        set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}")
     endforeach(JAVA_INCLUDE_DIR)
 
-    set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
+    set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_JAVA_TARGET_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
 
     set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
     if (CMAKE_JAVA_TARGET_OUTPUT_NAME AND CMAKE_JAVA_TARGET_VERSION)
@@ -246,7 +264,7 @@ function(add_jar _TARGET_NAME)
         get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
         get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
 
-        file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR} ${_JAVA_FULL})
+        file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_JAVA_TARGET_OUTPUT_DIR} ${_JAVA_FULL})
         file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
         string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
         string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
@@ -312,20 +330,22 @@ function(add_jar _TARGET_NAME)
     endif (_JAVA_COMPILE_FILES)
 
     # create the jar file
+    set(_JAVA_JAR_OUTPUT_PATH
+      ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
     if (CMAKE_JNI_TARGET)
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
+            OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
             COMMAND ${Java_JAR_EXECUTABLE}
-                -cf ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
+                -cf${_ENTRY_POINT_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE}
                 ${_JAVA_RESOURCE_FILES} @java_class_filelist
             COMMAND ${CMAKE_COMMAND}
-                -D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}
+                -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
                 -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
                 -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
                 -P ${_JAVA_SYMLINK_SCRIPT}
             COMMAND ${CMAKE_COMMAND}
-                -D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}
-                -D_JAVA_TARGET_OUTPUT_NAME=${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
+                -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
+                -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_JAR_OUTPUT_PATH}
                 -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
                 -P ${_JAVA_SYMLINK_SCRIPT}
             DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
@@ -334,12 +354,12 @@ function(add_jar _TARGET_NAME)
         )
     else ()
         add_custom_command(
-            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
+            OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
             COMMAND ${Java_JAR_EXECUTABLE}
-                -cf ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
+                -cf${_ENTRY_POINT_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE}
                 ${_JAVA_RESOURCE_FILES} @java_class_filelist
             COMMAND ${CMAKE_COMMAND}
-                -D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR}
+                -D_JAVA_TARGET_DIR=${CMAKE_JAVA_TARGET_OUTPUT_DIR}
                 -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
                 -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
                 -P ${_JAVA_SYMLINK_SCRIPT}
@@ -350,14 +370,14 @@ function(add_jar _TARGET_NAME)
     endif (CMAKE_JNI_TARGET)
 
     # Add the target and make sure we have the latest resource files.
-    add_custom_target(${_TARGET_NAME} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
+    add_custom_target(${_TARGET_NAME} ALL DEPENDS ${_JAVA_JAR_OUTPUT_PATH})
 
     set_property(
         TARGET
             ${_TARGET_NAME}
         PROPERTY
             INSTALL_FILES
-                ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
+                ${_JAVA_JAR_OUTPUT_PATH}
     )
 
     if (_JAVA_TARGET_OUTPUT_LINK)
@@ -366,8 +386,8 @@ function(add_jar _TARGET_NAME)
                 ${_TARGET_NAME}
             PROPERTY
                 INSTALL_FILES
-                    ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
-                    ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
+                    ${_JAVA_JAR_OUTPUT_PATH}
+                    ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
         )
 
         if (CMAKE_JNI_TARGET)
@@ -376,7 +396,7 @@ function(add_jar _TARGET_NAME)
                     ${_TARGET_NAME}
                 PROPERTY
                     JNI_SYMLINK
-                        ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
+                        ${CMAKE_JAVA_TARGET_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
             )
         endif (CMAKE_JNI_TARGET)
     endif (_JAVA_TARGET_OUTPUT_LINK)
@@ -386,7 +406,7 @@ function(add_jar _TARGET_NAME)
             ${_TARGET_NAME}
         PROPERTY
             JAR_FILE
-                ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}
+                ${_JAVA_JAR_OUTPUT_PATH}
     )
 
     set_property(

+ 2 - 0
Source/CMakeLists.txt

@@ -466,6 +466,8 @@ SET(CPACK_SRCS
   CPack/cmCPackTarBZip2Generator.cxx
   CPack/cmCPackTarCompressGenerator.cxx
   CPack/cmCPackZIPGenerator.cxx
+  CPack/cmCPackDocumentVariables.cxx
+  CPack/cmCPackDocumentMacros.cxx
   )
 
 IF(CYGWIN)

+ 9 - 2
Source/CPack/cmCPackArchiveGenerator.cxx

@@ -57,13 +57,20 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
   std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
   // Change to local toplevel
   cmSystemTools::ChangeDirectory(localToplevel.c_str());
+  std::string filePrefix;
+  if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY"))
+    {
+    filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
+    filePrefix += "/";
+    }
   std::vector<std::string>::const_iterator fileIt;
   for (fileIt = component->Files.begin(); fileIt != component->Files.end();
        ++fileIt )
     {
+    std::string rp = filePrefix + *fileIt;
     cmCPackLogger(cmCPackLog::LOG_DEBUG,"Adding file: "
-                  << (*fileIt) << std::endl);
-    archive.Add(*fileIt);
+                  << rp << std::endl);
+    archive.Add(rp);
     if (!archive)
       {
       cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: "

+ 16 - 0
Source/CPack/cmCPackDocumentMacros.cxx

@@ -0,0 +1,16 @@
+#include "cmCPackDocumentMacros.h"
+
+void cmCPackDocumentMacros::GetMacrosDocumentation(
+        std::vector<cmDocumentationEntry>& )
+{
+   // Commented-out example of use
+   //
+   //    cmDocumentationEntry e("cpack_<macro>",
+   //            "Brief Description"
+   //            "which may be on several lines.",
+   //            "Long description in pre-formatted format"
+   //            "                          blah\n"
+   //            "                          blah\n"
+   //);
+   //v.push_back(e);
+}

+ 21 - 0
Source/CPack/cmCPackDocumentMacros.h

@@ -0,0 +1,21 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2009 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 cmCPackDocumentMacros_h
+#define cmCPackDocumentMacros_h
+#include "cmStandardIncludes.h"
+class cmCPackDocumentMacros
+{
+public:
+  static void GetMacrosDocumentation(std::vector<cmDocumentationEntry>& v);
+};
+
+#endif

+ 32 - 0
Source/CPack/cmCPackDocumentVariables.cxx

@@ -0,0 +1,32 @@
+#include "cmCPackDocumentVariables.h"
+#include "cmake.h"
+
+void cmCPackDocumentVariables::DefineVariables(cmake* cm)
+{
+  // Subsection: variables defined/used by cpack,
+  // which are common to all CPack generators
+
+  cm->DefineProperty
+      ("CPACK_PACKAGING_INSTALL_PREFIX", cmProperty::VARIABLE,
+       "The prefix used in the built package.",
+       "Each CPack generator has a default value (like /usr)."
+       " This default value may"
+       " be overwritten from the CMakeLists.txt or the cpack command line"
+       " by setting an alternative value.\n"
+       "e.g. "
+       " set(CPACK_PACKAGING_INSTALL_PREFIX \"/opt\")\n"
+       "This is not the same purpose as CMAKE_INSTALL_PREFIX which"
+       " is used when installing from the build tree without building"
+       " a package."
+       "", false,
+       "Variables common to all CPack generators");
+
+  // Subsection: variables defined/used by cpack,
+  // which are specific to one CPack generator
+//  cm->DefineProperty
+//      ("CPACK_RPM_PACKAGE_NAME", cmProperty::VARIABLE,
+//       "RPM specific package name.",
+//       "If not specified, defaults to CPACK_PACKAGE_NAME."
+//       "", false,
+//       "Variables specific to a CPack generator");
+}

+ 21 - 0
Source/CPack/cmCPackDocumentVariables.h

@@ -0,0 +1,21 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2009 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 cmCPackDocumentVariables_h
+#define cmCPackDocumentVariables_h
+class cmake;
+class cmCPackDocumentVariables
+{
+public:
+  static void DefineVariables(cmake* cm);
+};
+
+#endif

+ 5 - 0
Source/CPack/cmCPackGenerator.cxx

@@ -691,6 +691,11 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
           //  one install directory for each component.
           tempInstallDirectory +=
             GetComponentInstallDirNameSuffix(installComponent);
+          if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY"))
+            {
+            tempInstallDirectory += "/";
+            tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
+            }
           }
 
         if (!setDestDir)

+ 3 - 3
Source/CPack/cmCPackNSISGenerator.cxx

@@ -344,9 +344,9 @@ int cmCPackNSISGenerator::InitializeInternal()
   if ( cmSystemTools::IsOn(this->GetOption(
         "CPACK_INCLUDE_TOPLEVEL_DIRECTORY")) )
     {
-    cmCPackLogger(cmCPackLog::LOG_ERROR,
-      "NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY. "
-      "This option will be ignored."
+    cmCPackLogger(cmCPackLog::LOG_WARNING,
+      "NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY set. "
+      "This option will be reset to 0 (for this generator only)."
       << std::endl);
     this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", 0);
     }

+ 88 - 6
Source/CPack/cpack.cxx

@@ -14,6 +14,8 @@
 // Need these for documentation support.
 #include "cmake.h"
 #include "cmDocumentation.h"
+#include "cmCPackDocumentVariables.h"
+#include "cmCPackDocumentMacros.h"
 #include "cmCPackGeneratorFactory.h"
 #include "cmCPackGenerator.h"
 #include "cmake.h"
@@ -24,6 +26,7 @@
 #include "cmCPackLog.h"
 
 #include <cmsys/CommandLineArguments.hxx>
+#include <cmsys/SystemTools.hxx>
 #include <memory> // auto_ptr
 
 //----------------------------------------------------------------------------
@@ -90,6 +93,40 @@ static const char * cmDocumentationOptions[][3] =
      "If vendor is not specified on cpack command line "
      "(or inside CMakeLists.txt) then"
      "CPack.cmake defines it with a default value"},
+    {"--help-command cmd [file]", "Print help for a single command and exit.",
+    "Full documentation specific to the given command is displayed. "
+    "If a file is specified, the documentation is written into and the output "
+    "format is determined depending on the filename suffix. Supported are man "
+    "page, HTML, DocBook and plain text."},
+    {"--help-command-list [file]", "List available commands and exit.",
+     "The list contains all commands for which help may be obtained by using "
+     "the --help-command argument followed by a command name. "
+    "If a file is specified, the documentation is written into and the output "
+    "format is determined depending on the filename suffix. Supported are man "
+    "page, HTML, DocBook and plain text."},
+    {"--help-commands [file]", "Print help for all commands and exit.",
+     "Full documentation specific for all current command is displayed."
+    "If a file is specified, the documentation is written into and the output "
+    "format is determined depending on the filename suffix. Supported are man "
+    "page, HTML, DocBook and plain text."},
+    {"--help-variable var [file]",
+     "Print help for a single variable and exit.",
+     "Full documentation specific to the given variable is displayed."
+    "If a file is specified, the documentation is written into and the output "
+    "format is determined depending on the filename suffix. Supported are man "
+    "page, HTML, DocBook and plain text."},
+    {"--help-variable-list [file]", "List documented variables and exit.",
+     "The list contains all variables for which help may be obtained by using "
+     "the --help-variable argument followed by a variable name.  If a file is "
+     "specified, the help is written into it."
+    "If a file is specified, the documentation is written into and the output "
+    "format is determined depending on the filename suffix. Supported are man "
+     "page, HTML, DocBook and plain text."},
+    {"--help-variables [file]", "Print help for all variables and exit.",
+     "Full documentation for all variables is displayed."
+    "If a file is specified, the documentation is written into and the output "
+    "format is determined depending on the filename suffix. Supported are man "
+    "page, HTML, DocBook and plain text."},
     {0,0,0}
 };
 
@@ -137,12 +174,15 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
   return 1;
 }
 
+
 //----------------------------------------------------------------------------
 // this is CPack.
 int main (int argc, char *argv[])
 {
   cmSystemTools::FindExecutableDirectory(argv[0]);
   cmCPackLog log;
+  int nocwd = 0;
+
   log.SetErrorPrefix("CPack Error: ");
   log.SetWarningPrefix("CPack Warning: ");
   log.SetOutputPrefix("CPack: ");
@@ -154,6 +194,7 @@ int main (int argc, char *argv[])
     {
     cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
       "Current working directory cannot be established." << std::endl);
+    nocwd = 1;
     }
 
   std::string generator;
@@ -179,7 +220,6 @@ int main (int argc, char *argv[])
 
   cpackConfigFile = "";
 
-  cmDocumentation doc;
   cmsys::CommandLineArguments arg;
   arg.Initialize(argc, argv);
   typedef cmsys::CommandLineArguments argT;
@@ -252,17 +292,25 @@ int main (int argc, char *argv[])
   generators.SetLogger(&log);
   cmCPackGenerator* cpackGenerator = 0;
 
-  if ( !helpFull.empty() || !helpMAN.empty() ||
-    !helpHTML.empty() || helpVersion )
+  cmDocumentation doc;
+  doc.addCPackStandardDocSections();
+  /* Were we invoked to display doc or to do some work ? */
+  if(doc.CheckOptions(argc, argv,"-G") || nocwd)
     {
-    help = true;
+      help = true;
     }
+  else
+    {
+      help = false;
+    }
+
+  // This part is used for cpack documentation lookup as well.
+  cminst.AddCMakePaths();
 
   if ( parsed && !help )
     {
     // find out which system cpack is running on, so it can setup the search
     // paths, so FIND_XXX() commands can be used in scripts
-    cminst.AddCMakePaths();
     std::string systemFile =
       globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
     if (!globalMF->ReadListFile(0, systemFile.c_str()))
@@ -465,14 +513,48 @@ int main (int argc, char *argv[])
    */
   if ( help )
     {
-    doc.CheckOptions(argc, argv);
     // Construct and print requested documentation.
+
     doc.SetName("cpack");
     doc.SetSection("Name",cmDocumentationName);
     doc.SetSection("Usage",cmDocumentationUsage);
     doc.SetSection("Description",cmDocumentationDescription);
     doc.PrependSection("Options",cmDocumentationOptions);
 
+    // statically (in C++ code) defined variables
+    cmCPackDocumentVariables::DefineVariables(&cminst);
+
+    std::vector<cmDocumentationEntry> commands;
+
+    std::string                              docedFile;
+    std::string                              docPath;
+    cmDocumentation::documentedModulesList_t docedModList;
+
+    docedFile = globalMF->GetModulesFile("CPack.cmake");
+    if (docedFile.length()!=0)
+      {
+      docPath = cmSystemTools::GetFilenamePath(docedFile.c_str());
+      doc.getDocumentedModulesListInDir(docPath,"CPack*.cmake",docedModList);
+      }
+
+    // parse the files for documentation.
+    cmDocumentation::documentedModulesList_t::iterator docedIt;
+    for (docedIt = docedModList.begin();
+         docedIt!= docedModList.end(); ++docedIt)
+      {
+          doc.GetStructuredDocFromFile(
+              (docedIt->first).c_str(),
+              commands,&cminst);
+      }
+
+    std::map<std::string,cmDocumentationSection *> propDocs;
+    cminst.GetPropertiesDocumentation(propDocs);
+    doc.SetSections(propDocs);
+    cminst.GetCommandDocumentation(commands,true,false);
+    // statically (in C++ code) defined macros/commands
+    cmCPackDocumentMacros::GetMacrosDocumentation(commands);
+    doc.SetSection("Commands",commands);
+
     std::vector<cmDocumentationEntry> v;
     cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
     for( generatorIt = generators.GetGeneratorsList().begin();

+ 1 - 1
Source/CTest/cmCTestCoverageHandler.cxx

@@ -555,7 +555,7 @@ int cmCTestCoverageHandler::ProcessHandler()
     covSumFile << "\t<File Name=\"" << cmXMLSafe(fileName)
       << "\" FullPath=\"" << cmXMLSafe(
         this->CTest->GetShortPathToFile(fullFileName.c_str()))
-      << "\" Covered=\"" << (tested > 0 ? "true":"false") << "\">\n"
+      << "\" Covered=\"" << (tested+untested > 0 ? "true":"false") << "\">\n"
       << "\t\t<LOCTested>" << tested << "</LOCTested>\n"
       << "\t\t<LOCUnTested>" << untested << "</LOCUnTested>\n"
       << "\t\t<PercentCoverage>";

+ 1 - 0
Source/CursesDialog/ccmake.cxx

@@ -102,6 +102,7 @@ int main(int argc, char** argv)
 {
   cmSystemTools::FindExecutableDirectory(argv[0]);
   cmDocumentation doc;
+  doc.addCMakeStandardDocSections();
   if(doc.CheckOptions(argc, argv))
     {
     cmake hcm;

+ 5 - 6
Source/CursesDialog/cmCursesMainForm.cxx

@@ -409,12 +409,11 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
   char thirdLine[512]="";
   if (process)
     {
-    sprintf(firstLine,
-            "                                                               ");
-    sprintf(secondLine,
-            "                                                               ");
-    sprintf(thirdLine,
-            "                                                               ");
+    const char* clearLine =
+      "                                                                    ";
+    strcpy(firstLine, clearLine);
+    strcpy(secondLine, clearLine);
+    strcpy(thirdLine, clearLine);
     }
   else
     {

+ 2 - 2
Source/QtDialog/CMakeLists.txt

@@ -10,11 +10,11 @@
 # See the License for more information.
 #=============================================================================
 PROJECT(QtDialog)
-SET(QT_MIN_VERSION "4.3.0")
+SET(QT_MIN_VERSION "4.4.0")
 FIND_PACKAGE(Qt4 REQUIRED)
 
 IF(NOT QT4_FOUND)
-  MESSAGE(SEND_ERROR "Failed to find Qt 4.3 or greater.")
+  MESSAGE(SEND_ERROR "Failed to find Qt 4.4 or greater.")
 ELSE(NOT QT4_FOUND)
 
   INCLUDE(${QT_USE_FILE})

+ 1 - 0
Source/QtDialog/CMakeSetup.cxx

@@ -64,6 +64,7 @@ int main(int argc, char** argv)
   // check docs first so that X is not need to get docs
   // do docs, if args were given
   cmDocumentation doc;
+  doc.addCMakeStandardDocSections();
   if(argc >1 && doc.CheckOptions(argc, argv))
     {
     // Construct and print requested documentation.

+ 1 - 2
Source/QtDialog/CMakeSetupDialog.cxx

@@ -554,8 +554,7 @@ void CMakeSetupDialog::doHelp()
 void CMakeSetupDialog::doInterrupt()
 {
   this->enterState(Interrupting);
-  QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
-    "interrupt", Qt::QueuedConnection);
+  this->CMakeThread->cmakeInstance()->interrupt();
 }
 
 void CMakeSetupDialog::doSourceBrowse()

+ 12 - 1
Source/QtDialog/QCMake.cxx

@@ -63,6 +63,8 @@ QCMake::QCMake(QObject* p)
 #endif
   this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this);
 
+  cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this);
+
   std::vector<std::string> generators;
   this->CMakeInstance->GetRegisteredGenerators(generators);
   std::vector<std::string>::iterator iter;
@@ -170,6 +172,7 @@ void QCMake::configure()
   this->CMakeInstance->SetWarnUnused(this->WarnUnusedMode);
   this->CMakeInstance->PreLoadCMakeFiles();
 
+  InterruptFlag = 0;
   cmSystemTools::ResetErrorOccuredFlag();
 
   int err = this->CMakeInstance->Configure();
@@ -188,7 +191,9 @@ void QCMake::generate()
   UINT lastErrorMode = SetErrorMode(0);
 #endif
 
+  InterruptFlag = 0;
   cmSystemTools::ResetErrorOccuredFlag();
+
   int err = this->CMakeInstance->Generate();
 
 #ifdef Q_OS_WIN
@@ -337,7 +342,13 @@ QCMakePropertyList QCMake::properties() const
   
 void QCMake::interrupt()
 {
-  cmSystemTools::SetFatalErrorOccured();
+  this->InterruptFlag.ref();
+}
+
+bool QCMake::interruptCallback(void* cd)
+{
+  QCMake* self = reinterpret_cast<QCMake*>(cd);
+  return self->InterruptFlag;
 }
 
 void QCMake::progressCallback(const char* msg, float percent, void* cd)

+ 4 - 1
Source/QtDialog/QCMake.h

@@ -23,6 +23,7 @@
 #include <QList>
 #include <QStringList>
 #include <QMetaType>
+#include <QAtomicInt>
 
 class cmake;
 
@@ -78,7 +79,7 @@ public slots:
   void generate();
   /// set the property values
   void setProperties(const QCMakePropertyList&);
-  /// interrupt the configure or generate process
+  /// interrupt the configure or generate process (if connecting, make a direct connection)
   void interrupt();
   /// delete the cache in binary directory
   void deleteCache();
@@ -133,6 +134,7 @@ signals:
 protected:
   cmake* CMakeInstance;
 
+  static bool interruptCallback(void*);
   static void progressCallback(const char* msg, float percent, void* cd);
   static void errorCallback(const char* msg, const char* title, 
                             bool&, void* cd);
@@ -145,6 +147,7 @@ protected:
   QString Generator;
   QStringList AvailableGenerators;
   QString CMakeExecutable;
+  QAtomicInt InterruptFlag;
 };
 
 #endif // __QCMake_h

+ 6 - 2
Source/cmBootstrapCommands.cxx

@@ -12,7 +12,7 @@
 // This file is used to compile all the commands
 // that CMake knows about at compile time.
 // This is sort of a boot strapping approach since you would
-// like to have CMake to build CMake.   
+// like to have CMake to build CMake.
 #include "cmCommands.h"
 #include "cmAddCustomCommandCommand.cxx"
 #include "cmAddCustomTargetCommand.cxx"
@@ -38,6 +38,7 @@
 #include "cmEndFunctionCommand.cxx"
 #include "cmEndIfCommand.cxx"
 #include "cmEndMacroCommand.cxx"
+#include "cmEndWhileCommand.cxx"
 #include "cmExecProgramCommand.cxx"
 #include "cmExecuteProcessCommand.cxx"
 #include "cmExternalMakefileProjectGenerator.cxx"
@@ -91,6 +92,7 @@
 #include "cmTryCompileCommand.cxx"
 #include "cmTryRunCommand.cxx"
 #include "cmUnsetCommand.cxx"
+#include "cmWhileCommand.cxx"
 
 void GetBootstrapCommands(std::list<cmCommand*>& commands)
 {
@@ -111,11 +113,12 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
   commands.push_back(new cmDefinePropertyCommand);
   commands.push_back(new cmElseCommand);
   commands.push_back(new cmEnableLanguageCommand);
-  commands.push_back(new cmEnableTestingCommand);  
+  commands.push_back(new cmEnableTestingCommand);
   commands.push_back(new cmEndForEachCommand);
   commands.push_back(new cmEndFunctionCommand);
   commands.push_back(new cmEndIfCommand);
   commands.push_back(new cmEndMacroCommand);
+  commands.push_back(new cmEndWhileCommand);
   commands.push_back(new cmExecProgramCommand);
   commands.push_back(new cmExecuteProcessCommand);
   commands.push_back(new cmFileCommand);
@@ -164,4 +167,5 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
   commands.push_back(new cmTryCompileCommand);
   commands.push_back(new cmTryRunCommand);
   commands.push_back(new cmUnsetCommand);
+  commands.push_back(new cmWhileCommand);
 }

+ 11 - 0
Source/cmCommand.h

@@ -110,6 +110,17 @@ public:
     return false;
     }
 
+  /**
+   * This is used to avoid including this command
+   * in documentation. This is mainly used by
+   * cmMacroHelperCommand and cmFunctionHelperCommand
+   * which cannot provide appropriate documentation.
+   */
+  virtual bool ShouldAppearInDocumentation()
+    {
+    return true;
+    }
+
   /**
    * The name of the command as specified in CMakeList.txt.
    */

+ 0 - 4
Source/cmCommands.cxx

@@ -14,7 +14,6 @@
 #include "cmAuxSourceDirectoryCommand.cxx"
 #include "cmBuildNameCommand.cxx"
 #include "cmElseIfCommand.cxx"
-#include "cmEndWhileCommand.cxx"
 #include "cmExportCommand.cxx"
 #include "cmExportLibraryDependencies.cxx"
 #include "cmFLTKWrapUICommand.cxx"
@@ -34,7 +33,6 @@
 #include "cmVariableRequiresCommand.cxx"
 #include "cmVariableWatchCommand.cxx"
 
-#include "cmWhileCommand.cxx"
 #include "cmWriteFileCommand.cxx"
 
 // This one must be last because it includes windows.h and
@@ -53,7 +51,6 @@ void GetPredefinedCommands(std::list<cmCommand*>&
   commands.push_back(new cmAuxSourceDirectoryCommand);
   commands.push_back(new cmBuildNameCommand);
   commands.push_back(new cmElseIfCommand);
-  commands.push_back(new cmEndWhileCommand);
   commands.push_back(new cmExportCommand);
   commands.push_back(new cmExportLibraryDependenciesCommand);
   commands.push_back(new cmFLTKWrapUICommand);
@@ -73,7 +70,6 @@ void GetPredefinedCommands(std::list<cmCommand*>&
   commands.push_back(new cmUtilitySourceCommand);
   commands.push_back(new cmVariableRequiresCommand);
   commands.push_back(new cmVariableWatchCommand);
-  commands.push_back(new cmWhileCommand);
   commands.push_back(new cmWriteFileCommand);
 #endif
 }

+ 13 - 1
Source/cmComputeLinkInformation.cxx

@@ -248,6 +248,10 @@ cmComputeLinkInformation
   this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
   this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
 
+  // Check whether to recognize OpenBSD-style library versioned names.
+  this->OpenBSD = this->Makefile->GetCMakeInstance()
+    ->GetPropertyAsBool("FIND_LIBRARY_USE_OPENBSD_VERSIONING");
+
   // The configuration being linked.
   this->Config = config;
 
@@ -973,7 +977,15 @@ cmComputeLinkInformation
     }
 
   // Finish the list.
-  libext += ")$";
+  libext += ")";
+
+  // Add an optional OpenBSD version component.
+  if(this->OpenBSD)
+    {
+    libext += "(\\.[0-9]+\\.[0-9]+)?";
+    }
+
+  libext += "$";
   return libext;
 }
 

+ 1 - 0
Source/cmComputeLinkInformation.h

@@ -128,6 +128,7 @@ private:
   cmsys::RegularExpression ExtractSharedLibraryName;
   cmsys::RegularExpression ExtractAnyLibraryName;
   std::string SharedRegexString;
+  bool OpenBSD;
   void AddLinkPrefix(const char* p);
   void AddLinkExtension(const char* e, LinkType type);
   std::string CreateExtensionRegex(std::vector<std::string> const& exts);

+ 9 - 4
Source/cmCoreTryCompile.cxx

@@ -26,6 +26,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
   const char* sourceDirectory = argv[2].c_str();
   const char* projectName = 0;
   const char* targetName = 0;
+  char targetNameBuf[64];
   int extraArgs = 0;
 
   // look for CMAKE_FLAGS and store them
@@ -281,16 +282,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
       cmakeFlags.push_back(flag);
       }
 
+    /* Use a random file name to avoid rapid creation and deletion
+       of the same executable name (some filesystems fail on that).  */
+    sprintf(targetNameBuf, "cmTryCompileExec%u",
+            cmSystemTools::RandomSeed());
+    targetName = targetNameBuf;
+
     /* Put the executable at a known location (for COPY_FILE).  */
     fprintf(fout, "SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
             this->BinaryDirectory.c_str());
     /* Create the actual executable.  */
-    fprintf(fout, "ADD_EXECUTABLE(cmTryCompileExec \"%s\")\n",source.c_str());
-    fprintf(fout,
-            "TARGET_LINK_LIBRARIES(cmTryCompileExec ${LINK_LIBRARIES})\n");
+    fprintf(fout, "ADD_EXECUTABLE(%s \"%s\")\n", targetName, source.c_str());
+    fprintf(fout, "TARGET_LINK_LIBRARIES(%s ${LINK_LIBRARIES})\n",targetName);
     fclose(fout);
     projectName = "CMAKE_TRY_COMPILE";
-    targetName = "cmTryCompileExec";
     // if the source is not in CMakeTmp
     if(source.find("CMakeTmp") == source.npos)
       {

+ 13 - 1
Source/cmDepends.cxx

@@ -260,12 +260,24 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
 //----------------------------------------------------------------------------
 void cmDepends::SetIncludePathFromLanguage(const char* lang)
 {
+  // Look for the new per "TARGET_" variant first:
   std::string includePathVar = "CMAKE_";
   includePathVar += lang;
-  includePathVar += "_INCLUDE_PATH";
+  includePathVar += "_TARGET_INCLUDE_PATH";
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
   if(const char* includePath = mf->GetDefinition(includePathVar.c_str()))
     {
     cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
     }
+  else
+    {
+    // Fallback to the old directory level variable if no per-target var:
+    includePathVar = "CMAKE_";
+    includePathVar += lang;
+    includePathVar += "_INCLUDE_PATH";
+    if(const char* includePath = mf->GetDefinition(includePathVar.c_str()))
+      {
+      cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
+      }
+    }
 }

+ 422 - 49
Source/cmDocumentation.cxx

@@ -14,7 +14,9 @@
 #include "cmSystemTools.h"
 #include "cmVersion.h"
 #include <cmsys/Directory.hxx>
+#include <cmsys/Glob.hxx>
 
+#include <algorithm>
 
 //----------------------------------------------------------------------------
 static const char *cmDocumentationStandardOptions[][3] =
@@ -220,55 +222,7 @@ cmDocumentation::cmDocumentation()
 :CurrentFormatter(0)
 {
   this->SetForm(TextForm);
-
-  cmDocumentationSection *sec;
-
-  sec = new cmDocumentationSection("Author","AUTHOR");
-  sec->Append(cmDocumentationEntry
-              (0,
-               "This manual page was generated by the \"--help-man\" option.",
-               0));
-  this->AllSections["Author"] = sec;
-
-  sec = new cmDocumentationSection("Copyright","COPYRIGHT");
-  sec->Append(cmDocumentationCopyright);
-  this->AllSections["Copyright"] = sec;
-
-  sec = new cmDocumentationSection("See Also","SEE ALSO");
-  sec->Append(cmDocumentationStandardSeeAlso);
-  this->AllSections["Standard See Also"] = sec;
-
-  sec = new cmDocumentationSection("Options","OPTIONS");
-  sec->Append(cmDocumentationStandardOptions);
-  this->AllSections["Options"] = sec;
-
-  sec = new cmDocumentationSection("Properties","PROPERTIES");
-  sec->Append(cmPropertiesDocumentationDescription);
-  this->AllSections["Properties Description"] = sec;
-
-  sec = new cmDocumentationSection("Generators","GENERATORS");
-  sec->Append(cmDocumentationGeneratorsHeader);
-  this->AllSections["Generators"] = sec;
-
-  sec = new cmDocumentationSection("Compatibility Commands",
-                                   "COMPATIBILITY COMMANDS");
-  sec->Append(cmCompatCommandsDocumentationDescription);
-  this->AllSections["Compatibility Commands"] = sec;
-
-
-  this->PropertySections.push_back("Properties of Global Scope");
-  this->PropertySections.push_back("Properties on Directories");
-  this->PropertySections.push_back("Properties on Targets");
-  this->PropertySections.push_back("Properties on Tests");
-  this->PropertySections.push_back("Properties on Source Files");
-  this->PropertySections.push_back("Properties on Cache Entries");
-
-  this->VariableSections.push_back("Variables that Provide Information");
-  this->VariableSections.push_back("Variables That Change Behavior");
-  this->VariableSections.push_back("Variables That Describe the System");
-  this->VariableSections.push_back("Variables that Control the Build");
-  this->VariableSections.push_back("Variables for Languages");
-
+  this->addCommonStandardDocSections();
   this->ShowGenerators = true;
 }
 
@@ -559,6 +513,8 @@ bool cmDocumentation::CreateSingleModule(const char* fname,
     {
     if(line.size() && line[0] == '#')
       {
+      /* line beginnings with ## are mark-up ignore them */
+      if (line.size()>=2 && line[1] == '#') continue;
       // blank line
       if(line.size() <= 2)
         {
@@ -709,6 +665,423 @@ cmDocumentation::Form cmDocumentation::GetFormFromFilename(
   return cmDocumentation::TextForm;
 }
 
+//----------------------------------------------------------------------------
+void cmDocumentation::addCommonStandardDocSections()
+{
+    cmDocumentationSection *sec;
+
+    sec = new cmDocumentationSection("Author","AUTHOR");
+    sec->Append(cmDocumentationEntry
+               (0,
+                "This manual page was generated by the \"--help-man\" option.",
+                0));
+    this->AllSections["Author"] = sec;
+
+    sec = new cmDocumentationSection("Copyright","COPYRIGHT");
+    sec->Append(cmDocumentationCopyright);
+    this->AllSections["Copyright"] = sec;
+
+    sec = new cmDocumentationSection("See Also","SEE ALSO");
+    sec->Append(cmDocumentationStandardSeeAlso);
+    this->AllSections["Standard See Also"] = sec;
+
+    sec = new cmDocumentationSection("Options","OPTIONS");
+    sec->Append(cmDocumentationStandardOptions);
+    this->AllSections["Options"] = sec;
+
+    sec = new cmDocumentationSection("Compatibility Commands",
+                                     "COMPATIBILITY COMMANDS");
+    sec->Append(cmCompatCommandsDocumentationDescription);
+    this->AllSections["Compatibility Commands"] = sec;
+}
+
+//----------------------------------------------------------------------------
+void cmDocumentation::addCMakeStandardDocSections()
+{
+    cmDocumentationSection *sec;
+
+    sec = new cmDocumentationSection("Properties","PROPERTIES");
+    sec->Append(cmPropertiesDocumentationDescription);
+    this->AllSections["Properties Description"] = sec;
+
+    sec = new cmDocumentationSection("Generators","GENERATORS");
+    sec->Append(cmDocumentationGeneratorsHeader);
+    this->AllSections["Generators"] = sec;
+
+    this->PropertySections.push_back("Properties of Global Scope");
+    this->PropertySections.push_back("Properties on Directories");
+    this->PropertySections.push_back("Properties on Targets");
+    this->PropertySections.push_back("Properties on Tests");
+    this->PropertySections.push_back("Properties on Source Files");
+    this->PropertySections.push_back("Properties on Cache Entries");
+
+    this->VariableSections.push_back("Variables that Provide Information");
+    this->VariableSections.push_back("Variables That Change Behavior");
+    this->VariableSections.push_back("Variables That Describe the System");
+    this->VariableSections.push_back("Variables that Control the Build");
+    this->VariableSections.push_back("Variables for Languages");
+
+}
+
+//----------------------------------------------------------------------------
+void cmDocumentation::addCTestStandardDocSections()
+{
+    // This is currently done for backward compatibility reason
+    // We may suppress some of these.
+    addCMakeStandardDocSections();
+}
+
+//----------------------------------------------------------------------------
+void cmDocumentation::addCPackStandardDocSections()
+{
+    cmDocumentationSection *sec;
+
+    sec = new cmDocumentationSection("Generators","GENERATORS");
+    sec->Append(cmDocumentationGeneratorsHeader);
+    this->AllSections["Generators"] = sec;
+
+    this->VariableSections.push_back(
+            "Variables common to all CPack generators");
+}
+
+void cmDocumentation::addAutomaticVariableSections(const std::string& section)
+{
+  std::vector<std::string>::iterator it;
+  it = std::find(this->VariableSections.begin(),
+                 this->VariableSections.end(),
+                 section);
+  /* if the section does not exist then add it */
+  if (it==this->VariableSections.end())
+    {
+    this->VariableSections.push_back(section);
+    }
+}
+//----------------------------------------------------------------------------
+int cmDocumentation::getDocumentedModulesListInDir(
+          std::string path,
+          std::string globExpr,
+          documentedModulesList_t& docedModuleList)
+{
+  cmsys::Glob gl;
+  std::string findExpr;
+  std::vector<std::string> files;
+  std::string line;
+  documentedModuleSectionPair_t docPair;
+  int nbDocumentedModules = 0;
+
+  findExpr = path + "/" + globExpr;
+  if (gl.FindFiles(findExpr))
+    {
+    files = gl.GetFiles();
+    for (std::vector<std::string>::iterator itf=files.begin();
+        itf!=files.end();++itf)
+      {
+      std::ifstream fin((*itf).c_str());
+      // file access trouble ignore it (ignore this kind of error)
+      if (!fin) continue;
+      /* read first line in order to get doc section */
+      if (cmSystemTools::GetLineFromStream(fin, line))
+        {
+        /* Doc section indicates that
+         * this file has structured doc in it.
+         */
+        if (line.find("##section")!=std::string::npos)
+          {
+          // ok found one more documented module
+          ++nbDocumentedModules;
+          docPair.first = *itf;
+          // 10 is the size of '##section' + 1
+          docPair.second = line.substr(10,std::string::npos);
+          docedModuleList.push_back(docPair);
+          }
+        // No else if no section is found (undocumented module)
+        }
+      // No else cannot read first line (ignore this kind of error)
+      line = "";
+      }
+    }
+  if (nbDocumentedModules>0)
+    {
+    return 0;
+    }
+  else
+    {
+    return 1;
+    }
+}
+
+//----------------------------------------------------------------------------
+static void trim(std::string& s)
+{
+  std::string::size_type pos = s.find_last_not_of(' ');
+  if(pos != std::string::npos)
+    {
+    s.erase(pos + 1);
+    pos = s.find_first_not_of(' ');
+    if(pos != std::string::npos) s.erase(0, pos);
+    }
+  else
+    {
+    s.erase(s.begin(), s.end());
+    }
+}
+
+int cmDocumentation::GetStructuredDocFromFile(
+        const char* fname,
+        std::vector<cmDocumentationEntry>& commands,
+        cmake* cm)
+{
+    typedef enum sdoce {
+        SDOC_NONE, SDOC_MODULE, SDOC_MACRO, SDOC_FUNCTION, SDOC_VARIABLE,
+        SDOC_SECTION,
+        SDOC_UNKNOWN} sdoc_t;
+    int nbDocItemFound = 0;
+    int docCtxIdx      = 0;
+    std::vector<int> docContextStack(60);
+    docContextStack[docCtxIdx]=SDOC_NONE;
+    cmDocumentationEntry e;
+    std::ifstream fin(fname);
+    if(!fin)
+      {
+      return nbDocItemFound;
+      }
+    std::string section;
+    std::string name;
+    std::string full;
+    std::string brief;
+    std::string line;
+    bool newCtx  = false; /* we've just entered ##<beginkey> context */
+    bool inBrief = false; /* we are currently parsing brief desc. */
+    bool inFullFirstParagraph = false; /* we are currently parsing full
+                                          desc. first paragraph */
+    brief = "";
+    full  = "";
+    bool newParagraph = true;
+    while ( fin && cmSystemTools::GetLineFromStream(fin, line) )
+      {
+      if(line.size() && line[0] == '#')
+        {
+        /* handle structured doc context */
+        if ((line.size()>=2) && line[1]=='#')
+        {
+            /* markup word is following '##' stopping at first space
+             * Some markup word like 'section' may have more characters
+             * following but we don't handle those here.
+             */
+            std::string mkword = line.substr(2,line.find(' ',2)-2);
+            if (mkword=="macro")
+            {
+               docCtxIdx++;
+               docContextStack[docCtxIdx]=SDOC_MACRO;
+               newCtx = true;
+            }
+            else if (mkword=="variable")
+            {
+               docCtxIdx++;
+               docContextStack[docCtxIdx]=SDOC_VARIABLE;
+               newCtx = true;
+            }
+            else if (mkword=="function")
+            {
+               docCtxIdx++;
+               docContextStack[docCtxIdx]=SDOC_FUNCTION;
+               newCtx = true;
+            }
+            else if (mkword=="module")
+            {
+               docCtxIdx++;
+               docContextStack[docCtxIdx]=SDOC_MODULE;
+               newCtx = true;
+            }
+            else if (mkword=="section")
+            {
+               docCtxIdx++;
+               docContextStack[docCtxIdx]=SDOC_SECTION;
+               // 10 is the size of '##section' + 1
+               section = line.substr(10,std::string::npos);
+               /* drop the rest of the line */
+               line = "";
+               newCtx = true;
+            }
+            else if (mkword.substr(0,3)=="end")
+            {
+               switch (docContextStack[docCtxIdx]) {
+               case SDOC_MACRO:
+                   /* for now MACRO and FUNCTION are handled in the same way */
+               case SDOC_FUNCTION:
+                   commands.push_back(cmDocumentationEntry(name.c_str(),
+                           brief.c_str(),full.c_str()));
+                   break;
+               case SDOC_VARIABLE:
+                   this->addAutomaticVariableSections(section);
+                   cm->DefineProperty
+                       (name.c_str(), cmProperty::VARIABLE,
+                        brief.c_str(),
+                        full.c_str(),false,
+                        section.c_str());
+                   break;
+               case SDOC_MODULE:
+                   /*  not implemented */
+                   break;
+               case SDOC_SECTION:
+                   /*  not implemented */
+                   break;
+               default:
+                   /* ignore other cases */
+                   break;
+               }
+               docCtxIdx--;
+               newCtx = false;
+               ++nbDocItemFound;
+            }
+            else
+            {
+                // error out unhandled context
+                return nbDocItemFound;
+            }
+            /* context is set go to next doc line */
+            continue;
+        }
+
+        // Now parse the text attached to the context
+
+        // The first line after the context mark-up contains::
+        //  name - brief until. (brief is dot terminated or
+        //                       followed by a blank line)
+        if (newCtx)
+        {
+            // no brief (for easy variable definition)
+            if (line.find("-")==std::string::npos)
+            {
+                name = line.substr(1,std::string::npos);
+                trim(name);
+                brief   = "";
+                inBrief = false;
+                full = "";
+            }
+            // here we have a name and brief beginning
+            else
+            {
+                name = line.substr(1,line.find("-")-1);
+                trim(name);
+                // we are parsing the brief context
+                brief = line.substr(line.find("-")+1,std::string::npos);
+                trim(brief);
+                // Brief may already be terminated on the first line
+                if (brief.find('.')!=std::string::npos)
+                {
+                   inBrief = false;
+                   full    = brief.substr(brief.find('.')+1,std::string::npos);
+                   trim(full);
+                   inFullFirstParagraph = true;
+                   brief   = brief.substr(0,brief.find('.'));
+                }
+                // brief is continued on following lines
+                else
+                {
+                    inBrief = true;
+                    full = "";
+                }
+            }
+            newCtx = false;
+            continue;
+        }
+        // blank line
+        if(line.size() <= 2)
+        {
+            if (inBrief) {
+              inBrief = false;
+              full    = "";
+            } else {
+              if (full.length()>0)
+                {
+                full += "\n";
+                }
+              // the first paragraph of full has ended
+              inFullFirstParagraph = false;
+            }
+            newParagraph = true;
+        }
+        // brief is terminated by '.'
+        else if (inBrief && (line.find('.')!=std::string::npos))
+        {
+            /* the brief just ended */
+            inBrief = false;
+            std::string endBrief  = line.substr(1,line.find('.'));
+            trim(endBrief);
+            trim(brief);
+            brief  += " " + endBrief;
+            full   += line.substr(line.find('.')+1,std::string::npos);
+            trim(full);
+            inFullFirstParagraph = true;
+        }
+        // we handle full text or multi-line brief.
+        else
+          {
+          std::string* text;
+          if (inBrief)
+            {
+            text = &brief;
+            }
+          else
+            {
+            text = &full;
+            }
+          // two spaces
+          if(line[1] == ' ' && line[2] == ' ')
+            {
+            // there is no "full first paragraph at all."
+            if (line[3] == ' ')
+              {
+              inFullFirstParagraph = false;
+              }
+
+            if(!newParagraph && !inFullFirstParagraph)
+              {
+              *text += "\n";
+              newParagraph = true;
+              }
+            // Skip #, and leave space for pre-formatted
+            if (inFullFirstParagraph)
+              {
+              std::string temp = line.c_str()+1;
+              trim(temp);
+              *text += " " + temp;
+              }
+            else
+              {
+              *text += line.c_str()+1;
+              *text += "\n";
+              }
+            }
+          else if(line[1] == ' ')
+            {
+            if(!newParagraph)
+              {
+              *text += " ";
+              }
+            newParagraph = false;
+            // skip # and space
+            *text += line.c_str()+2;
+            }
+          else
+            {
+            if(!newParagraph)
+              {
+              *text += " ";
+              }
+            newParagraph = false;
+            // skip #
+            *text += line.c_str()+1;
+            }
+          }
+        }
+      /* next line is not the first context line */
+      newCtx = false;
+      }
+    return nbDocItemFound;
+}
+
 //----------------------------------------------------------------------------
 bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
                                    const char* exitOpt)

+ 70 - 0
Source/cmDocumentation.h

@@ -21,6 +21,7 @@
 #include "cmDocumentationFormatterText.h"
 #include "cmDocumentationFormatterUsage.h"
 #include "cmDocumentationSection.h"
+#include "cmake.h"
 
 namespace cmsys
 {
@@ -34,6 +35,21 @@ public:
   cmDocumentation();
   
   ~cmDocumentation();
+
+  /**
+   * An helper type pair for [structured] documented modules.
+   * The comment of those module contains structure markup
+   * which makes it possible to retrieve the documentation
+   * of variables, macros and functions defined in the module.
+   * - first is the filename of the module
+   * - second is the section of the doc the module belongs too
+   */
+  typedef std::pair<std::string,std::string> documentedModuleSectionPair_t;
+  /**
+   * A list of documented module(s).
+   */
+  typedef std::list<documentedModuleSectionPair_t>  documentedModulesList_t;
+
   // High-level interface for standard documents:
   
   /**
@@ -119,6 +135,60 @@ public:
   
   static Form GetFormFromFilename(const std::string& filename);
 
+  /** Add common (to all tools) documentation section(s) */
+  void addCommonStandardDocSections();
+
+  /** Add the CMake standard documentation section(s) */
+  void addCMakeStandardDocSections();
+
+  /** Add the CTest standard documentation section(s) */
+  void addCTestStandardDocSections();
+
+  /** Add the CPack standard documentation section(s) */
+  void addCPackStandardDocSections();
+
+  /** Add automatic variables sections */
+  void addAutomaticVariableSections(const std::string& section);
+
+  /**
+   * Retrieve the list of documented module located in
+   * path which match the globing expression globExpr.
+   * @param[in] path, directory where to start the search
+   *                  we will recurse into it.
+   * @param[in] globExpr, the globing expression used to
+   *                      match the file in path.
+   * @param[out] the list of obtained pairs (may be empty)
+   * @return 0 on success 1 on error or empty list
+   */
+  int getDocumentedModulesListInDir(
+          std::string path,
+          std::string globExpr,
+          documentedModulesList_t& docModuleList);
+
+  /**
+   * Get the documentation of macros, functions and variable documented
+   * with CMake structured documentation in a CMake script.
+   * (in fact it may be in any file which follow the structured doc format)
+   * Structured documentation begin with
+   * ## (double sharp) in column 1 & 2 immediately followed
+   * by a markup. Those ## are ignored by the legacy module
+   * documentation parser @see CreateSingleModule.
+   * Current markup are ##section, ##module,
+   * ##macro, ##function, ##variable and ##end.
+   * ##end is closing either of the previous ones.
+   * @param[in] fname the script file name to be parsed for documentation
+   * @param[in,out] commands the vector of command/macros documentation
+   *                entry found in the script file.
+   * @param[in,out] the cmake object instance to which variable documentation
+   *                will be attached (using @see cmake::DefineProperty)
+   * @param[in] the documentation section in which the property will be
+   *            inserted.
+   * @return the number of documented items (command and variable)
+   *         found in the file.
+   */
+  int GetStructuredDocFromFile(const char* fname,
+                               std::vector<cmDocumentationEntry>& commands,
+                               cmake* cm);
 private:
   void SetForm(Form f);
   void SetDocName(const char* docname);

+ 6 - 5
Source/cmExtraCodeBlocksGenerator.cxx

@@ -600,16 +600,17 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
 
       // the include directories for this target
       std::set<std::string> uniqIncludeDirs;
-      const std::vector<std::string>& incDirs =
-          target->GetMakefile()->GetIncludeDirectories();
-      for(std::vector<std::string>::const_iterator dirIt=incDirs.begin();
-          dirIt != incDirs.end();
+
+      std::vector<std::string> includes;
+      target->GetMakefile()->GetLocalGenerator()->
+        GetIncludeDirectories(includes, target);
+      for(std::vector<std::string>::const_iterator dirIt=includes.begin();
+          dirIt != includes.end();
           ++dirIt)
         {
         uniqIncludeDirs.insert(*dirIt);
         }
 
-
       std::string systemIncludeDirs = makefile->GetSafeDefinition(
                                 "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
       if (!systemIncludeDirs.empty())

+ 7 - 3
Source/cmExtraEclipseCDT4Generator.cxx

@@ -893,9 +893,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
        it != this->GlobalGenerator->GetLocalGenerators().end();
        ++it)
     {
-    const std::vector<std::string>& includeDirs
-      = (*it)->GetMakefile()->GetIncludeDirectories();
-    this->AppendIncludeDirectories(fout, includeDirs, emmited);
+    cmTargets & targets = (*it)->GetMakefile()->GetTargets();
+    for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l)
+      {
+      std::vector<std::string> includeDirs;
+      (*it)->GetIncludeDirectories(includeDirs, &l->second);
+      this->AppendIncludeDirectories(fout, includeDirs, emmited);
+      }
     }
   // now also the system include directories, in case we found them in
   // CMakeSystemSpecificInformation.cmake. This makes Eclipse find the

+ 14 - 4
Source/cmFindLibraryCommand.cxx

@@ -354,13 +354,23 @@ void cmFindLibraryHelper::RegexFromList(std::string& out,
 //----------------------------------------------------------------------------
 bool cmFindLibraryHelper::HasValidSuffix(std::string const& name)
 {
-  // Check if the given name ends in a valid library suffix.
   for(std::vector<std::string>::const_iterator si = this->Suffixes.begin();
       si != this->Suffixes.end(); ++si)
     {
-    std::string const& suffix = *si;
-    if(name.length() > suffix.length() &&
-       name.substr(name.size()-suffix.length()) == suffix)
+    std::string suffix = *si;
+    if(name.length() <= suffix.length())
+      {
+      continue;
+      }
+    // Check if the given name ends in a valid library suffix.
+    if(name.substr(name.size()-suffix.length()) == suffix)
+      {
+      return true;
+      }
+    // Check if a valid library suffix is somewhere in the name,
+    // this may happen e.g. for versioned shared libraries: libfoo.so.2
+    suffix += ".";
+    if(name.find(suffix) != name.npos)
       {
       return true;
       }

+ 9 - 0
Source/cmFindPackageCommand.cxx

@@ -1226,6 +1226,15 @@ void cmFindPackageCommand::AppendSuccessInformation()
     }
   this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName.c_str(),
                                                   versionInfo.c_str());
+  if (this->Required)
+    {
+    std::string requiredInfoPropName = "_CMAKE_";
+    requiredInfoPropName += this->Name;
+    requiredInfoPropName += "_TYPE";
+    this->Makefile->GetCMakeInstance()->SetProperty(
+                                     requiredInfoPropName.c_str(), "REQUIRED");
+    }
+
 
   // Restore original state of "_FIND_" variables we set.
   this->RestoreFindDefinitions();

+ 11 - 0
Source/cmFunctionCommand.cxx

@@ -22,6 +22,17 @@ public:
   ///! clean up any memory allocated by the function
   ~cmFunctionHelperCommand() {};
 
+  /**
+   * This is used to avoid including this command
+   * in documentation. This is mainly used by
+   * cmMacroHelperCommand and cmFunctionHelperCommand
+   * which cannot provide appropriate documentation.
+   */
+  virtual bool ShouldAppearInDocumentation()
+    {
+    return false;
+    }
+
   /**
    * This is a virtual constructor for the command.
    */

+ 20 - 19
Source/cmGlobalGenerator.cxx

@@ -1067,9 +1067,9 @@ void cmGlobalGenerator::CheckLocalGenerators()
     {
     manager = this->LocalGenerators[i]->GetMakefile()->GetCacheManager();
     this->LocalGenerators[i]->ConfigureFinalPass();
-    const cmTargets & targets =
+    cmTargets & targets =
       this->LocalGenerators[i]->GetMakefile()->GetTargets();
-    for (cmTargets::const_iterator l = targets.begin();
+    for (cmTargets::iterator l = targets.begin();
          l != targets.end(); l++)
       {
       const cmTarget::LinkLibraryVectorType& libs =
@@ -1095,27 +1095,28 @@ void cmGlobalGenerator::CheckLocalGenerators()
           notFoundMap[varName] = text;
           }
         }
-      }
-    const std::vector<std::string>& incs =
-      this->LocalGenerators[i]->GetMakefile()->GetIncludeDirectories();
+      std::vector<std::string> incs;
+      this->LocalGenerators[i]->GetIncludeDirectories(incs, &l->second);
 
-    for( std::vector<std::string>::const_iterator incDir = incs.begin();
-          incDir != incs.end(); ++incDir)
-      {
-      if(incDir->size() > 9 &&
-          cmSystemTools::IsNOTFOUND(incDir->c_str()))
+      for( std::vector<std::string>::const_iterator incDir = incs.begin();
+            incDir != incs.end(); ++incDir)
         {
-        std::string varName = incDir->substr(0, incDir->size()-9);
-        cmCacheManager::CacheIterator it =
-          manager->GetCacheIterator(varName.c_str());
-        if(it.GetPropertyAsBool("ADVANCED"))
+        if(incDir->size() > 9 &&
+            cmSystemTools::IsNOTFOUND(incDir->c_str()))
           {
-          varName += " (ADVANCED)";
+          std::string varName = incDir->substr(0, incDir->size()-9);
+          cmCacheManager::CacheIterator it =
+            manager->GetCacheIterator(varName.c_str());
+          if(it.GetPropertyAsBool("ADVANCED"))
+            {
+            varName += " (ADVANCED)";
+            }
+          std::string text = notFoundMap[varName];
+          text += "\n   used as include directory in directory ";
+          text += this->LocalGenerators[i]
+                      ->GetMakefile()->GetCurrentDirectory();
+          notFoundMap[varName] = text;
           }
-        std::string text = notFoundMap[varName];
-        text += "\n   used as include directory in directory ";
-        text += this->LocalGenerators[i]->GetMakefile()->GetCurrentDirectory();
-        notFoundMap[varName] = text;
         }
       }
     this->CMakeInstance->UpdateProgress

+ 1 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -1811,7 +1811,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
   BuildObjectListOrString dirs(this, this->XcodeVersion >= 30);
   BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30);
   std::vector<std::string> includes;
-  this->CurrentLocalGenerator->GetIncludeDirectories(includes);
+  this->CurrentLocalGenerator->GetIncludeDirectories(includes, &target);
   std::set<cmStdString> emitted;
   emitted.insert("/System/Library/Frameworks");
   for(std::vector<std::string>::iterator i = includes.begin();

+ 15 - 7
Source/cmIncludeDirectoryCommand.h

@@ -58,13 +58,21 @@ public:
     {
     return
       "  include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)\n"
-      "Add the given directories to those searched by the compiler for "
-      "include files. By default the directories are appended onto "
-      "the current list of directories. This default behavior can be "
-      "changed by setting CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. "
-      "By using BEFORE or AFTER you can select between appending and "
-      "prepending, independent from the default. "
-      "If the SYSTEM option is given the compiler will be told that the "
+      "Add the given directories to those the compiler uses to search "
+      "for include files. "
+      "These directories are added to the directory property "
+      "INCLUDE_DIRECTORIES for the current CMakeLists file. "
+      "They are also added to the target property INCLUDE_DIRECTORIES "
+      "for each target in the current CMakeLists file. "
+      "The target property values are the ones used by the generators."
+      "\n"
+      "By default the directories are appended onto the current list of "
+      "directories. "
+      "This default behavior can be changed by setting "
+      "CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. "
+      "By using AFTER or BEFORE explicitly, you can select between "
+      "appending and prepending, independent of the default. "
+      "If the SYSTEM option is given, the compiler will be told the "
       "directories are meant as system include directories on some "
       "platforms.";
     }

+ 26 - 26
Source/cmLocalGenerator.cxx

@@ -556,7 +556,7 @@ void cmLocalGenerator::GenerateTargetManifest()
 void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
                                                       const char* lang,
                                                       cmSourceFile& source,
-                                                      cmTarget& )
+                                                      cmTarget& target)
 {
   std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
   objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
@@ -574,7 +574,11 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
   std::string flags;
   flags += this->Makefile->GetSafeDefinition(varString.c_str());
   flags += " ";
-  flags += this->GetIncludeFlags(lang);
+    {
+    std::vector<std::string> includes;
+    this->GetIncludeDirectories(includes, &target, lang);
+    flags += this->GetIncludeFlags(includes, lang);
+    }
   flags += this->Makefile->GetDefineFlags();
 
   // Construct the command lines.
@@ -1192,24 +1196,16 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
 }
 
 //----------------------------------------------------------------------------
-const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
-                                              bool forResponseFile)
+std::string cmLocalGenerator::GetIncludeFlags(
+                                     const std::vector<std::string> &includes,
+                                     const char* lang, bool forResponseFile)
 {
   if(!lang)
     {
     return "";
     }
-  std::string key = lang;
-  key += forResponseFile? "@" : "";
-  if(this->LanguageToIncludeFlags.count(key))
-    {
-    return this->LanguageToIncludeFlags[key].c_str();
-    }
 
   cmOStringStream includeFlags;
-  std::vector<std::string> includes;
-  this->GetIncludeDirectories(includes, lang);
-  std::vector<std::string>::iterator i;
 
   std::string flagVar = "CMAKE_INCLUDE_FLAG_";
   flagVar += lang;
@@ -1251,6 +1247,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
 #ifdef __APPLE__
   emitted.insert("/System/Library/Frameworks");
 #endif
+  std::vector<std::string>::const_iterator i;
   for(i = includes.begin(); i != includes.end(); ++i)
     {
     if(this->Makefile->IsOn("APPLE")
@@ -1311,16 +1308,12 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
     {
     flags[flags.size()-1] = ' ';
     }
-  this->LanguageToIncludeFlags[key] = flags;
-
-  // Use this temorary variable for the return value to work-around a
-  // bogus GCC 2.95 warning.
-  const char* ret = this->LanguageToIncludeFlags[key].c_str();
-  return ret;
+  return flags;
 }
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
+                                             cmTarget* target,
                                              const char* lang)
 {
   // Need to decide whether to automatically include the source and
@@ -1375,8 +1368,12 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
   // Store the automatic include paths.
   if(includeBinaryDir)
     {
-    dirs.push_back(this->Makefile->GetStartOutputDirectory());
-    emitted.insert(this->Makefile->GetStartOutputDirectory());
+    if(emitted.find(
+                this->Makefile->GetStartOutputDirectory()) == emitted.end())
+      {
+      dirs.push_back(this->Makefile->GetStartOutputDirectory());
+      emitted.insert(this->Makefile->GetStartOutputDirectory());
+      }
     }
   if(includeSourceDir)
     {
@@ -1402,9 +1399,12 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
       }
     }
 
-  // Get the project-specified include directories.
-  std::vector<std::string>& includes =
-    this->Makefile->GetIncludeDirectories();
+  // Get the target-specific include directories.
+  std::vector<std::string> includes;
+  if(target)
+    {
+    includes = target->GetIncludeDirectories();
+    }
 
   // Support putting all the in-project include directories first if
   // it is requested by the project.
@@ -1412,7 +1412,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
     {
     const char* topSourceDir = this->Makefile->GetHomeDirectory();
     const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory();
-    for(std::vector<std::string>::iterator i = includes.begin();
+    for(std::vector<std::string>::const_iterator i = includes.begin();
         i != includes.end(); ++i)
       {
       // Emit this directory only if it is a subdirectory of the
@@ -1431,7 +1431,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
     }
 
   // Construct the final ordered include directory list.
-  for(std::vector<std::string>::iterator i = includes.begin();
+  for(std::vector<std::string>::const_iterator i = includes.begin();
       i != includes.end(); ++i)
     {
     if(emitted.insert(*i).second)

+ 3 - 3
Source/cmLocalGenerator.h

@@ -146,8 +146,8 @@ public:
   ///! Append flags to a string.
   virtual void AppendFlags(std::string& flags, const char* newFlags);
   ///! Get the include flags for the current makefile and language
-  const char* GetIncludeFlags(const char* lang,
-                              bool forResponseFile = false);
+  std::string GetIncludeFlags(const std::vector<std::string> &includes,
+                              const char* lang, bool forResponseFile = false);
 
   /**
    * Encode a list of preprocessor definitions for the compiler
@@ -195,6 +195,7 @@ public:
 
   /** Get the include flags for the current makefile and language.  */
   void GetIncludeDirectories(std::vector<std::string>& dirs,
+                             cmTarget* target,
                              const char* lang = "C");
 
   /** Compute the language used to compile the given source file.  */
@@ -392,7 +393,6 @@ protected:
   std::vector<std::string> StartOutputDirectoryComponents;
   cmLocalGenerator* Parent;
   std::vector<cmLocalGenerator*> Children;
-  std::map<cmStdString, cmStdString> LanguageToIncludeFlags;
   std::map<cmStdString, cmStdString> UniqueObjectNamesMap;
   std::string::size_type ObjectPathMax;
   std::set<cmStdString> ObjectMaxPathViolations;

+ 15 - 22
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -452,28 +452,6 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
       << "\n";
     }
 
-  // Store the include search path for this directory.
-  infoFileStream
-    << "# The C and CXX include file search paths:\n";
-  infoFileStream
-    << "SET(CMAKE_C_INCLUDE_PATH\n";
-  std::vector<std::string> includeDirs;
-  this->GetIncludeDirectories(includeDirs);
-  for(std::vector<std::string>::iterator i = includeDirs.begin();
-      i != includeDirs.end(); ++i)
-    {
-    infoFileStream
-      << "  \"" << this->Convert(i->c_str(),HOME_OUTPUT).c_str() << "\"\n";
-    }
-  infoFileStream
-    << "  )\n";
-  infoFileStream
-    << "SET(CMAKE_CXX_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n";
-  infoFileStream
-    << "SET(CMAKE_Fortran_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n";
-  infoFileStream
-    << "SET(CMAKE_ASM_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n";
-
   // Store the include regular expressions for this directory.
   infoFileStream
     << "\n"
@@ -562,6 +540,21 @@ cmLocalUnixMakefileGenerator3
     space = " ";
     }
 
+  // Warn about paths not supported by Make tools.
+  std::string::size_type pos = tgt.find_first_of("=");
+  if(pos != std::string::npos)
+    {
+    cmOStringStream m;
+    m <<
+      "Make rule for\n"
+      "  " << tgt << "\n"
+      "has '=' on left hand side.  "
+      "The make tool may not support this.";
+    cmListFileBacktrace bt;
+    this->GlobalGenerator->GetCMakeInstance()
+      ->IssueMessage(cmake::WARNING, m.str(), bt);
+    }
+
   // Mark the rule as symbolic if requested.
   if(symbolic)
     {

+ 60 - 45
Source/cmLocalVisualStudio6Generator.cxx

@@ -103,52 +103,9 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
       }
     }
 
-  // Setup /I and /LIBPATH options for the resulting DSP file.  VS 6
-  // truncates long include paths so make it as short as possible if
-  // the length threatens this problem.
-  unsigned int maxIncludeLength = 3000;
-  bool useShortPath = false;
-  for(int j=0; j < 2; ++j)
-    {
-    std::vector<std::string> includes;
-    this->GetIncludeDirectories(includes);
-    std::vector<std::string>::iterator i;
-    for(i = includes.begin(); i != includes.end(); ++i)
-      {
-      std::string tmp = 
-        this->ConvertToOptionallyRelativeOutputPath(i->c_str());
-      if(useShortPath)
-        {
-        cmSystemTools::GetShortPath(tmp.c_str(), tmp);
-        }
-      this->IncludeOptions +=  " /I ";
-
-      // quote if not already quoted
-      if (tmp[0] != '"')
-        {
-        this->IncludeOptions += "\"";
-        this->IncludeOptions += tmp;
-        this->IncludeOptions += "\"";
-        }
-      else
-        {
-        this->IncludeOptions += tmp;
-        }
-      }
-    if(j == 0 && this->IncludeOptions.size() > maxIncludeLength)
-      {
-      this->IncludeOptions = "";
-      useShortPath = true;
-      }
-    else
-      {
-      break;
-      }
-    }
-  
   // Create the DSP or set of DSP's for libraries and executables
 
-  cmTargets &tgts = this->Makefile->GetTargets(); 
+  cmTargets &tgts = this->Makefile->GetTargets();
   for(cmTargets::iterator l = tgts.begin(); 
       l != tgts.end(); l++)
     {
@@ -895,6 +852,61 @@ inline std::string removeQuotes(const std::string& s)
   return s;
 }
 
+
+std::string
+cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target)
+{
+  std::string includeOptions;
+
+  // Setup /I and /LIBPATH options for the resulting DSP file.  VS 6
+  // truncates long include paths so make it as short as possible if
+  // the length threatens this problem.
+  unsigned int maxIncludeLength = 3000;
+  bool useShortPath = false;
+  for(int j=0; j < 2; ++j)
+    {
+    std::vector<std::string> includes;
+    this->GetIncludeDirectories(includes, &target);
+
+    std::vector<std::string>::iterator i;
+    for(i = includes.begin(); i != includes.end(); ++i)
+      {
+      std::string tmp =
+        this->ConvertToOptionallyRelativeOutputPath(i->c_str());
+      if(useShortPath)
+        {
+        cmSystemTools::GetShortPath(tmp.c_str(), tmp);
+        }
+      includeOptions +=  " /I ";
+
+      // quote if not already quoted
+      if (tmp[0] != '"')
+        {
+        includeOptions += "\"";
+        includeOptions += tmp;
+        includeOptions += "\"";
+        }
+      else
+        {
+        includeOptions += tmp;
+        }
+      }
+
+    if(j == 0 && includeOptions.size() > maxIncludeLength)
+      {
+      includeOptions = "";
+      useShortPath = true;
+      }
+    else
+      {
+      break;
+      }
+    }
+
+  return includeOptions;
+}
+
+
 // Code in blocks surrounded by a test for this definition is needed
 // only for compatibility with user project's replacement DSP
 // templates.  The CMake templates no longer use them.
@@ -1132,6 +1144,9 @@ void cmLocalVisualStudio6Generator
     }
 #endif
 
+  // Get include options for this target.
+  std::string includeOptions = this->GetTargetIncludeOptions(target);
+
   // Get extra linker options for this target type.
   std::string extraLinkOptions;
   std::string extraLinkOptionsDebug;
@@ -1510,7 +1525,7 @@ void cmLocalVisualStudio6Generator
                                  optionsRelWithDebInfo.c_str());
 
     cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
-                                 this->IncludeOptions.c_str());
+                                 includeOptions.c_str());
     cmSystemTools::ReplaceString(line, "TARGET_VERSION_FLAG",
                                  targetVersionFlag.c_str());
     cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_DEBUG",

+ 1 - 1
Source/cmLocalVisualStudio6Generator.h

@@ -89,7 +89,7 @@ private:
   void ComputeLinkOptions(cmTarget& target, const char* configName,
                           const std::string extraOptions,
                           std::string& options);
-  std::string IncludeOptions;
+  std::string GetTargetIncludeOptions(cmTarget &target);
   std::vector<std::string> Configurations;
 
   std::string GetConfigName(std::string const& configuration) const;

Some files were not shown because too many files changed in this diff