Browse Source

Merge branch 'master' into AutomocIncludedDotMocFileHandling

Conflicts:
	Source/cmTarget.cxx
David Cole 14 years ago
parent
commit
2d1195123e
100 changed files with 1513 additions and 369 deletions
  1. 1 0
      .gitattributes
  2. 6 0
      CMakeLists.txt
  3. 1 1
      Copyright.txt
  4. 2 0
      Modules/AutomocInfo.cmake.in
  5. 3 0
      Modules/CMakeCCompilerId.c.in
  6. 6 0
      Modules/CMakeCInformation.cmake
  7. 6 0
      Modules/CMakeCXXInformation.cmake
  8. 2 0
      Modules/CMakeDetermineCompilerABI.cmake
  9. 2 2
      Modules/CMakeFindEclipseCDT4.cmake
  10. 5 0
      Modules/CMakeFortranCompilerABI.F
  11. 6 0
      Modules/CMakeFortranInformation.cmake
  12. 6 0
      Modules/CMakeTestCCompiler.cmake
  13. 6 0
      Modules/CMakeTestCXXCompiler.cmake
  14. 6 0
      Modules/CMakeTestFortranCompiler.cmake
  15. 29 3
      Modules/CPackRPM.cmake
  16. 8 0
      Modules/Compiler/TinyCC-C.cmake
  17. 5 1
      Modules/DeployQt4.cmake
  18. 11 2
      Modules/FindBISON.cmake
  19. 6 4
      Modules/FindBoost.cmake
  20. 22 17
      Modules/FindCUDA.cmake
  21. 16 2
      Modules/FindCUDA/make2cmake.cmake
  22. 15 15
      Modules/FindCUDA/run_nvcc.cmake
  23. 9 6
      Modules/FindGettext.cmake
  24. 1 1
      Modules/FindLAPACK.cmake
  25. 11 6
      Modules/FindPNG.cmake
  26. 9 0
      Modules/FindX11.cmake
  27. 25 10
      Modules/FindZLIB.cmake
  28. 58 38
      Modules/InstallRequiredSystemLibraries.cmake
  29. 3 0
      Modules/Platform/GNUtoMS_lib.bat.in
  30. 10 0
      Modules/Platform/GNUtoMS_lib.cmake
  31. 4 0
      Modules/Platform/Linux-TinyCC-C.cmake
  32. 1 0
      Modules/Platform/Windows-GNU-C-ABI.cmake
  33. 1 0
      Modules/Platform/Windows-GNU-CXX-ABI.cmake
  34. 1 0
      Modules/Platform/Windows-GNU-Fortran-ABI.cmake
  35. 3 0
      Modules/Platform/Windows-GNU-Fortran.cmake
  36. 54 0
      Modules/Platform/Windows-GNU.cmake
  37. 9 9
      Modules/Qt4Macros.cmake
  38. 3 3
      Modules/UseQt4.cmake
  39. 2 0
      Source/.gitattributes
  40. 7 0
      Source/CMakeLists.txt
  41. 7 5
      Source/QtDialog/AddCacheEntry.cxx
  42. 2 1
      Source/QtDialog/AddCacheEntry.h
  43. 24 1
      Source/QtDialog/CMakeSetupDialog.cxx
  44. 6 4
      Source/QtDialog/CMakeSetupDialog.h
  45. 51 6
      Source/cmCTest.cxx
  46. 4 0
      Source/cmCTest.h
  47. 3 2
      Source/cmComputeLinkInformation.cxx
  48. 14 1
      Source/cmConfigureFileCommand.cxx
  49. 9 2
      Source/cmConfigureFileCommand.h
  50. 130 0
      Source/cmCryptoHash.cxx
  51. 65 0
      Source/cmCryptoHash.h
  52. 24 0
      Source/cmDocumentLocationUndefined.h
  53. 20 0
      Source/cmDocumentVariables.cxx
  54. 2 0
      Source/cmExportBuildFileGenerator.cxx
  55. 2 0
      Source/cmExportCommand.h
  56. 63 0
      Source/cmExportFileGenerator.cxx
  57. 5 0
      Source/cmExportFileGenerator.h
  58. 20 10
      Source/cmExportInstallFileGenerator.cxx
  59. 3 1
      Source/cmExportInstallFileGenerator.h
  60. 40 7
      Source/cmExtraEclipseCDT4Generator.cxx
  61. 3 2
      Source/cmExtraEclipseCDT4Generator.h
  62. 46 0
      Source/cmFileCommand.cxx
  63. 4 0
      Source/cmFileCommand.h
  64. 2 1
      Source/cmGlobalVisualStudio10Generator.cxx
  65. 11 0
      Source/cmGlobalVisualStudio11Generator.cxx
  66. 3 0
      Source/cmGlobalVisualStudio11Generator.h
  67. 2 2
      Source/cmGlobalVisualStudio71Generator.cxx
  68. 2 1
      Source/cmGlobalVisualStudio7Generator.cxx
  69. 2 2
      Source/cmGlobalVisualStudio8Generator.cxx
  70. 2 2
      Source/cmGlobalVisualStudio8Win64Generator.cxx
  71. 2 2
      Source/cmGlobalVisualStudio9Generator.cxx
  72. 2 2
      Source/cmGlobalVisualStudio9IA64Generator.cxx
  73. 2 2
      Source/cmGlobalVisualStudio9Win64Generator.cxx
  74. 24 2
      Source/cmInstallTargetGenerator.cxx
  75. 73 73
      Source/cmLocalGenerator.cxx
  76. 26 18
      Source/cmLocalUnixMakefileGenerator3.cxx
  77. 1 0
      Source/cmLocalUnixMakefileGenerator3.h
  78. 2 1
      Source/cmLocalVisualStudio10Generator.cxx
  79. 1 1
      Source/cmLocalVisualStudio10Generator.h
  80. 2 1
      Source/cmLocalVisualStudio6Generator.cxx
  81. 16 9
      Source/cmLocalVisualStudio7Generator.cxx
  82. 1 5
      Source/cmLocalVisualStudio7Generator.h
  83. 16 1
      Source/cmLocalVisualStudioGenerator.cxx
  84. 18 1
      Source/cmLocalVisualStudioGenerator.h
  85. 15 3
      Source/cmMakefile.cxx
  86. 4 1
      Source/cmMakefile.h
  87. 8 2
      Source/cmMakefileExecutableTargetGenerator.cxx
  88. 8 1
      Source/cmMakefileLibraryTargetGenerator.cxx
  89. 17 0
      Source/cmMakefileTargetGenerator.cxx
  90. 3 0
      Source/cmMakefileTargetGenerator.h
  91. 95 0
      Source/cmNewLineStyle.cxx
  92. 46 0
      Source/cmNewLineStyle.h
  93. 35 10
      Source/cmQtAutomoc.cxx
  94. 3 1
      Source/cmQtAutomoc.h
  95. 2 1
      Source/cmSetTargetPropertiesCommand.h
  96. 5 0
      Source/cmStandardIncludes.h
  97. 39 0
      Source/cmStringCommand.cxx
  98. 5 0
      Source/cmStringCommand.h
  99. 7 50
      Source/cmSystemTools.cxx
  100. 83 12
      Source/cmTarget.cxx

+ 1 - 0
.gitattributes

@@ -8,6 +8,7 @@ configure        crlf=input
 *.sh.in          crlf=input
 
 *.bat           -crlf
+*.bat.in        -crlf
 *.dsp           -crlf
 *.dsptemplate   -crlf
 *.dsw           -crlf

+ 6 - 0
CMakeLists.txt

@@ -213,6 +213,12 @@ ENDMACRO(CMAKE_SET_TARGET_FOLDER)
 # Simply to improve readability of the main script.
 #-----------------------------------------------------------------------
 MACRO (CMAKE_BUILD_UTILITIES)
+  #---------------------------------------------------------------------
+  # Create the KWIML library for CMake.
+  SET(KWIML cmIML)
+  SET(KWIML_HEADER_ROOT ${CMake_BINARY_DIR}/Utilities)
+  ADD_SUBDIRECTORY(Utilities/KWIML)
+
   #---------------------------------------------------------------------
   # Create the kwsys library for CMake.
   SET(KWSYS_NAMESPACE cmsys)

+ 1 - 1
Copyright.txt

@@ -1,5 +1,5 @@
 CMake - Cross Platform Makefile Generator
-Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without

+ 2 - 0
Modules/AutomocInfo.cmake.in

@@ -3,6 +3,7 @@ set(AM_HEADERS "@_moc_headers@" )
 set(AM_MOC_COMPILE_DEFINITIONS "@_moc_compile_defs@")
 set(AM_MOC_DEFINITIONS "@_moc_defs@")
 set(AM_MOC_INCLUDES "@_moc_incs@")
+set(AM_MOC_OPTIONS "@_moc_options@")
 set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@")
 set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/")
 set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/")
@@ -10,5 +11,6 @@ set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@")
 set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
 set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
 set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" )
+set(AM_Qt5Core_VERSION_MAJOR "@Qt5Core_VERSION_MAJOR@" )
 set(AM_TARGET_NAME "@_moc_target_name@")
 set(AM_STRICT_MODE "@_moc_strict_mode@")

+ 3 - 0
Modules/CMakeCCompilerId.c.in

@@ -48,6 +48,9 @@
 #elif defined(__TI_COMPILER_VERSION__)
 # define COMPILER_ID "TI_DSP"
 
+#elif defined(__TINYC__)
+# define COMPILER_ID "TinyCC"
+
 #elif defined(__SCO_VERSION__)
 # define COMPILER_ID "SCO"
 

+ 6 - 0
Modules/CMakeCInformation.cmake

@@ -68,6 +68,12 @@ IF (NOT _INCLUDED_FILE)
   INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL)
 ENDIF (NOT _INCLUDED_FILE)
 
+IF(CMAKE_C_SIZEOF_DATA_PTR)
+  FOREACH(f ${CMAKE_C_ABI_FILES})
+    INCLUDE(${f})
+  ENDFOREACH()
+  UNSET(CMAKE_C_ABI_FILES)
+ENDIF()
 
 # This should be included before the _INIT variables are
 # used to initialize the cache.  Since the rule variables 

+ 6 - 0
Modules/CMakeCXXInformation.cmake

@@ -67,6 +67,12 @@ IF (NOT _INCLUDED_FILE)
   INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL)
 ENDIF (NOT _INCLUDED_FILE)
 
+IF(CMAKE_CXX_SIZEOF_DATA_PTR)
+  FOREACH(f ${CMAKE_CXX_ABI_FILES})
+    INCLUDE(${f})
+  ENDFOREACH()
+  UNSET(CMAKE_CXX_ABI_FILES)
+ENDIF()
 
 # This should be included before the _INIT variables are
 # used to initialize the cache.  Since the rule variables 

+ 2 - 0
Modules/CMakeDetermineCompilerABI.cmake

@@ -57,6 +57,8 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
 
       IF(ABI_SIZEOF_DPTR)
         SET(CMAKE_${lang}_SIZEOF_DATA_PTR "${ABI_SIZEOF_DPTR}" PARENT_SCOPE)
+      ELSEIF(CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT)
+        SET(CMAKE_${lang}_SIZEOF_DATA_PTR "${CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT}" PARENT_SCOPE)
       ENDIF(ABI_SIZEOF_DPTR)
 
       IF(ABI_NAME)

+ 2 - 2
Modules/CMakeFindEclipseCDT4.cmake

@@ -70,8 +70,8 @@ ENDIF()
 SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j<some_number> to get parallel builds")
 
 # This variable is used by the Eclipse generator in out-of-source builds only.
-SET(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")
-MARK_AS_ADVANCED(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT)
+SET(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")
+MARK_AS_ADVANCED(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT)
 
 # Determine builtin macros and include dirs:
 INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake)

+ 5 - 0
Modules/CMakeFortranCompilerABI.F

@@ -15,6 +15,11 @@
         PRINT *, 'INFO:sizeof_dptr[4]'
 #elif defined(_M_IX86)
         PRINT *, 'INFO:sizeof_dptr[4]'
+
+#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8
+        PRINT *, 'INFO:sizeof_dptr[8]'
+#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4
+        PRINT *, 'INFO:sizeof_dptr[4]'
 #endif
 
 #if 0

+ 6 - 0
Modules/CMakeFortranInformation.cmake

@@ -44,6 +44,12 @@ IF (NOT _INCLUDED_FILE)
   INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL)
 ENDIF (NOT _INCLUDED_FILE)
 
+IF(CMAKE_Fortran_SIZEOF_DATA_PTR)
+  FOREACH(f ${CMAKE_Fortran_ABI_FILES})
+    INCLUDE(${f})
+  ENDFOREACH()
+  UNSET(CMAKE_Fortran_ABI_FILES)
+ENDIF()
 
 # This should be included before the _INIT variables are
 # used to initialize the cache.  Since the rule variables 

+ 6 - 0
Modules/CMakeTestCCompiler.cmake

@@ -76,5 +76,11 @@ ELSE(NOT CMAKE_C_COMPILER_WORKS)
       )
     INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCCompiler.cmake)
   ENDIF(CMAKE_C_COMPILER_FORCED)
+  IF(CMAKE_C_SIZEOF_DATA_PTR)
+    FOREACH(f ${CMAKE_C_ABI_FILES})
+      INCLUDE(${f})
+    ENDFOREACH()
+    UNSET(CMAKE_C_ABI_FILES)
+  ENDIF()
 ENDIF(NOT CMAKE_C_COMPILER_WORKS)
 

+ 6 - 0
Modules/CMakeTestCXXCompiler.cmake

@@ -69,4 +69,10 @@ ELSE(NOT CMAKE_CXX_COMPILER_WORKS)
       )
     INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake)
   ENDIF(CMAKE_CXX_COMPILER_FORCED)
+  IF(CMAKE_CXX_SIZEOF_DATA_PTR)
+    FOREACH(f ${CMAKE_CXX_ABI_FILES})
+      INCLUDE(${f})
+    ENDFOREACH()
+    UNSET(CMAKE_CXX_ABI_FILES)
+  ENDIF()
 ENDIF(NOT CMAKE_CXX_COMPILER_WORKS)

+ 6 - 0
Modules/CMakeTestFortranCompiler.cmake

@@ -92,4 +92,10 @@ ELSE(NOT CMAKE_Fortran_COMPILER_WORKS)
       )
     INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake)
   ENDIF(CMAKE_Fortran_COMPILER_FORCED)
+  IF(CMAKE_Fortran_SIZEOF_DATA_PTR)
+    FOREACH(f ${CMAKE_Fortran_ABI_FILES})
+      INCLUDE(${f})
+    ENDFOREACH()
+    UNSET(CMAKE_Fortran_ABI_FILES)
+  ENDIF()
 ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS)

+ 29 - 3
Modules/CPackRPM.cmake

@@ -7,7 +7,9 @@
 # the specifics CPACK_RPM_XXX variables. CPackRPM is a component aware
 # generator so when CPACK_RPM_COMPONENT_INSTALL is ON some more
 # CPACK_RPM_<ComponentName>_XXXX variables may be used in order
-# to have component specific values.
+# to have component specific values. Note however that <componentName>
+# refers to the **grouping name**. This may be either a component name
+# or a component GROUP name.
 # Usually those vars correspond to RPM spec file entities, one may find
 # information about spec files here http://www.rpm.org/wiki/Docs.
 # You'll find a detailed usage of CPackRPM on the wiki:
@@ -101,9 +103,11 @@
 #     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
+#  CPACK_RPM_SPEC_INSTALL_POST [deprecated]
 #     Mandatory : NO
 #     Default   : -
+#     This way of specifying post-install script is deprecated use
+#     CPACK_RPM_POST_INSTALL_SCRIPT_FILE
 #     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.
@@ -161,7 +165,7 @@
 #     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
+#     The refered file will be read and directly put after the %changelog
 #     section.
 
 #=============================================================================
@@ -462,20 +466,31 @@ else(CPACK_RPM_PACKAGE_COMPONENT)
   set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE})
   set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE})
 endif(CPACK_RPM_PACKAGE_COMPONENT)
+
+# Handle post-install file if it has been specified
 if(CPACK_RPM_POST_INSTALL_READ_FILE)
   if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE})
     file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL)
   else(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE})
     message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring")
   endif(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE})
+else(CPACK_RPM_POST_INSTALL_READ_FILE)
+  # reset SPEC var value if no post install file has been specified
+  # (either globally or component-wise)
+  set(CPACK_RPM_SPEC_POSTINSTALL "")
 endif(CPACK_RPM_POST_INSTALL_READ_FILE)
 
+# Handle post-uninstall file if it has been specified
 if(CPACK_RPM_POST_UNINSTALL_READ_FILE)
   if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE})
     file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL)
   else(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE})
     message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring")
   endif(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE})
+else(CPACK_RPM_POST_UNINSTALL_READ_FILE)
+  # reset SPEC var value if no post uninstall file has been specified
+  # (either globally or component-wise)
+  set(CPACK_RPM_SPEC_POSTUNINSTALL "")
 endif(CPACK_RPM_POST_UNINSTALL_READ_FILE)
 
 # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE)
@@ -498,20 +513,31 @@ else(CPACK_RPM_PACKAGE_COMPONENT)
   set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE})
   set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE})
 endif(CPACK_RPM_PACKAGE_COMPONENT)
+
+# Handle pre-install file if it has been specified
 if(CPACK_RPM_PRE_INSTALL_READ_FILE)
   if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE})
     file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL)
   else(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE})
     message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring")
   endif(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE})
+else(CPACK_RPM_PRE_INSTALL_READ_FILE)
+  # reset SPEC var value if no pre-install file has been specified
+  # (either globally or component-wise)
+  set(CPACK_RPM_SPEC_PREINSTALL "")
 endif(CPACK_RPM_PRE_INSTALL_READ_FILE)
 
+# Handle pre-uninstall file if it has been specified
 if(CPACK_RPM_PRE_UNINSTALL_READ_FILE)
   if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE})
     file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL)
   else(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE})
     message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring")
   endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE})
+else(CPACK_RPM_PRE_UNINSTALL_READ_FILE)
+  # reset SPEC var value if no pre-uninstall file has been specified
+  # (either globally or component-wise)
+  set(CPACK_RPM_SPEC_PREUNINSTALL "")
 endif(CPACK_RPM_PRE_UNINSTALL_READ_FILE)
 
 # CPACK_RPM_CHANGELOG_FILE

+ 8 - 0
Modules/Compiler/TinyCC-C.cmake

@@ -0,0 +1,8 @@
+SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
+
+# no optimization in tcc:
+SET (CMAKE_C_FLAGS_INIT "")
+SET (CMAKE_C_FLAGS_DEBUG_INIT "-g")
+SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG")
+SET (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG")
+SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g")

+ 5 - 1
Modules/DeployQt4.cmake

@@ -250,7 +250,11 @@ function(install_qt4_executable executable)
         endif()
 
         get_filename_component(executable_absolute "${executable}" ABSOLUTE)
-        gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY}" qtcore_type)
+        if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}")
+            gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type)
+        elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}")
+            gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type)
+        endif()
         if(qtcore_type STREQUAL "system")
                 set(qt_plugins_dir "")
         endif()

+ 11 - 2
Modules/FindBISON.cmake

@@ -67,8 +67,17 @@ IF(BISON_EXECUTABLE)
   IF(NOT ${BISON_version_result} EQUAL 0)
     MESSAGE(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}")
   ELSE()
-    STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1"
-      BISON_VERSION "${BISON_version_output}")
+    # Bison++
+    IF("${BISON_version_output}" MATCHES "^bison\\+\\+")
+      STRING(REGEX REPLACE "^bison\\+\\+ Version ([^,]+).*" "\\1"
+        BISON_VERSION "${BISON_version_output}")
+    # GNU Bison
+    ELSEIF("${BISON_version_output}" MATCHES "^bison[^+]")
+      STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1"
+        BISON_VERSION "${BISON_version_output}")
+    ELSE()
+      SET(BISON_VERSION "unknown")
+    ENDIF()
   ENDIF()
 
   # internal macro

+ 6 - 4
Modules/FindBoost.cmake

@@ -65,7 +65,7 @@
 # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1,
 # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0,
 # 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0,
-# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1
+# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0
 #
 # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should
 # add both 1.x and 1.x.0 as shown above.  Official Boost include directories
@@ -449,7 +449,7 @@ else(Boost_FIND_VERSION_EXACT)
   # The user has not requested an exact version.  Among known
   # versions, find those that are acceptable to the user request.
   set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
-    "1.46.1"
+    "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1"
     "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42"
     "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37"
     "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
@@ -750,10 +750,12 @@ else(_boost_IN_CACHE)
       else()
         set (_boost_COMPILER "-il")
       endif()
-    elseif (MSVC90)
-      set(_boost_COMPILER "-vc90")
+    elseif (MSVC11)
+      set(_boost_COMPILER "-vc110")
     elseif (MSVC10)
       set(_boost_COMPILER "-vc100")
+    elseif (MSVC90)
+      set(_boost_COMPILER "-vc90")
     elseif (MSVC80)
       set(_boost_COMPILER "-vc80")
     elseif (MSVC71)

+ 22 - 17
Modules/FindCUDA.cmake

@@ -339,6 +339,8 @@ macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file)
   # output depend on the dependency file itself, which should cause the
   # rule to re-run.
   if(CUDA_NVCC_DEPEND_REGENERATE)
+    set(CUDA_NVCC_DEPEND ${dependency_file})
+    #message("Generating an empty dependency_file: ${dependency_file}")
     file(WRITE ${dependency_file} "#FindCUDA.cmake generated file.  Do not edit.\n")
   endif(CUDA_NVCC_DEPEND_REGENERATE)
 
@@ -443,7 +445,10 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR)
   # Search in the CUDA_BIN_PATH first.
   find_path(CUDA_TOOLKIT_ROOT_DIR
     NAMES nvcc nvcc.exe
-    PATHS ENV CUDA_BIN_PATH
+    PATHS
+      ENV CUDA_PATH
+      ENV CUDA_BIN_PATH
+    PATH_SUFFIXES bin bin64
     DOC "Toolkit location."
     NO_DEFAULT_PATH
     )
@@ -472,9 +477,10 @@ endif (NOT CUDA_TOOLKIT_ROOT_DIR)
 # CUDA_NVCC_EXECUTABLE
 find_program(CUDA_NVCC_EXECUTABLE
   NAMES nvcc
-  PATHS "${CUDA_TOOLKIT_ROOT_DIR}/bin"
-        "${CUDA_TOOLKIT_ROOT_DIR}/bin64"
+  PATHS "${CUDA_TOOLKIT_ROOT_DIR}"
+  ENV CUDA_PATH
   ENV CUDA_BIN_PATH
+  PATH_SUFFIXES bin bin64
   NO_DEFAULT_PATH
   )
 # Search default search paths, after we search our own set of paths.
@@ -500,8 +506,10 @@ set(CUDA_VERSION_STRING "${CUDA_VERSION}")
 # CUDA_TOOLKIT_INCLUDE
 find_path(CUDA_TOOLKIT_INCLUDE
   device_functions.h # Header included in toolkit
-  PATHS "${CUDA_TOOLKIT_ROOT_DIR}/include"
+  PATHS "${CUDA_TOOLKIT_ROOT_DIR}"
+  ENV CUDA_PATH
   ENV CUDA_INC_PATH
+  PATH_SUFFIXES include
   NO_DEFAULT_PATH
   )
 # Search default search paths, after we search our own set of paths.
@@ -516,19 +524,16 @@ macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc)
   if(CMAKE_SIZEOF_VOID_P EQUAL 8)
     # CUDA 3.2+ on Windows moved the library directoryies, so we need the new
     # and old paths.
-    set(_cuda_64bit_lib_dir
-      "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64"
-      "${CUDA_TOOLKIT_ROOT_DIR}/lib64"
-      )
+    set(_cuda_64bit_lib_dir "lib/x64" "lib64" )
   endif()
   # CUDA 3.2+ on Windows moved the library directories, so we need to new
   # (lib/Win32) and the old path (lib).
   find_library(${_var}
     NAMES ${_names}
-    PATHS ${_cuda_64bit_lib_dir}
-          "${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32"
-          "${CUDA_TOOLKIT_ROOT_DIR}/lib"
+    PATHS "${CUDA_TOOLKIT_ROOT_DIR}"
+    ENV CUDA_PATH
     ENV CUDA_LIB_PATH
+    PATH_SUFFIXES ${_cuda_64bit_lib_dir} "lib/Win32" "lib"
     DOC ${_doc}
     NO_DEFAULT_PATH
     )
@@ -707,7 +712,7 @@ find_package_handle_standard_args(CUDA
 # Add include directories to pass to the nvcc command.
 macro(CUDA_INCLUDE_DIRECTORIES)
   foreach(dir ${ARGN})
-    list(APPEND CUDA_NVCC_INCLUDE_ARGS_USER "-I${dir}")
+    list(APPEND CUDA_NVCC_INCLUDE_ARGS_USER -I${dir})
   endforeach(dir ${ARGN})
 endmacro(CUDA_INCLUDE_DIRECTORIES)
 
@@ -736,13 +741,13 @@ macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options)
         arg STREQUAL "SHARED" OR
         arg STREQUAL "MODULE"
         )
-      list(APPEND ${_cmake_options} "${arg}")
+      list(APPEND ${_cmake_options} ${arg})
     else()
       if ( _found_options )
-        list(APPEND ${_options} "${arg}")
+        list(APPEND ${_options} ${arg})
       else()
         # Assume this is a file
-        list(APPEND ${_sources} "${arg}")
+        list(APPEND ${_sources} ${arg})
       endif()
     endif()
   endforeach()
@@ -890,7 +895,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
   get_directory_property(CUDA_NVCC_INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES)
   if(CUDA_NVCC_INCLUDE_DIRECTORIES)
     foreach(dir ${CUDA_NVCC_INCLUDE_DIRECTORIES})
-      list(APPEND CUDA_NVCC_INCLUDE_ARGS "-I${dir}")
+      list(APPEND CUDA_NVCC_INCLUDE_ARGS -I${dir})
     endforeach()
   endif()
 
@@ -956,7 +961,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
     # Note that if we ever want CUDA_NVCC_FLAGS_<CONFIG> to be string (instead of a list
     # like it is currently), we can remove the quotes around the
     # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_<CONFIG> variable.
-    set(CUDA_NVCC_FLAGS_CONFIG "${CUDA_NVCC_FLAGS_CONFIG}\nset(CUDA_NVCC_FLAGS_${config_upper} \"${CUDA_NVCC_FLAGS_${config_upper}};;${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}}\")")
+    set(CUDA_NVCC_FLAGS_CONFIG "${CUDA_NVCC_FLAGS_CONFIG}\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})")
   endforeach()
 
   if(compile_to_ptx)

+ 16 - 2
Modules/FindCUDA/make2cmake.cmake

@@ -54,13 +54,27 @@ if (${depend_text} MATCHES ".+")
 
     string(REGEX REPLACE "^ +" "" file ${file})
 
-    if(NOT IS_DIRECTORY ${file})
+    # OK, now if we had a UNC path, nvcc has a tendency to only output the first '/'
+    # instead of '//'.  Here we will test to see if the file exists, if it doesn't then
+    # try to prepend another '/' to the path and test again.  If it still fails remove the
+    # path.
+
+    if(NOT EXISTS "${file}")
+      if (EXISTS "/${file}")
+        set(file "/${file}")
+      else()
+        message(WARNING " Removing non-existant dependency file: ${file}")
+        set(file "")
+      endif()
+    endif()
+
+    if(NOT IS_DIRECTORY "${file}")
       # If softlinks start to matter, we should change this to REALPATH.  For now we need
       # to flatten paths, because nvcc can generate stuff like /bin/../include instead of
       # just /include.
       get_filename_component(file_absolute "${file}" ABSOLUTE)
       list(APPEND dependency_list "${file_absolute}")
-    endif(NOT IS_DIRECTORY ${file})
+    endif()
 
   endforeach(file)
 

+ 15 - 15
Modules/FindCUDA/run_nvcc.cmake

@@ -55,25 +55,25 @@ if(NOT generated_file)
 endif()
 
 # Set these up as variables to make reading the generated file easier
-set(CMAKE_COMMAND "@CMAKE_COMMAND@")
-set(source_file "@source_file@")
-set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@")
-set(cmake_dependency_file "@cmake_dependency_file@")
-set(CUDA_make2cmake "@CUDA_make2cmake@")
-set(CUDA_parse_cubin "@CUDA_parse_cubin@")
-set(build_cubin @build_cubin@)
+set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path
+set(source_file "@source_file@") # path
+set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@") # path
+set(cmake_dependency_file "@cmake_dependency_file@") # path
+set(CUDA_make2cmake "@CUDA_make2cmake@") # path
+set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path
+set(build_cubin @build_cubin@) # bool
 # We won't actually use these variables for now, but we need to set this, in
 # order to force this file to be run again if it changes.
-set(generated_file_path "@generated_file_path@")
-set(generated_file_internal "@generated_file@")
-set(generated_cubin_file_internal "@generated_cubin_file@")
+set(generated_file_path "@generated_file_path@") # path
+set(generated_file_internal "@generated_file@") # path
+set(generated_cubin_file_internal "@generated_cubin_file@") # path
 
-set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@")
-set(CUDA_NVCC_FLAGS "@CUDA_NVCC_FLAGS@;;@CUDA_WRAP_OPTION_NVCC_FLAGS@")
+set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path
+set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
 @CUDA_NVCC_FLAGS_CONFIG@
-set(nvcc_flags "@nvcc_flags@")
-set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@")
-set(format_flag "@format_flag@")
+set(nvcc_flags @nvcc_flags@) # list
+set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly).
+set(format_flag "@format_flag@") # string
 
 if(build_cubin AND NOT generated_cubin_file)
   message(FATAL_ERROR "You must specify generated_cubin_file on the command line")

+ 9 - 6
Modules/FindGettext.cmake

@@ -1,5 +1,5 @@
 # - Find GNU gettext tools
-# This module looks for the GNU gettext tools. This module defines the 
+# This module looks for the GNU gettext tools. This module defines the
 # following values:
 #  GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
 #  GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
@@ -7,8 +7,8 @@
 #
 # Additionally it provides the following macros:
 # GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
-#    This will create a target "translations" which will convert the 
-#    given input po files into the binary output mo file. If the 
+#    This will create a target "translations" which will convert the
+#    given input po files into the binary output mo file. If the
 #    ALL option is used, the translations will also be created when
 #    building the default target.
 # GETTEXT_PROCESS_POT( <potfile> [ALL] [INSTALL_DESTINATION <destdir>] LANGUAGES <lang1> <lang2> ... )
@@ -52,7 +52,8 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg)
    SET(_firstPoFile "${_firstPoFileArg}")
 
    SET(_gmoFiles)
-   GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE)
+   GET_FILENAME_COMPONENT(_potName ${_potFile} NAME)
+   STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
    GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
 
    SET(_addToAll)
@@ -92,7 +93,8 @@ FUNCTION(GETTEXT_PROCESS_POT_FILE _potFile)
 
    CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
 
-   GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE)
+   GET_FILENAME_COMPONENT(_potName ${_potFile} NAME)
+   STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
    GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE)
 
    FOREACH (_lang ${_parsedArguments_LANGUAGES})
@@ -134,7 +136,8 @@ FUNCTION(GETTEXT_PROCESS_PO_FILES _lang)
    CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
 
    FOREACH(_current_PO_FILE ${_parsedArguments_PO_FILES})
-      GET_FILENAME_COMPONENT(_basename ${_current_PO_FILE} NAME_WE)
+      GET_FILENAME_COMPONENT(_name ${_current_PO_FILE} NAME)
+      STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
       SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
       ADD_CUSTOM_COMMAND(OUTPUT ${_gmoFile}
             COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}

+ 1 - 1
Modules/FindLAPACK.cmake

@@ -106,7 +106,7 @@ endforeach(_library ${_list})
 if(_libraries_work)
   # Test this combination of libraries.
   if(UNIX AND BLA_STATIC)
-    set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group ${${LIBRARIES}} ${_blas};-Wl,--end-group" ${_threads})
+    set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads})
   else(UNIX AND BLA_STATIC)
     set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads})
   endif(UNIX AND BLA_STATIC)

+ 11 - 6
Modules/FindPNG.cmake

@@ -1,14 +1,18 @@
 # - Find the native PNG includes and library
 #
-# This module defines
-#  PNG_INCLUDE_DIR, where to find png.h, etc.
+# This module searches libpng, the library for working with PNG images.
+#
+# It defines the following variables
+#  PNG_INCLUDE_DIRS, where to find png.h, etc.
 #  PNG_LIBRARIES, the libraries to link against to use PNG.
 #  PNG_DEFINITIONS - You should add_definitons(${PNG_DEFINITIONS}) before compiling code that includes png library files.
 #  PNG_FOUND, If false, do not try to use PNG.
-# also defined, but not for general use are
+# Also defined, but not for general use are
 #  PNG_LIBRARY, where to find the PNG library.
-# None of the above will be defined unles zlib can be found.
-# PNG depends on Zlib
+# For backward compatiblity the variable PNG_INCLUDE_DIR is also set. It has the same value as PNG_INCLUDE_DIRS.
+#
+# Since PNG depends on the ZLib compression library, none of the above will be
+# defined unless ZLib can be found.
 
 #=============================================================================
 # Copyright 2002-2009 Kitware, Inc.
@@ -38,7 +42,8 @@ if(ZLIB_FOUND)
 
   if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR)
       # png.h includes zlib.h. Sigh.
-      SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
+      SET(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
+      SET(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatiblity
       SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
 
       if (CYGWIN)

+ 9 - 0
Modules/FindX11.cmake

@@ -108,6 +108,7 @@ IF (UNIX)
   FIND_PATH(X11_XShm_INCLUDE_PATH X11/extensions/XShm.h              ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_Xrandr_INCLUDE_PATH X11/extensions/Xrandr.h          ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_Xrender_INCLUDE_PATH X11/extensions/Xrender.h        ${X11_INC_SEARCH_PATH})
+  FIND_PATH(X11_XRes_INCLUDE_PATH X11/extensions/XRes.h              ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_Xscreensaver_INCLUDE_PATH X11/extensions/scrnsaver.h ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_Xshape_INCLUDE_PATH X11/extensions/shape.h           ${X11_INC_SEARCH_PATH})
   FIND_PATH(X11_Xutil_INCLUDE_PATH X11/Xutil.h                       ${X11_INC_SEARCH_PATH})
@@ -136,6 +137,7 @@ IF (UNIX)
   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})
+  FIND_LIBRARY(X11_XRes_LIB XRes             ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xscreensaver_LIB Xss      ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_Xt_LIB Xt                 ${X11_LIB_SEARCH_PATH})
   FIND_LIBRARY(X11_XTest_LIB Xtst            ${X11_LIB_SEARCH_PATH})
@@ -250,6 +252,11 @@ IF (UNIX)
      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrender_INCLUDE_PATH})
   ENDIF (X11_Xrender_INCLUDE_PATH AND X11_Xrender_LIB)
 
+  IF (X11_XRes_INCLUDE_PATH AND X11_XRes_LIB)
+     SET(X11_XRes_FOUND TRUE)
+     SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XRes_INCLUDE_PATH})
+  ENDIF (X11_XRes_INCLUDE_PATH AND X11_XRes_LIB)
+
   IF (X11_Xrandr_INCLUDE_PATH AND X11_Xrandr_LIB)
      SET(X11_Xrandr_FOUND TRUE)
      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrandr_INCLUDE_PATH})
@@ -424,6 +431,8 @@ IF (UNIX)
     X11_Xdamage_INCLUDE_PATH
     X11_Xrender_LIB
     X11_Xrender_INCLUDE_PATH
+    X11_XRes_LIB
+    X11_XRes_INCLUDE_PATH
     X11_Xxf86misc_LIB
     X11_xf86misc_INCLUDE_PATH
     X11_xf86vmode_INCLUDE_PATH

+ 25 - 10
Modules/FindZLIB.cmake

@@ -17,9 +17,12 @@
 #  ZLIB_MAJOR_VERSION  - The major version of zlib
 #  ZLIB_MINOR_VERSION  - The minor version of zlib
 #  ZLIB_PATCH_VERSION  - The patch version of zlib
+#
+# An includer may set ZLIB_ROOT to a zlib installation root to tell
+# this module where to look.
 
 #=============================================================================
-# Copyright 2001-2009 Kitware, Inc.
+# Copyright 2001-2011 Kitware, Inc.
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -31,17 +34,29 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
-FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
-    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include"
-)
+SET(_ZLIB_SEARCHES)
+
+# Search ZLIB_ROOT first if it is set.
+IF(ZLIB_ROOT)
+  SET(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH)
+  LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT)
+ENDIF()
+
+# Normal search.
+SET(_ZLIB_SEARCH_NORMAL
+  PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]"
+        "$ENV{PROGRAMFILES}/zlib"
+  )
+LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
 
 SET(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1)
-FIND_LIBRARY(ZLIB_LIBRARY
-    NAMES
-        ${ZLIB_NAMES}
-    PATHS
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/lib"
-)
+
+# Try each search configuration.
+FOREACH(search ${_ZLIB_SEARCHES})
+  FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h        ${${search}} PATH_SUFFIXES include)
+  FIND_LIBRARY(ZLIB_LIBRARY  NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib)
+ENDFOREACH()
+
 MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
 
 IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")

+ 58 - 38
Modules/InstallRequiredSystemLibraries.cmake

@@ -141,36 +141,46 @@ IF(MSVC)
     ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES)
   ENDIF(MSVC90)
 
-  IF(MSVC10)
+  MACRO(MSVCRT_FILES_FOR_VERSION version)
+    SET(v "${version}")
+
     # Find the runtime library redistribution directory.
     GET_FILENAME_COMPONENT(msvc_install_dir
-      "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]" ABSOLUTE)
-    FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT
+      "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${v}.0;InstallDir]" ABSOLUTE)
+    FIND_PATH(MSVC${v}_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT
       PATHS
         "${msvc_install_dir}/../../VC/redist"
         "${base_dir}/VC/redist"
-        "$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/VC/redist"
-        "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio 10.0/VC/redist"
+        "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist"
+        "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio ${v}.0/VC/redist"
       )
-    MARK_AS_ADVANCED(MSVC10_REDIST_DIR)
-    SET(MSVC10_CRT_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT")
+    MARK_AS_ADVANCED(MSVC${v}_REDIST_DIR)
+    SET(MSVC${v}_CRT_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT")
 
     IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
       SET(__install__libs
-        "${MSVC10_CRT_DIR}/msvcp100.dll"
-        "${MSVC10_CRT_DIR}/msvcr100.dll"
+        "${MSVC${v}_CRT_DIR}/msvcp${v}0.dll"
+        "${MSVC${v}_CRT_DIR}/msvcr${v}0.dll"
         )
     ENDIF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
 
     IF(CMAKE_INSTALL_DEBUG_LIBRARIES)
-      SET(MSVC10_CRT_DIR
-        "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugCRT")
+      SET(MSVC${v}_CRT_DIR
+        "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugCRT")
       SET(__install__libs ${__install__libs}
-        "${MSVC10_CRT_DIR}/msvcp100d.dll"
-        "${MSVC10_CRT_DIR}/msvcr100d.dll"
+        "${MSVC${v}_CRT_DIR}/msvcp${v}0d.dll"
+        "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll"
         )
     ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES)
-  ENDIF(MSVC10)
+  ENDMACRO()
+
+  IF(MSVC10)
+    MSVCRT_FILES_FOR_VERSION(10)
+  ENDIF()
+
+  IF(MSVC11)
+    MSVCRT_FILES_FOR_VERSION(11)
+  ENDIF()
 
   IF(CMAKE_INSTALL_MFC_LIBRARIES)
     IF(MSVC70)
@@ -273,42 +283,52 @@ IF(MSVC)
         )
     ENDIF(MSVC90)
 
-    IF(MSVC10)
+    MACRO(MFC_FILES_FOR_VERSION version)
+      SET(v "${version}")
+
       IF(CMAKE_INSTALL_DEBUG_LIBRARIES)
-        SET(MSVC10_MFC_DIR
-          "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugMFC")
+        SET(MSVC${v}_MFC_DIR
+          "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugMFC")
         SET(__install__libs ${__install__libs}
-          "${MSVC10_MFC_DIR}/mfc100d.dll"
-          "${MSVC10_MFC_DIR}/mfc100ud.dll"
-          "${MSVC10_MFC_DIR}/mfcm100d.dll"
-          "${MSVC10_MFC_DIR}/mfcm100ud.dll"
+          "${MSVC${v}_MFC_DIR}/mfc${v}0d.dll"
+          "${MSVC${v}_MFC_DIR}/mfc${v}0ud.dll"
+          "${MSVC${v}_MFC_DIR}/mfcm${v}0d.dll"
+          "${MSVC${v}_MFC_DIR}/mfcm${v}0ud.dll"
           )
       ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES)
 
-      SET(MSVC10_MFC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFC")
+      SET(MSVC${v}_MFC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFC")
       IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
         SET(__install__libs ${__install__libs}
-          "${MSVC10_MFC_DIR}/mfc100.dll"
-          "${MSVC10_MFC_DIR}/mfc100u.dll"
-          "${MSVC10_MFC_DIR}/mfcm100.dll"
-          "${MSVC10_MFC_DIR}/mfcm100u.dll"
+          "${MSVC${v}_MFC_DIR}/mfc${v}0.dll"
+          "${MSVC${v}_MFC_DIR}/mfc${v}0u.dll"
+          "${MSVC${v}_MFC_DIR}/mfcm${v}0.dll"
+          "${MSVC${v}_MFC_DIR}/mfcm${v}0u.dll"
           )
       ENDIF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
 
-      # include the language dll's for vs10 as well as the actuall dll's
-      SET(MSVC10_MFCLOC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFCLOC")
+      # include the language dll's as well as the actuall dll's
+      SET(MSVC${v}_MFCLOC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFCLOC")
       SET(__install__libs ${__install__libs}
-        "${MSVC10_MFCLOC_DIR}/mfc100chs.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100cht.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100enu.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100esp.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100deu.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100fra.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100ita.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100jpn.dll"
-        "${MSVC10_MFCLOC_DIR}/mfc100kor.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0chs.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0cht.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0enu.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0esp.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0deu.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0fra.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0ita.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0jpn.dll"
+        "${MSVC${v}_MFCLOC_DIR}/mfc${v}0kor.dll"
         )
-    ENDIF(MSVC10)
+    ENDMACRO()
+
+    IF(MSVC10)
+      MFC_FILES_FOR_VERSION(10)
+    ENDIF()
+
+    IF(MSVC11)
+      MFC_FILES_FOR_VERSION(11)
+    ENDIF()
   ENDIF(CMAKE_INSTALL_MFC_LIBRARIES)
 
   FOREACH(lib

+ 3 - 0
Modules/Platform/GNUtoMS_lib.bat.in

@@ -0,0 +1,3 @@
+@echo off
+call "@CMAKE_GNUtoMS_BAT@"
+lib /machine:"@CMAKE_GNUtoMS_ARCH@" %*

+ 10 - 0
Modules/Platform/GNUtoMS_lib.cmake

@@ -0,0 +1,10 @@
+# Usage: cmake -Dlib=lib.bat -Ddef=out.def -Ddll=out.dll -Dimp=out.dll.a -P GNUtoMS_lib.cmake
+get_filename_component(name ${dll} NAME) # .dll file name
+string(REGEX REPLACE "\\.dll\\.a$" ".lib" out "${imp}") # .dll.a -> .lib
+execute_process(
+  COMMAND ${lib} /def:${def} /name:${name} /out:${out}
+  RESULT_VARIABLE res
+  )
+if(res)
+  message(FATAL_ERROR "lib failed: ${res}")
+endif()

+ 4 - 0
Modules/Platform/Linux-TinyCC-C.cmake

@@ -0,0 +1,4 @@
+SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "")
+SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "")
+SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "")
+SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-soname ")

+ 1 - 0
Modules/Platform/Windows-GNU-C-ABI.cmake

@@ -0,0 +1 @@
+__windows_compiler_gnu_abi(C)

+ 1 - 0
Modules/Platform/Windows-GNU-CXX-ABI.cmake

@@ -0,0 +1 @@
+__windows_compiler_gnu_abi(CXX)

+ 1 - 0
Modules/Platform/Windows-GNU-Fortran-ABI.cmake

@@ -0,0 +1 @@
+__windows_compiler_gnu_abi(Fortran)

+ 3 - 0
Modules/Platform/Windows-GNU-Fortran.cmake

@@ -1,2 +1,5 @@
 include(Platform/Windows-GNU)
 __windows_compiler_gnu(Fortran)
+
+# gfortran on 64-bit MinGW defines __SIZEOF_POINTER__
+set(CMAKE_Fortran_SIZEOF_DATA_PTR_DEFAULT 4)

+ 54 - 0
Modules/Platform/Windows-GNU.cmake

@@ -108,6 +108,8 @@ macro(__windows_compiler_gnu lang)
   set(CMAKE_${lang}_LINK_EXECUTABLE
     "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS>  -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
 
+  list(APPEND CMAKE_${lang}_ABI_FILES "Platform/Windows-GNU-${lang}-ABI")
+
   # Support very long lists of object files.
   if("${CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG}" STREQUAL "@")
     foreach(rule CREATE_SHARED_MODULE CREATE_SHARED_LIBRARY LINK_EXECUTABLE)
@@ -125,3 +127,55 @@ macro(__windows_compiler_gnu lang)
     endforeach()
   endif()
 endmacro()
+
+macro(__windows_compiler_gnu_abi lang)
+  if(CMAKE_NO_GNUtoMS)
+    set(CMAKE_GNUtoMS 0)
+  else()
+    option(CMAKE_GNUtoMS "Convert GNU import libraries to MS format (requires Visual Studio)" OFF)
+  endif()
+
+  if(CMAKE_GNUtoMS AND NOT CMAKE_GNUtoMS_LIB)
+    # Find MS development environment setup script for this architecture.
+    if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
+      find_program(CMAKE_GNUtoMS_VCVARS NAMES vcvars32.bat
+        DOC "Visual Studio vcvars32.bat"
+        PATHS
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VC;ProductDir]/bin"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC;ProductDir]/bin"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++;ProductDir]/bin"
+        )
+      set(CMAKE_GNUtoMS_ARCH x86)
+    elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
+      find_program(CMAKE_GNUtoMS_VCVARS NAMES vcvarsamd64.bat
+        DOC "Visual Studio vcvarsamd64.bat"
+        PATHS
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VC;ProductDir]/bin/amd64"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin/amd64"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin/amd64"
+        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin/amd64"
+        )
+      set(CMAKE_GNUtoMS_ARCH amd64)
+    endif()
+    set_property(CACHE CMAKE_GNUtoMS_VCVARS PROPERTY ADVANCED 1)
+    if(CMAKE_GNUtoMS_VCVARS)
+      # Create helper script to run lib.exe from MS environment.
+      string(REPLACE "/" "\\" CMAKE_GNUtoMS_BAT "${CMAKE_GNUtoMS_VCVARS}")
+      set(CMAKE_GNUtoMS_LIB ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeGNUtoMS_lib.bat)
+      configure_file(${CMAKE_ROOT}/Modules/Platform/GNUtoMS_lib.bat.in ${CMAKE_GNUtoMS_LIB})
+    else()
+      message(WARNING "Disabling CMAKE_GNUtoMS option because CMAKE_GNUtoMS_VCVARS is not set.")
+      set(CMAKE_GNUtoMS 0)
+    endif()
+  endif()
+
+  if(CMAKE_GNUtoMS)
+    # Teach CMake how to create a MS import library at link time.
+    set(CMAKE_${lang}_GNUtoMS_RULE " -Wl,--output-def,<TARGET_NAME>.def"
+      "<CMAKE_COMMAND> -Dlib=\"${CMAKE_GNUtoMS_LIB}\" -Ddef=\"<TARGET_NAME>.def\" -Ddll=\"<TARGET>\" -Dimp=\"<TARGET_IMPLIB>\" -P \"${CMAKE_ROOT}/Modules/Platform/GNUtoMS_lib.cmake\""
+      )
+  endif()
+endmacro()

+ 9 - 9
Modules/Qt4Macros.cmake

@@ -118,7 +118,7 @@ MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options)
     ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
                        COMMAND ${QT_MOC_EXECUTABLE}
                        ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile}
-                       DEPENDS ${infile})
+                       DEPENDS ${infile} VERBATIM)
   ENDIF (WIN32)
 ENDMACRO (QT4_CREATE_MOC_COMMAND)
 
@@ -165,7 +165,7 @@ MACRO (QT4_WRAP_UI outfiles )
     ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
       COMMAND ${QT_UIC_EXECUTABLE}
       ARGS ${ui_options} -o ${outfile} ${infile}
-      MAIN_DEPENDENCY ${infile})
+      MAIN_DEPENDENCY ${infile} VERBATIM)
     SET(${outfiles} ${${outfiles}} ${outfile})
   ENDFOREACH (it)
 
@@ -203,7 +203,7 @@ MACRO (QT4_ADD_RESOURCES outfiles )
       COMMAND ${QT_RCC_EXECUTABLE}
       ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
       MAIN_DEPENDENCY ${infile}
-      DEPENDS ${_RC_DEPENDS} "${out_depends}")
+      DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM)
     SET(${outfiles} ${${outfiles}} ${outfile})
   ENDFOREACH (it)
 
@@ -235,7 +235,7 @@ MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
 
   ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
       COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
-      DEPENDS ${_infile})
+      DEPENDS ${_infile} VERBATIM)
 
   SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
 
@@ -280,7 +280,7 @@ MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options
 
   ADD_CUSTOM_COMMAND(OUTPUT ${_target}
       COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
-      DEPENDS ${_in_file}
+      DEPENDS ${_in_file} VERBATIM
   )
 ENDMACRO(QT4_GENERATE_DBUS_INTERFACE)
 
@@ -304,12 +304,12 @@ MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional
   IF(_optionalClassName)
     ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
        COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
-       DEPENDS ${_infile}
+       DEPENDS ${_infile} VERBATIM
     )
   ELSE(_optionalClassName)
     ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
        COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
-       DEPENDS ${_infile}
+       DEPENDS ${_infile} VERBATIM
      )
   ENDIF(_optionalClassName)
 
@@ -398,7 +398,7 @@ MACRO(QT4_CREATE_TRANSLATION _qm_files)
      ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
         COMMAND ${QT_LUPDATE_EXECUTABLE}
         ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
-        DEPENDS ${_my_sources} ${_ts_pro})
+        DEPENDS ${_my_sources} ${_ts_pro} VERBATIM)
    ENDFOREACH(_ts_file)
    QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
 ENDMACRO(QT4_CREATE_TRANSLATION)
@@ -419,7 +419,7 @@ MACRO(QT4_ADD_TRANSLATION _qm_files)
     ADD_CUSTOM_COMMAND(OUTPUT ${qm}
        COMMAND ${QT_LRELEASE_EXECUTABLE}
        ARGS ${_abs_FILE} -qm ${qm}
-       DEPENDS ${_abs_FILE}
+       DEPENDS ${_abs_FILE} VERBATIM
     )
     SET(${_qm_files} ${${_qm_files}} ${qm})
   ENDFOREACH (_current_FILE)

+ 3 - 3
Modules/UseQt4.cmake

@@ -68,7 +68,7 @@ SET(QT_QAXCONTAINER_MODULE_DEPENDS QTGUI QTCORE)
 SET(QT_QAXSERVER_MODULE_DEPENDS QTGUI QTCORE)
 SET(QT_QTSCRIPTTOOLS_MODULE_DEPENDS QTGUI QTCORE)
 SET(QT_QTWEBKIT_MODULE_DEPENDS QTXMLPATTERNS QTGUI QTCORE)
-SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTWEBKIT QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTXML QTOPENGL QTGUI QTNETWORK QTCORE)
+SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTGUI QTCORE)
 SET(QT_QTMULTIMEDIA_MODULE_DEPENDS QTGUI QTCORE)
 SET(QT_QTOPENGL_MODULE_DEPENDS QTGUI QTCORE)
 SET(QT_QTSCRIPT_MODULE_DEPENDS QTCORE)
@@ -81,8 +81,8 @@ SET(QT_QTNETWORK_MODULE_DEPENDS QTCORE)
 # Qt modules  (in order of dependence)
 FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN
                QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP
-               QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTGUI QTTEST QTDBUS QTXML QTSQL
-               QTXMLPATTERNS QTNETWORK QTCORE)
+               QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTXMLPATTERNS QTGUI QTTEST
+               QTDBUS QTXML QTSQL QTNETWORK QTCORE)
 
   IF (QT_USE_${module} OR QT_USE_${module}_DEPENDS)
     IF (QT_${module}_FOUND)

+ 2 - 0
Source/.gitattributes

@@ -0,0 +1,2 @@
+# Preserve upstream indentation style.
+cm_sha2.*        whitespace=indent-with-non-tab

+ 7 - 0
Source/CMakeLists.txt

@@ -129,6 +129,8 @@ SET(SRCS
   cmComputeLinkInformation.h
   cmComputeTargetDepends.h
   cmComputeTargetDepends.cxx
+  cmCryptoHash.cxx
+  cmCryptoHash.h
   cmCustomCommand.cxx
   cmCustomCommand.h
   cmCustomCommandGenerator.cxx
@@ -160,6 +162,7 @@ SET(SRCS
   cmDocumentationSection.cxx
   cmDocumentCompileDefinitions.h
   cmDocumentGeneratorExpressions.h
+  cmDocumentLocationUndefined.h
   cmDocumentVariables.cxx
   cmDynamicLoader.cxx
   cmDynamicLoader.h
@@ -214,6 +217,8 @@ SET(SRCS
   cmMakefileExecutableTargetGenerator.cxx
   cmMakefileLibraryTargetGenerator.cxx
   cmMakefileUtilityTargetGenerator.cxx
+  cmNewLineStyle.h
+  cmNewLineStyle.cxx
   cmOrderDirectories.cxx
   cmOrderDirectories.h
   cmPolicies.h
@@ -259,6 +264,8 @@ SET(SRCS
   cmakewizard.cxx
   cmakewizard.h
 
+  cm_sha2.h
+  cm_sha2.c
   cm_utf8.h
   cm_utf8.c
   )

+ 7 - 5
Source/QtDialog/AddCacheEntry.cxx

@@ -12,15 +12,16 @@
 
 #include "AddCacheEntry.h"
 #include <QMetaProperty>
+#include <QCompleter>
 
 static const int NumTypes = 4;
-static const QString TypeStrings[NumTypes] = 
+static const QString TypeStrings[NumTypes] =
   { "BOOL", "PATH", "FILEPATH", "STRING" };
-static const QCMakeProperty::PropertyType Types[NumTypes] = 
-  { QCMakeProperty::BOOL, QCMakeProperty::PATH, 
-    QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; 
+static const QCMakeProperty::PropertyType Types[NumTypes] =
+  { QCMakeProperty::BOOL, QCMakeProperty::PATH,
+    QCMakeProperty::FILEPATH, QCMakeProperty::STRING};
 
-AddCacheEntry::AddCacheEntry(QWidget* p)
+AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions)
   : QWidget(p)
 {
   this->setupUi(this);
@@ -42,6 +43,7 @@ AddCacheEntry::AddCacheEntry(QWidget* p)
   this->setTabOrder(path, filepath);
   this->setTabOrder(filepath, string);
   this->setTabOrder(string, this->Description);
+  this->Name->setCompleter(new QCompleter(completions, this));
 }
 
 QString AddCacheEntry::name() const

+ 2 - 1
Source/QtDialog/AddCacheEntry.h

@@ -15,6 +15,7 @@
 
 #include <QWidget>
 #include <QCheckBox>
+#include <QStringList>
 
 #include "QCMake.h"
 #include "ui_AddCacheEntry.h"
@@ -23,7 +24,7 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry
 {
   Q_OBJECT
 public:
-  AddCacheEntry(QWidget* p);
+  AddCacheEntry(QWidget* p, const QStringList& completions);
 
   QString name() const;
   QVariant value() const;

+ 24 - 1
Source/QtDialog/CMakeSetupDialog.cxx

@@ -68,6 +68,9 @@ CMakeSetupDialog::CMakeSetupDialog()
   int w = settings.value("Width", 700).toInt();
   this->resize(w, h);
 
+  this->AddVariableCompletions = settings.value("AddVariableCompletionEntries",
+                           QStringList("CMAKE_INSTALL_PREFIX")).toStringList();
+
   QWidget* cont = new QWidget(this);
   this->setupUi(cont);
   this->Splitter->setStretchFactor(0, 3);
@@ -1008,7 +1011,7 @@ void CMakeSetupDialog::addCacheEntry()
   dialog.resize(400, 200);
   dialog.setWindowTitle(tr("Add Cache Entry"));
   QVBoxLayout* l = new QVBoxLayout(&dialog);
-  AddCacheEntry* w = new AddCacheEntry(&dialog);
+  AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableCompletions);
   QDialogButtonBox* btns = new QDialogButtonBox(
       QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
       Qt::Horizontal, &dialog);
@@ -1021,6 +1024,26 @@ void CMakeSetupDialog::addCacheEntry()
     {
     QCMakeCacheModel* m = this->CacheValues->cacheModel();
     m->insertProperty(w->type(), w->name(), w->description(), w->value(), false);
+
+    // only add variable names to the completion which are new
+    if (!this->AddVariableCompletions.contains(w->name()))
+      {
+      this->AddVariableCompletions << w->name();
+      // limit to at most 100 completion items
+      if (this->AddVariableCompletions.size() > 100)
+        {
+        this->AddVariableCompletions.removeFirst();
+        }
+      // make sure CMAKE_INSTALL_PREFIX is always there
+      if (!this->AddVariableCompletions.contains("CMAKE_INSTALL_PREFIX"))
+        {
+        this->AddVariableCompletions << QString("CMAKE_INSTALL_PREFIX");
+        }
+      QSettings settings;
+      settings.beginGroup("Settings/StartPath");
+      settings.setValue("AddVariableCompletionEntries",
+                        this->AddVariableCompletions);
+      }
     }
 }
 

+ 6 - 4
Source/QtDialog/CMakeSetupDialog.h

@@ -36,7 +36,7 @@ public slots:
   void setBinaryDirectory(const QString& dir);
   void setSourceDirectory(const QString& dir);
 
-protected slots: 
+protected slots:
   void initialize();
   void doConfigure();
   void doGenerate();
@@ -46,7 +46,7 @@ protected slots:
   void doInterrupt();
   void error(const QString& message);
   void message(const QString& message);
-  
+
   void doSourceBrowse();
   void doBinaryBrowse();
   void doReloadCache();
@@ -105,6 +105,8 @@ protected:
   QTextCharFormat ErrorFormat;
   QTextCharFormat MessageFormat;
 
+  QStringList AddVariableCompletions;
+
   QEventLoop LocalLoop;
 
   float ProgressOffset;
@@ -118,8 +120,8 @@ class QCMakeThread : public QThread
 public:
   QCMakeThread(QObject* p);
   QCMake* cmakeInstance() const;
-  
-signals:  
+
+signals:
   void cmakeInitialized();
 
 protected:

+ 51 - 6
Source/cmCTest.cxx

@@ -1440,6 +1440,43 @@ int cmCTest::RunTest(std::vector<const char*> argv,
   return result;
 }
 
+//----------------------------------------------------------------------
+std::string cmCTest::SafeBuildIdField(const std::string& value)
+{
+  std::string safevalue(value);
+
+  if (safevalue != "")
+    {
+    // Disallow non-filename and non-space whitespace characters.
+    // If they occur, replace them with ""
+    //
+    const char *disallowed = "\\/:*?\"<>|\n\r\t\f\v";
+
+    if (safevalue.find_first_of(disallowed) != value.npos)
+      {
+      std::string::size_type i = 0;
+      std::string::size_type n = strlen(disallowed);
+      char replace[2];
+      replace[1] = 0;
+
+      for (i= 0; i<n; ++i)
+        {
+        replace[0] = disallowed[i];
+        cmSystemTools::ReplaceString(safevalue, replace, "");
+        }
+      }
+
+    safevalue = cmXMLSafe(safevalue).str();
+    }
+
+  if (safevalue == "")
+    {
+    safevalue = "(empty)";
+    }
+
+  return safevalue;
+}
+
 //----------------------------------------------------------------------
 void cmCTest::StartXML(std::ostream& ostr, bool append)
 {
@@ -1450,19 +1487,27 @@ void cmCTest::StartXML(std::ostream& ostr, bool append)
                " NightlStartTime was not set correctly." << std::endl);
     cmSystemTools::SetFatalErrorOccured();
     }
+
   // find out about the system
   cmsys::SystemInformation info;
   info.RunCPUCheck();
   info.RunOSCheck();
   info.RunMemoryCheck();
+
+  std::string buildname = cmCTest::SafeBuildIdField(
+    this->GetCTestConfiguration("BuildName"));
+  std::string stamp = cmCTest::SafeBuildIdField(
+    this->CurrentTag + "-" + this->GetTestModelString());
+  std::string site = cmCTest::SafeBuildIdField(
+    this->GetCTestConfiguration("Site"));
+
   ostr << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-       << "<Site BuildName=\"" << this->GetCTestConfiguration("BuildName")
-       << "\"\n\tBuildStamp=\"" << this->CurrentTag << "-"
-       << this->GetTestModelString() << "\"\n\tName=\""
-       << this->GetCTestConfiguration("Site") << "\"\n\tGenerator=\"ctest-"
-       << cmVersion::GetCMakeVersion()  << "\"\n"
+       << "<Site BuildName=\"" << buildname << "\"\n"
+       << "\tBuildStamp=\"" << stamp << "\"\n"
+       << "\tName=\"" << site << "\"\n"
+       << "\tGenerator=\"ctest-" << cmVersion::GetCMakeVersion() << "\"\n"
        << (append? "\tAppend=\"true\"\n":"")
-       << "\tCompilerName=\"" << this->GetCTestConfiguration("Compiler") 
+       << "\tCompilerName=\"" << this->GetCTestConfiguration("Compiler")
        << "\"\n"
 #ifdef _COMPILER_VERSION
        << "\tCompilerVersion=\"_COMPILER_VERSION\"\n"

+ 4 - 0
Source/cmCTest.h

@@ -259,6 +259,10 @@ public:
     std::string* stdOut, std::string* stdErr,
     int* retVal = 0, const char* dir = 0, double timeout = 0.0);
 
+  //! Clean/make safe for xml the given value such that it may be used as
+  // one of the key fields by CDash when computing the buildid.
+  static std::string SafeBuildIdField(const std::string& value);
+
   //! Start CTest XML output file
   void StartXML(std::ostream& ostr, bool append);
 

+ 3 - 2
Source/cmComputeLinkInformation.cxx

@@ -1318,8 +1318,9 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
   this->AddFrameworkPath(this->SplitFramework.match(1));
 
   // Add the item using the -framework option.
-  std::string fw = "-framework ";
-  fw += this->SplitFramework.match(2);
+  this->Items.push_back(Item("-framework", false));
+  std::string fw = this->SplitFramework.match(2);
+  fw = this->LocalGenerator->EscapeForShell(fw.c_str());
   this->Items.push_back(Item(fw, false));
 }
 

+ 14 - 1
Source/cmConfigureFileCommand.cxx

@@ -65,6 +65,12 @@ bool cmConfigureFileCommand
     cmSystemTools::SetFatalErrorOccured();
     return false;
     }
+  std::string errorMessage;
+  if (!this->NewLineStyle.ReadFromArguments(args, errorMessage))
+    {
+    this->SetError(errorMessage.c_str());
+    return false;
+    }
   this->CopyOnly = false;
   this->EscapeQuotes = false;
 
@@ -78,6 +84,12 @@ bool cmConfigureFileCommand
     if(args[i] == "COPYONLY")
       {
       this->CopyOnly = true;
+      if (this->NewLineStyle.IsValid())
+        {
+        this->SetError("COPYONLY could not be used in combination "
+                       "with NEWLINE_STYLE");
+        return false;
+        }
       }
     else if(args[i] == "ESCAPE_QUOTES")
       {
@@ -122,7 +134,8 @@ int cmConfigureFileCommand::ConfigureFile()
     this->OutputFile.c_str(),
     this->CopyOnly,
     this->AtOnly,
-    this->EscapeQuotes);
+    this->EscapeQuotes,
+    this->NewLineStyle);
 }
 
 

+ 9 - 2
Source/cmConfigureFileCommand.h

@@ -56,7 +56,8 @@ public:
     {
       return
         "  configure_file(<input> <output>\n"
-        "                 [COPYONLY] [ESCAPE_QUOTES] [@ONLY])\n"
+        "                 [COPYONLY] [ESCAPE_QUOTES] [@ONLY] \n"
+        "                 [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])\n"
         "Copies a file <input> to file <output> and substitutes variable "
         "values referenced in the file content.  "
         "If <input> is a relative path it is evaluated with respect to "
@@ -81,14 +82,20 @@ public:
         "either #define VAR or /* #undef VAR */ depending on "
         "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR "
         "will be replaced with either #define VAR 1 or #define VAR 0 "
-        "depending on whether VAR evaluates to TRUE or FALSE in CMake";
+        "depending on whether VAR evaluates to TRUE or FALSE in CMake.\n"
+        "With NEWLINE_STYLE the line ending could be adjusted: \n"
+        "    'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n"
+        "COPYONLY must not be used with NEWLINE_STYLE.\n";
     }
 
   virtual void FinalPass();
   virtual bool HasFinalPass() const { return !this->Immediate; }
+
 private:
   int ConfigureFile();
   
+  cmNewLineStyle NewLineStyle;
+
   std::string InputFile;
   std::string OutputFile;
   bool CopyOnly;

+ 130 - 0
Source/cmCryptoHash.cxx

@@ -0,0 +1,130 @@
+/*============================================================================
+  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.
+============================================================================*/
+#include "cmCryptoHash.h"
+
+#include <cmsys/MD5.h>
+#include "cm_sha2.h"
+
+//----------------------------------------------------------------------------
+cmsys::auto_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo)
+{
+  if(strcmp(algo,"MD5") == 0)
+    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashMD5); }
+  else if(strcmp(algo,"SHA1") == 0)
+    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA1); }
+  else if(strcmp(algo,"SHA224") == 0)
+    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA224); }
+  else if(strcmp(algo,"SHA256") == 0)
+    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA256); }
+  else if(strcmp(algo,"SHA384") == 0)
+    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA384); }
+  else if(strcmp(algo,"SHA512") == 0)
+    { return cmsys::auto_ptr<cmCryptoHash>(new cmCryptoHashSHA512); }
+  else
+    { return cmsys::auto_ptr<cmCryptoHash>(0); }
+}
+
+//----------------------------------------------------------------------------
+std::string cmCryptoHash::HashString(const char* input)
+{
+  this->Initialize();
+  this->Append(reinterpret_cast<unsigned char const*>(input),
+               static_cast<int>(strlen(input)));
+  return this->Finalize();
+}
+
+//----------------------------------------------------------------------------
+std::string cmCryptoHash::HashFile(const char* file)
+{
+  std::ifstream fin(file, std::ios::in | cmsys_ios_binary);
+  if(!fin)
+    {
+    return "";
+    }
+
+  this->Initialize();
+
+  // Should be efficient enough on most system:
+  const int bufferSize = 4096;
+  char buffer[bufferSize];
+  unsigned char const* buffer_uc =
+    reinterpret_cast<unsigned char const*>(buffer);
+  // This copy loop is very sensitive on certain platforms with
+  // slightly broken stream libraries (like HPUX).  Normally, it is
+  // incorrect to not check the error condition on the fin.read()
+  // before using the data, but the fin.gcount() will be zero if an
+  // error occurred.  Therefore, the loop should be safe everywhere.
+  while(fin)
+    {
+    fin.read(buffer, bufferSize);
+    if(int gcount = static_cast<int>(fin.gcount()))
+      {
+      this->Append(buffer_uc, gcount);
+      }
+    }
+  if(fin.eof())
+    {
+    return this->Finalize();
+    }
+  return "";
+}
+
+//----------------------------------------------------------------------------
+cmCryptoHashMD5::cmCryptoHashMD5(): MD5(cmsysMD5_New())
+{
+}
+
+//----------------------------------------------------------------------------
+cmCryptoHashMD5::~cmCryptoHashMD5()
+{
+  cmsysMD5_Delete(this->MD5);
+}
+
+//----------------------------------------------------------------------------
+void cmCryptoHashMD5::Initialize()
+{
+  cmsysMD5_Initialize(this->MD5);
+}
+
+//----------------------------------------------------------------------------
+void cmCryptoHashMD5::Append(unsigned char const* buf, int sz)
+{
+  cmsysMD5_Append(this->MD5, buf, sz);
+}
+
+//----------------------------------------------------------------------------
+std::string cmCryptoHashMD5::Finalize()
+{
+  char md5out[32];
+  cmsysMD5_FinalizeHex(this->MD5, md5out);
+  return std::string(md5out, 32);
+}
+
+
+#define cmCryptoHash_SHA_CLASS_IMPL(SHA) \
+cmCryptoHash##SHA::cmCryptoHash##SHA(): SHA(new SHA_CTX) {} \
+cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; } \
+void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); } \
+void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz) \
+{ SHA##_Update(this->SHA, buf, sz); } \
+std::string cmCryptoHash##SHA::Finalize() \
+{ \
+  char out[SHA##_DIGEST_STRING_LENGTH]; \
+  SHA##_End(this->SHA, out); \
+  return std::string(out, SHA##_DIGEST_STRING_LENGTH-1); \
+}
+
+cmCryptoHash_SHA_CLASS_IMPL(SHA1)
+cmCryptoHash_SHA_CLASS_IMPL(SHA224)
+cmCryptoHash_SHA_CLASS_IMPL(SHA256)
+cmCryptoHash_SHA_CLASS_IMPL(SHA384)
+cmCryptoHash_SHA_CLASS_IMPL(SHA512)

+ 65 - 0
Source/cmCryptoHash.h

@@ -0,0 +1,65 @@
+/*============================================================================
+  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 cmCryptoHash_h
+#define cmCryptoHash_h
+
+#include "cmStandardIncludes.h"
+
+#include <cmsys/auto_ptr.hxx>
+
+class cmCryptoHash
+{
+public:
+  virtual ~cmCryptoHash() {}
+  static cmsys::auto_ptr<cmCryptoHash> New(const char* algo);
+  std::string HashString(const char* input);
+  std::string HashFile(const char* file);
+protected:
+  virtual void Initialize()=0;
+  virtual void Append(unsigned char const*, int)=0;
+  virtual std::string Finalize()=0;
+};
+
+class cmCryptoHashMD5: public cmCryptoHash
+{
+  struct cmsysMD5_s* MD5;
+public:
+  cmCryptoHashMD5();
+  ~cmCryptoHashMD5();
+protected:
+  virtual void Initialize();
+  virtual void Append(unsigned char const* buf, int sz);
+  virtual std::string Finalize();
+};
+
+#define cmCryptoHash_SHA_CLASS_DECL(SHA) \
+  class cmCryptoHash##SHA: public cmCryptoHash \
+  { \
+    union _SHA_CTX* SHA; \
+  public: \
+    cmCryptoHash##SHA(); \
+    ~cmCryptoHash##SHA(); \
+  protected: \
+    virtual void Initialize(); \
+    virtual void Append(unsigned char const* buf, int sz); \
+    virtual std::string Finalize(); \
+  }
+
+cmCryptoHash_SHA_CLASS_DECL(SHA1);
+cmCryptoHash_SHA_CLASS_DECL(SHA224);
+cmCryptoHash_SHA_CLASS_DECL(SHA256);
+cmCryptoHash_SHA_CLASS_DECL(SHA384);
+cmCryptoHash_SHA_CLASS_DECL(SHA512);
+
+#undef cmCryptoHash_SHA_CLASS_DECL
+
+#endif

+ 24 - 0
Source/cmDocumentLocationUndefined.h

@@ -0,0 +1,24 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2011 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 cmDocumentLocationUndefined_h
+#define cmDocumentLocationUndefined_h
+
+#define CM_LOCATION_UNDEFINED_BEHAVIOR(action) \
+  "\n" \
+  "Do not set properties that affect the location of a target after " \
+  action ".  These include properties whose names match " \
+  "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?\" " \
+  "or \"(IMPLIB_)?(PREFIX|SUFFIX)\".  " \
+  "Failure to follow this rule is not diagnosed and leaves the location " \
+  "of the target undefined."
+
+#endif

+ 20 - 0
Source/cmDocumentVariables.cxx

@@ -1116,6 +1116,24 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
      false,
      "Variables that Control the Build");
 
+  cm->DefineProperty
+    ("CMAKE_AUTOMOC_MOC_OPTIONS", cmProperty::VARIABLE,
+     "Additional options for moc when using automoc (see CMAKE_AUTOMOC).",
+     "This variable is used to initialize the "
+     "AUTOMOC_MOC_OPTIONS property on all the targets. "
+     "See that target property for additional information.",
+     false,
+     "Variables that Control the Build");
+
+  cm->DefineProperty
+    ("CMAKE_GNUtoMS", cmProperty::VARIABLE,
+     "Convert GNU import libraries (.dll.a) to MS format (.lib).",
+     "This variable is used to initialize the GNUtoMS property on targets "
+     "when they are created.  "
+     "See that target property for additional information.",
+     false,
+     "Variables that Control the Build");
+
   cm->DefineProperty
     ("CMAKE_DEBUG_POSTFIX", cmProperty::VARIABLE,
      "See variable CMAKE_<CONFIG>_POSTFIX.",
@@ -1520,6 +1538,8 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
                      cmProperty::VARIABLE,0,0);
   cm->DefineProperty("CMAKE_<LANG>_COMPILER_ID_RUN",
                      cmProperty::VARIABLE,0,0);
+  cm->DefineProperty("CMAKE_<LANG>_ABI_FILES",
+                     cmProperty::VARIABLE,0,0);
   cm->DefineProperty("CMAKE_<LANG>_CREATE_ASSEMBLY_SOURCE",
                      cmProperty::VARIABLE,0,0);
   cm->DefineProperty("CMAKE_<LANG>_CREATE_PREPROCESSED_SOURCE",

+ 2 - 0
Source/cmExportBuildFileGenerator.cxx

@@ -125,6 +125,8 @@ cmExportBuildFileGenerator
     std::string prop = "IMPORTED_IMPLIB";
     prop += suffix;
     std::string value = target->GetFullPath(config, true);
+    target->GetImplibGNUtoMS(value, value,
+                             "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
     properties[prop] = value;
     }
 }

+ 2 - 0
Source/cmExportCommand.h

@@ -13,6 +13,7 @@
 #define cmExportCommand_h
 
 #include "cmCommand.h"
+#include "cmDocumentLocationUndefined.h"
 
 class cmExportBuildFileGenerator;
 
@@ -80,6 +81,7 @@ public:
       "should never be installed.  "
       "See the install(EXPORT) command to export targets from an "
       "installation tree."
+      CM_LOCATION_UNDEFINED_BEHAVIOR("passing it to this command")
       "\n"
       "  export(PACKAGE <name>)\n"
       "Store the current build directory in the CMake user package registry "

+ 63 - 0
Source/cmExportFileGenerator.cxx

@@ -368,3 +368,66 @@ cmExportFileGenerator
   os << "  )\n"
      << "\n";
 }
+
+
+//----------------------------------------------------------------------------
+void
+cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
+{
+  // Add code which verifies at cmake time that the file which is being
+  // imported actually exists on disk. This should in theory always be theory
+  // case, but still when packages are split into normal and development
+  // packages this might get broken (e.g. the Config.cmake could be part of
+  // the non-development package, something similar happened to me without
+  // on SUSE with a mysql pkg-config file, which claimed everything is fine,
+  // but the development package was not installed.).
+  os << "# Loop over all imported files and verify that they actually exist\n"
+        "FOREACH(target ${_IMPORT_CHECK_TARGETS} )\n"
+        "  FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
+        "    IF(NOT EXISTS \"${file}\" )\n"
+        "      MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\""
+        " references the file\n"
+        "   \\\"${file}\\\"\n"
+        "but this file does not exist.  Possible reasons include:\n"
+        "* The file was deleted, renamed, or moved to another location.\n"
+        "* An install or uninstall procedure did not complete successfully.\n"
+        "* The installation package was faulty and contained\n"
+        "   \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n"
+        "but not all the files it references.\n"
+        "\")\n"
+        "    ENDIF()\n"
+        "  ENDFOREACH()\n"
+        "  UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n"
+        "ENDFOREACH()\n"
+        "UNSET(_IMPORT_CHECK_TARGETS)\n"
+        "\n";
+}
+
+
+//----------------------------------------------------------------------------
+void
+cmExportFileGenerator
+::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
+                                 ImportPropertyMap const& properties,
+                                const std::set<std::string>& importedLocations)
+{
+  // Construct the imported target name.
+  std::string targetName = this->Namespace;
+  targetName += target->GetName();
+
+  os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
+        "LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
+
+  for(std::set<std::string>::const_iterator li = importedLocations.begin();
+      li != importedLocations.end();
+      ++li)
+    {
+    ImportPropertyMap::const_iterator pi = properties.find(*li);
+    if (pi != properties.end())
+      {
+      os << "\"" << pi->second << "\" ";
+      }
+    }
+
+  os << ")\n\n";
+}

+ 5 - 0
Source/cmExportFileGenerator.h

@@ -56,6 +56,11 @@ protected:
   void GenerateImportPropertyCode(std::ostream& os, const char* config,
                                   cmTarget* target,
                                   ImportPropertyMap const& properties);
+  void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
+                                      ImportPropertyMap const& properties,
+                               const std::set<std::string>& importedLocations);
+  void GenerateImportedFileCheckLoop(std::ostream& os);
+
 
   // Collect properties with detailed information about targets beyond
   // their location on disk.

+ 20 - 10
Source/cmExportInstallFileGenerator.cxx

@@ -167,16 +167,18 @@ cmExportInstallFileGenerator
     // Collect import properties for this target.
     cmTargetExport* te = *tei;
     ImportPropertyMap properties;
+    std::set<std::string> importedLocations;
+    this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator,
+                                    properties, importedLocations);
+    this->SetImportLocationProperty(config, suffix, te->LibraryGenerator,
+                                    properties, importedLocations);
     this->SetImportLocationProperty(config, suffix,
-                                    te->ArchiveGenerator, properties);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->LibraryGenerator, properties);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->RuntimeGenerator, properties);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->FrameworkGenerator, properties);
-    this->SetImportLocationProperty(config, suffix,
-                                    te->BundleGenerator, properties);
+                                    te->RuntimeGenerator, properties,
+                                    importedLocations);
+    this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator,
+                                    properties, importedLocations);
+    this->SetImportLocationProperty(config, suffix, te->BundleGenerator,
+                                    properties, importedLocations);
 
     // If any file location was set for the target add it to the
     // import file.
@@ -194,9 +196,13 @@ cmExportInstallFileGenerator
 
       // Generate code in the export file.
       this->GenerateImportPropertyCode(os, config, te->Target, properties);
+      this->GenerateImportedFileChecksCode(os, te->Target, properties,
+                                           importedLocations);
       }
     }
 
+  this->GenerateImportedFileCheckLoop(os);
+
   // Cleanup the import prefix variable.
   if(!this->ImportPrefix.empty())
     {
@@ -211,7 +217,9 @@ void
 cmExportInstallFileGenerator
 ::SetImportLocationProperty(const char* config, std::string const& suffix,
                             cmInstallTargetGenerator* itgen,
-                            ImportPropertyMap& properties)
+                            ImportPropertyMap& properties,
+                            std::set<std::string>& importedLocations
+                           )
 {
   // Skip rules that do not match this configuration.
   if(!(itgen && itgen->InstallsForConfig(config)))
@@ -249,6 +257,7 @@ cmExportInstallFileGenerator
 
     // Store the property.
     properties[prop] = value;
+    importedLocations.insert(prop);
     }
   else
     {
@@ -291,6 +300,7 @@ cmExportInstallFileGenerator
 
     // Store the property.
     properties[prop] = value;
+    importedLocations.insert(prop);
     }
 }
 

+ 3 - 1
Source/cmExportInstallFileGenerator.h

@@ -75,7 +75,9 @@ protected:
   void SetImportLocationProperty(const char* config,
                                  std::string const& suffix,
                                  cmInstallTargetGenerator* itgen,
-                                 ImportPropertyMap& properties);
+                                 ImportPropertyMap& properties,
+                                 std::set<std::string>& importedLocations
+                                );
 
   void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen);
 

+ 40 - 7
Source/cmExtraEclipseCDT4Generator.cxx

@@ -85,7 +85,26 @@ void cmExtraEclipseCDT4Generator::Generate()
   this->IsOutOfSourceBuild = (this->HomeDirectory!=this->HomeOutputDirectory);
 
   this->GenerateSourceProject = (this->IsOutOfSourceBuild &&
-                            mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT"));
+                            mf->IsOn("CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT"));
+
+  if ((this->GenerateSourceProject == false)
+    && (mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT")))
+    {
+    mf->IssueMessage(cmake::WARNING,
+              "ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT is set to TRUE, "
+              "but this variable is not supported anymore since CMake 2.8.7.\n"
+              "Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead.");
+    }
+
+  if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(),
+                                    this->HomeDirectory.c_str()))
+    {
+    mf->IssueMessage(cmake::WARNING, "The build directory is a subdirectory "
+                     "of the source directory.\n"
+                     "This is not supported well by Eclipse. It is strongly "
+                     "recommended to use a build directory which is a "
+                     "sibling of the source directory.");
+    }
 
   // NOTE: This is not good, since it pollutes the source tree. However,
   //       Eclipse doesn't allow CVS/SVN to work when the .project is not in
@@ -103,7 +122,7 @@ void cmExtraEclipseCDT4Generator::Generate()
   this->CreateCProjectFile();
 }
 
-void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const
+void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
 {
   assert(this->HomeDirectory != this->HomeOutputDirectory);
 
@@ -131,6 +150,16 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const
     "\t</buildSpec>\n"
     "\t<natures>\n"
     "\t</natures>\n"
+    "\t<linkedResources>\n";
+
+  if (this->SupportsVirtualFolders)
+    {
+    this->CreateLinksToSubprojects(fout, this->HomeDirectory);
+    this->SrcLinkedResources.clear();
+    }
+
+  fout <<
+    "\t</linkedResources>\n"
     "</projectDescription>\n"
     ;
 }
@@ -424,7 +453,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
 
   if (this->SupportsVirtualFolders)
     {
-    this->CreateLinksToSubprojects(fout);
+    this->CreateLinksToSubprojects(fout, this->HomeOutputDirectory);
 
     this->CreateLinksForTargets(fout);
     }
@@ -531,7 +560,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
 
 //----------------------------------------------------------------------------
 void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
-                                                   cmGeneratedFileStream& fout)
+                       cmGeneratedFileStream& fout, const std::string& baseDir)
 {
   // for each sub project create a linked resource to the source dir
   // - only if it is an out-of-source build
@@ -547,8 +576,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
                             it->second[0]->GetMakefile()->GetStartDirectory());
     // a linked resource must not point to a parent directory of .project or
     // .project itself
-    if ((this->HomeOutputDirectory != linkSourceDirectory) &&
-        !cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(),
+    if ((baseDir != linkSourceDirectory) &&
+        !cmSystemTools::IsSubDirectory(baseDir.c_str(),
                                        linkSourceDirectory.c_str()))
       {
       std::string linkName = "[Subprojects]/";
@@ -998,7 +1027,11 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
           std::string virtDir = "[Targets]/";
           virtDir += prefix;
           virtDir += ti->first;
-          this->AppendTarget(fout, "Build", make, makeArgs, virtDir, "",
+          std::string buildArgs = "-C \"";
+          buildArgs += makefile->GetHomeOutputDirectory();
+          buildArgs += "\" ";
+          buildArgs += makeArgs;
+          this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "",
                              ti->first.c_str());
 
           std::string cleanArgs = "-E chdir \"";

+ 3 - 2
Source/cmExtraEclipseCDT4Generator.h

@@ -46,7 +46,7 @@ public:
 
 private:
   // create .project file in the source tree
-  void CreateSourceProjectFile() const;
+  void CreateSourceProjectFile();
 
   // create .project file
   void CreateProjectFile();
@@ -104,7 +104,8 @@ private:
   static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar,
                         cmMakefile* mf);
 
-  void CreateLinksToSubprojects(cmGeneratedFileStream& fout);
+  void CreateLinksToSubprojects(cmGeneratedFileStream& fout,
+                                const std::string& baseDir);
   void CreateLinksForTargets(cmGeneratedFileStream& fout);
 
   std::vector<std::string> SrcLinkedResources;

+ 46 - 0
Source/cmFileCommand.cxx

@@ -13,6 +13,7 @@
 #include "cmake.h"
 #include "cmHexFileConverter.h"
 #include "cmFileTimeComparison.h"
+#include "cmCryptoHash.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #include "cm_curl.h"
@@ -22,6 +23,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#include <cmsys/auto_ptr.hxx>
 #include <cmsys/Directory.hxx>
 #include <cmsys/Glob.hxx>
 #include <cmsys/RegularExpression.hxx>
@@ -83,6 +85,15 @@ bool cmFileCommand
     {
     return this->HandleReadCommand(args);
     }
+  else if ( subCommand == "MD5" ||
+            subCommand == "SHA1" ||
+            subCommand == "SHA224" ||
+            subCommand == "SHA256" ||
+            subCommand == "SHA384" ||
+            subCommand == "SHA512" )
+    {
+    return this->HandleHashCommand(args);
+    }
   else if ( subCommand == "STRINGS" )
     {
     return this->HandleStringsCommand(args);
@@ -338,6 +349,41 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
   return true;
 }
 
+//----------------------------------------------------------------------------
+bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
+{
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+  if(args.size() != 3)
+    {
+    cmOStringStream e;
+    e << args[0] << " requires a file name and output variable";
+    this->SetError(e.str().c_str());
+    return false;
+    }
+
+  cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
+  if(hash.get())
+    {
+    std::string out = hash->HashFile(args[1].c_str());
+    if(!out.empty())
+      {
+      this->Makefile->AddDefinition(args[2].c_str(), out.c_str());
+      return true;
+      }
+    cmOStringStream e;
+    e << args[0] << " failed to read file \"" << args[1] << "\": "
+      << cmSystemTools::GetLastSystemError();
+    this->SetError(e.str().c_str());
+    }
+  return false;
+#else
+  cmOStringStream e;
+  e << args[0] << " not available during bootstrap";
+  this->SetError(e.str().c_str());
+  return false;
+#endif
+}
+
 //----------------------------------------------------------------------------
 bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
 {

+ 4 - 0
Source/cmFileCommand.h

@@ -65,6 +65,7 @@ public:
       "  file(WRITE filename \"message to write\"... )\n"
       "  file(APPEND filename \"message to write\"... )\n"
       "  file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX])\n"
+      "  file(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> filename variable)\n"
       "  file(STRINGS filename variable [LIMIT_COUNT num]\n"
       "       [LIMIT_INPUT numBytes] [LIMIT_OUTPUT numBytes]\n"
       "       [LENGTH_MINIMUM numBytes] [LENGTH_MAXIMUM numBytes]\n"
@@ -94,6 +95,8 @@ public:
       "variable. It will start at the given offset and read up to numBytes. "
       "If the argument HEX is given, the binary data will be converted to "
       "hexadecimal representation and this will be stored in the variable.\n"
+      "MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 "
+      "will compute a cryptographic hash of the content of a file.\n"
       "STRINGS will parse a list of ASCII strings from a file and "
       "store it in a variable. Binary data in the file are ignored. Carriage "
       "return (CR) characters are ignored. It works also for Intel Hex and "
@@ -227,6 +230,7 @@ protected:
   bool HandleRemove(std::vector<std::string> const& args, bool recurse);
   bool HandleWriteCommand(std::vector<std::string> const& args, bool append);
   bool HandleReadCommand(std::vector<std::string> const& args);
+  bool HandleHashCommand(std::vector<std::string> const& args);
   bool HandleStringsCommand(std::vector<std::string> const& args);
   bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse);
   bool HandleMakeDirectoryCommand(std::vector<std::string> const& args);

+ 2 - 1
Source/cmGlobalVisualStudio10Generator.cxx

@@ -43,7 +43,8 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator()
 {
-  cmLocalVisualStudio10Generator* lg =  new cmLocalVisualStudio10Generator;
+  cmLocalVisualStudio10Generator* lg =
+    new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS10);
   lg->SetPlatformName(this->GetPlatformName());
   lg->SetGlobalGenerator(this);
   return lg;

+ 11 - 0
Source/cmGlobalVisualStudio11Generator.cxx

@@ -10,6 +10,7 @@
   See the License for more information.
 ============================================================================*/
 #include "cmGlobalVisualStudio11Generator.h"
+#include "cmLocalVisualStudio10Generator.h"
 #include "cmMakefile.h"
 
 //----------------------------------------------------------------------------
@@ -35,6 +36,16 @@ void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
   fout << "# Visual Studio 11\n";
 }
 
+//----------------------------------------------------------------------------
+cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator()
+{
+  cmLocalVisualStudio10Generator* lg =
+    new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS11);
+  lg->SetPlatformName(this->GetPlatformName());
+  lg->SetGlobalGenerator(this);
+  return lg;
+}
+
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudio11Generator
 ::GetDocumentation(cmDocumentationEntry& entry) const

+ 3 - 0
Source/cmGlobalVisualStudio11Generator.h

@@ -35,6 +35,9 @@ public:
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry) const;
 
+  ///! create the correct local generator
+  virtual cmLocalGenerator *CreateLocalGenerator();
+
   /** TODO: VS 11 user macro support. */
   virtual std::string GetUserMacrosDirectory() { return ""; }
 protected:

+ 2 - 2
Source/cmGlobalVisualStudio71Generator.cxx

@@ -26,8 +26,8 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator()
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator()
 {
-  cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
-  lg->SetVersion71();
+  cmLocalVisualStudio7Generator *lg =
+    new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS71);
   lg->SetExtraFlagTable(this->GetExtraFlagTableVS7());
   lg->SetGlobalGenerator(this);
   return lg;

+ 2 - 1
Source/cmGlobalVisualStudio7Generator.cxx

@@ -133,7 +133,8 @@ std::string cmGlobalVisualStudio7Generator
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator()
 {
-  cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
+  cmLocalVisualStudio7Generator *lg =
+    new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS7);
   lg->SetExtraFlagTable(this->GetExtraFlagTableVS7());
   lg->SetGlobalGenerator(this);
   return lg;

+ 2 - 2
Source/cmGlobalVisualStudio8Generator.cxx

@@ -28,8 +28,8 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator()
 {
-  cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
-  lg->SetVersion8();
+  cmLocalVisualStudio7Generator *lg =
+    new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8);
   lg->SetPlatformName(this->GetPlatformName());
   lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
   lg->SetGlobalGenerator(this);

+ 2 - 2
Source/cmGlobalVisualStudio8Win64Generator.cxx

@@ -25,8 +25,8 @@ cmGlobalVisualStudio8Win64Generator::cmGlobalVisualStudio8Win64Generator()
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio8Win64Generator::CreateLocalGenerator()
 {
-  cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
-  lg->SetVersion8();
+  cmLocalVisualStudio7Generator *lg
+    = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8);
   lg->SetPlatformName(this->GetPlatformName());
   lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
   lg->SetGlobalGenerator(this);

+ 2 - 2
Source/cmGlobalVisualStudio9Generator.cxx

@@ -40,8 +40,8 @@ void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator()
 {
-  cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
-  lg->SetVersion9();
+  cmLocalVisualStudio7Generator *lg
+    = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
   lg->SetPlatformName(this->GetPlatformName());
   lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
   lg->SetGlobalGenerator(this);

+ 2 - 2
Source/cmGlobalVisualStudio9IA64Generator.cxx

@@ -22,8 +22,8 @@ cmGlobalVisualStudio9IA64Generator::cmGlobalVisualStudio9IA64Generator()
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio9IA64Generator::CreateLocalGenerator()
 {
-  cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
-  lg->SetVersion9();
+  cmLocalVisualStudio7Generator *lg =
+    new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
   lg->SetPlatformName(this->GetPlatformName());
   lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
   lg->SetGlobalGenerator(this);

+ 2 - 2
Source/cmGlobalVisualStudio9Win64Generator.cxx

@@ -22,8 +22,8 @@ cmGlobalVisualStudio9Win64Generator::cmGlobalVisualStudio9Win64Generator()
 ///! Create a local generator appropriate to this Global Generator
 cmLocalGenerator *cmGlobalVisualStudio9Win64Generator::CreateLocalGenerator()
 {
-  cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator;
-  lg->SetVersion9();
+  cmLocalVisualStudio7Generator *lg =
+    new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
   lg->SetPlatformName(this->GetPlatformName());
   lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
   lg->SetGlobalGenerator(this);

+ 24 - 2
Source/cmInstallTargetGenerator.cxx

@@ -101,6 +101,13 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
       std::string to1 = toDir + targetNameImport;
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
+      std::string targetNameImportLib;
+      if(this->Target->GetImplibGNUtoMS(targetNameImport,
+                                        targetNameImportLib))
+        {
+        filesFrom.push_back(fromDirConfig + targetNameImportLib);
+        filesTo.push_back(toDir + targetNameImportLib);
+        }
 
       // An import library looks like a static library.
       type = cmTarget::STATIC_LIBRARY;
@@ -157,6 +164,13 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
       std::string to1 = toDir + targetNameImport;
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
+      std::string targetNameImportLib;
+      if(this->Target->GetImplibGNUtoMS(targetNameImport,
+                                        targetNameImportLib))
+        {
+        filesFrom.push_back(fromDirConfig + targetNameImportLib);
+        filesTo.push_back(toDir + targetNameImportLib);
+        }
 
       // An import library looks like a static library.
       type = cmTarget::STATIC_LIBRARY;
@@ -314,7 +328,11 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
     if(nameType == NameImplib)
       {
       // Use the import library name.
-      fname = targetNameImport;
+      if(!target->GetImplibGNUtoMS(targetNameImport, fname,
+                                   "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
+        {
+        fname = targetNameImport;
+        }
       }
     else if(nameType == NameReal)
       {
@@ -339,7 +357,11 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
     if(nameType == NameImplib)
       {
       // Use the import library name.
-      fname = targetNameImport;
+      if(!target->GetImplibGNUtoMS(targetNameImport, fname,
+                                   "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
+        {
+        fname = targetNameImport;
+        }
       }
     else if(nameType == NameSO)
       {

+ 73 - 73
Source/cmLocalGenerator.cxx

@@ -96,14 +96,14 @@ void cmLocalGenerator::Configure()
   std::string filesDir = this->Makefile->GetStartOutputDirectory();
   filesDir += cmake::GetCMakeFilesDirectory();
   cmSystemTools::MakeDirectory(filesDir.c_str());
-  
+
   // find & read the list file
   this->ReadInputFile();
 
   // at the end of the ReadListFile handle any old style subdirs
   // first get all the subdirectories
   std::vector<cmLocalGenerator *> subdirs = this->GetChildren();
-  
+
   // for each subdir recurse
   std::vector<cmLocalGenerator *>::iterator sdi = subdirs.begin();
   for (; sdi != subdirs.end(); ++sdi)
@@ -112,7 +112,7 @@ void cmLocalGenerator::Configure()
       {
       this->Makefile->ConfigureSubDirectory(*sdi);
       }
-    }  
+    }
 
   // Check whether relative paths should be used for optionally
   // relative paths.
@@ -212,10 +212,10 @@ void cmLocalGenerator::ReadInputFile()
 }
 
 void cmLocalGenerator::SetupPathConversions()
-{  
+{
   // Setup the current output directory components for use by
   // Convert
-  std::string outdir; 
+  std::string outdir;
   outdir =
     cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory());
   cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents);
@@ -225,12 +225,12 @@ void cmLocalGenerator::SetupPathConversions()
 
   outdir = cmSystemTools::CollapseFullPath
     (this->Makefile->GetHomeOutputDirectory());
-  cmSystemTools::SplitPath(outdir.c_str(), 
+  cmSystemTools::SplitPath(outdir.c_str(),
                            this->HomeOutputDirectoryComponents);
 
   outdir = cmSystemTools::CollapseFullPath
     (this->Makefile->GetStartOutputDirectory());
-  cmSystemTools::SplitPath(outdir.c_str(), 
+  cmSystemTools::SplitPath(outdir.c_str(),
                            this->StartOutputDirectoryComponents);
 }
 
@@ -289,17 +289,17 @@ void cmLocalGenerator::GenerateTestFiles()
   fout.SetCopyIfDifferent(true);
 
   fout << "# CMake generated Testfile for " << std::endl
-       << "# Source directory: " 
+       << "# Source directory: "
        << this->Makefile->GetStartDirectory() << std::endl
-       << "# Build directory: " 
+       << "# Build directory: "
        << this->Makefile->GetStartOutputDirectory() << std::endl
        << "# " << std::endl
        << "# This file includes the relevent testing commands "
        << "required for " << std::endl
        << "# testing this directory and lists subdirectories to "
        << "be tested as well." << std::endl;
-  
-  const char* testIncludeFile = 
+
+  const char* testIncludeFile =
     this->Makefile->GetProperty("TEST_INCLUDE_FILE");
   if ( testIncludeFile )
     {
@@ -320,7 +320,7 @@ void cmLocalGenerator::GenerateTestFiles()
     for(i = 0; i < this->Children.size(); ++i)
       {
       fout << "SUBDIRS(";
-      std::string outP = 
+      std::string outP =
         this->Children[i]->GetMakefile()->GetStartOutputDirectory();
       fout << this->Convert(outP.c_str(),START_OUTPUT);
       fout << ")" << std::endl;
@@ -472,7 +472,7 @@ void cmLocalGenerator::GenerateInstallRules()
   // Ask each install generator to write its code.
   std::vector<cmInstallGenerator*> const& installers =
     this->Makefile->GetInstallGenerators();
-  for(std::vector<cmInstallGenerator*>::const_iterator 
+  for(std::vector<cmInstallGenerator*>::const_iterator
         gi = installers.begin();
       gi != installers.end(); ++gi)
     {
@@ -553,15 +553,15 @@ void cmLocalGenerator::GenerateTargetManifest()
     }
 }
 
-void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, 
-                                                      const char* lang, 
+void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
+                                                      const char* lang,
                                                       cmSourceFile& source,
                                                       cmTarget& )
-{ 
+{
   std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
   objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
   std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
-  std::string sourceFile = 
+  std::string sourceFile =
     this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true);
   std::string varString = "CMAKE_";
   varString += lang;
@@ -655,7 +655,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
         ofname += "/";
         ofname += obj;
         objVector.push_back(ofname);
-        this->AddCustomCommandToCreateObject(ofname.c_str(), 
+        this->AddCustomCommandToCreateObject(ofname.c_str(),
                                              llang, *(*i), target);
         objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE);
         objs += " ";
@@ -672,7 +672,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
   // Shared Module:
   std::string linkLibs; // should be set
   std::string flags; // should be set
-  std::string linkFlags; // should be set 
+  std::string linkFlags; // should be set
   this->GetTargetFlags(linkLibs, flags, linkFlags, target);
   cmLocalGenerator::RuleVariables vars;
   vars.Language = llang;
@@ -682,17 +682,17 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
   vars.LinkLibraries = linkLibs.c_str();
   vars.Flags = flags.c_str();
   vars.LinkFlags = linkFlags.c_str();
- 
+
   std::string langFlags;
   this->AddLanguageFlags(langFlags, llang, 0);
   this->AddArchitectureFlags(langFlags, &target, llang, 0);
   vars.LanguageCompileFlags = langFlags.c_str();
-  
+
   cmCustomCommandLines commandLines;
   std::vector<std::string> rules;
   rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str()));
   std::vector<std::string> commands;
-  cmSystemTools::ExpandList(rules, commands);  
+  cmSystemTools::ExpandList(rules, commands);
   for(std::vector<std::string>::iterator i = commands.begin();
       i != commands.end(); ++i)
     {
@@ -728,21 +728,21 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
     (this->Makefile->GetSource(targetFullPath.c_str()));
 }
 
-  
+
 void cmLocalGenerator
 ::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang)
-{ 
+{
   cmTargets &tgts = this->Makefile->GetTargets();
-  for(cmTargets::iterator l = tgts.begin(); 
+  for(cmTargets::iterator l = tgts.begin();
       l != tgts.end(); l++)
     {
     cmTarget& target = l->second;
     switch(target.GetType())
-      { 
+      {
       case cmTarget::STATIC_LIBRARY:
       case cmTarget::SHARED_LIBRARY:
       case cmTarget::MODULE_LIBRARY:
-      case cmTarget::EXECUTABLE: 
+      case cmTarget::EXECUTABLE:
         {
         const char* llang = target.GetLinkerLanguage();
         if(!llang)
@@ -759,7 +759,7 @@ void cmLocalGenerator
           this->AddBuildTargetRule(llang, target);
           }
         }
-        break; 
+        break;
       default:
         break;
       }
@@ -769,14 +769,14 @@ void cmLocalGenerator
 // List of variables that are replaced when
 // rules are expanced.  These variables are
 // replaced in the form <var> with GetSafeDefinition(var).
-// ${LANG} is replaced in the variable first with all enabled 
+// ${LANG} is replaced in the variable first with all enabled
 // languages.
 static const char* ruleReplaceVars[] =
 {
   "CMAKE_${LANG}_COMPILER",
   "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS",
   "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS",
-  "CMAKE_SHARED_MODULE_${LANG}_FLAGS", 
+  "CMAKE_SHARED_MODULE_${LANG}_FLAGS",
   "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS",
   "CMAKE_${LANG}_LINK_FLAGS",
   "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG",
@@ -807,7 +807,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
       return replaceValues.Flags;
       }
     }
-    
+
   if(replaceValues.Source)
     {
     if(variable == "SOURCE")
@@ -870,7 +870,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
     }
 
   if(replaceValues.Target)
-    { 
+    {
     if(variable == "TARGET_QUOTED")
       {
       std::string targetQuoted = replaceValues.Target;
@@ -1018,13 +1018,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
   int pos = 0;
   while(ruleReplaceVars[pos])
     {
-    for(std::vector<std::string>::iterator i = enabledLanguages.begin();   
-        i != enabledLanguages.end(); ++i)   
-      { 
+    for(std::vector<std::string>::iterator i = enabledLanguages.begin();
+        i != enabledLanguages.end(); ++i)
+      {
       const char* lang = i->c_str();
       std::string actualReplace = ruleReplaceVars[pos];
       // If this is the compiler then look for the extra variable
-      // _COMPILER_ARG1 which must be the first argument to the compiler 
+      // _COMPILER_ARG1 which must be the first argument to the compiler
       const char* compilerArg1 = 0;
       if(actualReplace == "CMAKE_${LANG}_COMPILER")
         {
@@ -1038,7 +1038,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
         }
       if(actualReplace == variable)
         {
-        std::string replace = 
+        std::string replace =
           this->Makefile->GetSafeDefinition(variable.c_str());
         // if the variable is not a FLAG then treat it like a path
         if(variable.find("_FLAG") == variable.npos)
@@ -1062,7 +1062,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
 }
 
 
-void 
+void
 cmLocalGenerator::ExpandRuleVariables(std::string& s,
                                       const RuleVariables& replaceValues)
 {
@@ -1213,7 +1213,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
 
   std::string flagVar = "CMAKE_INCLUDE_FLAG_";
   flagVar += lang;
-  const char* includeFlag = 
+  const char* includeFlag =
     this->Makefile->GetSafeDefinition(flagVar.c_str());
   flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
   flagVar += lang;
@@ -1223,7 +1223,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang,
     {
     quotePaths = true;
     }
-  bool repeatFlag = true; 
+  bool repeatFlag = true;
   // should the include flag be repeated like ie. -IA -IB
   if(!sep)
     {
@@ -1354,15 +1354,15 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
     this->Makefile->GetDefinition("VTK_SOURCE_DIR");
   if(vtkSourceDir)
     {
-    const char* vtk_major = 
+    const char* vtk_major =
       this->Makefile->GetDefinition("VTK_MAJOR_VERSION");
-    const char* vtk_minor = 
+    const char* vtk_minor =
       this->Makefile->GetDefinition("VTK_MINOR_VERSION");
     vtk_major = vtk_major? vtk_major : "4";
     vtk_minor = vtk_minor? vtk_minor : "4";
     int vmajor = 0;
     int vminor = 0;
-    if(sscanf(vtk_major, "%d", &vmajor) && 
+    if(sscanf(vtk_major, "%d", &vmajor) &&
        sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4)
       {
       includeSourceDir = true;
@@ -1403,7 +1403,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
     }
 
   // Get the project-specified include directories.
-  std::vector<std::string>& includes = 
+  std::vector<std::string>& includes =
     this->Makefile->GetIncludeDirectories();
 
   // Support putting all the in-project include directories first if
@@ -1446,17 +1446,17 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
                                  std::string& linkFlags,
                                  cmTarget& target)
 {
-  std::string buildType =  
+  std::string buildType =
     this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
-  buildType = cmSystemTools::UpperCase(buildType); 
-  const char* libraryLinkVariable = 
+  buildType = cmSystemTools::UpperCase(buildType);
+  const char* libraryLinkVariable =
     "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library
-  
+
   switch(target.GetType())
     {
-    case cmTarget::STATIC_LIBRARY: 
+    case cmTarget::STATIC_LIBRARY:
       {
-      const char* targetLinkFlags = 
+      const char* targetLinkFlags =
         target.GetProperty("STATIC_LIBRARY_FLAGS");
       if(targetLinkFlags)
         {
@@ -1475,11 +1475,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
           }
         }
       }
-      break; 
+      break;
     case cmTarget::MODULE_LIBRARY:
       libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
     case cmTarget::SHARED_LIBRARY:
-      { 
+      {
       linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable);
       linkFlags += " ";
       if(!buildType.empty())
@@ -1489,8 +1489,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
         build += buildType;
         linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
         linkFlags += " ";
-        }  
-      if(this->Makefile->IsOn("WIN32") && 
+        }
+      if(this->Makefile->IsOn("WIN32") &&
          !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
         {
         const std::vector<cmSourceFile*>& sources = target.GetSourceFiles();
@@ -1500,14 +1500,14 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
           cmSourceFile* sf = *i;
           if(sf->GetExtension() == "def")
             {
-            linkFlags += 
+            linkFlags +=
               this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
             linkFlags += this->Convert(sf->GetFullPath().c_str(),
                                        START_OUTPUT, SHELL);
             linkFlags += " ";
             }
           }
-        } 
+        }
       const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
       if(targetLinkFlags)
         {
@@ -1520,11 +1520,11 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
         configLinkFlags += buildType;
         targetLinkFlags = target.GetProperty(configLinkFlags.c_str());
         if(targetLinkFlags)
-          { 
+          {
           linkFlags += targetLinkFlags;
           linkFlags += " ";
           }
-        }  
+        }
       cmOStringStream linklibsStr;
       this->OutputLinkLibraries(linklibsStr, target, false);
       linkLibs = linklibsStr.str();
@@ -1532,7 +1532,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
       break;
     case cmTarget::EXECUTABLE:
       {
-      linkFlags += 
+      linkFlags +=
         this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
       linkFlags += " ";
       if(!buildType.empty())
@@ -1541,7 +1541,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
         build += buildType;
         linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
         linkFlags += " ";
-        } 
+        }
       const char* linkLanguage = target.GetLinkerLanguage();
       if(!linkLanguage)
         {
@@ -1566,7 +1566,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
       if(cmSystemTools::IsOn
          (this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
         {
-        std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") 
+        std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_")
           + linkLanguage + std::string("_FLAGS");
         linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str());
         linkFlags += " ";
@@ -1579,7 +1579,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
         }
       else
         {
-        linkFlags +=  
+        linkFlags +=
           this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE");
         linkFlags += " ";
         }
@@ -1595,13 +1595,13 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
         configLinkFlags += buildType;
         targetLinkFlags = target.GetProperty(configLinkFlags.c_str());
         if(targetLinkFlags)
-          { 
+          {
           linkFlags += targetLinkFlags;
           linkFlags += " ";
           }
         }
       }
-      break; 
+      break;
     default:
       break;
     }
@@ -1661,9 +1661,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
 
   const char* linkLanguage = cli.GetLinkLanguage();
 
-  std::string libPathFlag = 
+  std::string libPathFlag =
     this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
-  std::string libPathTerminator = 
+  std::string libPathTerminator =
     this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
 
   // Flags to link an executable to shared libraries.
@@ -1786,11 +1786,11 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
     {
     std::vector<std::string> archs;
     target->GetAppleArchs(config, archs);
-    const char* sysroot = 
+    const char* sysroot =
       this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
-    const char* sysrootDefault = 
+    const char* sysrootDefault =
       this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
-    const char* deploymentTarget = 
+    const char* deploymentTarget =
       this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
     std::string isysrootVar = std::string("CMAKE_") + lang + "_HAS_ISYSROOT";
     bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str());
@@ -1876,7 +1876,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
     if(cmSystemTools::FileIsFullPath(inName))
       {
       std::string tLocation;
-      if(target->GetType() >= cmTarget::EXECUTABLE && 
+      if(target->GetType() >= cmTarget::EXECUTABLE &&
          target->GetType() <= cmTarget::MODULE_LIBRARY)
         {
         tLocation = target->GetLocation(config);
@@ -2904,7 +2904,7 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
   else
     {
     cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags);
-    }  
+    }
   return std::string(&arg[0]);
 }
 
@@ -2976,9 +2976,9 @@ cmLocalGenerator::GetTargetDirectory(cmTarget const&) const
 
 
 //----------------------------------------------------------------------------
-void 
+void
 cmLocalGenerator::GetTargetObjectFileDirectories(cmTarget* ,
-                                                 std::vector<std::string>& 
+                                                 std::vector<std::string>&
                                                  )
 {
   cmSystemTools::Error("GetTargetObjectFileDirectories"

+ 26 - 18
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -607,6 +607,27 @@ cmLocalUnixMakefileGenerator3
     }
 }
 
+//----------------------------------------------------------------------------
+std::string
+cmLocalUnixMakefileGenerator3
+::ConvertShellCommand(std::string const& cmd, RelativeRoot root)
+{
+  if(this->WatcomWMake &&
+     cmSystemTools::FileIsFullPath(cmd.c_str()) &&
+     cmd.find_first_of("( )") != cmd.npos)
+    {
+    // On Watcom WMake use the windows short path for the command
+    // name.  This is needed to avoid funny quoting problems on
+    // lines with shell redirection operators.
+    std::string scmd;
+    if(cmSystemTools::GetShortPath(cmd.c_str(), scmd))
+      {
+      return this->Convert(scmd.c_str(), NONE, SHELL);
+      }
+    }
+  return this->Convert(cmd.c_str(), root, SHELL);
+}
+
 //----------------------------------------------------------------------------
 void
 cmLocalUnixMakefileGenerator3
@@ -646,13 +667,13 @@ cmLocalUnixMakefileGenerator3
   makefileStream
     << "# The CMake executable.\n"
     << "CMAKE_COMMAND = "
-    << this->Convert(cmakecommand.c_str(), FULL, SHELL).c_str()
+    << this->ConvertShellCommand(cmakecommand, FULL)
     << "\n"
     << "\n";
   makefileStream
     << "# The command to remove a file.\n"
     << "RM = "
-    << this->Convert(cmakecommand.c_str(),FULL,SHELL).c_str()
+    << this->ConvertShellCommand(cmakecommand, FULL)
     << " -E remove -f\n"
     << "\n";
 
@@ -662,7 +683,7 @@ cmLocalUnixMakefileGenerator3
     makefileStream
       << "# The program to use to edit the cache.\n"
       << "CMAKE_EDIT_COMMAND = "
-      << this->Convert(edit_cmd,FULL,SHELL) << "\n"
+      << this->ConvertShellCommand(edit_cmd, FULL) << "\n"
       << "\n";
     }
 
@@ -697,7 +718,7 @@ cmLocalUnixMakefileGenerator3
   // This should be the first target except for the default_target in
   // the interface Makefile.
   this->WriteMakeRule(
-    makefileStream, "Disable implicit rules so canoncical targets will work.",
+    makefileStream, "Disable implicit rules so canonical targets will work.",
     ".SUFFIXES", no_depends, no_commands, false);
 
   if(!this->NMake && !this->WatcomWMake && !this->BorlandMakeCurlyHack)
@@ -1019,22 +1040,9 @@ cmLocalUnixMakefileGenerator3
         // without the current directory being in the search path.
         cmd = "./" + cmd;
         }
-      if(this->WatcomWMake &&
-         cmSystemTools::FileIsFullPath(cmd.c_str()) &&
-         cmd.find(" ") != cmd.npos)
-        {
-        // On Watcom WMake use the windows short path for the command
-        // name.  This is needed to avoid funny quoting problems on
-        // lines with shell redirection operators.
-        std::string scmd;
-        if(cmSystemTools::GetShortPath(cmd.c_str(), scmd))
-          {
-          cmd = scmd;
-          }
-        }
       std::string launcher =
         this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT);
-      cmd = launcher + this->Convert(cmd.c_str(),NONE,SHELL);
+      cmd = launcher + this->ConvertShellCommand(cmd, NONE);
 
       ccg.AppendArguments(c, cmd);
       if(content)

+ 1 - 0
Source/cmLocalUnixMakefileGenerator3.h

@@ -340,6 +340,7 @@ protected:
   void CheckMultipleOutputs(bool verbose);
 
 private:
+  std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root);
   std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target,
                            RelativeRoot relative);
 

+ 2 - 1
Source/cmLocalVisualStudio10Generator.cxx

@@ -61,7 +61,8 @@ class cmVS10XMLParser : public cmXMLParser
 
 
 //----------------------------------------------------------------------------
-cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator()
+cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator(VSVersion v):
+  cmLocalVisualStudio7Generator(v)
 {
 }
 

+ 1 - 1
Source/cmLocalVisualStudio10Generator.h

@@ -25,7 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
 {
 public:
   ///! Set cache only and recurse to false by default.
-  cmLocalVisualStudio10Generator();
+  cmLocalVisualStudio10Generator(VSVersion v);
 
   virtual ~cmLocalVisualStudio10Generator();
 

+ 2 - 1
Source/cmLocalVisualStudio6Generator.cxx

@@ -21,7 +21,8 @@
 
 #include <cmsys/RegularExpression.hxx>
 
-cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator()
+cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator():
+  cmLocalVisualStudioGenerator(VS6)
 {
 }
 

+ 16 - 9
Source/cmLocalVisualStudio7Generator.cxx

@@ -45,9 +45,9 @@ private:
 extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[];
 
 //----------------------------------------------------------------------------
-cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator()
+cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator(VSVersion v):
+  cmLocalVisualStudioGenerator(v)
 {
-  this->Version = 7;
   this->PlatformName = "Win32";
   this->ExtraFlagTable = 0;
   this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);
@@ -719,7 +719,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
     t = Options::FortranCompiler;
     table = cmLocalVisualStudio7GeneratorFortranFlagTable;
     }
-  Options targetOptions(this, this->Version, t, 
+  Options targetOptions(this, t,
                         table,
                         this->ExtraFlagTable);
   targetOptions.FixExceptionHandlingDefault();
@@ -888,7 +888,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   // end of <Tool Name=VCMIDLTool
 
   // Check if we need the FAT32 workaround.
-  if(targetBuilds && this->Version >= 8)
+  if(targetBuilds && this->Version >= VS8)
     {
     // Check the filesystem type where the target will be written.
     if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str()))
@@ -975,7 +975,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
     extraLinkOptions += " ";
     extraLinkOptions += targetLinkFlags;
     }
-  Options linkOptions(this, this->Version, Options::Linker,
+  Options linkOptions(this, Options::Linker,
                       cmLocalVisualStudio7GeneratorLinkFlagTable);
   linkOptions.Parse(extraLinkOptions.c_str());
   if(!this->ModuleDefinitionFile.empty())
@@ -1604,7 +1604,7 @@ void cmLocalVisualStudio7Generator
               tool = Options::FortranCompiler;
               table = cmLocalVisualStudio7GeneratorFortranFlagTable;
               }
-            Options fileOptions(this, this->Version, tool, table,
+            Options fileOptions(this, tool, table,
                                 this->ExtraFlagTable);
             fileOptions.Parse(fc.CompileFlags.c_str());
             fileOptions.AddDefines(fc.CompileDefs.c_str());
@@ -1811,11 +1811,18 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout,
   const char* vsProjectname = target.GetProperty("VS_SCC_PROJECTNAME");
   const char* vsLocalpath = target.GetProperty("VS_SCC_LOCALPATH");
   const char* vsProvider = target.GetProperty("VS_SCC_PROVIDER");
+
   if(vsProvider && vsLocalpath && vsProjectname)
     {
     fout << "\tSccProjectName=\"" << vsProjectname << "\"\n"
          << "\tSccLocalPath=\"" << vsLocalpath << "\"\n"
          << "\tSccProvider=\"" << vsProvider << "\"\n";
+
+    const char* vsAuxPath = target.GetProperty("VS_SCC_AUXPATH");
+    if(vsAuxPath)
+      {
+      fout << "\tSccAuxPath=\"" << vsAuxPath << "\"\n";
+      }
     }
 }
 
@@ -1913,13 +1920,13 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
   fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
        << "<VisualStudioProject\n"
        << "\tProjectType=\"Visual C++\"\n";
-  if(this->Version == 71)
+  if(this->Version == VS71)
     {
     fout << "\tVersion=\"7.10\"\n";
     }
   else
     {
-    fout <<  "\tVersion=\"" << this->Version << ".00\"\n";
+    fout <<  "\tVersion=\"" << (this->Version/10) << ".00\"\n";
     }
   const char* projLabel = target.GetProperty("PROJECT_LABEL");
   if(!projLabel)
@@ -1934,7 +1941,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
   cmGlobalVisualStudio7Generator* gg =
     static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
   fout << "\tName=\"" << projLabel << "\"\n";
-  if(this->Version >= 8)
+  if(this->Version >= VS8)
     {
     fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
     }

+ 1 - 5
Source/cmLocalVisualStudio7Generator.h

@@ -35,7 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
 {
 public:
   ///! Set cache only and recurse to false by default.
-  cmLocalVisualStudio7Generator();
+  cmLocalVisualStudio7Generator(VSVersion v);
 
   virtual ~cmLocalVisualStudio7Generator();
 
@@ -53,9 +53,6 @@ public:
    */
   void SetBuildType(BuildType,const char *name);
 
-  void SetVersion71() {this->Version = 71;}
-  void SetVersion8() {this->Version = 8;}
-  void SetVersion9() {this->Version = 9;}
   void SetPlatformName(const char* n) { this->PlatformName = n;}
   void GetTargetObjectFileDirectories(cmTarget* target,
                                       std::vector<std::string>& 
@@ -130,7 +127,6 @@ private:
 
   cmVS7FlagTable const* ExtraFlagTable;
   std::string ModuleDefinitionFile;
-  int Version;
   bool FortranProject;
   std::string PlatformName; // Win32 or x64 
   cmLocalVisualStudio7GeneratorInternals* Internal;

+ 16 - 1
Source/cmLocalVisualStudioGenerator.cxx

@@ -18,10 +18,11 @@
 #include "windows.h"
 
 //----------------------------------------------------------------------------
-cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator()
+cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator(VSVersion v)
 {
   this->WindowsShell = true;
   this->WindowsVSIDE = true;
+  this->Version = v;
 }
 
 //----------------------------------------------------------------------------
@@ -249,6 +250,20 @@ cmLocalVisualStudioGenerator
 
     // Add this command line.
     std::string cmd = ccg.GetCommand(c);
+
+    // Use "call " before any invocations of .bat or .cmd files
+    // invoked as custom commands.
+    //
+    std::string suffix;
+    if (cmd.size() > 4)
+      {
+      suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size()-4));
+      if (suffix == ".bat" || suffix == ".cmd")
+        {
+        script += "call ";
+        }
+      }
+
     script += this->Convert(cmd.c_str(), relativeRoot, SHELL);
     ccg.AppendArguments(c, script);
 

+ 18 - 1
Source/cmLocalVisualStudioGenerator.h

@@ -29,7 +29,19 @@ class cmCustomCommand;
 class cmLocalVisualStudioGenerator : public cmLocalGenerator
 {
 public:
-  cmLocalVisualStudioGenerator();
+  /** Known versions of Visual Studio.  */
+  enum VSVersion
+  {
+    VS6 = 60,
+    VS7 = 70,
+    VS71 = 71,
+    VS8 = 80,
+    VS9 = 90,
+    VS10 = 100,
+    VS11 = 110
+  };
+
+  cmLocalVisualStudioGenerator(VSVersion v);
   virtual ~cmLocalVisualStudioGenerator();
 
   /** Construct a script from the given list of command lines.  */
@@ -41,6 +53,9 @@ public:
       sequence of custom commands. */
   const char* GetReportErrorLabel() const;
 
+  /** Version of Visual Studio.  */
+  VSVersion GetVersion() const { return this->Version; }
+
 protected:
   virtual const char* ReportErrorLabel() const;
   virtual bool CustomCommandUseLocal() const { return false; }
@@ -58,6 +73,8 @@ protected:
                              std::map<cmStdString, int>& count);
   std::set<const cmSourceFile*> NeedObjectName;
   friend class cmVisualStudio10TargetGenerator;
+
+  VSVersion Version;
 };
 
 #endif

+ 15 - 3
Source/cmMakefile.cxx

@@ -3213,7 +3213,8 @@ void cmMakefile::ConfigureString(const std::string& input,
 }
 
 int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
-                              bool copyonly, bool atOnly, bool escapeQuotes)
+                              bool copyonly, bool atOnly, bool escapeQuotes,
+                              const cmNewLineStyle& newLine)
 {
   int res = 1;
   if ( !this->CanIWriteThisFile(outfile) )
@@ -3250,9 +3251,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
     }
   else
     {
+    std::string newLineCharacters;
+    std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc;
+    if (newLine.IsValid())
+      {
+      newLineCharacters = newLine.GetCharacters();
+      omode |= std::ios::binary;
+      }
+    else
+      {
+      newLineCharacters = "\n";
+      }
     std::string tempOutputFile = soutfile;
     tempOutputFile += ".tmp";
-    std::ofstream fout(tempOutputFile.c_str());
+    std::ofstream fout(tempOutputFile.c_str(), omode);
     if(!fout)
       {
       cmSystemTools::Error(
@@ -3277,7 +3289,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
       {
       outLine = "";
       this->ConfigureString(inLine, outLine, atOnly, escapeQuotes);
-      fout << outLine.c_str() << "\n";
+      fout << outLine.c_str() << newLineCharacters;
       }
     // close the files before attempting to copy
     fin.close();

+ 4 - 1
Source/cmMakefile.h

@@ -19,6 +19,7 @@
 #include "cmPropertyMap.h"
 #include "cmSystemTools.h"
 #include "cmTarget.h"
+#include "cmNewLineStyle.h"
 #include "cmake.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -703,7 +704,9 @@ public:
    * Copy file but change lines acording to ConfigureString
    */
   int ConfigureFile(const char* infile, const char* outfile,
-                    bool copyonly, bool atOnly, bool escapeQuotes);
+                    bool copyonly, bool atOnly, bool escapeQuotes,
+                    const cmNewLineStyle& = cmNewLineStyle());
+
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**

+ 8 - 2
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -241,6 +241,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
     exeCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
                                           cmLocalGenerator::START_OUTPUT,
                                           cmLocalGenerator::UNCHANGED));
+    std::string implib;
+    if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
+      {
+      exeCleanFiles.push_back(this->Convert(implib.c_str(),
+                                            cmLocalGenerator::START_OUTPUT,
+                                            cmLocalGenerator::UNCHANGED));
+      }
     }
 
   // List the PDB for cleaning only when the whole target is
@@ -270,8 +277,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   std::string linkRuleVar = "CMAKE_";
   linkRuleVar += linkLanguage;
   linkRuleVar += "_LINK_EXECUTABLE";
-  std::string linkRule =
-    this->Makefile->GetRequiredDefinition(linkRuleVar.c_str());
+  std::string linkRule = this->GetLinkRule(linkRuleVar.c_str());
   std::vector<std::string> commands1;
   cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
   if(this->Target->IsExecutableWithExports())

+ 8 - 1
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -512,6 +512,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
         cmLocalGenerator::START_OUTPUT,
         cmLocalGenerator::UNCHANGED));
+    std::string implib;
+    if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
+      {
+      libCleanFiles.push_back(this->Convert(implib.c_str(),
+                                            cmLocalGenerator::START_OUTPUT,
+                                            cmLocalGenerator::UNCHANGED));
+      }
     }
 
   // List the PDB for cleaning only when the whole target is
@@ -772,7 +779,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   else
     {
     // Get the set of commands.
-    std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
+    std::string linkRule = this->GetLinkRule(linkRuleVar);
     cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
 
     // Expand placeholders.

+ 17 - 0
Source/cmMakefileTargetGenerator.cxx

@@ -1633,6 +1633,23 @@ void cmMakefileTargetGenerator
     }
 }
 
+//----------------------------------------------------------------------------
+std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
+{
+  std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
+  if(this->Target->HasImplibGNUtoMS())
+    {
+    std::string ruleVar = "CMAKE_";
+    ruleVar += this->Target->GetLinkerLanguage(this->ConfigName);
+    ruleVar += "_GNUtoMS_RULE";
+    if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str()))
+      {
+      linkRule += rule;
+      }
+    }
+  return linkRule;
+}
+
 //----------------------------------------------------------------------------
 void cmMakefileTargetGenerator
 ::CloseFileStreams()

+ 3 - 0
Source/cmMakefileTargetGenerator.h

@@ -120,6 +120,9 @@ protected:
   // Append link rule dependencies (objects, etc.).
   void AppendLinkDepends(std::vector<std::string>& depends);
 
+  // Lookup the link rule for this target.
+  std::string GetLinkRule(const char* linkRuleVar);
+
   /** In order to support parallel builds for custom commands with
       multiple outputs the outputs are given a serial order, and only
       the first output actually has the build rule.  Other outputs

+ 95 - 0
Source/cmNewLineStyle.cxx

@@ -0,0 +1,95 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2011 Kitware, Inc., Insight Software Consortium
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+#include "cmNewLineStyle.h"
+
+
+
+cmNewLineStyle::cmNewLineStyle() : NewLineStyle(Invalid)
+{
+}
+
+
+bool cmNewLineStyle::IsValid() const
+{
+  return NewLineStyle != Invalid;
+}
+
+
+bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args,
+                                       std::string& errorString)
+{
+  NewLineStyle = Invalid;
+
+  for (size_t i = 0; i< args.size(); i++)
+    {
+    if (args[i] == "NEWLINE_STYLE")
+      {
+      size_t const styleIndex = i + 1;
+      if (args.size() > styleIndex)
+        {
+        const std::string eol = args[styleIndex];
+        if (eol == "LF" || eol == "UNIX")
+          {
+          NewLineStyle = LF;
+          return true;
+          }
+        else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS")
+          {
+          NewLineStyle = CRLF;
+          return true;
+          }
+        else
+          {
+          errorString = "NEWLINE_STYLE sets an unknown style, only LF, "
+                        "CRLF, UNIX, DOS, and WIN32 are supported";
+          return false;
+          }
+        }
+      else
+        {
+        errorString = "NEWLINE_STYLE must set a style: "
+                      "LF, CRLF, UNIX, DOS, or WIN32";
+        return false;
+        }
+      }
+    }
+  return true;
+}
+
+
+const std::string cmNewLineStyle::GetCharacters() const
+{
+  switch (NewLineStyle)
+    {
+    case Invalid:
+      return "";
+    case LF:
+      return "\n";
+    case CRLF:
+      return "\r\n";
+    default:
+      ;
+    };
+  return "";
+}
+
+
+void cmNewLineStyle::SetStyle(Style style)
+{
+  NewLineStyle = style;
+}
+
+
+cmNewLineStyle::Style cmNewLineStyle::GetStyle() const
+{
+  return NewLineStyle;
+}

+ 46 - 0
Source/cmNewLineStyle.h

@@ -0,0 +1,46 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2011 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 cmNewLineStyle_h
+#define cmNewLineStyle_h
+
+#include "cmStandardIncludes.h"
+
+class cmNewLineStyle
+{
+public:
+
+  cmNewLineStyle();
+
+  enum Style
+  {
+    Invalid,
+               // LF = '\n', 0x0A, 10
+               // CR = '\r', 0x0D, 13
+    LF,        // Unix
+    CRLF       // Dos
+  };
+
+  void SetStyle(Style);
+  Style GetStyle() const;
+
+  bool IsValid() const;
+
+  bool ReadFromArguments(const std::vector<std::string>& args,
+                         std::string &errorString);
+
+  const std::string GetCharacters() const;
+
+private:
+  Style NewLineStyle;
+};
+
+#endif

+ 35 - 10
Source/cmQtAutomoc.cxx

@@ -108,9 +108,13 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
 {
   cmMakefile* makefile = target->GetMakefile();
   const char* targetName = target->GetName();
-  // don't do anything if there is no Qt4:
+  // don't do anything if there is no Qt4 or Qt5Core (which contains moc):
   std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
-  if (qtMajorVersion != "4")
+  if (qtMajorVersion == "")
+    {
+    qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
+    }
+  if (qtMajorVersion != "4" && qtMajorVersion != "5")
     {
     return;
     }
@@ -132,7 +136,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
   targetDir += ".dir/";
 
   cmCustomCommandLine currentLine;
-  currentLine.push_back(makefile->GetCMakeInstance()->GetCMakeCommand());
+  currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND"));
   currentLine.push_back("-E");
   currentLine.push_back("cmake_automoc");
   currentLine.push_back(targetDir);
@@ -189,9 +193,15 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
       }
     }
 
-  std::string _moc_incs = makefile->GetProperty("INCLUDE_DIRECTORIES");
-  std::string _moc_defs = makefile->GetProperty("DEFINITIONS");
-  std::string _moc_compile_defs = makefile->GetProperty("COMPILE_DEFINITIONS");
+  const char* tmp = makefile->GetProperty("INCLUDE_DIRECTORIES");
+  std::string _moc_incs = (tmp!=0 ? tmp : "");
+  tmp = makefile->GetProperty("DEFINITIONS");
+  std::string _moc_defs = (tmp!=0 ? tmp : "");
+  tmp = makefile->GetProperty("COMPILE_DEFINITIONS");
+  std::string _moc_compile_defs = (tmp!=0 ? tmp : "");
+  tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
+  std::string _moc_options = (tmp!=0 ? tmp : "");
+
   // forget the variables added here afterwards again:
   cmMakefile::ScopePushPop varScope(makefile);
   static_cast<void>(varScope);
@@ -200,11 +210,12 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
   makefile->AddDefinition("_moc_incs", _moc_incs.c_str());
   makefile->AddDefinition("_moc_defs", _moc_defs.c_str());
   makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str());
+  makefile->AddDefinition("_moc_options", _moc_options.c_str());
   makefile->AddDefinition("_moc_files", _moc_files.c_str());
   makefile->AddDefinition("_moc_headers", _moc_headers.c_str());
   makefile->AddDefinition("_moc_strict_mode", strictMode ? "TRUE" : "FALSE");
 
-  const char* cmakeRoot = makefile->GetDefinition("CMAKE_ROOT");
+  const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
   std::string inputFile = cmakeRoot;
   inputFile += "/Modules/AutomocInfo.cmake.in";
   std::string outputFile = targetDir;
@@ -236,9 +247,9 @@ bool cmQtAutomoc::Run(const char* targetDirectory)
 
   this->Init();
 
-  if (this->QtMajorVersion == "4")
+  if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5")
     {
-    this->RunAutomocQt4();
+    this->RunAutomoc();
     }
 
   this->WriteOldMocDefinitionsFile(targetDirectory);
@@ -281,6 +292,11 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile,
     }
 
   this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR");
+  if (this->QtMajorVersion == "")
+    {
+    this->QtMajorVersion = makefile->GetSafeDefinition(
+                                     "AM_Qt5Core_VERSION_MAJOR");
+    }
   this->Sources = makefile->GetSafeDefinition("AM_SOURCES");
   this->Headers = makefile->GetSafeDefinition("AM_HEADERS");
   this->IncludeProjectDirsBefore = makefile->IsOn(
@@ -292,6 +308,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile,
                                                  "AM_MOC_COMPILE_DEFINITIONS");
   this->MocDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_DEFINITIONS");
   this->MocIncludesStr = makefile->GetSafeDefinition("AM_MOC_INCLUDES");
+  this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS");
   this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR");
   this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR");
   this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME");
@@ -370,6 +387,8 @@ void cmQtAutomoc::Init()
       }
     }
 
+  cmSystemTools::ExpandListArgument(this->MocOptionsStr, this->MocOptions);
+
   std::vector<std::string> incPaths;
   cmSystemTools::ExpandListArgument(this->MocIncludesStr, incPaths);
 
@@ -440,7 +459,7 @@ void cmQtAutomoc::Init()
 }
 
 
-bool cmQtAutomoc::RunAutomocQt4()
+bool cmQtAutomoc::RunAutomoc()
 {
   if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str())
     || (this->OldMocDefinitionsStr != this->Join(this->MocDefinitions, ' ')))
@@ -970,6 +989,12 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile,
       {
       command.push_back(*it);
       }
+    for(std::vector<std::string>::const_iterator it=this->MocOptions.begin();
+        it != this->MocOptions.end();
+        ++it)
+      {
+      command.push_back(*it);
+      }
 #ifdef _WIN32
     command.push_back("-DWIN32");
 #endif

+ 3 - 1
Source/cmQtAutomoc.h

@@ -35,7 +35,7 @@ private:
                                  const char* targetDirectory);
   void WriteOldMocDefinitionsFile(const char* targetDirectory);
 
-  bool RunAutomocQt4();
+  bool RunAutomoc();
   bool GenerateMoc(const std::string& sourceFile,
                    const std::string& mocFileName);
   void ParseCppFile(const std::string& absFilename,
@@ -69,6 +69,7 @@ private:
   std::string MocCompileDefinitionsStr;
   std::string MocDefinitionsStr;
   std::string MocIncludesStr;
+  std::string MocOptionsStr;
   std::string ProjectBinaryDir;
   std::string ProjectSourceDir;
   std::string TargetName;
@@ -78,6 +79,7 @@ private:
   std::string OutMocCppFilename;
   std::list<std::string> MocIncludes;
   std::list<std::string> MocDefinitions;
+  std::vector<std::string> MocOptions;
 
   bool Verbose;
   bool ColorOutput;

+ 2 - 1
Source/cmSetTargetPropertiesCommand.h

@@ -140,7 +140,8 @@ public:
         "the target in an IDE like visual studio.  VS_KEYWORD can be set "
         "to change the visual studio keyword, for example QT integration "
         "works better if this is set to Qt4VSv1.0.\n"
-        "VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER can be set "
+        "VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER and "
+        "VS_SCC_AUXPATH can be set "
         "to add support for source control bindings in a  Visual Studio "
         "project file.\n"
         "VS_GLOBAL_<variable> can be set to add a Visual Studio "

+ 5 - 0
Source/cmStandardIncludes.h

@@ -161,6 +161,11 @@ extern int putenv (char *__string) __THROW;
 #define for if(false) {} else for
 #endif
 
+// Provide std::ios_base on ancient GCC 2.9x
+#if defined(__GNUC__) && __GNUC__ < 3
+namespace std { typedef ios ios_base; }
+#endif
+
 // check for the 720 compiler on the SGI
 // which has some strange properties that I don't think are worth
 // checking for in a general way in configure

+ 39 - 0
Source/cmStringCommand.cxx

@@ -10,6 +10,8 @@
   See the License for more information.
 ============================================================================*/
 #include "cmStringCommand.h"
+#include "cmCryptoHash.h"
+
 #include <cmsys/RegularExpression.hxx>
 #include <cmsys/SystemTools.hxx>
 
@@ -36,6 +38,15 @@ bool cmStringCommand
     {
     return this->HandleReplaceCommand(args);
     }
+  else if ( subCommand == "MD5" ||
+            subCommand == "SHA1" ||
+            subCommand == "SHA224" ||
+            subCommand == "SHA256" ||
+            subCommand == "SHA384" ||
+            subCommand == "SHA512" )
+    {
+    return this->HandleHashCommand(args);
+    }
   else if(subCommand == "TOLOWER")
     {
     return this->HandleToUpperLowerCommand(args, false);
@@ -82,6 +93,34 @@ bool cmStringCommand
   return false;
 }
 
+//----------------------------------------------------------------------------
+bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
+{
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+  if(args.size() != 3)
+    {
+    cmOStringStream e;
+    e << args[0] << " requires an output variable and an input string";
+    this->SetError(e.str().c_str());
+    return false;
+    }
+
+  cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
+  if(hash.get())
+    {
+    std::string out = hash->HashString(args[2].c_str());
+    this->Makefile->AddDefinition(args[1].c_str(), out.c_str());
+    return true;
+    }
+  return false;
+#else
+  cmOStringStream e;
+  e << args[0] << " not available during bootstrap";
+  this->SetError(e.str().c_str());
+  return false;
+#endif
+}
+
 //----------------------------------------------------------------------------
 bool cmStringCommand::HandleToUpperLowerCommand(
   std::vector<std::string> const& args, bool toUpper)

+ 5 - 0
Source/cmStringCommand.h

@@ -76,6 +76,8 @@ public:
       "  string(REPLACE <match_string>\n"
       "         <replace_string> <output variable>\n"
       "         <input> [<input>...])\n"
+      "  string(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512>\n"
+      "         <output variable> <input>)\n"
       "  string(COMPARE EQUAL <string1> <string2> <output variable>)\n"
       "  string(COMPARE NOTEQUAL <string1> <string2> <output variable>)\n"
       "  string(COMPARE LESS <string1> <string2> <output variable>)\n"
@@ -103,6 +105,8 @@ public:
       "backslash through argument parsing.\n"
       "REPLACE will replace all occurrences of match_string in the input with "
       "replace_string and store the result in the output.\n"
+      "MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 "
+      "will compute a cryptographic hash of the input string.\n"
       "COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and "
       "store true or false in the output variable.\n"
       "ASCII will convert all numbers into corresponding ASCII characters.\n"
@@ -150,6 +154,7 @@ protected:
   bool RegexMatch(std::vector<std::string> const& args);
   bool RegexMatchAll(std::vector<std::string> const& args);
   bool RegexReplace(std::vector<std::string> const& args);
+  bool HandleHashCommand(std::vector<std::string> const& args);
   bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
                                  bool toUpper);
   bool HandleCompareCommand(std::vector<std::string> const& args);

+ 7 - 50
Source/cmSystemTools.cxx

@@ -54,7 +54,7 @@
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 #  include <memory> // auto_ptr
 #  include <fcntl.h>
-#  include <cmsys/MD5.h>
+#  include "cmCryptoHash.h"
 #endif
 
 #if defined(CMAKE_USE_ELF_PARSER)
@@ -1197,48 +1197,10 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
 bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-  if(!cmSystemTools::FileExists(source))
-    {
-    return false;
-    }
-
-  // Open files
-#if defined(_WIN32) || defined(__CYGWIN__)
-  cmsys_ios::ifstream fin(source, cmsys_ios::ios::binary | cmsys_ios::ios::in);
-#else
-  cmsys_ios::ifstream fin(source);
-#endif
-  if(!fin)
-    {
-    return false;
-    }
-
-  cmsysMD5* md5 = cmsysMD5_New();
-  cmsysMD5_Initialize(md5);
-
-  // Should be efficient enough on most system:
-  const int bufferSize = 4096;
-  char buffer[bufferSize];
-  unsigned char const* buffer_uc =
-    reinterpret_cast<unsigned char const*>(buffer);
-  // This copy loop is very sensitive on certain platforms with
-  // slightly broken stream libraries (like HPUX).  Normally, it is
-  // incorrect to not check the error condition on the fin.read()
-  // before using the data, but the fin.gcount() will be zero if an
-  // error occurred.  Therefore, the loop should be safe everywhere.
-  while(fin)
-    {
-    fin.read(buffer, bufferSize);
-    if(int gcount = static_cast<int>(fin.gcount()))
-      {
-      cmsysMD5_Append(md5, buffer_uc, gcount);
-      }
-    }
-  cmsysMD5_FinalizeHex(md5, md5out);
-  cmsysMD5_Delete(md5);
-
-  fin.close();
-  return true;
+  cmCryptoHashMD5 md5;
+  std::string str = md5.HashFile(source);
+  strncpy(md5out, str.c_str(), 32);
+  return !str.empty();
 #else
   (void)source;
   (void)md5out;
@@ -1250,13 +1212,8 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out)
 std::string cmSystemTools::ComputeStringMD5(const char* input)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-  char md5out[32];
-  cmsysMD5* md5 = cmsysMD5_New();
-  cmsysMD5_Initialize(md5);
-  cmsysMD5_Append(md5, reinterpret_cast<unsigned char const*>(input), -1);
-  cmsysMD5_FinalizeHex(md5, md5out);
-  cmsysMD5_Delete(md5);
-  return std::string(md5out, 32);
+  cmCryptoHashMD5 md5;
+  return md5.HashString(input);
 #else
   (void)input;
   cmSystemTools::Message("md5sum not supported in bootstrapping mode","Error");

+ 83 - 12
Source/cmTarget.cxx

@@ -17,6 +17,7 @@
 #include "cmGlobalGenerator.h"
 #include "cmComputeLinkInformation.h"
 #include "cmDocumentCompileDefinitions.h"
+#include "cmDocumentLocationUndefined.h"
 #include "cmListFileCache.h"
 #include "cmGeneratorExpression.h"
 #include <cmsys/RegularExpression.hxx>
@@ -158,10 +159,22 @@ void cmTarget::DefineProperties(cmake *cm)
      "which is compiled as part of the target."
      "This property is initialized by the value of the variable "
      "CMAKE_AUTOMOC if it is set when a target is created.\n"
+     "Additional command line options for moc can be set via the "
+     "AUTOMOC_MOC_OPTIONS property.\n"
      "By setting the CMAKE_AUTOMOC_STRICT_MODE variable to FALSE the rules "
      "for searching the files which will be processed by moc can be relaxed. "
      "See the documentation for this variable for more details.");
 
+  cm->DefineProperty
+    ("AUTOMOC_MOC_OPTIONS", cmProperty::TARGET,
+    "Additional options for moc when using automoc (see the AUTOMOC property)",
+     "This property is only used if the AUTOMOC property is set to TRUE for "
+     "this target. In this case, it holds additional command line options "
+     "which will be used when moc is executed during the build, i.e. it is "
+     "equivalent to the optional OPTIONS argument of the qt4_wrap_cpp() "
+     "macro.\n"
+     "By default it is empty.");
+
   cm->DefineProperty
     ("BUILD_WITH_INSTALL_RPATH", cmProperty::TARGET,
      "Should build tree targets have install tree rpaths.",
@@ -574,15 +587,6 @@ void cmTarget::DefineProperties(cmake *cm)
      "value is the default.  "
      "See documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables.");
 
-#define CM_LOCATION_UNDEFINED_BEHAVIOR \
-  "\n" \
-  "Do not set properties that affect the location of the target after " \
-  "reading this property.  These include properties whose names match " \
-  "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?\" " \
-  "or \"(IMPLIB_)?(PREFIX|SUFFIX)\".  " \
-  "Failure to follow this rule is not diagnosed and leaves the location " \
-  "of the target undefined."
-
   cm->DefineProperty
     ("LOCATION", cmProperty::TARGET,
      "Read-only location of a target on disk.",
@@ -602,7 +606,7 @@ void cmTarget::DefineProperties(cmake *cm)
      "In CMake 2.8.4 and above add_custom_command recognizes generator "
      "expressions to refer to target locations anywhere in the command.  "
      "Therefore this property is not needed for creating custom commands."
-     CM_LOCATION_UNDEFINED_BEHAVIOR);
+     CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property"));
 
   cm->DefineProperty
     ("LOCATION_<CONFIG>", cmProperty::TARGET,
@@ -616,7 +620,7 @@ void cmTarget::DefineProperties(cmake *cm)
      "arbitrary available configuration.  "
      "Use the MAP_IMPORTED_CONFIG_<CONFIG> property to map imported "
      "configurations explicitly."
-     CM_LOCATION_UNDEFINED_BEHAVIOR);
+     CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property"));
 
   cm->DefineProperty
     ("LINK_DEPENDS", cmProperty::TARGET,
@@ -969,6 +973,23 @@ void cmTarget::DefineProperties(cmake *cm)
      "If the variable CMAKE_Fortran_MODULE_DIRECTORY is set when a target "
      "is created its value is used to initialize this property.");
 
+  cm->DefineProperty
+    ("GNUtoMS", cmProperty::TARGET,
+     "Convert GNU import library (.dll.a) to MS format (.lib).",
+     "When linking a shared library or executable that exports symbols "
+     "using GNU tools on Windows (MinGW/MSYS) with Visual Studio installed "
+     "convert the import library (.dll.a) from GNU to MS format (.lib).  "
+     "Both import libraries will be installed by install(TARGETS) and "
+     "exported by install(EXPORT) and export() to be linked by applications "
+     "with either GNU- or MS-compatible tools."
+     "\n"
+     "If the variable CMAKE_GNUtoMS is set when a target "
+     "is created its value is used to initialize this property.  "
+     "The variable must be set prior to the first command that enables "
+     "a language such as project() or enable_language().  "
+     "CMake provides the variable as an option to the user automatically "
+     "when configuring on Windows with GNU tools.");
+
   cm->DefineProperty
     ("XCODE_ATTRIBUTE_<an-attribute>", cmProperty::TARGET,
      "Set Xcode target attributes directly.",
@@ -1014,7 +1035,7 @@ void cmTarget::DefineProperties(cmake *cm)
      "provider property.");
   cm->DefineProperty
     ("VS_SCC_LOCALPATH", cmProperty::TARGET,
-     "Visual Studio Source Code Control Provider.",
+     "Visual Studio Source Code Control Local Path.",
      "Can be set to change the visual studio source code control "
      "local path property.");
   cm->DefineProperty
@@ -1022,6 +1043,34 @@ void cmTarget::DefineProperties(cmake *cm)
      "Visual Studio Source Code Control Project.",
      "Can be set to change the visual studio source code control "
      "project name property.");
+  cm->DefineProperty
+    ("VS_SCC_AUXPATH", cmProperty::TARGET,
+     "Visual Studio Source Code Control Aux Path.",
+     "Can be set to change the visual studio source code control "
+     "auxpath property.");
+  cm->DefineProperty
+    ("VS_GLOBAL_PROJECT_TYPES", cmProperty::TARGET,
+     "Visual Studio project type(s).",
+     "Can be set to one or more UUIDs recognized by Visual Studio "
+     "to indicate the type of project. This value is copied "
+     "verbatim into the generated project file. Example for a "
+     "managed C++ unit testing project: \""
+     "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};"
+     "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\". UUIDs are "
+     "semicolon-delimited.");
+  cm->DefineProperty
+    ("VS_GLOBAL_KEYWORD", cmProperty::TARGET,
+     "Visual Studio project keyword.",
+     "Sets the \"keyword\" attribute for a generated Visual Studio "
+     "project. Defaults to \"Win32Proj\". You may wish to override "
+     "this value with \"ManagedCProj\", for example, in a Visual "
+     "Studio managed C++ unit test project.");
+  cm->DefineProperty
+    ("VS_DOTNET_REFERENCES", cmProperty::TARGET,
+     "Visual Studio managed project .NET references",
+     "Adds one or more semicolon-delimited .NET references to a "
+     "generated Visual Studio project. For example, \"System;"
+     "System.Windows.Forms\".");
   cm->DefineProperty
     ("VS_GLOBAL_<variable>", cmProperty::TARGET,
      "Visual Studio project-specific global variable.",
@@ -1180,8 +1229,10 @@ void cmTarget::SetMakefile(cmMakefile* mf)
   this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0);
   this->SetPropertyDefault("Fortran_FORMAT", 0);
   this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0);
+  this->SetPropertyDefault("GNUtoMS", 0);
   this->SetPropertyDefault("OSX_ARCHITECTURES", 0);
   this->SetPropertyDefault("AUTOMOC", 0);
+  this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0);
   this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0);
 
   // Collect the set of configuration types.
@@ -3440,6 +3491,26 @@ void cmTarget::GetExecutableNames(std::string& name,
   pdbName = prefix+base+".pdb";
 }
 
+//----------------------------------------------------------------------------
+bool cmTarget::HasImplibGNUtoMS()
+{
+  return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
+}
+
+//----------------------------------------------------------------------------
+bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
+                                std::string& out, const char* newExt)
+{
+  if(this->HasImplibGNUtoMS() &&
+     gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a")
+    {
+    out = gnuName.substr(0, gnuName.size()-6);
+    out += newExt? newExt : ".lib";
+    return true;
+    }
+  return false;
+}
+
 //----------------------------------------------------------------------------
 void cmTarget::GenerateTargetManifest(const char* config)
 {

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