Merge branch 'parent-scope-tests' into variable-pull-failure

* parent-scope-tests:
  test: add a test for PARENT_SCOPE with multiple scopes
  test: add test for PARENT_SCOPE behavior

Conflicts:
	Tests/RunCMake/set/RunCMakeTest.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 761ad20..5e4cd15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,9 @@
   unset(CMAKE_BOOTSTRAP CACHE)
 endif()
 
-set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+  set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
+endif()
 
 if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
   # Disallow architecture-specific try_run.  It may not run on the host.
@@ -34,6 +36,13 @@
   endmacro()
 endif()
 
+# option to set the internal encoding of CMake to UTF-8
+option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally (experimental)." OFF)
+mark_as_advanced(CMAKE_ENCODING_UTF8)
+if(CMAKE_ENCODING_UTF8)
+  set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8)
+endif()
+
 #-----------------------------------------------------------------------
 # a macro to deal with system libraries, implemented as a macro
 # simply to improve readability of the main script
@@ -102,9 +111,11 @@
 
 
 
-set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
-if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
-  set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+  set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
+  if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
+    set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
+  endif()
 endif()
 
 
@@ -114,29 +125,6 @@
 #-----------------------------------------------------------------------
 macro(CMAKE_SETUP_TESTING)
   if(BUILD_TESTING)
-    set(CMAKE_TEST_GENERATOR "" CACHE STRING
-      "Generator used when running tests")
-    set(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH
-      "Generator used when running tests")
-    if(NOT CMAKE_TEST_GENERATOR)
-      set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}")
-      set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}")
-    else()
-      set(CMAKE_TEST_DIFFERENT_GENERATOR TRUE)
-      set(CMAKE_TEST_GENERATOR_TOOLSET "")
-    endif()
-
-    # Are we testing with the MSVC compiler?
-    set(CMAKE_TEST_MSVC 0)
-    if(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
-      set(CMAKE_TEST_MSVC 1)
-    else()
-      if("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
-          "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
-        set(CMAKE_TEST_MSVC 1)
-      endif()
-    endif()
-
     set(CMAKE_TEST_SYSTEM_LIBRARIES 0)
     foreach(util CURL EXPAT XMLRPC ZLIB)
       if(CMAKE_USE_SYSTEM_${util})
@@ -149,9 +137,19 @@
     # the ctest from this cmake is used for testing
     # and not the ctest from the cmake building and testing
     # cmake.
-    set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest")
-    set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake")
-    set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack")
+    if(CMake_TEST_EXTERNAL_CMAKE)
+      set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest")
+      set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake")
+      set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack")
+      foreach(exe cmake ctest cpack)
+        add_executable(${exe} IMPORTED)
+        set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe})
+      endforeach()
+    else()
+      set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest")
+      set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake")
+      set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack")
+    endif()
   endif()
 
   # configure some files for testing
@@ -164,8 +162,6 @@
     ${CMake_BINARY_DIR}/Modules/.NoDartCoverage)
   configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in
     ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
-  configure_file(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
-    ${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
   if(BUILD_TESTING AND DART_ROOT)
     configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif
       ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY)
@@ -325,6 +321,12 @@
     add_definitions(-DLIBARCHIVE_STATIC)
     set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
     set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
+    set(ENABLE_LZMA OFF CACHE INTERNAL "Enable the use of the system found LZMA library if found")
+    set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system found ZLIB library if found")
+    set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system found BZip2 library if found")
+    set(ENABLE_EXPAT OFF CACHE INTERNAL "Enable the use of the system found EXPAT library if found")
+    set(ENABLE_PCREPOSIX OFF CACHE INTERNAL "Enable the use of the system found PCREPOSIX library if found")
+    set(ENABLE_LibGCC OFF CACHE INTERNAL "Enable the use of the system found LibGCC library if found")
     set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support")
     set(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support")
     set(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support")
@@ -387,18 +389,20 @@
 endmacro ()
 
 #-----------------------------------------------------------------------
-if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
-  execute_process(COMMAND ${CMAKE_CXX_COMPILER}
-    ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
-    OUTPUT_VARIABLE _GXX_VERSION
-  )
-  string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
-    _GXX_VERSION_SHORT ${_GXX_VERSION})
-  if(_GXX_VERSION_SHORT EQUAL 33)
-    message(FATAL_ERROR
-      "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n"
-      "Please use GXX 4.2 or greater to build CMake on OpenBSD\n"
-      "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+  if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
+    execute_process(COMMAND ${CMAKE_CXX_COMPILER}
+      ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
+      OUTPUT_VARIABLE _GXX_VERSION
+    )
+    string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
+      _GXX_VERSION_SHORT ${_GXX_VERSION})
+    if(_GXX_VERSION_SHORT EQUAL 33)
+      message(FATAL_ERROR
+        "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n"
+        "Please use GXX 4.2 or greater to build CMake on OpenBSD\n"
+        "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
+    endif()
   endif()
 endif()
 
@@ -417,31 +421,33 @@
 set_directory_properties(PROPERTIES
   TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake")
 
-# where to write the resulting executables and libraries
-set(BUILD_SHARED_LIBS OFF)
-set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
-set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
-  "Where to put the libraries for CMake")
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+  # where to write the resulting executables and libraries
+  set(BUILD_SHARED_LIBS OFF)
+  set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
+  set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
+    "Where to put the libraries for CMake")
 
-# The CMake executables usually do not need any rpath to run in the build or
-# install tree.
-set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
+  # The CMake executables usually do not need any rpath to run in the build or
+  # install tree.
+  set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
 
-# Load install destinations.
-include(Source/CMakeInstallDestinations.cmake)
+  # Load install destinations.
+  include(Source/CMakeInstallDestinations.cmake)
 
-if(BUILD_TESTING)
-  include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
+  if(BUILD_TESTING)
+    include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
+  endif()
+
+  # include special compile flags for some compilers
+  include(CompileFlags.cmake)
+
+  # no clue why we are testing for this here
+  include(CheckSymbolExists)
+  CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
+  CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
 endif()
 
-# include special compile flags for some compilers
-include(CompileFlags.cmake)
-
-# no clue why we are testing for this here
-include(CheckSymbolExists)
-CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
-CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
-
 # CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests.
 #
 # If not defined or "", this variable defaults to the server at
@@ -459,70 +465,73 @@
   set(CMAKE_TESTS_CDASH_SERVER "http://www.cdash.org/CDash")
 endif()
 
-# build the utilities (a macro defined in this file)
-CMAKE_BUILD_UTILITIES()
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+  # build the utilities (a macro defined in this file)
+  CMAKE_BUILD_UTILITIES()
 
-# On NetBSD ncurses is required, since curses doesn't have the wsyncup()
-# function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
-# which isn't in the default linker search path. So without RPATH ccmake
-# doesn't run and the build doesn't succeed since ccmake is executed for
-# generating the documentation.
-if(BUILD_CursesDialog)
-  get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
-  set(CURSES_NEED_RPATH FALSE)
-  if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64")
-    set(CURSES_NEED_RPATH TRUE)
-  endif()
-endif()
-
-if(BUILD_QtDialog)
-  if(APPLE)
-    set(CMAKE_BUNDLE_VERSION
-      "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
-    set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
-    # make sure CMAKE_INSTALL_PREFIX ends in /
-    string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
-    math(EXPR LEN "${LEN} -1" )
-    string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
-    if(NOT "${ENDCH}" STREQUAL "/")
-      set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
+  # On NetBSD ncurses is required, since curses doesn't have the wsyncup()
+  # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
+  # which isn't in the default linker search path. So without RPATH ccmake
+  # doesn't run and the build doesn't succeed since ccmake is executed for
+  # generating the documentation.
+  if(BUILD_CursesDialog)
+    get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
+    set(CURSES_NEED_RPATH FALSE)
+    if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64")
+      set(CURSES_NEED_RPATH TRUE)
     endif()
-    set(CMAKE_INSTALL_PREFIX
-      "${CMAKE_INSTALL_PREFIX}CMake.app/Contents")
   endif()
 
-  set(QT_NEED_RPATH FALSE)
-  if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")
-    set(QT_NEED_RPATH TRUE)
+  if(BUILD_QtDialog)
+    if(APPLE)
+      set(CMAKE_BUNDLE_VERSION
+        "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
+      set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
+      # make sure CMAKE_INSTALL_PREFIX ends in /
+      string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
+      math(EXPR LEN "${LEN} -1" )
+      string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
+      if(NOT "${ENDCH}" STREQUAL "/")
+        set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
+      endif()
+      set(CMAKE_INSTALL_PREFIX
+        "${CMAKE_INSTALL_PREFIX}CMake.app/Contents")
+    endif()
+
+    set(QT_NEED_RPATH FALSE)
+    if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")
+      set(QT_NEED_RPATH TRUE)
+    endif()
   endif()
+
+
+  # The same might be true on other systems for other libraries.
+  # Then only enable RPATH if we have are building at least with cmake 2.4,
+  # since this one has much better RPATH features than cmake 2.2.
+  # The executables are then built with the RPATH for the libraries outside
+  # the build tree, which is both the build and the install RPATH.
+  if (UNIX)
+    if(   CMAKE_USE_SYSTEM_CURL   OR  CMAKE_USE_SYSTEM_ZLIB
+          OR  CMAKE_USE_SYSTEM_EXPAT  OR  CTEST_USE_XMLRPC  OR  CURSES_NEED_RPATH  OR  QT_NEED_RPATH)
+      set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
+      set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+      set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+    endif()
+  endif ()
+
+
+  # add the uninstall support
+  configure_file(
+    "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+    @ONLY)
+  add_custom_target(uninstall
+    "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
+
+  include (CMakeCPack.cmake)
+
 endif()
 
-
-# The same might be true on other systems for other libraries.
-# Then only enable RPATH if we have are building at least with cmake 2.4,
-# since this one has much better RPATH features than cmake 2.2.
-# The executables are then built with the RPATH for the libraries outside
-# the build tree, which is both the build and the install RPATH.
-if (UNIX)
-  if(   CMAKE_USE_SYSTEM_CURL   OR  CMAKE_USE_SYSTEM_ZLIB
-        OR  CMAKE_USE_SYSTEM_EXPAT  OR  CTEST_USE_XMLRPC  OR  CURSES_NEED_RPATH  OR  QT_NEED_RPATH)
-    set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
-    set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-    set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
-  endif()
-endif ()
-
-
-# add the uninstall support
-configure_file(
-  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
-  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
-  @ONLY)
-add_custom_target(uninstall
-  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
-
-include (CMakeCPack.cmake)
-
 # setup some Testing support (a macro defined in this file)
 CMAKE_SETUP_TESTING()
 configure_file(
@@ -530,62 +539,69 @@
   "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
   COPYONLY)
 
-if(NOT CMake_VERSION_IS_RELEASE)
-  if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
-      NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
-    set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
-                     -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
-                     -Wmissing-format-attribute -fno-common -Wundef
-    )
-    set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W
-                       -Wshadow -Wpointer-arith -Wformat-security -Wundef
-    )
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+  if(NOT CMake_VERSION_IS_RELEASE)
+    if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
+        NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
+      set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
+                       -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
+                       -Wmissing-format-attribute -fno-common -Wundef
+      )
+      set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W
+                         -Wshadow -Wpointer-arith -Wformat-security -Wundef
+      )
 
-    foreach(FLAG_LANG  C CXX)
-      foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST})
-        if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ")
-          set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}")
-        endif()
+      foreach(FLAG_LANG  C CXX)
+        foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST})
+          if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ")
+            set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}")
+          endif()
+        endforeach()
       endforeach()
-    endforeach()
 
-    unset(C_FLAGS_LIST)
-    unset(CXX_FLAGS_LIST)
+      unset(C_FLAGS_LIST)
+      unset(CXX_FLAGS_LIST)
+    endif()
   endif()
+
+  # build the remaining subdirectories
+  add_subdirectory(Source)
+  add_subdirectory(Utilities)
 endif()
 
-# build the remaining subdirectories
-add_subdirectory(Source)
-add_subdirectory(Utilities)
 add_subdirectory(Tests)
 
-if(BUILD_TESTING)
-  CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
-endif()
-CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat")
-if(TARGET documentation)
-  CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+  if(BUILD_TESTING)
+    CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
+  endif()
+  CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat")
+  if(TARGET documentation)
+    CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
+  endif()
 endif()
 
 # add a test
 add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
-  --system-information  -G "${CMAKE_TEST_GENERATOR}" )
+  --system-information  -G "${CMAKE_GENERATOR}" )
 
-# Install license file as it requires.
-install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+  # Install license file as it requires.
+  install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})
 
-# Install script directories.
-install(
-  DIRECTORY Help Modules Templates
-  DESTINATION ${CMAKE_DATA_DIR}
-  FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
-                        GROUP_READ GROUP_EXECUTE
-                        WORLD_READ WORLD_EXECUTE
-  PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
-                              GROUP_READ GROUP_EXECUTE
-                              WORLD_READ WORLD_EXECUTE
-  )
+  # Install script directories.
+  install(
+    DIRECTORY Help Modules Templates
+    DESTINATION ${CMAKE_DATA_DIR}
+    FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+    DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
+                          GROUP_READ GROUP_EXECUTE
+                          WORLD_READ WORLD_EXECUTE
+    PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
+                                GROUP_READ GROUP_EXECUTE
+                                WORLD_READ WORLD_EXECUTE
+    )
 
-# Install auxiliary files integrating with other tools.
-add_subdirectory(Auxiliary)
+  # Install auxiliary files integrating with other tools.
+  add_subdirectory(Auxiliary)
+endif()
diff --git a/CTestConfig.cmake b/CTestConfig.cmake
index 92eacd8..819f9ba 100644
--- a/CTestConfig.cmake
+++ b/CTestConfig.cmake
@@ -18,8 +18,3 @@
 set(CTEST_DROP_SITE_CDASH TRUE)
 set(CTEST_CDASH_VERSION "1.6")
 set(CTEST_CDASH_QUERY_VERSION TRUE)
-
-# use old trigger stuff so that cmake 2.4 and below will not
-# get errors on trigger
-set (TRIGGER_SITE
-  "http://public.kitware.com/cgi-bin/Submit-CMake-TestingResults.cgi")
diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in
index eb0b2f6..f499be1 100644
--- a/CTestCustom.cmake.in
+++ b/CTestCustom.cmake.in
@@ -19,6 +19,7 @@
   "Utilities.cmbzip2."
   "Source.CTest.Curl"
   "Source.CursesDialog.form"
+  "Source.cm_sha2.*warning.*cast increases required alignment of target type"
   "Utilities.cmcurl"
   "Utilities.cmexpat."
   "Utilities.cmlibarchive"
@@ -39,12 +40,14 @@
   "Warning: public.*BZ2_bz.*in module.*bzlib.*clashes with prior module.*bzlib.*"
   "Warning: public.*_archive.*clashes with prior module.*"
   "Warning: LINN32: Last line.*is less.*"
+  "Warning: Olimit was exceeded on function.*"
+  "Warning: To override Olimit for all functions in file.*"
   "warning.*directory name.*CMake-Xcode.*/bin/.*does not exist.*"
   "stl_deque.h:1051"
   "(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)"
-  "(Lexer|Parser).*warning.*statement is unreachable"
+  "(Lexer|Parser).*warning.*(statement is unreachable|will never be executed)"
   "PGC-W-0095-Type cast required for this conversion.*ProcessUNIX.c"
-  "[Qq]t([Cc]ore|[Gg]ui).*warning.*conversion.*may alter its value"
+  "[Qq]t([Cc]ore|[Gg]ui|[Ww]idgets).*warning.*conversion.*may alter its value"
   "warning:.*is.*very unsafe.*consider using.*"
   "warning:.*is.*misused, please use.*"
   "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element"
@@ -52,6 +55,9 @@
   "ld: warning: directory not found for option .-(F|L)"
   "warning.*This version of Mac OS X is unsupported"
   "clang.*: warning: argument unused during compilation: .-g"
+  "note: in expansion of macro" # diagnostic context note
+  "cm(StringCommand|CTestTestHandler)\\.cxx.*warning.*rand.*isn.*t random" # we do not do crypto
+  "cm(StringCommand|CTestTestHandler)\\.cxx.*warning.*srand.*seed choices are.*poor" # we do not do crypto
 
   # Ignore clang's summary warning, assuming prior text has matched some
   # other warning expression:
diff --git a/CTestCustom.ctest.in b/CTestCustom.ctest.in
deleted file mode 100644
index 6127843..0000000
--- a/CTestCustom.ctest.in
+++ /dev/null
@@ -1,3 +0,0 @@
-# This file is provided for compatibility with CMake 2.2 and lower.
-# Just include the custom file by its new name.
-INCLUDE("CTestCustom.cmake")
diff --git a/CompileFlags.cmake b/CompileFlags.cmake
index 5874031..a4a4a78 100644
--- a/CompileFlags.cmake
+++ b/CompileFlags.cmake
@@ -34,20 +34,20 @@
 endif()
 
 #silence duplicate symbol warnings on AIX
-if(CMAKE_SYSTEM MATCHES "AIX.*")
+if(CMAKE_SYSTEM_NAME MATCHES "AIX")
   if(NOT CMAKE_COMPILER_IS_GNUCXX)
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -bhalt:5 ")
   endif()
 endif()
 
-if(CMAKE_SYSTEM MATCHES "IRIX.*")
+if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
   if(NOT CMAKE_COMPILER_IS_GNUCXX)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include")
     set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15")
   endif()
 endif()
 
-if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-V")
   if(NOT CMAKE_COMPILER_IS_GNUCXX)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
   endif()
diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst
index 5d71e11..214f4be 100644
--- a/Help/command/add_compile_options.rst
+++ b/Help/command/add_compile_options.rst
@@ -14,7 +14,7 @@
 include directories (:command:`target_include_directories` and
 :command:`include_directories`).  See documentation of the
 :prop_tgt:`directory <COMPILE_OPTIONS>` and
-:prop_tgt:` target <COMPILE_OPTIONS>` ``COMPILE_OPTIONS`` properties.
+:prop_tgt:`target <COMPILE_OPTIONS>` ``COMPILE_OPTIONS`` properties.
 
 Arguments to ``add_compile_options`` may use "generator expressions" with
 the syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)`
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index b0c5446..028ca5a 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -156,3 +156,7 @@
 Additionally, if the target is an executable or library a file-level
 dependency is created to cause the custom command to re-run whenever
 the target is recompiled.
+
+Arguments to ``DEPENDS`` may use "generator expressions" with the syntax
+``$<...>``.  See the :manual:`cmake-generator-expressions(7)` manual for
+available expressions.
diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst
index 231eeed..4ed10e1 100644
--- a/Help/command/add_executable.rst
+++ b/Help/command/add_executable.rst
@@ -35,8 +35,11 @@
 the created target.  See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL`
 target property for details.
 
-See the :manual:`cmake-buildsystem(7)` manual for more on defining
-buildsystem properties.
+Source arguments to ``add_executable`` may use "generator expressions" with
+the syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions.  See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
+
 
 --------------------------------------------------------------------------
 
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst
index 0944269..e93ef53 100644
--- a/Help/command/add_library.rst
+++ b/Help/command/add_library.rst
@@ -39,8 +39,10 @@
 the created target.  See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL`
 target property for details.
 
-See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem
-properties.
+Source arguments to ``add_library`` may use "generator expressions" with
+the syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions.  See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
 
 --------------------------------------------------------------------------
 
diff --git a/Help/command/cmake_policy.rst b/Help/command/cmake_policy.rst
index 46db8d3..2bc3287 100644
--- a/Help/command/cmake_policy.rst
+++ b/Help/command/cmake_policy.rst
@@ -1,77 +1,93 @@
 cmake_policy
 ------------
 
-Manage CMake Policy settings.
+Manage CMake Policy settings.  See the :manual:`cmake-policies(7)`
+manual for defined policies.
 
 As CMake evolves it is sometimes necessary to change existing behavior
 in order to fix bugs or improve implementations of existing features.
 The CMake Policy mechanism is designed to help keep existing projects
 building as new versions of CMake introduce changes in behavior.  Each
 new policy (behavioral change) is given an identifier of the form
-"CMP<NNNN>" where "<NNNN>" is an integer index.  Documentation
-associated with each policy describes the OLD and NEW behavior and the
-reason the policy was introduced.  Projects may set each policy to
-select the desired behavior.  When CMake needs to know which behavior
+``CMP<NNNN>`` where ``<NNNN>`` is an integer index.  Documentation
+associated with each policy describes the ``OLD`` and ``NEW`` behavior
+and the reason the policy was introduced.  Projects may set each policy
+to select the desired behavior.  When CMake needs to know which behavior
 to use it checks for a setting specified by the project.  If no
-setting is available the OLD behavior is assumed and a warning is
+setting is available the ``OLD`` behavior is assumed and a warning is
 produced requesting that the policy be set.
 
-The cmake_policy command is used to set policies to OLD or NEW
-behavior.  While setting policies individually is supported, we
-encourage projects to set policies based on CMake versions.
+Setting Policies by CMake Version
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-::
+The ``cmake_policy`` command is used to set policies to ``OLD`` or ``NEW``
+behavior.  While setting policies individually is supported, we
+encourage projects to set policies based on CMake versions::
 
   cmake_policy(VERSION major.minor[.patch[.tweak]])
 
-Specify that the current CMake list file is written for the given
+Specify that the current CMake code is written for the given
 version of CMake.  All policies introduced in the specified version or
-earlier will be set to use NEW behavior.  All policies introduced
-after the specified version will be unset (unless variable
-CMAKE_POLICY_DEFAULT_CMP<NNNN> sets a default).  This effectively
-requests behavior preferred as of a given CMake version and tells
-newer CMake versions to warn about their new policies.  The policy
-version specified must be at least 2.4 or the command will report an
-error.  In order to get compatibility features supporting versions
-earlier than 2.4 see documentation of policy CMP0001.
+earlier will be set to use ``NEW`` behavior.  All policies introduced
+after the specified version will be unset (unless the
+:variable:`CMAKE_POLICY_DEFAULT_CMP<NNNN>` variable sets a default).
+This effectively requests behavior preferred as of a given CMake
+version and tells newer CMake versions to warn about their new policies.
+The policy version specified must be at least 2.4 or the command will
+report an error.
+
+Note that the :command:`cmake_minimum_required(VERSION)`
+command implicitly calls ``cmake_policy(VERSION)`` too.
+
+Setting Policies Explicitly
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 ::
 
   cmake_policy(SET CMP<NNNN> NEW)
   cmake_policy(SET CMP<NNNN> OLD)
 
-Tell CMake to use the OLD or NEW behavior for a given policy.
+Tell CMake to use the ``OLD`` or ``NEW`` behavior for a given policy.
 Projects depending on the old behavior of a given policy may silence a
-policy warning by setting the policy state to OLD.  Alternatively one
-may fix the project to work with the new behavior and set the policy
-state to NEW.
+policy warning by setting the policy state to ``OLD``.  Alternatively
+one may fix the project to work with the new behavior and set the
+policy state to ``NEW``.
+
+Checking Policy Settings
+^^^^^^^^^^^^^^^^^^^^^^^^
 
 ::
 
   cmake_policy(GET CMP<NNNN> <variable>)
 
-Check whether a given policy is set to OLD or NEW behavior.  The
-output variable value will be "OLD" or "NEW" if the policy is set, and
-empty otherwise.
+Check whether a given policy is set to ``OLD`` or ``NEW`` behavior.
+The output ``<variable>`` value will be ``OLD`` or ``NEW`` if the
+policy is set, and empty otherwise.
+
+CMake Policy Stack
+^^^^^^^^^^^^^^^^^^
 
 CMake keeps policy settings on a stack, so changes made by the
 cmake_policy command affect only the top of the stack.  A new entry on
 the policy stack is managed automatically for each subdirectory to
 protect its parents and siblings.  CMake also manages a new entry for
-scripts loaded by include() and find_package() commands except when
-invoked with the NO_POLICY_SCOPE option (see also policy CMP0011).
-The cmake_policy command provides an interface to manage custom
-entries on the policy stack:
-
-::
+scripts loaded by :command:`include` and :command:`find_package` commands
+except when invoked with the ``NO_POLICY_SCOPE`` option
+(see also policy :policy:`CMP0011`).
+The ``cmake_policy`` command provides an interface to manage custom
+entries on the policy stack::
 
   cmake_policy(PUSH)
   cmake_policy(POP)
 
-Each PUSH must have a matching POP to erase any changes.  This is
-useful to make temporary changes to policy settings.
+Each ``PUSH`` must have a matching ``POP`` to erase any changes.
+This is useful to make temporary changes to policy settings.
+Calls to the :command:`cmake_minimum_required(VERSION)`,
+``cmake_policy(VERSION)``, or ``cmake_policy(SET)`` commands
+influence only the current top of the policy stack.
 
-Functions and macros record policy settings when they are created and
+Commands created by the :command:`function` and :command:`macro`
+commands record policy settings when they are created and
 use the pre-record policies when they are invoked.  If the function or
 macro implementation sets policies, the changes automatically
 propagate up through callers until they reach the closest nested
diff --git a/Help/command/ctest_build.rst b/Help/command/ctest_build.rst
index ac2a0c1..4a95cdd 100644
--- a/Help/command/ctest_build.rst
+++ b/Help/command/ctest_build.rst
@@ -22,3 +22,8 @@
 The APPEND option marks results for append to those previously
 submitted to a dashboard server since the last ctest_start.  Append
 semantics are defined by the dashboard server in use.
+
+If set, the contents of the variable CTEST_BUILD_FLAGS are passed as
+additional arguments to the underlying build command. This can e.g. be
+used to trigger a parallel build using the -j option of make. See
+:module:`ProcessorCount` for an example.
diff --git a/Help/command/ctest_start.rst b/Help/command/ctest_start.rst
index f16142e..d7472db 100644
--- a/Help/command/ctest_start.rst
+++ b/Help/command/ctest_start.rst
@@ -10,7 +10,15 @@
 Starts the testing for a given model.  The command should be called
 after the binary directory is initialized.  If the 'source' and
 'binary' directory are not specified, it reads the
-CTEST_SOURCE_DIRECTORY and CTEST_BINARY_DIRECTORY.  If the track is
+:variable:`CTEST_SOURCE_DIRECTORY` and :variable:`CTEST_BINARY_DIRECTORY`.
+If the track is
 specified, the submissions will go to the specified track.  If APPEND
 is used, the existing TAG is used rather than creating a new one based
 on the current time stamp.
+
+If the :variable:`CTEST_CHECKOUT_COMMAND` variable
+(or the :variable:`CTEST_CVS_CHECKOUT` variable)
+is set, its content is treated as command-line.  The command is
+invoked with the current working directory set to the parent of the source
+directory, even if the source directory already exists.  This can be used
+to create the source tree from a version control repository.
diff --git a/Help/command/export.rst b/Help/command/export.rst
index 6b83587..d4bab35 100644
--- a/Help/command/export.rst
+++ b/Help/command/export.rst
@@ -51,4 +51,7 @@
 without help from the user.  Note that the entry in the package
 registry that this command creates works only in conjunction with a
 package configuration file (<name>Config.cmake) that works with the
-build tree.
+build tree. In some cases, for example for packaging and for system
+wide installations, it is not desirable to write the user package
+registry. If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable
+is enabled, the ``export(PACKAGE)`` command will do nothing.
diff --git a/Help/command/file.rst b/Help/command/file.rst
index 83ade1d..869350a 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -3,211 +3,301 @@
 
 File manipulation command.
 
-::
-
-  file(WRITE filename "message to write"... )
-  file(APPEND filename "message to write"... )
-  file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX])
-  file(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> filename variable)
-  file(STRINGS filename variable [LIMIT_COUNT num]
-       [LIMIT_INPUT numBytes] [LIMIT_OUTPUT numBytes]
-       [LENGTH_MINIMUM numBytes] [LENGTH_MAXIMUM numBytes]
-       [NEWLINE_CONSUME] [REGEX regex]
-       [NO_HEX_CONVERSION])
-  file(GLOB variable [RELATIVE path] [globbing expressions]...)
-  file(GLOB_RECURSE variable [RELATIVE path]
-       [FOLLOW_SYMLINKS] [globbing expressions]...)
-  file(RENAME <oldname> <newname>)
-  file(REMOVE [file1 ...])
-  file(REMOVE_RECURSE [file1 ...])
-  file(MAKE_DIRECTORY [directory1 directory2 ...])
-  file(RELATIVE_PATH variable directory file)
-  file(TO_CMAKE_PATH path result)
-  file(TO_NATIVE_PATH path result)
-  file(DOWNLOAD url file [INACTIVITY_TIMEOUT timeout]
-       [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS]
-       [EXPECTED_HASH ALGO=value] [EXPECTED_MD5 sum]
-       [TLS_VERIFY on|off] [TLS_CAINFO file])
-  file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]
-       [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])
-  file(TIMESTAMP filename variable [<format string>] [UTC])
-  file(GENERATE OUTPUT output_file
-       <INPUT input_file|CONTENT input_content>
-       [CONDITION expression])
-
-WRITE will write a message into a file called 'filename'.  It
-overwrites the file if it already exists, and creates the file if it
-does not exist.  (If the file is a build input, use configure_file to
-update the file only when its content changes.)
-
-APPEND will write a message into a file same as WRITE, except it will
-append it to the end of the file
-
-READ will read the content of a file and store it into the 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.
-
-MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 will compute a
-cryptographic hash of the content of a file.
-
-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 Motorola
-S-record files, which are automatically converted to binary format
-when reading them.  Disable this using NO_HEX_CONVERSION.
-
-LIMIT_COUNT sets the maximum number of strings to return.  LIMIT_INPUT
-sets the maximum number of bytes to read from the input file.
-LIMIT_OUTPUT sets the maximum number of bytes to store in the output
-variable.  LENGTH_MINIMUM sets the minimum length of a string to
-return.  Shorter strings are ignored.  LENGTH_MAXIMUM sets the maximum
-length of a string to return.  Longer strings are split into strings
-no longer than the maximum length.  NEWLINE_CONSUME allows newlines to
-be included in strings instead of terminating them.
-
-REGEX specifies a regular expression that a string must match to be
-returned.  Typical usage
+------------------------------------------------------------------------------
 
 ::
 
+  file(WRITE <filename> <content>...)
+  file(APPEND <filename> <content>...)
+
+Write ``<content>`` into a file called ``<filename>``.  If the file does
+not exist, it will be created.  If the file already exists, ``WRITE``
+mode will overwrite it and ``APPEND`` mode will append to the end.
+(If the file is a build input, use the :command:`configure_file` command
+to update the file only when its content changes.)
+
+------------------------------------------------------------------------------
+
+::
+
+  file(READ <filename> <variable>
+       [OFFSET <offset>] [LIMIT <max-in>] [HEX])
+
+Read content from a file called ``<filename>`` and store it in a
+``<variable>``.  Optionally start from the given ``<offset>`` and
+read at most ``<max-in>`` bytes.  The ``HEX`` option causes data to
+be converted to a hexadecimal representation (useful for binary data).
+
+------------------------------------------------------------------------------
+
+::
+
+  file(STRINGS <filename> <variable> [<options>...])
+
+Parse a list of ASCII strings from ``<filename>`` and store it in
+``<variable>``.  Binary data in the file are ignored.  Carriage return
+(``\r``, CR) characters are ignored.  The options are:
+
+``LENGTH_MAXIMUM <max-len>``
+ Consider only strings of at most a given length.
+
+``LENGTH_MINIMUM <min-len>``
+ Consider only strings of at least a given length.
+
+``LIMIT_COUNT <max-num>``
+ Limit the number of distinct strings to be extracted.
+
+``LIMIT_INPUT <max-in>``
+ Limit the number of input bytes to read from the file.
+
+``LIMIT_OUTPUT <max-out>``
+ Limit the number of total bytes to store in the ``<variable>``.
+
+``NEWLINE_CONSUME``
+ Treat newline characters (``\n``, LF) as part of string content
+ instead of terminating at them.
+
+``NO_HEX_CONVERSION``
+ Intel Hex and Motorola S-record files are automatically converted to
+ binary while reading unless this option is given.
+
+``REGEX <regex>``
+ Consider only strings that match the given regular expression.
+
+For example, the code
+
+.. code-block:: cmake
+
   file(STRINGS myfile.txt myfile)
 
-stores a list in the variable "myfile" in which each item is a line
+stores a list in the variable ``myfile`` in which each item is a line
 from the input file.
 
-GLOB will generate a list of all files that match the globbing
-expressions and store it into the variable.  Globbing expressions are
-similar to regular expressions, but much simpler.  If RELATIVE flag is
-specified for an expression, the results will be returned as a
-relative path to the given path.  (We do not recommend using GLOB to
-collect a list of source files from your source tree.  If no
-CMakeLists.txt file changes when a source is added or removed then the
-generated build system cannot know when to ask CMake to regenerate.)
-
-Examples of globbing expressions include:
+------------------------------------------------------------------------------
 
 ::
 
-   *.cxx      - match all files with extension cxx
-   *.vt?      - match all files with extension vta,...,vtz
-   f[3-5].txt - match files f3.txt, f4.txt, f5.txt
+  file(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> <filename> <variable>)
 
-GLOB_RECURSE will generate a list similar to the regular GLOB, except
-it will traverse all the subdirectories of the matched directory and
-match the files.  Subdirectories that are symlinks are only traversed
-if FOLLOW_SYMLINKS is given or cmake policy CMP0009 is not set to NEW.
-See cmake --help-policy CMP0009 for more information.
+Compute a cryptographic hash of the content of ``<filename>`` and
+store it in a ``<variable>``.
 
-Examples of recursive globbing include:
+------------------------------------------------------------------------------
 
 ::
 
-   /dir/*.py  - match all python files in /dir and subdirectories
+  file(GLOB <variable> [RELATIVE <path>] [<globbing-expressions>...])
+  file(GLOB_RECURSE <variable> [RELATIVE <path>]
+       [FOLLOW_SYMLINKS] [<globbing-expressions>...])
 
-MAKE_DIRECTORY will create the given directories, also if their parent
-directories don't exist yet
+Generate a list of files that match the ``<globbing-expressions>`` and
+store it into the ``<variable>``.  Globbing expressions are similar to
+regular expressions, but much simpler.  If ``RELATIVE`` flag is
+specified, the results will be returned as relative paths to the given
+path.
 
-RENAME moves a file or directory within a filesystem, replacing the
-destination atomically.
+.. note::
+  We do not recommend using GLOB to collect a list of source files from
+  your source tree.  If no CMakeLists.txt file changes when a source is
+  added or removed then the generated build system cannot know when to
+  ask CMake to regenerate.
 
-REMOVE will remove the given files, also in subdirectories
+Examples of globbing expressions include::
 
-REMOVE_RECURSE will remove the given files and directories, also
-non-empty directories
+  *.cxx      - match all files with extension cxx
+  *.vt?      - match all files with extension vta,...,vtz
+  f[3-5].txt - match files f3.txt, f4.txt, f5.txt
 
-RELATIVE_PATH will determine relative path from directory to the given
-file.
+The ``GLOB_RECURSE`` mode will traverse all the subdirectories of the
+matched directory and match the files.  Subdirectories that are symlinks
+are only traversed if ``FOLLOW_SYMLINKS`` is given or policy
+:policy:`CMP0009` is not set to ``NEW``.
 
-TO_CMAKE_PATH will convert path into a cmake style path with unix /.
-The input can be a single path or a system path like "$ENV{PATH}".
-Note the double quotes around the ENV call TO_CMAKE_PATH only takes
-one argument.  This command will also convert the native list
-delimiters for a list of paths like the PATH environment variable.
+Examples of recursive globbing include::
 
-TO_NATIVE_PATH works just like TO_CMAKE_PATH, but will convert from a
-cmake style path into the native path style \ for windows and / for
-UNIX.
+  /dir/*.py  - match all python files in /dir and subdirectories
 
-DOWNLOAD will download the given URL to the given file.  If LOG var is
-specified a log of the download will be put in var.  If STATUS var is
-specified the status of the operation will be put in var.  The status
-is returned in a list of length 2.  The first element is the numeric
-return value for the operation, and the second element is a string
-value for the error.  A 0 numeric error means no error in the
-operation.  If TIMEOUT time is specified, the operation will timeout
-after time seconds, time should be specified as an integer.  The
-INACTIVITY_TIMEOUT specifies an integer number of seconds of
-inactivity after which the operation should terminate.  If
-EXPECTED_HASH ALGO=value is specified, the operation will verify that
-the downloaded file's actual hash matches the expected value, where
-ALGO is one of MD5, SHA1, SHA224, SHA256, SHA384, or SHA512.  If it
-does not match, the operation fails with an error.  ("EXPECTED_MD5
-sum" is short-hand for "EXPECTED_HASH MD5=sum".) If SHOW_PROGRESS is
-specified, progress information will be printed as status messages
-until the operation is complete.  For https URLs CMake must be built
-with OpenSSL.  TLS/SSL certificates are not checked by default.  Set
-TLS_VERIFY to ON to check certificates and/or use EXPECTED_HASH to
-verify downloaded content.  Set TLS_CAINFO to specify a custom
-Certificate Authority file.  If either TLS option is not given CMake
-will check variables CMAKE_TLS_VERIFY and CMAKE_TLS_CAINFO,
-respectively.
-
-UPLOAD will upload the given file to the given URL.  If LOG var is
-specified a log of the upload will be put in var.  If STATUS var is
-specified the status of the operation will be put in var.  The status
-is returned in a list of length 2.  The first element is the numeric
-return value for the operation, and the second element is a string
-value for the error.  A 0 numeric error means no error in the
-operation.  If TIMEOUT time is specified, the operation will timeout
-after time seconds, time should be specified as an integer.  The
-INACTIVITY_TIMEOUT specifies an integer number of seconds of
-inactivity after which the operation should terminate.  If
-SHOW_PROGRESS is specified, progress information will be printed as
-status messages until the operation is complete.
-
-TIMESTAMP will write a string representation of the modification time
-of filename to variable.
-
-Should the command be unable to obtain a timestamp variable will be
-set to the empty string "".
-
-See documentation of the string TIMESTAMP sub-command for more
-details.
-
-The file() command also provides COPY and INSTALL signatures:
+------------------------------------------------------------------------------
 
 ::
 
-  file(<COPY|INSTALL> files... DESTINATION <dir>
-       [FILE_PERMISSIONS permissions...]
-       [DIRECTORY_PERMISSIONS permissions...]
+  file(RENAME <oldname> <newname>)
+
+Move a file or directory within a filesystem from ``<oldname>`` to
+``<newname>``, replacing the destination atomically.
+
+------------------------------------------------------------------------------
+
+::
+
+  file(REMOVE [<files>...])
+  file(REMOVE_RECURSE [<files>...])
+
+Remove the given files.  The ``REMOVE_RECURSE`` mode will remove the given
+files and directories, also non-empty directories
+
+------------------------------------------------------------------------------
+
+::
+
+  file(MAKE_DIRECTORY [<directories>...])
+
+Create the given directories and their parents as needed.
+
+------------------------------------------------------------------------------
+
+::
+
+  file(RELATIVE_PATH <variable> <directory> <file>)
+
+Compute the relative path from a ``<directory>`` to a ``<file>`` and
+store it in the ``<variable>``.
+
+------------------------------------------------------------------------------
+
+::
+
+  file(TO_CMAKE_PATH "<path>" <variable>)
+  file(TO_NATIVE_PATH "<path>" <variable>)
+
+The ``TO_CMAKE_PATH`` mode converts a native ``<path>`` into a cmake-style
+path with forward-slashes (``/``).  The input can be a single path or a
+system search path like ``$ENV{PATH}``.  A search path will be converted
+to a cmake-style list separated by ``;`` characters.
+
+The ``TO_NATIVE_PATH`` mode converts a cmake-style ``<path>`` into a native
+path with platform-specific slashes (``\`` on Windows and ``/`` elsewhere).
+
+Always use double quotes around the ``<path>`` to be sure it is treated
+as a single argument to this command.
+
+------------------------------------------------------------------------------
+
+::
+
+  file(DOWNLOAD <url> <file> [<options>...])
+  file(UPLOAD   <file> <url> [<options>...])
+
+The ``DOWNLOAD`` mode downloads the given ``<url>`` to a local ``<file>``.
+The ``UPLOAD`` mode uploads a local ``<file>`` to a given ``<url>``.
+
+Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
+
+``INACTIVITY_TIMEOUT <seconds>``
+  Terminate the operation after a period of inactivity.
+
+``LOG <variable>``
+  Store a human-readable log of the operation in a variable.
+
+``SHOW_PROGRESS``
+  Print progress information as status messages until the operation is
+  complete.
+
+``STATUS <variable>``
+  Store the resulting status of the operation in a variable.
+  The status is a ``;`` separated list of length 2.
+  The first element is the numeric return value for the operation,
+  and the second element is a string value for the error.
+  A ``0`` numeric error means no error in the operation.
+
+``TIMEOUT <seconds>``
+  Terminate the operation after a given total time has elapsed.
+
+Additional options to ``DOWNLOAD`` are:
+
+``EXPECTED_HASH ALGO=<value>``
+
+  Verify that the downloaded content hash matches the expected value, where
+  ``ALGO`` is one of ``MD5``, ``SHA1``, ``SHA224``, ``SHA256``, ``SHA384``, or
+  ``SHA512``.  If it does not match, the operation fails with an error.
+
+``EXPECTED_MD5 <value>``
+  Historical short-hand for ``EXPECTED_HASH MD5=<value>``.
+
+``TLS_VERIFY <ON|OFF>``
+  Specify whether to verify the server certificate for ``https://`` URLs.
+  The default is to *not* verify.
+
+``TLS_CAINFO <file>``
+  Specify a custom Certificate Authority file for ``https://`` URLs.
+
+For ``https://`` URLs CMake must be built with OpenSSL support.  ``TLS/SSL``
+certificates are not checked by default.  Set ``TLS_VERIFY`` to ``ON`` to
+check certificates and/or use ``EXPECTED_HASH`` to verify downloaded content.
+If neither ``TLS`` option is given CMake will check variables
+``CMAKE_TLS_VERIFY`` and ``CMAKE_TLS_CAINFO``, respectively.
+
+------------------------------------------------------------------------------
+
+::
+
+  file(TIMESTAMP <filename> <variable> [<format>] [UTC])
+
+Compute a string representation of the modification time of ``<filename>``
+and store it in ``<variable>``.  Should the command be unable to obtain a
+timestamp variable will be set to the empty string ("").
+
+See the :command:`string(TIMESTAMP)` command for documentation of
+the ``<format>`` and ``UTC`` options.
+
+------------------------------------------------------------------------------
+
+::
+
+  file(GENERATE <options>...)
+
+Generate an output file for each build configuration supported by the current
+:manual:`CMake Generator <cmake-generators(7)>`.  Evaluate
+:manual:`generator expressions <cmake-generator-expressions(7)>`
+from the input content to produce the output content.  The options are:
+
+``CONDITION <condition>``
+  Generate the output file for a particular configuration only if
+  the condition is true.  The condition must be either ``0`` or ``1``
+  after evaluating generator expressions.
+
+``CONTENT <content>``
+  Use the content given explicitly as input.
+
+``INPUT <input-file>``
+  Use the content from a given file as input.
+
+``OUTPUT <output-file>``
+  Specify the output file name to generate.  Use generator expressions
+  such as ``$<CONFIG>`` to specify a configuration-specific output file
+  name.  Multiple configurations may generate the same output file only
+  if the generated content is identical.  Otherwise, the ``<output-file>``
+  must evaluate to an unique name for each configuration.
+
+Exactly one ``CONTENT`` or ``INPUT`` option must be given.  A specific
+``OUTPUT`` file may be named by at most one invocation of ``file(GENERATE)``.
+Generated files are modified on subsequent cmake runs only if their content
+is changed.
+
+------------------------------------------------------------------------------
+
+::
+
+  file(<COPY|INSTALL> <files>... DESTINATION <dir>
+       [FILE_PERMISSIONS <permissions>...]
+       [DIRECTORY_PERMISSIONS <permissions>...]
        [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]
        [FILES_MATCHING]
        [[PATTERN <pattern> | REGEX <regex>]
-        [EXCLUDE] [PERMISSIONS permissions...]] [...])
+        [EXCLUDE] [PERMISSIONS <permissions>...]] [...])
 
-The COPY signature copies files, directories, and symlinks to a
+The ``COPY`` signature copies files, directories, and symlinks to a
 destination folder.  Relative input paths are evaluated with respect
 to the current source directory, and a relative destination is
 evaluated with respect to the current build directory.  Copying
 preserves input file timestamps, and optimizes out a file if it exists
 at the destination with the same timestamp.  Copying preserves input
-permissions unless explicit permissions or NO_SOURCE_PERMISSIONS are
-given (default is USE_SOURCE_PERMISSIONS).  See the install(DIRECTORY)
-command for documentation of permissions, PATTERN, REGEX, and EXCLUDE
-options.
+permissions unless explicit permissions or ``NO_SOURCE_PERMISSIONS``
+are given (default is ``USE_SOURCE_PERMISSIONS``).
+See the :command:`install(DIRECTORY)` command for documentation of
+permissions, ``PATTERN``, ``REGEX``, and ``EXCLUDE`` options.
 
-The INSTALL signature differs slightly from COPY: it prints status
-messages, and NO_SOURCE_PERMISSIONS is default.  Installation scripts
-generated by the install() command use this signature (with some
-undocumented options for internal use).
-
-GENERATE will write an <output_file> with content from an
-<input_file>, or from <input_content>.  The output is generated
-conditionally based on the content of the <condition>.  The file is
-written at CMake generate-time and the input may contain generator
-expressions.  The <condition>, <output_file> and <input_file> may also
-contain generator expressions.  The <condition> must evaluate to
-either '0' or '1'.  The <output_file> must evaluate to a unique name
-among all configurations and among all invocations of file(GENERATE).
+The ``INSTALL`` signature differs slightly from ``COPY``: it prints
+status messages, and ``NO_SOURCE_PERMISSIONS`` is default.
+Installation scripts generated by the :command:`install` command
+use this signature (with some undocumented options for internal use).
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index 5d9aea6..190d05c 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -272,7 +272,9 @@
    (This step is implemented only on Windows.)
 
 6. Search paths stored in the CMake :ref:`User Package Registry`.
-   This can be skipped if ``NO_CMAKE_PACKAGE_REGISTRY`` is passed.
+   This can be skipped if ``NO_CMAKE_PACKAGE_REGISTRY`` is passed or by
+   setting the :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
+   to ``TRUE``.
    See the :manual:`cmake-packages(7)` manual for details on the user
    package registry.
 
@@ -285,7 +287,9 @@
      CMAKE_SYSTEM_APPBUNDLE_PATH
 
 8. Search paths stored in the CMake :ref:`System Package Registry`.
-   This can be skipped if ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` is passed.
+   This can be skipped if ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` is passed
+   or by setting the
+   :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` to ``TRUE``.
    See the :manual:`cmake-packages(7)` manual for details on the system
    package registry.
 
diff --git a/Help/command/string.rst b/Help/command/string.rst
index af18825..abde6ee 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -35,6 +35,7 @@
   string(FIND <string> <substring> <output variable> [REVERSE])
   string(TIMESTAMP <output variable> [<format string>] [UTC])
   string(MAKE_C_IDENTIFIER <input string> <output variable>)
+  string(GENEX_STRIP <input string> <output variable>)
 
 REGEX MATCH will match the regular expression once and store the match
 in the output variable.
@@ -154,3 +155,7 @@
 
 MAKE_C_IDENTIFIER will write a string which can be used as an
 identifier in C.
+
+``GENEX_STRIP`` will strip any
+:manual:`generator expressions <cmake-generator-expressions(7)>` from the
+``input string`` and store the result in the ``output variable``.
diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst
new file mode 100644
index 0000000..29a8b41
--- /dev/null
+++ b/Help/command/target_compile_features.rst
@@ -0,0 +1,32 @@
+target_compile_features
+-----------------------
+
+Add expected compiler features to a target.
+
+::
+
+  target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...])
+
+Specify compiler features required when compiling a given target.  If the
+feature is not listed in the :variable:`CMAKE_C_COMPILE_FEATURES` variable
+or :variable:`CMAKE_CXX_COMPILE_FEATURES` variable,
+then an error will be reported by CMake.  If the use of the feature requires
+an additional compiler flag, such as ``-std=gnu++11``, the flag will be added
+automatically.
+
+The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
+specify the scope of the features.  ``PRIVATE`` and ``PUBLIC`` items will
+populate the :prop_tgt:`COMPILE_FEATURES` property of ``<target>``.
+``PUBLIC`` and ``INTERFACE`` items will populate the
+:prop_tgt:`INTERFACE_COMPILE_FEATURES` property of ``<target>``.  Repeated
+calls for the same ``<target>`` append items.
+
+The named ``<target>`` must have been created by a command such as
+:command:`add_executable` or :command:`add_library` and must not be
+an ``IMPORTED`` target.
+
+Arguments to ``target_compile_features`` may use "generator expressions"
+with the syntax ``$<...>``.
+See the :manual:`cmake-generator-expressions(7)` manual for available
+expressions.  See the :manual:`cmake-compile-features(7)` manual for
+information on compile features.
diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst
new file mode 100644
index 0000000..ff756b4
--- /dev/null
+++ b/Help/command/target_sources.rst
@@ -0,0 +1,28 @@
+target_sources
+--------------
+
+Add sources to a target.
+
+::
+
+  target_sources(<target>
+    <INTERFACE|PUBLIC|PRIVATE> [items1...]
+    [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
+
+Specify sources to use when compiling a given target.  The
+named ``<target>`` must have been created by a command such as
+:command:`add_executable` or :command:`add_library` and must not be an
+:prop_tgt:`IMPORTED Target`.
+
+The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
+specify the scope of the following arguments.  ``PRIVATE`` and ``PUBLIC``
+items will populate the :prop_tgt:`SOURCES` property of
+``<target>``.  ``PUBLIC`` and ``INTERFACE`` items will populate the
+:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``.  The
+following arguments specify sources.  Repeated calls for the same
+``<target>`` append items in the order called.
+
+Arguments to ``target_sources`` may use "generator expressions"
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions.  See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
diff --git a/Help/index.rst b/Help/index.rst
index a4abfbf..2d3f156 100644
--- a/Help/index.rst
+++ b/Help/index.rst
@@ -27,6 +27,7 @@
 
    /manual/cmake-buildsystem.7
    /manual/cmake-commands.7
+   /manual/cmake-compile-features.7
    /manual/cmake-developer.7
    /manual/cmake-generator-expressions.7
    /manual/cmake-generators.7
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index f3a5770..fdd1be4 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -551,7 +551,7 @@
 .. _`Include Directories and Usage Requirements`:
 
 Include Directories and Usage Requirements
-''''''''''''''''''''''''''''''''''''''''''
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 Include directories require some special consideration when specified as usage
 requirements and when used with generator expressions.  The
diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst
index fb0d2b5..8ff73a4 100644
--- a/Help/manual/cmake-commands.7.rst
+++ b/Help/manual/cmake-commands.7.rst
@@ -91,9 +91,11 @@
    /command/source_group
    /command/string
    /command/target_compile_definitions
+   /command/target_compile_features
    /command/target_compile_options
    /command/target_include_directories
    /command/target_link_libraries
+   /command/target_sources
    /command/try_compile
    /command/try_run
    /command/unset
@@ -126,6 +128,8 @@
    /command/variable_requires
    /command/write_file
 
+.. _`CTest Commands`:
+
 CTest Commands
 ==============
 
diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst
new file mode 100644
index 0000000..d4bbecc
--- /dev/null
+++ b/Help/manual/cmake-compile-features.7.rst
@@ -0,0 +1,294 @@
+.. cmake-manual-description: CMake Compile Features Reference
+
+cmake-compile-features(7)
+*************************
+
+.. only:: html or latex
+
+   .. contents::
+
+Introduction
+============
+
+Project source code may depend on, or be conditional on, the availability
+of certain features of the compiler.  There are three use-cases which arise:
+`Compile Feature Requirements`_, `Optional Compile Features`_
+and `Conditional Compilation Options`_.
+
+While features are typically specified in programming language standards,
+CMake provides a primary user interface based on granular handling of
+the features, not the language standard that introduced the feature.
+
+The :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and
+:prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties contain all the
+features known to CMake, regardless of compiler support for the feature.
+The :variable:`CMAKE_C_COMPILE_FEATURES` and
+:variable:`CMAKE_CXX_COMPILE_FEATURES` variables contain all features
+CMake knows are known to the compiler, regardless of language standard
+or compile flags needed to use them.
+
+Features known to CMake are named mostly following the same convention
+as the Clang feature test macros.  The are some execptions, such as
+CMake using ``cxx_final`` and ``cxx_override`` instead of the single
+``cxx_override_control`` used by Clang.
+
+Compile Feature Requirements
+============================
+
+Compile feature requirements may be specified with the
+:command:`target_compile_features` command.  For example, if a target must
+be compiled with compiler support for the
+:prop_gbl:`cxx_constexpr <CMAKE_CXX_KNOWN_FEATURES>` feature:
+
+.. code-block:: cmake
+
+  add_library(mylib requires_constexpr.cpp)
+  target_compile_features(mylib PRIVATE cxx_constexpr)
+
+In processing the requirement for the ``cxx_constexpr`` feature,
+:manual:`cmake(1)` will ensure that the in-use C++ compiler is capable
+of the feature, and will add any necessary flags such as ``-std=gnu++11``
+to the compile lines of C++ files in the ``mylib`` target.  A
+``FATAL_ERROR`` is issued if the compiler is not capable of the
+feature.
+
+The exact compile flags and language standard are deliberately not part
+of the user interface for this use-case.  CMake will compute the
+appropriate compile flags to use by considering the features specified
+for each target.
+
+Such compile flags are added even if the compiler supports the
+particular feature without the flag. For example, the GNU compiler
+supports variadic templates (with a warning) even if ``-std=gnu++98`` is
+used.  CMake adds the ``-std=gnu++11`` flag if ``cxx_variadic_templates``
+is specified as a requirement.
+
+In the above example, ``mylib`` requires ``cxx_constexpr`` when it
+is built itself, but consumers of ``mylib`` are not required to use a
+compiler which supports ``cxx_constexpr``.  If the interface of
+``mylib`` does require the ``cxx_constexpr`` feature (or any other
+known feature), that may be specified with the ``PUBLIC`` or
+``INTERFACE`` signatures of :command:`target_compile_features`:
+
+.. code-block:: cmake
+
+  add_library(mylib requires_constexpr.cpp)
+  # cxx_constexpr is a usage-requirement
+  target_compile_features(mylib PUBLIC cxx_constexpr)
+
+  # main.cpp will be compiled with -std=gnu++11 on GNU for cxx_constexpr.
+  add_executable(myexe main.cpp)
+  target_link_libraries(myexe mylib)
+
+Feature requirements are evaluated transitively by consuming the link
+implementation.  See :manual:`cmake-buildsystem(7)` for more on
+transitive behavior of build properties and usage requirements.
+
+Because the :prop_tgt:`CXX_EXTENSIONS` target property is ``ON`` by default,
+CMake uses extended variants of language dialects by default, such as
+``-std=gnu++11`` instead of ``-std=c++11``.  That target property may be
+set to ``OFF`` to use the non-extended variant of the dialect flag.  Note
+that because most compilers enable extensions by default, this could
+expose cross-platform bugs in user code or in the headers of third-party
+dependencies.
+
+Optional Compile Features
+=========================
+
+Compile features may be preferred if available, without creating a hard
+requirement.  For example, a library may provides alternative
+implementations depending on whether the ``cxx_variadic_templates``
+feature is available:
+
+.. code-block:: c++
+
+  #if Foo_COMPILER_CXX_VARIADIC_TEMPLATES
+  template<int I, int... Is>
+  struct Interface;
+
+  template<int I>
+  struct Interface<I>
+  {
+    static int accumulate()
+    {
+      return I;
+    }
+  };
+
+  template<int I, int... Is>
+  struct Interface
+  {
+    static int accumulate()
+    {
+      return I + Interface<Is...>::accumulate();
+    }
+  };
+  #else
+  template<int I1, int I2 = 0, int I3 = 0, int I4 = 0>
+  struct Interface
+  {
+    static int accumulate() { return I1 + I2 + I3 + I4; }
+  };
+  #endif
+
+Such an interface depends on using the correct preprocessor defines for the
+compiler features.  CMake can generate a header file containing such
+defines using the :module:`WriteCompilerDetectionHeader` module.  The
+module contains the ``write_compiler_detection_header`` function which
+accepts parameters to control the content of the generated header file:
+
+.. code-block:: cmake
+
+  write_compiler_detection_header(
+    FILE "${CMAKE_CURRENT_BINARY_DIR}/foo_compiler_detection.h"
+    PREFIX Foo
+    COMPILERS GNU
+    FEATURES
+      cxx_variadic_templates
+  )
+
+Such a header file may be used internally in the source code of a project,
+and it may be installed and used in the interface of library code.
+
+For each feature listed in ``FEATURES``, a preprocessor definition
+is created in the header file, and defined to either ``1`` or ``0``.
+
+Additionally, some features call for additional defines, such as the
+``cxx_final`` and ``cxx_override`` features. Rather than being used in
+``#ifdef`` code, the ``final`` keyword is abstracted by a symbol
+which is defined to either ``final``, a compiler-specific equivalent, or
+to empty.  That way, C++ code can be written to unconditionally use the
+symbol, and compiler support determines what it is expanded to:
+
+.. code-block:: c++
+
+  struct Interface {
+    virtual void Execute() = 0;
+  };
+
+  struct Concrete Foo_CXX_FINAL {
+    void Execute() Foo_CXX_OVERRIDE;
+  };
+
+In this case, ``Foo_CXX_FINAL`` will expand to ``final`` if the
+compiler supports the keyword, or to empty otherwise.
+
+In this use-case, the CMake code will wish to enable a particular language
+standard if available from the compiler. The :prop_tgt:`CXX_STANDARD`
+target property variable may be set to the desired language standard
+for a particular target, and the :variable:`CMAKE_CXX_STANDARD` may be
+set to influence all following targets:
+
+.. code-block:: cmake
+
+  write_compiler_detection_header(
+    FILE "${CMAKE_CURRENT_BINARY_DIR}/foo_compiler_detection.h"
+    PREFIX Foo
+    COMPILERS GNU
+    FEATURES
+      cxx_final cxx_override
+  )
+
+  # Includes foo_compiler_detection.h and uses the Foo_DECL_CXX_FINAL symbol
+  # which will expand to 'final' if the compiler supports the requested
+  # CXX_STANDARD.
+  add_library(foo foo.cpp)
+  set_property(TARGET foo PROPERTY CXX_STANDARD 11)
+
+  # Includes foo_compiler_detection.h and uses the Foo_DECL_CXX_FINAL symbol
+  # which will expand to 'final' if the compiler supports the feature,
+  # even though CXX_STANDARD is not set explicitly.  The requirement of
+  # cxx_constexpr causes CMake to set CXX_STANDARD internally, which
+  # affects the compile flags.
+  add_library(foo_impl foo_impl.cpp)
+  target_compile_features(foo_impl PRIVATE cxx_constexpr)
+
+The ``write_compiler_detection_header`` function also creates compatibility
+code for other features which have standard equivalents.  For example, the
+``cxx_static_assert`` feature is emulated with a template and abstracted
+via the ``<PREFIX>_STATIC_ASSERT`` and ``<PREFIX>_STATIC_ASSERT_MSG``
+function-macros.
+
+Conditional Compilation Options
+===============================
+
+Libraries may provide entirely different header files depending on
+requested compiler features.
+
+For example, a header at ``with_variadics/interface.h`` may contain:
+
+.. code-block:: c++
+
+  template<int I, int... Is>
+  struct Interface;
+
+  template<int I>
+  struct Interface<I>
+  {
+    static int accumulate()
+    {
+      return I;
+    }
+  };
+
+  template<int I, int... Is>
+  struct Interface
+  {
+    static int accumulate()
+    {
+      return I + Interface<Is...>::accumulate();
+    }
+  };
+
+while a header at ``no_variadics/interface.h`` may contain:
+
+.. code-block:: c++
+
+  template<int I1, int I2 = 0, int I3 = 0, int I4 = 0>
+  struct Interface
+  {
+    static int accumulate() { return I1 + I2 + I3 + I4; }
+  };
+
+It would be possible to write a abstraction ``interface.h`` header
+containing something like:
+
+.. code-block:: c++
+
+  #include "foo_compiler_detection.h"
+  #if Foo_COMPILER_CXX_VARIADIC_TEMPLATES
+  #include "with_variadics/interface.h"
+  #else
+  #include "no_variadics/interface.h"
+  #endif
+
+However this could be unmaintainable if there are many files to
+abstract. What is needed is to use alternative include directories
+depending on the compiler capabilities.
+
+CMake provides a ``COMPILE_FEATURES``
+:manual:`generator expression <cmake-generator-expressions(7)>` to implement
+such conditions.  This may be used with the build-property commands such as
+:command:`target_include_directories` and :command:`target_link_libraries`
+to set the appropriate :manual:`buildsystem <cmake-buildsystem(7)>`
+properties:
+
+.. code-block:: cmake
+
+  add_library(foo INTERFACE)
+  target_link_libraries(foo
+    INTERFACE
+      "$<$<COMPILE_FEATURES:cxx_variadic_templates>:${CMAKE_CURRENT_SOURCE_DIR}/with_variadics>"
+      "$<$<NOT:$<COMPILE_FEATURES:cxx_variadic_templates>>:${CMAKE_CURRENT_SOURCE_DIR}/no_variadics>")
+
+Consuming code then simply links to the ``foo`` target as usual and uses
+the feature-appropriate include directory
+
+.. code-block:: cmake
+
+  add_executable(consumer_with consumer_with.cpp)
+  target_link_libraries(consumer_with foo)
+  set_property(TARGET consumer_with CXX_STANDARD 11)
+
+  add_executable(consumer_no consumer_no.cpp)
+  target_link_libraries(consumer_no foo)
diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst
index 376b56c..9851c12 100644
--- a/Help/manual/cmake-developer.7.rst
+++ b/Help/manual/cmake-developer.7.rst
@@ -55,7 +55,7 @@
 
 .. code-block:: c++
 
-  const std::set<cmStdString>& someSet = getSet();
+  const std::set<std::string>& someSet = getSet();
   if (someSet.find("needle") == someSet.end()) // Wrong
     {
     // ...
@@ -66,8 +66,8 @@
 
 .. code-block:: c++
 
-  const std::set<cmStdString>& someSet;
-  const std::set<cmStdString>::const_iterator i = someSet.find("needle");
+  const std::set<std::string>& someSet;
+  const std::set<std::string>::const_iterator i = someSet.find("needle");
   if (i != propSet.end()) // Ok
     {
     // ...
@@ -110,7 +110,7 @@
 
 .. code-block:: c++
 
-  std::set<cmStdString> theSet;
+  std::set<const char*> theSet;
   std::vector<std::string> theVector;
   theVector.insert(theVector.end(), theSet.begin(), theSet.end()); // Wrong
 
@@ -118,9 +118,9 @@
 
 .. code-block:: c++
 
-  std::set<cmStdString> theSet;
+  std::set<const char*> theSet;
   std::vector<std::string> theVector;
-  for(std::set<cmStdString>::iterator li = theSet.begin();
+  for(std::set<const char*>::iterator li = theSet.begin();
       li != theSet.end(); ++li)
     {
     theVector.push_back(*li);
@@ -197,6 +197,51 @@
 Some template code is permitted, but with some limitations. Member templates
 may not be used, and template friends may not be used.
 
+Adding Compile Features
+=======================
+
+CMake reports an error if a compiler whose features are known does not report
+support for a particular requested feature.  A compiler is considered to have
+known features if it reports support for at least one feature.
+
+When adding a new compile feature to CMake, it is therefore necessary to list
+support for the feature for all CompilerIds which already have one or more
+feature supported, if the new feature is available for any version of the
+compiler.
+
+When adding the first supported feature to a particular CompilerId, it is
+necessary to list support for all features known to cmake (See
+:variable:`CMAKE_C_COMPILE_FEATURES` and
+:variable:`CMAKE_CXX_COMPILE_FEATURES` as appropriate), where available for
+the compiler.
+
+It is sensible to record the features for the most recent version of a
+particular CompilerId first, and then work backwards.  It is sensible to
+try to create a continuous range of versions of feature releases of the
+compiler.  Gaps in the range indicate incorrect features recorded for
+intermediate releases.
+
+Generally, features are made available for a particular version if the
+compiler vendor documents availability of the feature with that
+version.  Note that sometimes partially implemented features appear to
+be functional in previous releases (such as ``cxx_constexpr`` in GNU 4.6,
+though availability is documented in GNU 4.7), and sometimes compiler vendors
+document availability of features, though supporting infrastructure is
+not available (such as ``__has_feature(cxx_generic_lambdas)`` indicating
+non-availability in Clang 3.4, though it is documented as available, and
+fixed in Clang 3.5).  Similar cases for other compilers and versions
+need to be investigated when extending CMake to support them.
+
+When a vendor releases a new version of a known compiler which supports
+a previously unsupported feature, and there are already known features for
+that compiler, the feature should be listed as supported in CMake for
+that version of the compiler as soon as reasonably possible.
+
+Standard-specific/compiler-specific variables such
+``CMAKE_CXX98_COMPILE_FEATURES`` are deliberately not documented.  They
+only exist for the compiler-specific implementation of adding the ``-std``
+compile flag for compilers which need that.
+
 Help
 ====
 
@@ -331,10 +376,10 @@
  See the :manual:`cmake-policies(7)` manual
  and the :command:`cmake_policy` command.
 
-``prop_cache, prop_dir, prop_gbl, prop_sf, prop_test, prop_tgt``
- A CMake cache, directory, global, source file, test, or target
- property, respectively.  See the :manual:`cmake-properties(7)` manual
- and the :command:`set_property` command.
+``prop_cache, prop_dir, prop_gbl, prop_sf, prop_inst, prop_test, prop_tgt``
+ A CMake cache, directory, global, source file, installed file, test,
+ or target property, respectively.  See the :manual:`cmake-properties(7)`
+ manual and the :command:`set_property` command.
 
 ``variable``
  A CMake language variable.
@@ -420,168 +465,195 @@
 Style
 -----
 
-1)
-  Command signatures should be marked up as plain literal blocks, not as
-  cmake ``code-blocks``.
+Style: Section Headers
+^^^^^^^^^^^^^^^^^^^^^^
 
-2)
-  Signatures are separated from preceding content by a horizontal
-  line. That is, use:
+When marking section titles, make the section decoration line as long as
+the title text.  Use only a line below the title, not above. For
+example:
 
-  .. code-block:: rst
+.. code-block:: rst
 
-    ... preceding paragraph.
+  Title Text
+  ----------
 
-    ---------------------------------------------------------------------
+Capitalize the first letter of each non-minor word in the title.
 
-    ::
+The section header underline character hierarchy is
 
-      add_library(<lib> ...)
+* ``#``: Manual group (part) in the master document
+* ``*``: Manual (chapter) title
+* ``=``: Section within a manual
+* ``-``: Subsection or `CMake Domain`_ object document title
+* ``^``: Subsubsection or `CMake Domain`_ object document section
+* ``"``: Paragraph or `CMake Domain`_ object document subsection
 
-    This signature is used for ...
+Style: Whitespace
+^^^^^^^^^^^^^^^^^
 
-3)
-  Use "``OFF``" and "``ON``" for boolean values which can be modified by
-  the user, such as :prop_tgt:`POSITION_INDEPENDENT_CODE`. Such properties
-  may be "enabled" and "disabled". Use "``True``" and "``False``" for
-  inherent values which can't be modified after being set, such as the
-  :prop_tgt:`IMPORTED` property of a build target.
+Use two spaces for indentation.  Use two spaces between sentences in
+prose.
 
-4)
-  Use two spaces for indentation.  Use two spaces between sentences in
-  prose.
+Style: Line Length
+^^^^^^^^^^^^^^^^^^
 
-5)
-  Prefer to mark the start of literal blocks with ``::`` at the end of
-  the preceding paragraph. In cases where the following block gets
-  a ``code-block`` marker, put a single ``:`` at the end of the preceding
-  paragraph.
+Prefer to restrict the width of lines to 75-80 columns.  This is not a
+hard restriction, but writing new paragraphs wrapped at 75 columns
+allows space for adding minor content without significant re-wrapping of
+content.
 
-6)
-  Prefer to restrict the width of lines to 75-80 columns.  This is not a
-  hard restriction, but writing new paragraphs wrapped at 75 columns
-  allows space for adding minor content without significant re-wrapping of
-  content.
+Style: Prose
+^^^^^^^^^^^^
 
-7)
-  Mark up self-references with  ``inline-literal`` syntax. For example,
-  within the add_executable command documentation, use
+Use American English spellings in prose.
 
-  .. code-block:: rst
+Style: Starting Literal Blocks
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-    ``add_executable``
+Prefer to mark the start of literal blocks with ``::`` at the end of
+the preceding paragraph. In cases where the following block gets
+a ``code-block`` marker, put a single ``:`` at the end of the preceding
+paragraph.
 
-  not
+Style: CMake Command Signatures
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-  .. code-block:: rst
+Command signatures should be marked up as plain literal blocks, not as
+cmake ``code-blocks``.
 
-    :command:`add_executable`
+Signatures are separated from preceding content by a horizontal
+line. That is, use:
 
-  which is used elsewhere.
+.. code-block:: rst
 
-8)
-  Mark up all other linkable references as links, including repeats. An
-  alternative, which is used by wikipedia (`<http://en.wikipedia.org/wiki/WP:REPEATLINK>`_),
-  is to link to a reference only once per article. That style is not used
-  in CMake documentation.
+  ... preceding paragraph.
 
-9)
-  Mark up references to keywords in signatures, file names, and other
-  technical terms with ``inline-literl`` syntax, for example:
+  ---------------------------------------------------------------------
 
-  .. code-block:: rst
+  ::
 
-    If ``WIN32`` is used with :command:`add_executable`, the
-    :prop_tgt:`WIN32_EXECUTABLE` target property is enabled. That command
-    creates the file ``<name>.exe`` on Windows.
+    add_library(<lib> ...)
 
+  This signature is used for ...
 
-10)
-  If referring to a concept which corresponds to a property, and that
-  concept is described in a high-level manual, prefer to link to the
-  manual section instead of the property. For example:
+Signatures of commands should wrap optional parts with square brackets,
+and should mark list of optional arguments with an ellipsis (``...``).
+Elements of the signature which are specified by the user should be
+specified with angle brackets, and may be referred to in prose using
+``inline-literal`` syntax.
 
-  .. code-block:: rst
+Style: Boolean Constants
+^^^^^^^^^^^^^^^^^^^^^^^^
 
-    This command creates an :ref:`Imported Target <Imported Targets>`.
+Use "``OFF``" and "``ON``" for boolean values which can be modified by
+the user, such as :prop_tgt:`POSITION_INDEPENDENT_CODE`. Such properties
+may be "enabled" and "disabled". Use "``True``" and "``False``" for
+inherent values which can't be modified after being set, such as the
+:prop_tgt:`IMPORTED` property of a build target.
 
-  instead of:
+Style: Inline Literals
+^^^^^^^^^^^^^^^^^^^^^^
 
-  .. code-block:: rst
+Mark up references to keywords in signatures, file names, and other
+technical terms with ``inline-literal`` syntax, for example:
 
-    This command creates an :prop_tgt:`IMPORTED` target.
+.. code-block:: rst
 
-  The latter should be used only when referring specifically to the
-  property.
+  If ``WIN32`` is used with :command:`add_executable`, the
+  :prop_tgt:`WIN32_EXECUTABLE` target property is enabled. That command
+  creates the file ``<name>.exe`` on Windows.
 
-  References to manual sections are not automatically created by creating
-  a section, but code such as:
+Style: Cross-References
+^^^^^^^^^^^^^^^^^^^^^^^
 
-  .. code-block:: rst
+Mark up linkable references as links, including repeats.
+An alternative, which is used by wikipedia
+(`<http://en.wikipedia.org/wiki/WP:REPEATLINK>`_),
+is to link to a reference only once per article. That style is not used
+in CMake documentation.
 
-    .. _`Imported Targets`:
+Style: Referencing CMake Concepts
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-  creates a suitable anchor.  Use an anchor name which matches the name
-  of the corresponding section.  Refer to the anchor using a
-  cross-reference with specified text.
+If referring to a concept which corresponds to a property, and that
+concept is described in a high-level manual, prefer to link to the
+manual section instead of the property. For example:
 
-  Imported Targets need the ``IMPORTED`` term marked up with care in
-  particular because the term may refer to a command keyword
-  (``IMPORTED``), a target property (:prop_tgt:`IMPORTED`), or a
-  concept (:ref:`Imported Targets`).
+.. code-block:: rst
 
-11)
-  Where a property, command or variable is related conceptually to others,
-  by for example, being related to the buildsystem description, generator
-  expressions or Qt, each relevant property, command or variable should
-  link to the primary manual, which provides high-level information.  Only
-  particular information relating to the command should be in the
-  documentation of the command.
+  This command creates an :ref:`Imported Target <Imported Targets>`.
 
-12)
-  When marking section titles, make the section decoration line as long as
-  the title text.  Use only a line below the title, not above. For
-  example:
+instead of:
 
-  .. code-block:: rst
+.. code-block:: rst
 
-    Title Text
-    ----------
+  This command creates an :prop_tgt:`IMPORTED` target.
 
-  Capitalize the first letter of each non-minor word in the title.
+The latter should be used only when referring specifically to the
+property.
 
-13)
-  When referring to properties, variables, commands etc, prefer to link
-  to the target object and follow that with the type of object it is.
-  For example:
+References to manual sections are not automatically created by creating
+a section, but code such as:
 
-  .. code-block:: rst
+.. code-block:: rst
 
-    Set the :prop_tgt:`AUTOMOC` target property to ``ON``.
+  .. _`Imported Targets`:
 
-  Instead of
+creates a suitable anchor.  Use an anchor name which matches the name
+of the corresponding section.  Refer to the anchor using a
+cross-reference with specified text.
 
-  .. code-block:: rst
+Imported Targets need the ``IMPORTED`` term marked up with care in
+particular because the term may refer to a command keyword
+(``IMPORTED``), a target property (:prop_tgt:`IMPORTED`), or a
+concept (:ref:`Imported Targets`).
 
-    Set the target property :prop_tgt:`AUTOMOC` to ``ON``.
+Where a property, command or variable is related conceptually to others,
+by for example, being related to the buildsystem description, generator
+expressions or Qt, each relevant property, command or variable should
+link to the primary manual, which provides high-level information.  Only
+particular information relating to the command should be in the
+documentation of the command.
 
-  The ``policy`` directive is an exception, and the type us usually
-  referred to before the link:
+Style: Referencing CMake Domain Objects
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-  .. code-block:: rst
+When referring to `CMake Domain`_ objects such as properties, variables,
+commands etc, prefer to link to the target object and follow that with
+the type of object it is.  For example:
 
-    If policy :prop_tgt:`CMP0022` is set to ``NEW`` the behavior is ...
+.. code-block:: rst
 
-14)
-  Signatures of commands should wrap optional parts with square brackets,
-  and should mark list of optional arguments with an ellipsis (``...``).
-  Elements of the signature which are specified by the user should be
-  specified with angle brackets, and may be referred to in prose using
-  ``inline-literal`` syntax.
+  Set the :prop_tgt:`AUTOMOC` target property to ``ON``.
 
-15)
-  Use American English spellings in prose.
+Instead of
 
+.. code-block:: rst
+
+  Set the target property :prop_tgt:`AUTOMOC` to ``ON``.
+
+The ``policy`` directive is an exception, and the type us usually
+referred to before the link:
+
+.. code-block:: rst
+
+  If policy :prop_tgt:`CMP0022` is set to ``NEW`` the behavior is ...
+
+However, markup self-references with ``inline-literal`` syntax.
+For example, within the :command:`add_executable` command
+documentation, use
+
+.. code-block:: rst
+
+  ``add_executable``
+
+not
+
+.. code-block:: rst
+
+  :command:`add_executable`
+
+which is used elsewhere.
 
 Modules
 =======
@@ -664,213 +736,408 @@
    <code>
  endmacro()
 
+After the top documentation block, leave a *BLANK* line, and then add a
+copyright and licence notice block like this one (change only the year
+range and name)
+
+.. code-block:: cmake
+
+  #=============================================================================
+  # Copyright 2009-2011 Your Name
+  #
+  # Distributed under the OSI-approved BSD License (the "License");
+  # see accompanying file Copyright.txt for details.
+  #
+  # This software is distributed WITHOUT ANY WARRANTY; without even the
+  # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  # See the License for more information.
+  #=============================================================================
+  # (To distribute this file outside of CMake, substitute the full
+  #  License text for the above reference.)
+
+Test the documentation formatting by running
+``cmake --help-module <module-name>``, and also by enabling the
+``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation.
+Edit the comments until generated documentation looks satisfactory.  To
+have a .cmake file in this directory NOT show up in the modules
+documentation, simply leave out the ``Help/module/<module-name>.rst``
+file and the ``Help/manual/cmake-modules.7.rst`` toctree entry.
+
+
 Find Modules
 ------------
 
 A "find module" is a ``Modules/Find<package>.cmake`` file to be loaded
 by the :command:`find_package` command when invoked for ``<package>``.
 
-We would like all ``FindXxx.cmake`` files to produce consistent variable
-names.  Please use the following consistent variable names for general use.
+The primary task of a find module is to determine whether a package
+exists on the system, set the ``<package>_FOUND`` variable to reflect
+this and provide any variables, macros and imported targets required to
+use the package.
 
-Xxx_INCLUDE_DIRS
- The final set of include directories listed in one variable for use by client
- code.  This should not be a cache entry.
+The traditional approach is to use variables for everything, including
+libraries and executables: see the `Standard Variable Names`_ section
+below.  This is what most of the existing find modules provided by CMake
+do.
 
-Xxx_LIBRARIES
- The libraries to link against to use Xxx. These should include full paths.
- This should not be a cache entry.
+The more modern approach is to behave as much like
+``<package>Config.cmake`` files as possible, by providing imported
+targets.  As well as matching how ``*Config.cmake`` files work, the
+libraries, include directories and compile definitions are all set just
+by using the target in a :command:`target_link_libraries` call.   The
+disadvantage is that ``*Config.cmake`` files of projects that use
+imported targets from find modules may require more work to make sure
+those imported targets that are in the link interface are available.
 
-Xxx_DEFINITIONS
- Definitions to use when compiling code that uses Xxx. This really shouldn't
- include options such as (-DHAS_JPEG)that a client source-code file uses to
- decide whether to #include <jpeg.h>
+In either case (or even when providing both variables and imported
+targets), find modules should provide backwards compatibility with old
+versions that had the same name.
 
-Xxx_EXECUTABLE
- Where to find the Xxx tool.
+A FindFoo.cmake module will typically be loaded by the command::
 
-Xxx_Yyy_EXECUTABLE
- Where to find the Yyy tool that comes with Xxx.
+  find_package(Foo [major[.minor[.patch[.tweak]]]]
+               [EXACT] [QUIET] [REQUIRED]
+               [[COMPONENTS] [components...]]
+               [OPTIONAL_COMPONENTS components...]
+               [NO_POLICY_SCOPE])
 
-Xxx_LIBRARY_DIRS
- Optionally, the final set of library directories listed in one variable for
- use by client code.  This should not be a cache entry.
+See the :command:`find_package` documentation for details on what
+variables are set for the find module.  Most of these are dealt with by
+using :module:`FindPackageHandleStandardArgs`.
 
-Xxx_ROOT_DIR
- Where to find the base directory of Xxx.
+Briefly, the module should only locate versions of the package
+compatible with the requested version, as described by the
+``Foo_FIND_VERSION`` family of variables.  If ``Foo_FIND_QUIETLY`` is
+set to true, it should avoid printing messages, including anything
+complaining about the package not being found.  If ``Foo_FIND_REQUIRED``
+is set to true, the module should issue a ``FATAL_ERROR`` if the package
+cannot be found.  If neither are set to true, it should print a
+non-fatal message if it cannot find the package.
 
-Xxx_VERSION_Yy
- Expect Version Yy if true. Make sure at most one of these is ever true.
+Packages that find multiple semi-independent parts (like bundles of
+libraries) should search for the components listed in
+``Foo_FIND_COMPONENTS`` if it is set , and only set ``Foo_FOUND`` to
+true if for each searched-for component ``<c>`` that was not found,
+``Foo_FIND_REQUIRED_<c>`` is not set to true.  The ``HANDLE_COMPONENTS``
+argument of ``find_package_handle_standard_args()`` can be used to
+implement this.
 
-Xxx_WRAP_Yy
- If False, do not try to use the relevant CMake wrapping command.
+If ``Foo_FIND_COMPONENTS`` is not set, which modules are searched for
+and required is up to the find module, but should be documented.
 
-Xxx_Yy_FOUND
- If False, optional Yy part of Xxx sytem is not available.
+For internal implementation, it is a generally accepted convention that
+variables starting with underscore are for temporary use only.
 
-Xxx_FOUND
- Set to false, or undefined, if we haven't found, or don't want to use Xxx.
+Like all modules, find modules should be properly documented.  To add a
+module to the CMake documentation, follow the steps in the `Module
+Documentation`_ section above.
 
-Xxx_NOT_FOUND_MESSAGE
- Should be set by config-files in the case that it has set Xxx_FOUND to FALSE.
- The contained message will be printed by the find_package() command and by
- find_package_handle_standard_args() to inform the user about the problem.
 
-Xxx_RUNTIME_LIBRARY_DIRS
- Optionally, the runtime library search path for use when running an
- executable linked to shared libraries.  The list should be used by user code
- to create the PATH on windows or LD_LIBRARY_PATH on unix.  This should not be
- a cache entry.
 
-Xxx_VERSION_STRING
- A human-readable string containing the version of the package found, if any.
+Standard Variable Names
+^^^^^^^^^^^^^^^^^^^^^^^
 
-Xxx_VERSION_MAJOR
- The major version of the package found, if any.
+For a ``FindXxx.cmake`` module that takes the approach of setting
+variables (either instead of or in addition to creating imported
+targets), the following variable names should be used to keep things
+consistent between find modules.  Note that all variables start with
+``Xxx_`` to make sure they do not interfere with other find modules; the
+same consideration applies to macros, functions and imported targets.
 
-Xxx_VERSION_MINOR
- The minor version of the package found, if any.
+``Xxx_INCLUDE_DIRS``
+  The final set of include directories listed in one variable for use by
+  client code.  This should not be a cache entry.
 
-Xxx_VERSION_PATCH
- The patch version of the package found, if any.
+``Xxx_LIBRARIES``
+  The libraries to link against to use Xxx. These should include full
+  paths.  This should not be a cache entry.
 
-You do not have to provide all of the above variables. You should provide
-Xxx_FOUND under most circumstances.  If Xxx is a library, then Xxx_LIBRARIES,
-should also be defined, and Xxx_INCLUDE_DIRS should usually be defined (I
-guess libm.a might be an exception)
+``Xxx_DEFINITIONS``
+  Definitions to use when compiling code that uses Xxx. This really
+  shouldn't include options such as ``-DHAS_JPEG`` that a client
+  source-code file uses to decide whether to ``#include <jpeg.h>``
+
+``Xxx_EXECUTABLE``
+  Where to find the Xxx tool.
+
+``Xxx_Yyy_EXECUTABLE``
+  Where to find the Yyy tool that comes with Xxx.
+
+``Xxx_LIBRARY_DIRS``
+  Optionally, the final set of library directories listed in one
+  variable for use by client code.  This should not be a cache entry.
+
+``Xxx_ROOT_DIR``
+  Where to find the base directory of Xxx.
+
+``Xxx_VERSION_Yy``
+  Expect Version Yy if true. Make sure at most one of these is ever true.
+
+``Xxx_WRAP_Yy``
+  If False, do not try to use the relevant CMake wrapping command.
+
+``Xxx_Yy_FOUND``
+  If False, optional Yy part of Xxx sytem is not available.
+
+``Xxx_FOUND``
+  Set to false, or undefined, if we haven't found, or don't want to use
+  Xxx.
+
+``Xxx_NOT_FOUND_MESSAGE``
+  Should be set by config-files in the case that it has set
+  ``Xxx_FOUND`` to FALSE.  The contained message will be printed by the
+  :command:`find_package` command and by
+  ``find_package_handle_standard_args()`` to inform the user about the
+  problem.
+
+``Xxx_RUNTIME_LIBRARY_DIRS``
+  Optionally, the runtime library search path for use when running an
+  executable linked to shared libraries.  The list should be used by
+  user code to create the ``PATH`` on windows or ``LD_LIBRARY_PATH`` on
+  UNIX.  This should not be a cache entry.
+
+``Xxx_VERSION``
+  The full version string of the package found, if any.  Note that many
+  existing modules provide ``Xxx_VERSION_STRING`` instead.
+
+``Xxx_VERSION_MAJOR``
+  The major version of the package found, if any.
+
+``Xxx_VERSION_MINOR``
+  The minor version of the package found, if any.
+
+``Xxx_VERSION_PATCH``
+  The patch version of the package found, if any.
 
 The following names should not usually be used in CMakeLists.txt files, but
-they may be usefully modified in users' CMake Caches to control stuff.
+are typically cache variables for users to edit and control the
+behaviour of find modules (like entering the path to a library manually)
 
-Xxx_LIBRARY
- Name of Xxx Library. A User may set this and Xxx_INCLUDE_DIR to ignore to
- force non-use of Xxx.
+``Xxx_LIBRARY``
+  The path of the Xxx library (as used with :command:`find_library`, for
+  example).
 
-Xxx_Yy_LIBRARY
- Name of Yy library that is part of the Xxx system. It may or may not be
- required to use Xxx.
+``Xxx_Yy_LIBRARY``
+  The path of the Yy library that is part of the Xxx system. It may or
+  may not be required to use Xxx.
 
-Xxx_INCLUDE_DIR
- Where to find xxx.h, etc.  (Xxx_INCLUDE_PATH was considered bad because a path
- includes an actual filename.)
+``Xxx_INCLUDE_DIR``
+  Where to find headers for using the Xxx library.
 
-Xxx_Yy_INCLUDE_DIR
- Where to find xxx_yy.h, etc.
+``Xxx_Yy_INCLUDE_DIR``
+  Where to find headers for using the Yy library of the Xxx system.
 
-For tidiness's sake, try to keep as many options as possible out of the cache,
-leaving at least one option which can be used to disable use of the module, or
-locate a not-found library (e.g. Xxx_ROOT_DIR).  For the same reason, mark
+To prevent users being overwhelmed with settings to configure, try to
+keep as many options as possible out of the cache, leaving at least one
+option which can be used to disable use of the module, or locate a
+not-found library (e.g. ``Xxx_ROOT_DIR``).  For the same reason, mark
 most cache options as advanced.
 
-If you need other commands to do special things then it should still begin
-with ``Xxx_``. This gives a sort of namespace effect and keeps things tidy for the
-user. You should put comments describing all the exported settings, plus
-descriptions of any the users can use to control stuff.
+While these are the standard variable names, you should provide
+backwards compatibility for any old names that were actually in use.
+Make sure you comment them as deprecated, so that no-one starts using
+them.
 
-You really should also provide backwards compatibility any old settings that
-were actually in use.  Make sure you comment them as deprecated, so that
-no-one starts using them.
 
-To add a module to the CMake documentation, follow the steps in the
-`Module Documentation`_ section above.  Test the documentation formatting
-by running ``cmake --help-module FindXxx``, and also by enabling the
-``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation.
-Edit the comments until generated documentation looks satisfactory.
-To have a .cmake file in this directory NOT show up in the modules
-documentation, simply leave out the ``Help/module/<module-name>.rst`` file
-and the ``Help/manual/cmake-modules.7.rst`` toctree entry.
 
-After the documentation, leave a *BLANK* line, and then add a
-copyright and licence notice block like this one::
+A Sample Find Module
+^^^^^^^^^^^^^^^^^^^^
 
- #=============================================================================
- # Copyright 2009-2011 Your Name
- #
- # Distributed under the OSI-approved BSD License (the "License");
- # see accompanying file Copyright.txt for details.
- #
- # This software is distributed WITHOUT ANY WARRANTY; without even the
- # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- # See the License for more information.
- #=============================================================================
- # (To distribute this file outside of CMake, substitute the full
- #  License text for the above reference.)
+We will describe how to create a simple find module for a library
+``Foo``.
 
-The layout of the notice block is strictly enforced by the ``ModuleNotices``
-test.  Only the year range and name may be changed freely.
+The first thing that is needed is documentation.  CMake's documentation
+system requires you to start the file with a documentation marker and
+the name of the module.  You should follow this with a simple statement
+of what the module does.
 
-A FindXxx.cmake module will typically be loaded by the command::
+.. code-block:: cmake
 
- FIND_PACKAGE(Xxx [major[.minor[.patch[.tweak]]]] [EXACT]
-              [QUIET] [[REQUIRED|COMPONENTS] [components...]])
+  #.rst:
+  # FindFoo
+  # -------
+  #
+  # Finds the Foo library
+  #
 
-If any version numbers are given to the command it will set the following
-variables before loading the module:
+More description may be required for some packages.  If there are
+caveats or other details users of the module should be aware of, you can
+add further paragraphs below this.  Then you need to document what
+variables and imported targets are set by the module, such as
 
-Xxx_FIND_VERSION
- full requested version string
+.. code-block:: cmake
 
-Xxx_FIND_VERSION_MAJOR
- major version if requested, else 0
+  # This will define the following variables::
+  #
+  #   Foo_FOUND    - True if the system has the Foo library
+  #   Foo_VERSION  - The version of the Foo library which was found
+  #
+  # and the following imported targets::
+  #
+  #   Foo::Foo   - The Foo library
 
-Xxx_FIND_VERSION_MINOR
- minor version if requested, else 0
+If the package provides any macros, they should be listed here, but can
+be documented where they are defined.  See the `Module
+Documentation`_ section above for more details.
 
-Xxx_FIND_VERSION_PATCH
- patch version if requested, else 0
+After the documentation, leave a blank line, and then add a copyright and
+licence notice block
 
-Xxx_FIND_VERSION_TWEAK
- tweak version if requested, else 0
+.. code-block:: cmake
 
-Xxx_FIND_VERSION_COUNT
- number of version components, 0 to 4
+  #=============================================================================
+  # Copyright 2009-2011 Your Name
+  #
+  # Distributed under the OSI-approved BSD License (the "License");
+  # see accompanying file Copyright.txt for details.
+  #
+  # This software is distributed WITHOUT ANY WARRANTY; without even the
+  # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  # See the License for more information.
+  #=============================================================================
+  # (To distribute this file outside of CMake, substitute the full
+  #  License text for the above reference.)
 
-Xxx_FIND_VERSION_EXACT
- true if EXACT option was given
+If the module is new to CMake, you may want to provide a warning for
+projects that do not require a high enough CMake version.
 
-If the find module supports versioning it should locate a version of
-the package that is compatible with the version requested.  If a
-compatible version of the package cannot be found the module should
-not report success.  The version of the package found should be stored
-in "Xxx_VERSION..." version variables documented by the module.
+.. code-block:: cmake
 
-If the QUIET option is given to the command it will set the variable
-Xxx_FIND_QUIETLY to true before loading the FindXxx.cmake module.  If
-this variable is set the module should not complain about not being
-able to find the package.  If the
-REQUIRED option is given to the command it will set the variable
-Xxx_FIND_REQUIRED to true before loading the FindXxx.cmake module.  If
-this variable is set the module should issue a FATAL_ERROR if the
-package cannot be found.
-If neither the QUIET nor REQUIRED options are given then the
-FindXxx.cmake module should look for the package and complain without
-error if the module is not found.
+  if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.0.0)
+    message(AUTHOR_WARNING "Your project should require at least CMake 3.0.0 to use FindFoo.cmake")
+  endif()
 
-FIND_PACKAGE() will set the variable CMAKE_FIND_PACKAGE_NAME to
-contain the actual name of the package.
+Now the actual libraries and so on have to be found.  The code here will
+obviously vary from module to module (dealing with that, after all, is the
+point of find modules), but there tends to be a common pattern for libraries.
 
-A package can provide sub-components.
-Those components can be listed after the COMPONENTS (or REQUIRED) or
-OPTIONAL_COMPONENTS keywords.  The set of all listed components will be
-specified in a Xxx_FIND_COMPONENTS variable.
-For each package-specific component, say Yyy, a variable Xxx_FIND_REQUIRED_Yyy
-will be set to true if it listed after COMPONENTS and it will be set to false
-if it was listed after OPTIONAL_COMPONENTS.
-Using those variables a FindXxx.cmake module and also a XxxConfig.cmake
-package configuration file can determine whether and which components have
-been requested, and whether they were requested as required or as optional.
-For each of the requested components a Xxx_Yyy_FOUND variable should be set
-accordingly.
-The per-package Xxx_FOUND variable should be only set to true if all requested
-required components have been found. A missing optional component should not
-keep the Xxx_FOUND variable from being set to true.
-If the package provides Xxx_INCLUDE_DIRS and Xxx_LIBRARIES variables, the
-include dirs and libraries for all components which were requested and which
-have been found should be added to those two variables.
+First, we try to use ``pkg-config`` to find the library.  Note that we
+cannot rely on this, as it may not be available, but it provides a good
+starting point.
 
-To get this behavior you can use the FIND_PACKAGE_HANDLE_STANDARD_ARGS()
-macro, as an example see FindJPEG.cmake.
+.. code-block:: cmake
 
-For internal implementation, it's a generally accepted convention that
-variables starting with underscore are for temporary use only. (variable
-starting with an underscore are not intended as a reserved prefix).
+  find_package(PkgConfig)
+  pkg_check_modules(PC_Foo QUIET Foo)
+
+This should define some variables starting ``PC_Foo_`` that contain the
+information from the ``Foo.pc`` file.
+
+Now we need to find the libraries and include files; we use the
+information from ``pkg-config`` to provide hints to CMake about where to
+look.
+
+.. code-block:: cmake
+
+  find_path(Foo_INCLUDE_DIR
+    NAMES foo.h
+    PATHS ${PC_Foo_INCLUDE_DIRS}
+    # if you need to put #include <Foo/foo.h> in your code, add:
+    PATH_SUFFIXES Foo
+  )
+  find_library(Foo_LIBRARY
+    NAMES foo
+    PATHS ${PC_Foo_LIBRARY_DIRS}
+  )
+
+If you have a good way of getting the version (from a header file, for
+example), you can use that information to set ``Foo_VERSION`` (although
+note that find modules have traditionally used ``Foo_VERSION_STRING``,
+so you may want to set both).  Otherwise, attempt to use the information
+from ``pkg-config``
+
+.. code-block:: cmake
+
+  set(Foo_VERSION ${PC_Foo_VERSION})
+
+Now we can use :module:`FindPackageHandleStandardArgs` to do most of the
+rest of the work for us
+
+.. code-block:: cmake
+
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(Foo
+    FOUND_VAR Foo_FOUND
+    REQUIRED_VARS
+      Foo_LIBRARY
+      Foo_INCLUDE_DIR
+    VERSION_VAR Foo_VERSION
+  )
+
+This will check that the ``REQUIRED_VARS`` contain values (that do not
+end in ``-NOTFOUND``) and set ``Foo_FOUND`` appropriately.  It will also
+cache those values.  If ``Foo_VERSION`` is set, and a required version
+was passed to :command:`find_package`, it will check the requested version
+against the one in ``Foo_VERSION``.  It will also print messages as
+appropriate; note that if the package was found, it will print the
+contents of the first required variable to indicate where it was found.
+
+At this point, we have to provide a way for users of the find module to
+link to the library or libraries that were found.  There are two
+approaches, as discussed in the `Find Modules`_ section above.  The
+traditional variable approach looks like
+
+.. code-block:: cmake
+
+  if(Foo_FOUND)
+    set(Foo_LIBRARIES ${Foo_LIBRARY})
+    set(Foo_INCLUDE_DIRS ${Foo_INCLUDE_DIR})
+    set(Foo_DEFINITIONS ${PC_Foo_CFLAGS_OTHER})
+  endif()
+
+If more than one library was found, all of them should be included in
+these variables (see the `Standard Variable Names`_ section for more
+information).
+
+When providing imported targets, these should be namespaced (hence the
+``Foo::`` prefix); CMake will recognize that values passed to
+:command:`target_link_libraries` that contain ``::`` in their name are
+supposed to be imported targets (rather than just library names), and
+will produce appropriate diagnostic messages if that target does not
+exist (see policy :policy:`CMP0028`).
+
+.. code-block:: cmake
+
+  if(Foo_FOUND AND NOT TARGET Foo::Foo)
+    add_library(Foo::Foo UNKNOWN IMPORTED)
+    set_target_properties(Foo::Foo PROPERTIES
+      IMPORTED_LOCATION "${Foo_LIBRARY}"
+      INTERFACE_COMPILE_OPTIONS "${PC_Foo_CFLAGS_OTHER}"
+      INTERFACE_INCLUDE_DIRECTORIES "${Foo_INCLUDE_DIR}"
+    )
+  endif()
+
+One thing to note about this is that the ``INTERFACE_INCLUDE_DIRECTORIES`` and
+similar properties should only contain information about the target itself, and
+not any of its dependencies.  Instead, those dependencies should also be
+targets, and CMake should be told that they are dependencies of this target.
+CMake will then combine all the necessary information automatically.
+
+We should also provide some information about the package, such as where to
+download it.
+
+.. code-block:: cmake
+
+  include(FeatureSummary)
+  set_package_properties(Foo PROPERTIES
+    URL "http://www.foo.example.com/"
+    DESCRIPTION "A library for doing useful things"
+  )
+
+Most of the cache variables should be hidden in the ``ccmake`` interface unless
+the user explicitly asks to edit them.
+
+.. code-block:: cmake
+
+  mark_as_advanced(
+    Foo_INCLUDE_DIR
+    Foo_LIBRARY
+  )
+
+If this module replaces an older version, you should set compatibility variables
+to cause the least disruption possible.
+
+.. code-block:: cmake
+
+  # compatibility variables
+  set(Foo_VERSION_STRING ${Foo_VERSION})
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index ac8c3f8..f04702e 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -83,6 +83,14 @@
   else ``0``.  If the policy was not set, the warning message for the policy
   will be emitted. This generator expression only works for a subset of
   policies.
+``$<COMPILE_FEATURES:feature[,feature]...>``
+  ``1`` if all of the ``feature`` features are available for the 'head'
+  target, and ``0`` otherwise. If this expression is used while evaluating
+  the link implementation of a target and if any dependency transitively
+  increases the required :prop_tgt:`C_STANDARD` or :prop_tgt:`CXX_STANDARD`
+  for the 'head' target, an error is reported.  See the
+  :manual:`cmake-compile-features(7)` manual for information on
+  compile features.
 
 Informational Expressions
 =========================
@@ -188,3 +196,8 @@
   Content of ``...`` converted to upper case.
 ``$<MAKE_C_IDENTIFIER:...>``
   Content of ``...`` converted to a C identifier.
+``$<TARGET_OBJECTS:objLib>``
+  List of objects resulting from build of ``objLib``. ``objLib`` must be an
+  object of type ``OBJECT_LIBRARY``.  This expression may only be used in
+  the sources of :command:`add_library` and :command:`add_executable`
+  commands.
diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst
index 1e4c6c5..b83dcad 100644
--- a/Help/manual/cmake-language.7.rst
+++ b/Help/manual/cmake-language.7.rst
@@ -287,6 +287,8 @@
  Instead use a `Quoted Argument`_ or a `Bracket Argument`_ to
  represent the content.
 
+.. _`Escape Sequences`:
+
 Escape Sequences
 ----------------
 
@@ -294,16 +296,20 @@
 
 .. productionlist::
  escape_sequence: `escape_identity` | `escape_encoded` | `escape_semicolon`
- escape_identity: '\(' | '\)' | '\#' | '\"' | '\ ' |
-                : '\\' | '\$' | '\@' | '\^'
+ escape_identity: '\' <match '[^A-Za-z0-9;]'>
  escape_encoded: '\t' | '\r' | '\n'
  escape_semicolon: '\;'
 
-A ``\`` followed by one of ``()#" \#@^`` simply encodes the literal
+A ``\`` followed by a non-alphanumeric character simply encodes the literal
 character without interpreting it as syntax.  A ``\t``, ``\r``, or ``\n``
-encodes a tab, carriage return, or newline character, respectively.
-A ``\;`` encodes itself but may be used in an `Unquoted Argument`_
-to encode the ``;`` without dividing the argument value on it.
+encodes a tab, carriage return, or newline character, respectively. A ``\;``
+outside of any `Variable References`_  encodes itself but may be used in an
+`Unquoted Argument`_ to encode the ``;`` without dividing the argument
+value on it.  A ``\;`` inside `Variable References`_ encodes the literal
+``;`` character.  (See also policy :policy:`CMP0053` documentation for
+historical considerations.)
+
+.. _`Variable References`:
 
 Variable References
 -------------------
@@ -315,6 +321,11 @@
 Variable references can nest and are evaluated from the
 inside out, e.g. ``${outer_${inner_variable}_variable}``.
 
+Literal variable references may consist of alphanumeric characters,
+the characters ``/_.+-``, and `Escape Sequences`_.  Nested references
+may be used to evaluate variables of any name.  (See also policy
+:policy:`CMP0053` documentation for historical considerations.)
+
 The `Variables`_ section documents the scope of variable names
 and how their values are set.
 
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 7a06be6..ecc9cc4 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -138,6 +138,7 @@
    /module/FindMPEG
    /module/FindMPI
    /module/FindOpenAL
+   /module/FindOpenCL
    /module/FindOpenGL
    /module/FindOpenMP
    /module/FindOpenSceneGraph
@@ -231,3 +232,4 @@
    /module/UsewxWidgets
    /module/Use_wxWindows
    /module/WriteBasicConfigVersionFile
+   /module/WriteCompilerDetectionHeader
diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst
index 1723826..c4cca6d 100644
--- a/Help/manual/cmake-packages.7.rst
+++ b/Help/manual/cmake-packages.7.rst
@@ -564,6 +564,21 @@
 
 There is no system package registry on non-Windows platforms.
 
+.. _`Disabling the Package Registry`:
+
+Disabling the Package Registry
+------------------------------
+
+In some cases using the Package Registries is not desirable. CMake
+allows to disable them using the following variables:
+
+ * :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` disables the
+   :command:`export(PACKAGE)` command.
+ * :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` disables the
+   User Package Registry in all the :command:`find_package` calls.
+ * :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` disables
+   the System Package Registry in all the :command:`find_package` calls.
+
 Package Registry Example
 ------------------------
 
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 8650a58..136cf5c 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -102,3 +102,6 @@
    /policy/CMP0048
    /policy/CMP0049
    /policy/CMP0050
+   /policy/CMP0051
+   /policy/CMP0052
+   /policy/CMP0053
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index d315fcb..e4546c1 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -16,6 +16,8 @@
    /prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS
    /prop_gbl/AUTOGEN_TARGETS_FOLDER
    /prop_gbl/AUTOMOC_TARGETS_FOLDER
+   /prop_gbl/CMAKE_C_KNOWN_FEATURES
+   /prop_gbl/CMAKE_CXX_KNOWN_FEATURES
    /prop_gbl/DEBUG_CONFIGURATIONS
    /prop_gbl/DISABLED_FEATURES
    /prop_gbl/ENABLED_FEATURES
@@ -92,16 +94,27 @@
    /prop_tgt/BUILD_WITH_INSTALL_RPATH
    /prop_tgt/BUNDLE_EXTENSION
    /prop_tgt/BUNDLE
+   /prop_tgt/C_EXTENSIONS
+   /prop_tgt/C_STANDARD
+   /prop_tgt/C_STANDARD_REQUIRED
    /prop_tgt/COMPATIBLE_INTERFACE_BOOL
    /prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MAX
    /prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MIN
    /prop_tgt/COMPATIBLE_INTERFACE_STRING
    /prop_tgt/COMPILE_DEFINITIONS_CONFIG
    /prop_tgt/COMPILE_DEFINITIONS
+   /prop_tgt/COMPILE_FEATURES
    /prop_tgt/COMPILE_FLAGS
    /prop_tgt/COMPILE_OPTIONS
+   /prop_tgt/COMPILE_PDB_NAME
+   /prop_tgt/COMPILE_PDB_NAME_CONFIG
+   /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY
+   /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
    /prop_tgt/CONFIG_OUTPUT_NAME
    /prop_tgt/CONFIG_POSTFIX
+   /prop_tgt/CXX_EXTENSIONS
+   /prop_tgt/CXX_STANDARD
+   /prop_tgt/CXX_STANDARD_REQUIRED
    /prop_tgt/DEBUG_POSTFIX
    /prop_tgt/DEFINE_SYMBOL
    /prop_tgt/EchoString
@@ -144,10 +157,12 @@
    /prop_tgt/INSTALL_RPATH_USE_LINK_PATH
    /prop_tgt/INTERFACE_AUTOUIC_OPTIONS
    /prop_tgt/INTERFACE_COMPILE_DEFINITIONS
+   /prop_tgt/INTERFACE_COMPILE_FEATURES
    /prop_tgt/INTERFACE_COMPILE_OPTIONS
    /prop_tgt/INTERFACE_INCLUDE_DIRECTORIES
    /prop_tgt/INTERFACE_LINK_LIBRARIES
    /prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE
+   /prop_tgt/INTERFACE_SOURCES
    /prop_tgt/INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
    /prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG
    /prop_tgt/INTERPROCEDURAL_OPTIMIZATION
@@ -278,6 +293,8 @@
    /prop_sf/OBJECT_OUTPUTS
    /prop_sf/SYMBOLIC
    /prop_sf/WRAP_EXCLUDE
+   /prop_sf/XCODE_EXPLICIT_FILE_TYPE
+   /prop_sf/XCODE_LAST_KNOWN_FILE_TYPE
 
 Properties on Cache Entries
 ===========================
@@ -291,3 +308,12 @@
    /prop_cache/STRINGS
    /prop_cache/TYPE
    /prop_cache/VALUE
+
+Properties on Installed Files
+=============================
+
+.. toctree::
+   :maxdepth: 1
+
+   /prop_inst/CPACK_NEVER_OVERWRITE.rst
+   /prop_inst/CPACK_PERMANENT.rst
diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst
index cad4951..fe8d62d 100644
--- a/Help/manual/cmake-qt.7.rst
+++ b/Help/manual/cmake-qt.7.rst
@@ -54,7 +54,7 @@
 to the :prop_tgt:`AUTOGEN_TARGET_DEPENDS` target property.
 
 AUTOMOC
-'''''''
+^^^^^^^
 
 The :prop_tgt:`AUTOMOC` target property controls whether :manual:`cmake(1)`
 inspects the C++ files in the target to determine if they require ``moc`` to
@@ -84,7 +84,7 @@
 .. _`Qt AUTOUIC`:
 
 AUTOUIC
-'''''''
+^^^^^^^
 
 The :prop_tgt:`AUTOUIC` target property controls whether :manual:`cmake(1)`
 inspects the C++ files in the target to determine if they require ``uic`` to
@@ -147,7 +147,7 @@
 .. _`Qt AUTORCC`:
 
 AUTORCC
-'''''''
+^^^^^^^
 
 The :prop_tgt:`AUTORCC` target property controls whether :manual:`cmake(1)`
 creates rules to execute ``rcc`` at the appropriate time on source files
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index f4b9666..df434c5 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -109,10 +109,13 @@
    /variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName
    /variable/CMAKE_ERROR_DEPRECATED
    /variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
+   /variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY
    /variable/CMAKE_SYSROOT
    /variable/CMAKE_FIND_LIBRARY_PREFIXES
    /variable/CMAKE_FIND_LIBRARY_SUFFIXES
    /variable/CMAKE_FIND_NO_INSTALL_PREFIX
+   /variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
+   /variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
    /variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE
    /variable/CMAKE_FIND_ROOT_PATH
    /variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
@@ -201,6 +204,8 @@
    /variable/CMAKE_AUTOUIC
    /variable/CMAKE_AUTOUIC_OPTIONS
    /variable/CMAKE_BUILD_WITH_INSTALL_RPATH
+   /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
+   /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
    /variable/CMAKE_CONFIG_POSTFIX
    /variable/CMAKE_DEBUG_POSTFIX
    /variable/CMAKE_EXE_LINKER_FLAGS_CONFIG
@@ -255,6 +260,14 @@
    :maxdepth: 1
 
    /variable/CMAKE_COMPILER_IS_GNULANG
+   /variable/CMAKE_C_COMPILE_FEATURES
+   /variable/CMAKE_C_EXTENSIONS
+   /variable/CMAKE_C_STANDARD
+   /variable/CMAKE_C_STANDARD_REQUIRED
+   /variable/CMAKE_CXX_COMPILE_FEATURES
+   /variable/CMAKE_CXX_EXTENSIONS
+   /variable/CMAKE_CXX_STANDARD
+   /variable/CMAKE_CXX_STANDARD_REQUIRED
    /variable/CMAKE_Fortran_MODDIR_DEFAULT
    /variable/CMAKE_Fortran_MODDIR_FLAG
    /variable/CMAKE_Fortran_MODOUT_FLAG
@@ -295,6 +308,57 @@
    /variable/CMAKE_LANG_SOURCE_FILE_EXTENSIONS
    /variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG
 
+Variables for CTest
+===================
+
+.. toctree::
+   :maxdepth: 1
+
+   /variable/CTEST_BINARY_DIRECTORY
+   /variable/CTEST_BUILD_COMMAND
+   /variable/CTEST_BUILD_NAME
+   /variable/CTEST_BZR_COMMAND
+   /variable/CTEST_BZR_UPDATE_OPTIONS
+   /variable/CTEST_CHECKOUT_COMMAND
+   /variable/CTEST_CONFIGURATION_TYPE
+   /variable/CTEST_CONFIGURE_COMMAND
+   /variable/CTEST_COVERAGE_COMMAND
+   /variable/CTEST_COVERAGE_EXTRA_FLAGS
+   /variable/CTEST_CURL_OPTIONS
+   /variable/CTEST_CVS_CHECKOUT
+   /variable/CTEST_CVS_COMMAND
+   /variable/CTEST_CVS_UPDATE_OPTIONS
+   /variable/CTEST_DROP_LOCATION
+   /variable/CTEST_DROP_METHOD
+   /variable/CTEST_DROP_SITE
+   /variable/CTEST_DROP_SITE_CDASH
+   /variable/CTEST_DROP_SITE_PASSWORD
+   /variable/CTEST_DROP_SITE_USER
+   /variable/CTEST_GIT_COMMAND
+   /variable/CTEST_GIT_UPDATE_CUSTOM
+   /variable/CTEST_GIT_UPDATE_OPTIONS
+   /variable/CTEST_HG_COMMAND
+   /variable/CTEST_HG_UPDATE_OPTIONS
+   /variable/CTEST_MEMORYCHECK_COMMAND
+   /variable/CTEST_MEMORYCHECK_COMMAND_OPTIONS
+   /variable/CTEST_MEMORYCHECK_SUPPRESSIONS_FILE
+   /variable/CTEST_NIGHTLY_START_TIME
+   /variable/CTEST_P4_CLIENT
+   /variable/CTEST_P4_COMMAND
+   /variable/CTEST_P4_OPTIONS
+   /variable/CTEST_P4_UPDATE_OPTIONS
+   /variable/CTEST_SCP_COMMAND
+   /variable/CTEST_SITE
+   /variable/CTEST_SOURCE_DIRECTORY
+   /variable/CTEST_SVN_COMMAND
+   /variable/CTEST_SVN_OPTIONS
+   /variable/CTEST_SVN_UPDATE_OPTIONS
+   /variable/CTEST_TEST_TIMEOUT
+   /variable/CTEST_TRIGGER_SITE
+   /variable/CTEST_UPDATE_COMMAND
+   /variable/CTEST_UPDATE_OPTIONS
+   /variable/CTEST_USE_LAUNCHERS
+
 Variables for CPack
 ===================
 
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index 60d08dd..a57a8f0 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -365,6 +365,607 @@
 
 .. include:: OPTIONS_HELP.txt
 
+Dashboard Client
+================
+
+CTest can operate as a client for the `CDash`_ software quality dashboard
+application.  As a dashboard client, CTest performs a sequence of steps
+to configure, build, and test software, and then submits the results to
+a `CDash`_ server.
+
+.. _`CDash`: http://cdash.org/
+
+Dashboard Client Steps
+----------------------
+
+CTest defines an ordered list of testing steps of which some or all may
+be run as a dashboard client:
+
+``Start``
+  Start a new dashboard submission to be composed of results recorded
+  by the following steps.
+  See the `CTest Start Step`_ section below.
+
+``Update``
+  Update the source tree from its version control repository.
+  Record the old and new versions and the list of updated source files.
+  See the `CTest Update Step`_ section below.
+
+``Configure``
+  Configure the software by running a command in the build tree.
+  Record the configuration output log.
+  See the `CTest Configure Step`_ section below.
+
+``Build``
+  Build the software by running a command in the build tree.
+  Record the build output log and detect warnings and errors.
+  See the `CTest Build Step`_ section below.
+
+``Test``
+  Test the software by loading a ``CTestTestfile.cmake``
+  from the build tree and executing the defined tests.
+  Record the output and result of each test.
+  See the `CTest Test Step`_ section below.
+
+``Coverage``
+  Compute coverage of the source code by running a coverage
+  analysis tool and recording its output.
+  See the `CTest Coverage Step`_ section below.
+
+``MemCheck``
+  Run the software test suite through a memory check tool.
+  Record the test output, results, and issues reported by the tool.
+  See the `CTest MemCheck Step`_ section below.
+
+``Submit``
+  Submit results recorded from other testing steps to the
+  software quality dashboard server.
+  See the `CTest Submit Step`_ section below.
+
+Dashboard Client Modes
+----------------------
+
+CTest defines three modes of operation as a dashboard client:
+
+``Nightly``
+  This mode is intended to be invoked once per day, typically at night.
+  It enables the ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
+  ``Coverage``, and ``Submit`` steps by default.  Selected steps run even
+  if the ``Update`` step reports no changes to the source tree.
+
+``Continuous``
+  This mode is intended to be invoked repeatedly throughout the day.
+  It enables the ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
+  ``Coverage``, and ``Submit`` steps by default, but exits after the
+  ``Update`` step if it reports no changes to the source tree.
+
+``Experimental``
+  This mode is intended to be invoked by a developer to test local changes.
+  It enables the ``Start``, ``Configure``, ``Build``, ``Test``, ``Coverage``,
+  and ``Submit`` steps by default.
+
+Dashboard Client via CTest Command-Line
+---------------------------------------
+
+CTest can perform testing on an already-generated build tree.
+Run the ``ctest`` command with the current working directory set
+to the build tree and use one of these signatures::
+
+  ctest -D <mode>[<step>]
+  ctest -M <mode> [ -T <step> ]...
+
+The ``<mode>`` must be one of the above `Dashboard Client Modes`_,
+and each ``<step>`` must be one of the above `Dashboard Client Steps`_.
+
+CTest reads the `Dashboard Client Configuration`_ settings from
+a file in the build tree called either ``CTestConfiguration.ini``
+or ``DartConfiguration.tcl`` (the names are historical).  The format
+of the file is::
+
+  # Lines starting in '#' are comments.
+  # Other non-blank lines are key-value pairs.
+  <setting>: <value>
+
+where ``<setting>`` is the setting name and ``<value>`` is the
+setting value.
+
+In build trees generated by CMake, this configuration file is
+generated by the :module:`CTest` module if included by the project.
+The module uses variables to obtain a value for each setting
+as documented with the settings below.
+
+.. _`CTest Script`:
+
+Dashboard Client via CTest Script
+---------------------------------
+
+CTest can perform testing driven by a :manual:`cmake-language(7)`
+script that creates and maintains the source and build tree as
+well as performing the testing steps.  Run the ``ctest`` command
+with the current working directory set outside of any build tree
+and use one of these signatures::
+
+  ctest -S <script>
+  ctest -SP <script>
+
+The ``<script>`` file must call :ref:`CTest Commands` commands
+to run testing steps explicitly as documented below.  The commands
+obtain `Dashboard Client Configuration`_ settings from their
+arguments or from variables set in the script.
+
+Dashboard Client Configuration
+==============================
+
+The `Dashboard Client Steps`_ may be configured by named
+settings as documented in the following sections.
+
+.. _`CTest Start Step`:
+
+CTest Start Step
+----------------
+
+Start a new dashboard submission to be composed of results recorded
+by the following steps.
+
+In a `CTest Script`_, the :command:`ctest_start` command runs this step.
+Arguments to the command may specify some of the step settings.
+The command first runs the command-line specified by the
+``CTEST_CHECKOUT_COMMAND`` variable, if set, to initialize the source
+directory.
+
+Configuration settings include:
+
+``BuildDirectory``
+  The full path to the project build tree.
+
+  * `CTest Script`_ variable: :variable:`CTEST_BINARY_DIRECTORY`
+  * :module:`CTest` module variable: :variable:`PROJECT_BINARY_DIR`
+
+``SourceDirectory``
+  The full path to the project source tree.
+
+  * `CTest Script`_ variable: :variable:`CTEST_SOURCE_DIRECTORY`
+  * :module:`CTest` module variable: :variable:`PROJECT_SOURCE_DIR`
+
+.. _`CTest Update Step`:
+
+CTest Update Step
+-----------------
+
+In a `CTest Script`_, the :command:`ctest_update` command runs this step.
+Arguments to the command may specify some of the step settings.
+
+Configuration settings to specify the version control tool include:
+
+``BZRCommand``
+  ``bzr`` command-line tool to use if source tree is managed by Bazaar.
+
+  * `CTest Script`_ variable: :variable:`CTEST_BZR_COMMAND`
+  * :module:`CTest` module variable: none
+
+``BZRUpdateOptions``
+  Command-line options to the ``BZRCommand`` when updating the source.
+
+  * `CTest Script`_ variable: :variable:`CTEST_BZR_UPDATE_OPTIONS`
+  * :module:`CTest` module variable: none
+
+``CVSCommand``
+  ``cvs`` command-line tool to use if source tree is managed by CVS.
+
+  * `CTest Script`_ variable: :variable:`CTEST_CVS_COMMAND`
+  * :module:`CTest` module variable: ``CVSCOMMAND``
+
+``CVSUpdateOptions``
+  Command-line options to the ``CVSCommand`` when updating the source.
+
+  * `CTest Script`_ variable: :variable:`CTEST_CVS_UPDATE_OPTIONS`
+  * :module:`CTest` module variable: ``CVS_UPDATE_OPTIONS``
+
+``GITCommand``
+  ``git`` command-line tool to use if source tree is managed by Git.
+
+  * `CTest Script`_ variable: :variable:`CTEST_GIT_COMMAND`
+  * :module:`CTest` module variable: ``GITCOMMAND``
+
+``GITUpdateCustom``
+  Specify a semicolon-separated list of custom command lines to run
+  in the source tree (Git work tree) to update it instead of running
+  the ``GITCommand``.
+
+  * `CTest Script`_ variable: :variable:`CTEST_GIT_UPDATE_CUSTOM`
+  * :module:`CTest` module variable: ``CTEST_GIT_UPDATE_CUSTOM``
+
+``GITUpdateOptions``
+  Command-line options to the ``GITCommand`` when updating the source.
+
+  * `CTest Script`_ variable: :variable:`CTEST_GIT_UPDATE_OPTIONS`
+  * :module:`CTest` module variable: ``GIT_UPDATE_OPTIONS``
+
+``HGCommand``
+  ``hg`` command-line tool to use if source tree is managed by Mercurial.
+
+  * `CTest Script`_ variable: :variable:`CTEST_HG_COMMAND`
+  * :module:`CTest` module variable: none
+
+``HGUpdateOptions``
+  Command-line options to the ``HGCommand`` when updating the source.
+
+  * `CTest Script`_ variable: :variable:`CTEST_HG_UPDATE_OPTIONS`
+  * :module:`CTest` module variable: none
+
+``P4Client``
+  Value of the ``-c`` option to the ``P4Command``.
+
+  * `CTest Script`_ variable: :variable:`CTEST_P4_CLIENT`
+  * :module:`CTest` module variable: ``CTEST_P4_CLIENT``
+
+``P4Command``
+  ``p4`` command-line tool to use if source tree is managed by Perforce.
+
+  * `CTest Script`_ variable: :variable:`CTEST_P4_COMMAND`
+  * :module:`CTest` module variable: ``P4COMMAND``
+
+``P4Options``
+  Command-line options to the ``P4Command`` for all invocations.
+
+  * `CTest Script`_ variable: :variable:`CTEST_P4_OPTIONS`
+  * :module:`CTest` module variable: ``CTEST_P4_OPTIONS``
+
+``P4UpdateCustom``
+  Specify a semicolon-separated list of custom command lines to run
+  in the source tree (Perforce tree) to update it instead of running
+  the ``P4Command``.
+
+  * `CTest Script`_ variable: none
+  * :module:`CTest` module variable: ``CTEST_P4_UPDATE_CUSTOM``
+
+``P4UpdateOptions``
+  Command-line options to the ``P4Command`` when updating the source.
+
+  * `CTest Script`_ variable: :variable:`CTEST_P4_UPDATE_OPTIONS`
+  * :module:`CTest` module variable: ``CTEST_P4_UPDATE_OPTIONS``
+
+``SVNCommand``
+  ``svn`` command-line tool to use if source tree is managed by Subversion.
+
+  * `CTest Script`_ variable: :variable:`CTEST_SVN_COMMAND`
+  * :module:`CTest` module variable: ``SVNCOMMAND``
+
+``SVNOptions``
+  Command-line options to the ``SVNCommand`` for all invocations.
+
+  * `CTest Script`_ variable: :variable:`CTEST_SVN_OPTIONS`
+  * :module:`CTest` module variable: ``CTEST_SVN_OPTIONS``
+
+``SVNUpdateOptions``
+  Command-line options to the ``SVNCommand`` when updating the source.
+
+  * `CTest Script`_ variable: :variable:`CTEST_SVN_UPDATE_OPTIONS`
+  * :module:`CTest` module variable: ``SVN_UPDATE_OPTIONS``
+
+``UpdateCommand``
+  Specify the version-control command-line tool to use without
+  detecting the VCS that manages the source tree.
+
+  * `CTest Script`_ variable: :variable:`CTEST_UPDATE_COMMAND`
+  * :module:`CTest` module variable: ``<VCS>COMMAND``
+    when ``UPDATE_TYPE`` is ``<vcs>``, else ``UPDATE_COMMAND``
+
+``UpdateOptions``
+  Command-line options to the ``UpdateCommand``.
+
+  * `CTest Script`_ variable: :variable:`CTEST_UPDATE_OPTIONS`
+  * :module:`CTest` module variable: ``<VCS>_UPDATE_OPTIONS``
+    when ``UPDATE_TYPE`` is ``<vcs>``, else ``UPDATE_OPTIONS``
+
+``UpdateType``
+  Specify the version-control system that manages the source
+  tree if it cannot be detected automatically.
+  The value may be ``bzr``, ``cvs``, ``git``, ``hg``,
+  ``p4``, or ``svn``.
+
+  * `CTest Script`_ variable: none, detected from source tree
+  * :module:`CTest` module variable: ``UPDATE_TYPE`` if set,
+    else ``CTEST_UPDATE_TYPE``
+
+Additional configuration settings include:
+
+``NightlyStartTime``
+  In the ``Nightly`` dashboard mode, specify the "nightly start time".
+  With centralized version control systems (``cvs`` and ``svn``),
+  the ``Update`` step checks out the version of the software as of
+  this time so that multiple clients choose a common version to test.
+  This is not well-defined in distributed version-control systems so
+  the setting is ignored.
+
+  * `CTest Script`_ variable: :variable:`CTEST_NIGHTLY_START_TIME`
+  * :module:`CTest` module variable: ``NIGHTLY_START_TIME`` if set,
+    else ``CTEST_NIGHTLY_START_TIME``
+
+.. _`CTest Configure Step`:
+
+CTest Configure Step
+--------------------
+
+In a `CTest Script`_, the :command:`ctest_configure` command runs this step.
+Arguments to the command may specify some of the step settings.
+
+Configuration settings include:
+
+``ConfigureCommand``
+  Command-line to launch the software configuration process.
+  It will be executed in the location specified by the
+  ``BuildDirectory`` setting.
+
+  * `CTest Script`_ variable: :variable:`CTEST_CONFIGURE_COMMAND`
+  * :module:`CTest` module variable: :variable:`CMAKE_COMMAND`
+    followed by :variable:`PROJECT_SOURCE_DIR`
+
+.. _`CTest Build Step`:
+
+CTest Build Step
+----------------
+
+In a `CTest Script`_, the :command:`ctest_build` command runs this step.
+Arguments to the command may specify some of the step settings.
+
+Configuration settings include:
+
+``DefaultCTestConfigurationType``
+  When the build system to be launched allows build-time selection
+  of the configuration (e.g. ``Debug``, ``Release``), this specifies
+  the default configuration to be built when no ``-C`` option is
+  given to the ``ctest`` command.  The value will be substituted into
+  the value of ``MakeCommand`` to replace the literal string
+  ``${CTEST_CONFIGURATION_TYPE}`` if it appears.
+
+  * `CTest Script`_ variable: :variable:`CTEST_CONFIGURATION_TYPE`
+  * :module:`CTest` module variable: ``DEFAULT_CTEST_CONFIGURATION_TYPE``,
+    initialized by the ``CMAKE_CONFIG_TYPE`` environment variable
+
+``MakeCommand``
+  Command-line to launch the software build process.
+  It will be executed in the location specified by the
+  ``BuildDirectory`` setting.
+
+  * `CTest Script`_ variable: :variable:`CTEST_BUILD_COMMAND`
+  * :module:`CTest` module variable: ``MAKECOMMAND``,
+    initialized by the :command:`build_command` command
+
+``UseLaunchers``
+  For build trees generated by CMake using a Makefile generator
+  or the :generator:`Ninja` generator, specify whether the
+  ``CTEST_USE_LAUNCHERS`` feature is enabled by the
+  :module:`CTestUseLaunchers` module (also included by the
+  :module:`CTest` module).  When enabled, the generated build
+  system wraps each invocation of the compiler, linker, or
+  custom command line with a "launcher" that communicates
+  with CTest via environment variables and files to report
+  granular build warning and error information.  Otherwise,
+  CTest must "scrape" the build output log for diagnostics.
+
+  * `CTest Script`_ variable: :variable:`CTEST_USE_LAUNCHERS`
+  * :module:`CTest` module variable: ``CTEST_USE_LAUNCHERS``
+
+.. _`CTest Test Step`:
+
+CTest Test Step
+---------------
+
+In a `CTest Script`_, the :command:`ctest_test` command runs this step.
+Arguments to the command may specify some of the step settings.
+
+Configuration settings include:
+
+``TimeOut``
+  The default timeout for each test if not specified by the
+  :prop_test:`TIMEOUT` test property.
+
+  * `CTest Script`_ variable: :variable:`CTEST_TEST_TIMEOUT`
+  * :module:`CTest` module variable: ``DART_TESTING_TIMEOUT``
+
+.. _`CTest Coverage Step`:
+
+CTest Coverage Step
+-------------------
+
+In a `CTest Script`_, the :command:`ctest_coverage` command runs this step.
+Arguments to the command may specify some of the step settings.
+
+Configuration settings include:
+
+``CoverageCommand``
+  Command-line tool to perform software coverage analysis.
+  It will be executed in the location specified by the
+  ``BuildDirectory`` setting.
+
+  * `CTest Script`_ variable: :variable:`CTEST_COVERAGE_COMMAND`
+  * :module:`CTest` module variable: ``COVERAGE_COMMAND``
+
+``CoverageExtraFlags``
+  Specify command-line options to the ``CoverageCommand`` tool.
+
+  * `CTest Script`_ variable: :variable:`CTEST_COVERAGE_EXTRA_FLAGS`
+  * :module:`CTest` module variable: ``COVERAGE_EXTRA_FLAGS``
+
+.. _`CTest MemCheck Step`:
+
+CTest MemCheck Step
+-------------------
+
+In a `CTest Script`_, the :command:`ctest_memcheck` command runs this step.
+Arguments to the command may specify some of the step settings.
+
+Configuration settings include:
+
+``MemoryCheckCommand``
+  Command-line tool to perform dynamic analysis.  Test command lines
+  will be launched through this tool.
+
+  * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_COMMAND`
+  * :module:`CTest` module variable: ``MEMORYCHECK_COMMAND``
+
+``MemoryCheckCommandOptions``
+  Specify command-line options to the ``MemoryCheckCommand`` tool.
+  They will be placed prior to the test command line.
+
+  * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_COMMAND_OPTIONS`
+  * :module:`CTest` module variable: ``MEMORYCHECK_COMMAND_OPTIONS``
+
+``MemoryCheckSuppressionFile``
+  Specify a file containing suppression rules for the
+  ``MemoryCheckCommand`` tool.  It will be passed with options
+  appropriate to the tool.
+
+  * `CTest Script`_ variable: :variable:`CTEST_MEMORYCHECK_SUPPRESSIONS_FILE`
+  * :module:`CTest` module variable: ``MEMORYCHECK_SUPPRESSIONS_FILE``
+
+Additional configuration settings include:
+
+``BoundsCheckerCommand``
+  Specify a ``MemoryCheckCommand`` that is known to be command-line
+  compatible with Bounds Checker.
+
+  * `CTest Script`_ variable: none
+  * :module:`CTest` module variable: none
+
+``PurifyCommand``
+  Specify a ``MemoryCheckCommand`` that is known to be command-line
+  compatible with Purify.
+
+  * `CTest Script`_ variable: none
+  * :module:`CTest` module variable: ``PURIFYCOMMAND``
+
+``ValgrindCommand``
+  Specify a ``MemoryCheckCommand`` that is known to be command-line
+  compatible with Valgrind.
+
+  * `CTest Script`_ variable: none
+  * :module:`CTest` module variable: ``VALGRIND_COMMAND``
+
+``ValgrindCommandOptions``
+  Specify command-line options to the ``ValgrindCommand`` tool.
+  They will be placed prior to the test command line.
+
+  * `CTest Script`_ variable: none
+  * :module:`CTest` module variable: ``VALGRIND_COMMAND_OPTIONS``
+
+.. _`CTest Submit Step`:
+
+CTest Submit Step
+-----------------
+
+In a `CTest Script`_, the :command:`ctest_submit` command runs this step.
+Arguments to the command may specify some of the step settings.
+
+Configuration settings include:
+
+``BuildName``
+  Describe the dashboard client platform with a short string.
+  (Operating system, compiler, etc.)
+
+  * `CTest Script`_ variable: :variable:`CTEST_BUILD_NAME`
+  * :module:`CTest` module variable: ``BUILDNAME``
+
+``CDashVersion``
+  Specify the version of `CDash`_ on the server.
+
+  * `CTest Script`_ variable: none, detected from server
+  * :module:`CTest` module variable: ``CTEST_CDASH_VERSION``
+
+``CTestSubmitRetryCount``
+  Specify a number of attempts to retry submission on network failure.
+
+  * `CTest Script`_ variable: none,
+    use the :command:`ctest_submit` ``RETRY_COUNT`` option.
+  * :module:`CTest` module variable: ``CTEST_SUBMIT_RETRY_COUNT``
+
+``CTestSubmitRetryDelay``
+  Specify a delay before retrying submission on network failure.
+
+  * `CTest Script`_ variable: none,
+    use the :command:`ctest_submit` ``RETRY_DELAY`` option.
+  * :module:`CTest` module variable: ``CTEST_SUBMIT_RETRY_DELAY``
+
+``CurlOptions``
+  Specify a semicolon-separated list of options to control the
+  Curl library that CTest uses internally to connect to the
+  server.  Possible options are ``CURLOPT_SSL_VERIFYPEER_OFF``
+  and ``CURLOPT_SSL_VERIFYHOST_OFF``.
+
+  * `CTest Script`_ variable: :variable:`CTEST_CURL_OPTIONS`
+  * :module:`CTest` module variable: ``CTEST_CURL_OPTIONS``
+
+``DropLocation``
+  The path on the dashboard server to send the submission.
+
+  * `CTest Script`_ variable: :variable:`CTEST_DROP_LOCATION`
+  * :module:`CTest` module variable: ``DROP_LOCATION`` if set,
+    else ``CTEST_DROP_LOCATION``
+
+``DropMethod``
+  Specify the method by which results should be submitted to the
+  dashboard server.  The value may be ``cp``, ``ftp``, ``http``,
+  ``https``, ``scp``, or ``xmlrpc`` (if CMake was built with
+  support for it).
+
+  * `CTest Script`_ variable: :variable:`CTEST_DROP_METHOD`
+  * :module:`CTest` module variable: ``DROP_METHOD`` if set,
+    else ``CTEST_DROP_METHOD``
+
+``DropSite``
+  The dashboard server name
+  (for ``ftp``, ``http``, and ``https``, ``scp``, and ``xmlrpc``).
+
+  * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE`
+  * :module:`CTest` module variable: ``DROP_SITE`` if set,
+    else ``CTEST_DROP_SITE``
+
+``DropSitePassword``
+  The dashboard server login password, if any
+  (for ``ftp``, ``http``, and ``https``).
+
+  * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_PASSWORD`
+  * :module:`CTest` module variable: ``DROP_SITE_PASSWORD`` if set,
+    else ``CTEST_DROP_SITE_PASWORD``
+
+``DropSiteUser``
+  The dashboard server login user name, if any
+  (for ``ftp``, ``http``, and ``https``).
+
+  * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_USER`
+  * :module:`CTest` module variable: ``DROP_SITE_USER`` if set,
+    else ``CTEST_DROP_SITE_USER``
+
+``IsCDash``
+  Specify whether the dashboard server is `CDash`_ or an older
+  dashboard server implementation requiring ``TriggerSite``.
+
+  * `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_CDASH`
+  * :module:`CTest` module variable: ``CTEST_DROP_SITE_CDASH``
+
+``ScpCommand``
+  ``scp`` command-line tool to use when ``DropMethod`` is ``scp``.
+
+  * `CTest Script`_ variable: :variable:`CTEST_SCP_COMMAND`
+  * :module:`CTest` module variable: ``SCPCOMMAND``
+
+``Site``
+  Describe the dashboard client host site with a short string.
+  (Hostname, domain, etc.)
+
+  * `CTest Script`_ variable: :variable:`CTEST_SITE`
+  * :module:`CTest` module variable: ``SITE``,
+    initialized by the :command:`site_name` command
+
+``TriggerSite``
+  Legacy option to support older dashboard server implementations.
+  Not used when ``IsCDash`` is true.
+
+  * `CTest Script`_ variable: :variable:`CTEST_TRIGGER_SITE`
+  * :module:`CTest` module variable: ``TRIGGER_SITE`` if set,
+    else ``CTEST_TRIGGER_SITE``
+
 See Also
 ========
 
diff --git a/Help/module/FindOpenCL.rst b/Help/module/FindOpenCL.rst
new file mode 100644
index 0000000..e87e289
--- /dev/null
+++ b/Help/module/FindOpenCL.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindOpenCL.cmake
diff --git a/Help/module/WriteCompilerDetectionHeader.rst b/Help/module/WriteCompilerDetectionHeader.rst
new file mode 100644
index 0000000..4c81b48
--- /dev/null
+++ b/Help/module/WriteCompilerDetectionHeader.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/WriteCompilerDetectionHeader.cmake
diff --git a/Help/policy/CMP0010.rst b/Help/policy/CMP0010.rst
index 01699e1..9d2eb76 100644
--- a/Help/policy/CMP0010.rst
+++ b/Help/policy/CMP0010.rst
@@ -10,6 +10,9 @@
 to warn about the error, leave the string untouched, and continue.
 The NEW behavior for this policy is to report an error.
 
+If :policy:`CMP0053` is set to ``NEW``, this policy has no effect
+and is treated as always being ``NEW``.
+
 This policy was introduced in CMake version 2.6.3.  CMake version
 |release| warns when the policy is not set and uses OLD behavior.  Use
 the cmake_policy command to set it to OLD or NEW explicitly.
diff --git a/Help/policy/CMP0020.rst b/Help/policy/CMP0020.rst
index ad664b0..6767d08 100644
--- a/Help/policy/CMP0020.rst
+++ b/Help/policy/CMP0020.rst
@@ -16,7 +16,7 @@
 documentation.
 
 The OLD behavior for this policy is not to link executables to
-qtmain.lib automatically when they link to the QtCore IMPORTEDtarget.
+qtmain.lib automatically when they link to the QtCore IMPORTED target.
 The NEW behavior for this policy is to link executables to qtmain.lib
 automatically when they link to QtCore IMPORTED target.
 
diff --git a/Help/policy/CMP0051.rst b/Help/policy/CMP0051.rst
new file mode 100644
index 0000000..1b56cb0
--- /dev/null
+++ b/Help/policy/CMP0051.rst
@@ -0,0 +1,24 @@
+CMP0051
+-------
+
+List TARGET_OBJECTS in SOURCES target property.
+
+CMake 3.0 and lower did not include the ``TARGET_OBJECTS``
+:manual:`generator expression <cmake-generator-expressions(7)>` when
+returning the :prop_tgt:`SOURCES` target property.
+
+Configure-time CMake code is not able to handle generator expressions.  If
+using the :prop_tgt:`SOURCES` target property at configure time, it may be
+necessary to first remove generator expressions using the
+:command:`string(GENEX_STRIP)` command.  Generate-time CMake code such as
+:command:`file(GENERATE)` can handle the content without stripping.
+
+The ``OLD`` behavior for this policy is to omit ``TARGET_OBJECTS``
+expressions from the :prop_tgt:`SOURCES` target property.  The ``NEW``
+behavior for this policy is to include ``TARGET_OBJECTS`` expressions
+in the output.
+
+This policy was introduced in CMake version 3.1.
+CMake version |release| warns when the policy is not set and uses
+``OLD`` behavior.  Use the :command:`cmake_policy` command to set it
+to ``OLD`` or ``NEW`` explicitly.
diff --git a/Help/policy/CMP0052.rst b/Help/policy/CMP0052.rst
new file mode 100644
index 0000000..48cfc9c
--- /dev/null
+++ b/Help/policy/CMP0052.rst
@@ -0,0 +1,24 @@
+CMP0052
+-------
+
+Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES.
+
+CMake 3.0 and lower allowed subdirectories of the source directory or build
+directory to be in the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of
+installed and exported targets, if the directory was also a subdirectory of
+the installation prefix.  This makes the installation depend on the
+existence of the source dir or binary dir, and the installation will be
+broken if either are removed after installation.
+
+See :ref:`Include Directories and Usage Requirements` for more on
+specifying include directories for targets.
+
+The OLD behavior for this policy is to export the content of the
+:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` with the source or binary
+directory.  The NEW behavior for this
+policy is to issue an error if such a directory is used.
+
+This policy was introduced in CMake version 3.1.
+CMake version |release| warns when the policy is not set and uses
+``OLD`` behavior.  Use the :command:`cmake_policy` command to set it
+to ``OLD`` or ``NEW`` explicitly.
diff --git a/Help/policy/CMP0053.rst b/Help/policy/CMP0053.rst
new file mode 100644
index 0000000..fac430e
--- /dev/null
+++ b/Help/policy/CMP0053.rst
@@ -0,0 +1,44 @@
+CMP0053
+-------
+
+Simplify variable reference and escape sequence evaluation.
+
+CMake 3.1 introduced a much faster implementation of evaluation of the
+:ref:`Variable References` and :ref:`Escape Sequences` documented in the
+:manual:`cmake-language(7)` manual.  While the behavior is identical
+to the legacy implementation in most cases, some corner cases were
+cleaned up to simplify the behavior.  Specifically:
+
+* Expansion of ``@VAR@`` reference syntax defined by the
+  :command:`configure_file` and :command:`string(CONFIGURE)`
+  commands is no longer performed in other contexts.
+
+* Literal ``${VAR}`` reference syntax may contain only
+  alphanumeric characters (``A-Z``, ``a-z``, ``0-9``) and
+  the characters ``_``, ``.``, ``/``, ``-``, and ``+``.
+  Variables with other characters in their name may still
+  be referenced indirectly, e.g.
+
+  .. code-block:: cmake
+
+    set(varname "otherwise & disallowed $ characters")
+    message("${${varname}}")
+
+* The setting of policy :policy:`CMP0010` is not considered,
+  so improper variable reference syntax is always an error.
+
+* More characters are allowed to be escaped in variable names.
+  Previously, only ``()#" \#@^`` were valid characters to
+  escape. Now any non-alphanumeric, non-semicolon, non-NUL
+  character may be escaped following the ``escape_identity``
+  production in the :ref:`Escape Sequences` section of the
+  :manual:`cmake-language(7)` manual.
+
+The ``OLD`` behavior for this policy is to honor the legacy behavior for
+variable references and escape sequences.  The ``NEW`` behavior is to
+use the simpler variable expansion and escape sequence evaluation rules.
+
+This policy was introduced in CMake version 3.1.
+CMake version |release| warns when the policy is not set and uses
+``OLD`` behavior.  Use the :command:`cmake_policy` command to set
+it to ``OLD`` or ``NEW`` explicitly.
diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
new file mode 100644
index 0000000..bdeabdb
--- /dev/null
+++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
@@ -0,0 +1,298 @@
+CMAKE_CXX_KNOWN_FEATURES
+------------------------
+
+List of C++ features known to this version of CMake.
+
+The features listed in this global property may be known to be available to the
+C++ compiler.  If the feature is available with the C++ compiler, it will
+be listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable.
+
+The features listed here may be used with the :command:`target_compile_features`
+command.  See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+
+The features known to this version of CMake are:
+
+``cxx_aggregate_default_initializers``
+  Aggregate default initializers, as defined in N3605_.
+
+  .. _N3605: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3605.html
+
+``cxx_alias_templates``
+  Template aliases, as defined in N2258_.
+
+  .. _N2258: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
+
+``cxx_alignas``
+  Alignment control ``alignas``, as defined in N2341_.
+
+  .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
+
+``cxx_alignof``
+  Alignment control ``alignof``, as defined in N2341_.
+
+  .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
+
+``cxx_attributes``
+  Generic attributes, as defined in N2761_.
+
+  .. _N2761: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf
+
+``cxx_attribute_deprecated``
+  ``[[deprecated]]`` attribute, as defined in N3760_.
+
+  .. _N3760: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html
+
+``cxx_auto_type``
+  Automatic type deduction, as defined in N1984_.
+
+  .. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf
+
+``cxx_binary_literals``
+  Binary literals, as defined in N3472_.
+
+  .. _N3472: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf
+
+``cxx_constexpr``
+  Constant expressions, as defined in N2235_.
+
+  .. _N2235: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf
+
+``cxx_contextual_conversions``
+  Contextual conversions, as defined in N3323_.
+
+  .. _N3323: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3323.pdf
+
+``cxx_decltype_incomplete_return_types``
+  Decltype on incomplete return types, as defined in N3276_.
+
+  .. _N3276 : http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3276.pdf
+
+``cxx_decltype``
+  Decltype, as defined in N2343_.
+
+  .. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf
+
+``cxx_decltype_auto``
+  ``decltype(auto)`` semantics, as defined in N3638_.
+
+  .. _N3638: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3638.html
+
+``cxx_default_function_template_args``
+  Default template arguments for function templates, as defined in DR226_
+
+  .. _DR226: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226
+
+``cxx_defaulted_functions``
+  Defaulted functions, as defined in N2346_.
+
+  .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
+
+``cxx_defaulted_move_initializers``
+  Defaulted move initializers, as defined in N3053_.
+
+  .. _N3053: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html
+
+``cxx_delegating_constructors``
+  Delegating constructors, as defined in N1986_.
+
+  .. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf
+
+``cxx_deleted_functions``
+  Deleted functions, as defined in N2346_.
+
+  .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
+
+``cxx_digit_separators``
+  Digit separators, as defined in N3781_.
+
+  .. _N3781: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf
+
+``cxx_enum_forward_declarations``
+  Enum forward declarations, as defined in N2764_.
+
+  .. _N2764: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf
+
+``cxx_explicit_conversions``
+  Explicit conversion operators, as defined in N2437_.
+
+  .. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
+
+``cxx_extended_friend_declarations``
+  Extended friend declarations, as defined in N1791_.
+
+  .. _N1791: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf
+
+``cxx_extern_templates``
+  Extern templates, as defined in N1987_.
+
+  .. _N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
+
+``cxx_final``
+  Override control ``final`` keyword, as defined in N2928_.
+
+  .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
+
+``cxx_func_identifier``
+  Predefined ``__func__`` identifier, as defined in N2340_.
+
+  .. _N2340: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm
+
+``cxx_generalized_initializers``
+  Initializer lists, as defined in N2672_.
+
+  .. _N2672: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm
+
+``cxx_generic_lambdas``
+  Generic lambdas, ss defined in N3649_.
+
+  .. _N3649: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3649.html
+
+``cxx_inheriting_constructors``
+  Inheriting constructors, as defined in N2540_.
+
+  .. _N2540: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm
+
+``cxx_inline_namespaces``
+  Inline namespaces, as defined in N2535_.
+
+  .. _N2535: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm
+
+``cxx_lambdas``
+  Lambda functions, as defined in N2927_.
+
+  .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf
+
+``cxx_lambda_init_captures``
+  Initialized lambda captures, as defined in N3648_.
+
+  .. _N3648: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3648.html
+
+``cxx_local_type_template_args``
+  Local and unnamed types as template arguments, as defined in N2657_.
+
+  .. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
+
+``cxx_long_long_type``
+  ``long long`` type, as defined in N1811_.
+
+  .. _N1811: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf
+
+``cxx_noexcept``
+  Exception specifications, as defined in N3050_.
+
+  .. _N3050: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html
+
+``cxx_nonstatic_member_init``
+  Non-static data member initialization, as defined in N2756_.
+
+  .. _N2756: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2756.htm
+
+``cxx_nullptr``
+  Null pointer, as defined in N2431_.
+
+  .. _N2431: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
+
+``cxx_override``
+  Override control ``override`` keyword, as defined in N2928_.
+
+  .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
+
+``cxx_range_for``
+  Range-based for, as defined in N2930_.
+
+  .. _N2930: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html
+
+``cxx_raw_string_literals``
+  Raw string literals, as defined in N2442_.
+
+  .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
+
+``cxx_reference_qualified_functions``
+  Reference qualified functions, as defined in N2439_.
+
+  .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm
+
+``cxx_relaxed_constexpr``
+  Relaxed constexpr, as defined in N3652_.
+
+  .. _N3652: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html
+
+``cxx_return_type_deduction``
+  Return type deduction on normal functions, as defined in N3386_.
+
+  .. _N3386: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3386.html
+
+``cxx_right_angle_brackets``
+  Right angle bracket parsing, as defined in N1757_.
+
+  .. _N1757: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html
+
+``cxx_rvalue_references``
+  R-value references, as defined in N2118_.
+
+  .. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html
+
+``cxx_sizeof_member``
+  Size of non-static data members, as defined in N2253_.
+
+  .. _N2253: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html
+
+``cxx_static_assert``
+  Static assert, as defined in N1720_.
+
+  .. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html
+
+``cxx_strong_enums``
+  Strongly typed enums, as defined in N2347_.
+
+  .. _N2347: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
+
+``cxx_thread_local``
+  Thread-local variables, as defined in N2659_.
+
+  .. _N2659: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm
+
+``cxx_trailing_return_types``
+  Automatic function return type, as defined in N2541_.
+
+  .. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm
+
+``cxx_unicode_literals``
+  Unicode string literals, as defined in N2442_.
+
+  .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
+
+``cxx_uniform_initialization``
+  Uniform intialization, as defined in N2640_.
+
+  .. _N2640: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2640.pdf
+
+``cxx_unrestricted_unions``
+  Unrestricted unions, as defined in N2544_.
+
+  .. _N2544: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
+
+``cxx_user_literals``
+  User-defined literals, as defined in N2765_.
+
+  .. _N2765: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf
+
+``cxx_variable_templates``
+  Variable templates, as defined in N3651_.
+
+  .. _N3651: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3651.pdf
+
+``cxx_variadic_macros``
+  Variadic macros, as defined in N1653_.
+
+  .. _N1653: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm
+
+``cxx_variadic_templates``
+  Variadic templates, as defined in N2242_.
+
+  .. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf
+
+``cxx_template_template_parameters``
+  Template template parameters, as defined in ``ISO/IEC 14882:1998``.
diff --git a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
new file mode 100644
index 0000000..18cd030
--- /dev/null
+++ b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
@@ -0,0 +1,26 @@
+CMAKE_C_KNOWN_FEATURES
+----------------------
+
+List of C features known to this version of CMake.
+
+The features listed in this global property may be known to be available to the
+C compiler.  If the feature is available with the C compiler, it will
+be listed in the :variable:`CMAKE_C_COMPILE_FEATURES` variable.
+
+The features listed here may be used with the :command:`target_compile_features`
+command.  See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+The features known to this version of CMake are:
+
+``c_function_prototypes``
+  Function prototypes, as defined in ``ISO/IEC 9899:1990``.
+
+``c_restrict``
+  ``restrict`` keyword, as defined in ``ISO/IEC 9899:1999``.
+
+``c_static_assert``
+  Static assert, as defined in ``ISO/IEC 9899:2011``.
+
+``c_variadic_macros``
+  Variadic macros, as defined in ``ISO/IEC 9899:1999``.
diff --git a/Help/prop_inst/CPACK_NEVER_OVERWRITE.rst b/Help/prop_inst/CPACK_NEVER_OVERWRITE.rst
new file mode 100644
index 0000000..11f44d0
--- /dev/null
+++ b/Help/prop_inst/CPACK_NEVER_OVERWRITE.rst
@@ -0,0 +1,6 @@
+CPACK_NEVER_OVERWRITE
+---------------------
+
+Request that this file not be overwritten on install or reinstall.
+
+The property is currently only supported by the WIX generator.
diff --git a/Help/prop_inst/CPACK_PERMANENT.rst b/Help/prop_inst/CPACK_PERMANENT.rst
new file mode 100644
index 0000000..5e191d0
--- /dev/null
+++ b/Help/prop_inst/CPACK_PERMANENT.rst
@@ -0,0 +1,6 @@
+CPACK_PERMANENT
+---------------
+
+Request that this file not be removed on uninstall.
+
+The property is currently only supported by the WIX generator.
diff --git a/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst b/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst
new file mode 100644
index 0000000..1b24701
--- /dev/null
+++ b/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst
@@ -0,0 +1,8 @@
+XCODE_EXPLICIT_FILE_TYPE
+------------------------
+
+Set the Xcode ``explicitFileType`` attribute on its reference to a
+source file.  CMake computes a default based on file extension but
+can be told explicitly with this property.
+
+See also :prop_sf:`XCODE_LAST_KNOWN_FILE_TYPE`.
diff --git a/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst b/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst
new file mode 100644
index 0000000..42e3757
--- /dev/null
+++ b/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst
@@ -0,0 +1,9 @@
+XCODE_LAST_KNOWN_FILE_TYPE
+--------------------------
+
+Set the Xcode ``lastKnownFileType`` attribute on its reference to a
+source file.  CMake computes a default based on file extension but
+can be told explicitly with this property.
+
+See also :prop_sf:`XCODE_EXPLICIT_FILE_TYPE`, which is preferred
+over this property if set.
diff --git a/Help/prop_tgt/COMPILE_FEATURES.rst b/Help/prop_tgt/COMPILE_FEATURES.rst
new file mode 100644
index 0000000..225ffee
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_FEATURES.rst
@@ -0,0 +1,12 @@
+COMPILE_FEATURES
+----------------
+
+Compiler features enabled for this target.
+
+The list of features in this property are a subset of the features listed
+in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable.
+
+Contents of ``COMPILE_FEATURES`` may use "generator expressions" with the
+syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)` manual for
+available expressions.  See the :manual:`cmake-compile-features(7)` manual
+for information on compile features.
diff --git a/Help/prop_tgt/COMPILE_PDB_NAME.rst b/Help/prop_tgt/COMPILE_PDB_NAME.rst
new file mode 100644
index 0000000..24a9f62
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_NAME.rst
@@ -0,0 +1,11 @@
+COMPILE_PDB_NAME
+----------------
+
+Output name for the MS debug symbol ``.pdb`` file generated by the
+compiler while building source files.
+
+This property specifies the base name for the debug symbols file.
+If not set, the default is unspecified.
+
+.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME`
+.. include:: COMPILE_PDB_NOTE.txt
diff --git a/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst
new file mode 100644
index 0000000..e4077f5
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst
@@ -0,0 +1,10 @@
+COMPILE_PDB_NAME_<CONFIG>
+-------------------------
+
+Per-configuration output name for the MS debug symbol ``.pdb`` file
+generated by the compiler while building source files.
+
+This is the configuration-specific version of :prop_tgt:`COMPILE_PDB_NAME`.
+
+.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME_<CONFIG>`
+.. include:: COMPILE_PDB_NOTE.txt
diff --git a/Help/prop_tgt/COMPILE_PDB_NOTE.txt b/Help/prop_tgt/COMPILE_PDB_NOTE.txt
new file mode 100644
index 0000000..5941d72
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_NOTE.txt
@@ -0,0 +1,8 @@
+.. note::
+ The compiler-generated program database files are specified by the
+ ``/Fd`` compiler flag and are not the same as linker-generated
+ program database files specified by the ``/pdb`` linker flag.
+ Use the |PDB_XXX| property to specify the latter.
+
+ This property is not implemented by the :generator:`Visual Studio 6`
+ generator.
diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst
new file mode 100644
index 0000000..34f49be
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst
@@ -0,0 +1,13 @@
+COMPILE_PDB_OUTPUT_DIRECTORY
+----------------------------
+
+Output directory for the MS debug symbol ``.pdb`` file
+generated by the compiler while building source files.
+
+This property specifies the directory into which the MS debug symbols
+will be placed by the compiler.  This property is initialized by the
+value of the :variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY` variable
+if it is set when a target is created.
+
+.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY`
+.. include:: COMPILE_PDB_NOTE.txt
diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
new file mode 100644
index 0000000..52ef013
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
@@ -0,0 +1,16 @@
+COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
+-------------------------------------
+
+Per-configuration output directory for the MS debug symbol ``.pdb`` file
+generated by the compiler while building source files.
+
+This is a per-configuration version of
+:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`,
+but multi-configuration generators (VS, Xcode) do NOT append a
+per-configuration subdirectory to the specified directory.  This
+property is initialized by the value of the
+:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable
+if it is set when a target is created.
+
+.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY_<CONFIG>`
+.. include:: COMPILE_PDB_NOTE.txt
diff --git a/Help/prop_tgt/CXX_EXTENSIONS.rst b/Help/prop_tgt/CXX_EXTENSIONS.rst
new file mode 100644
index 0000000..67c5cb0
--- /dev/null
+++ b/Help/prop_tgt/CXX_EXTENSIONS.rst
@@ -0,0 +1,16 @@
+CXX_EXTENSIONS
+--------------
+
+Boolean specifying whether compiler specific extensions are requested.
+
+This property specifies whether compiler specific extensions should be
+used.  For some compilers, this results in adding a flag such
+as ``-std=gnu++11`` instead of ``-std=c++11`` to the compile line.  This
+property is ``ON`` by default.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+This property is initialized by the value of
+the :variable:`CMAKE_CXX_EXTENSIONS` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst
new file mode 100644
index 0000000..b50cdf9
--- /dev/null
+++ b/Help/prop_tgt/CXX_STANDARD.rst
@@ -0,0 +1,30 @@
+CXX_STANDARD
+------------
+
+The C++ standard whose features are requested to build this target.
+
+This property specifies the C++ standard whose features are requested
+to build this target.  For some compilers, this results in adding a
+flag such as ``-std=gnu++11`` to the compile line.
+
+Supported values are ``98`` and ``11``.
+
+If the value requested does not result in a compile flag being added for
+the compiler in use, a previous standard flag will be added instead.  This
+means that using:
+
+.. code-block:: cmake
+
+  set_property(TARGET tgt PROPERTY CXX_STANDARD 11)
+
+with a compiler which does not support ``-std=gnu++11`` or an equivalent
+flag will not result in an error or warning, but will instead add the
+``-std=gnu++98`` flag if supported.  This "decay" behavior may be controlled
+with the :prop_tgt:`CXX_STANDARD_REQUIRED` target property.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+This property is initialized by the value of
+the :variable:`CMAKE_CXX_STANDARD` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst
new file mode 100644
index 0000000..ac103a4
--- /dev/null
+++ b/Help/prop_tgt/CXX_STANDARD_REQUIRED.rst
@@ -0,0 +1,17 @@
+CXX_STANDARD_REQUIRED
+---------------------
+
+Boolean describing whether the value of :prop_tgt:`CXX_STANDARD` is a requirement.
+
+If this property is set to ``ON``, then the value of the
+:prop_tgt:`CXX_STANDARD` target property is treated as a requirement.  If this
+property is ``OFF`` or unset, the :prop_tgt:`CXX_STANDARD` target property is
+treated as optional and may "decay" to a previous standard if the requested is
+not available.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+This property is initialized by the value of
+the :variable:`CMAKE_CXX_STANDARD_REQUIRED` variable if it is set when a
+target is created.
diff --git a/Help/prop_tgt/C_EXTENSIONS.rst b/Help/prop_tgt/C_EXTENSIONS.rst
new file mode 100644
index 0000000..dc48cc6
--- /dev/null
+++ b/Help/prop_tgt/C_EXTENSIONS.rst
@@ -0,0 +1,16 @@
+C_EXTENSIONS
+------------
+
+Boolean specifying whether compiler specific extensions are requested.
+
+This property specifies whether compiler specific extensions should be
+used.  For some compilers, this results in adding a flag such
+as ``-std=gnu11`` instead of ``-std=c11`` to the compile line.  This
+property is ``ON`` by default.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+This property is initialized by the value of
+the :variable:`CMAKE_C_EXTENSIONS` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/C_STANDARD.rst b/Help/prop_tgt/C_STANDARD.rst
new file mode 100644
index 0000000..88ca926
--- /dev/null
+++ b/Help/prop_tgt/C_STANDARD.rst
@@ -0,0 +1,30 @@
+C_STANDARD
+----------
+
+The C standard whose features are requested to build this target.
+
+This property specifies the C standard whose features are requested
+to build this target.  For some compilers, this results in adding a
+flag such as ``-std=gnu11`` to the compile line.
+
+Supported values are ``90``, ``99`` and ``11``.
+
+If the value requested does not result in a compile flag being added for
+the compiler in use, a previous standard flag will be added instead.  This
+means that using:
+
+.. code-block:: cmake
+
+  set_property(TARGET tgt PROPERTY C_STANDARD 11)
+
+with a compiler which does not support ``-std=gnu11`` or an equivalent
+flag will not result in an error or warning, but will instead add the
+``-std=gnu99`` or ``-std=gnu90`` flag if supported.  This "decay" behavior may
+be controlled with the :prop_tgt:`C_STANDARD_REQUIRED` target property.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+This property is initialized by the value of
+the :variable:`CMAKE_C_STANDARD` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/C_STANDARD_REQUIRED.rst b/Help/prop_tgt/C_STANDARD_REQUIRED.rst
new file mode 100644
index 0000000..a7304f4
--- /dev/null
+++ b/Help/prop_tgt/C_STANDARD_REQUIRED.rst
@@ -0,0 +1,17 @@
+C_STANDARD_REQUIRED
+-------------------
+
+Boolean describing whether the value of :prop_tgt:`C_STANDARD` is a requirement.
+
+If this property is set to ``ON``, then the value of the
+:prop_tgt:`C_STANDARD` target property is treated as a requirement.  If this
+property is ``OFF`` or unset, the :prop_tgt:`C_STANDARD` target property is
+treated as optional and may "decay" to a previous standard if the requested is
+not available.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+This property is initialized by the value of
+the :variable:`CMAKE_C_STANDARD_REQUIRED` variable if it is set when a
+target is created.
diff --git a/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst b/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst
new file mode 100644
index 0000000..7abdecb
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst
@@ -0,0 +1,16 @@
+INTERFACE_COMPILE_FEATURES
+--------------------------
+
+List of public compile requirements for a library.
+
+Targets may populate this property to publish the compiler features
+required to compile against the headers for the target.  Consuming
+targets can add entries to their own :prop_tgt:`COMPILE_FEATURES`
+property such as ``$<TARGET_PROPERTY:foo,INTERFACE_COMPILE_FEATURES>``
+to require the features specified in the interface of ``foo``.
+
+Contents of ``INTERFACE_COMPILE_FEATURES`` may use "generator expressions"
+with the syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions.  See the
+:manual:`cmake-compile-features(7)` manual for information on compile
+features.
diff --git a/Help/prop_tgt/INTERFACE_SOURCES.rst b/Help/prop_tgt/INTERFACE_SOURCES.rst
new file mode 100644
index 0000000..fb28231
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_SOURCES.rst
@@ -0,0 +1,15 @@
+INTERFACE_SOURCES
+-----------------
+
+List of interface sources to pass to the compiler.
+
+Targets may populate this property to publish the sources
+for consuming targets to compile.  Consuming
+targets can add entries to their own :prop_tgt:`SOURCES` property
+such as ``$<TARGET_PROPERTY:foo,INTERFACE_SOURCES>`` to use the
+sources specified in the interface of ``foo``.
+
+Contents of ``INTERFACE_SOURCES`` may use "generator expressions"
+with the syntax ``$<...>``.  See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions.  See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
diff --git a/Help/prop_tgt/PDB_NAME.rst b/Help/prop_tgt/PDB_NAME.rst
index e8fc3be..479dec3 100644
--- a/Help/prop_tgt/PDB_NAME.rst
+++ b/Help/prop_tgt/PDB_NAME.rst
@@ -7,7 +7,5 @@
 This property specifies the base name for the debug symbols file.
 If not set, the logical target name is used by default.
 
+.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME`
 .. include:: PDB_NOTE.txt
-
-This property is not implemented by the :generator:`Visual Studio 6`
-generator.
diff --git a/Help/prop_tgt/PDB_NAME_CONFIG.rst b/Help/prop_tgt/PDB_NAME_CONFIG.rst
index c846b57..cb3121c 100644
--- a/Help/prop_tgt/PDB_NAME_CONFIG.rst
+++ b/Help/prop_tgt/PDB_NAME_CONFIG.rst
@@ -6,5 +6,5 @@
 
 This is the configuration-specific version of :prop_tgt:`PDB_NAME`.
 
-This property is not implemented by the :generator:`Visual Studio 6`
-generator.
+.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME_<CONFIG>`
+.. include:: PDB_NOTE.txt
diff --git a/Help/prop_tgt/PDB_NOTE.txt b/Help/prop_tgt/PDB_NOTE.txt
index e55aba2..f90ea81 100644
--- a/Help/prop_tgt/PDB_NOTE.txt
+++ b/Help/prop_tgt/PDB_NOTE.txt
@@ -3,6 +3,10 @@
  is invoked to produce them so they have no linker-generated ``.pdb`` file
  containing debug symbols.
 
- The compiler-generated program database files specified by the MSVC
- ``/Fd`` flag are not the same as linker-generated program database
- files and so are not influenced by this property.
+ The linker-generated program database files are specified by the
+ ``/pdb`` linker flag and are not the same as compiler-generated
+ program database files specified by the ``/Fd`` compiler flag.
+ Use the |COMPILE_PDB_XXX| property to specify the latter.
+
+ This property is not implemented by the :generator:`Visual Studio 6`
+ generator.
diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
index 9a863a1..730cf57 100644
--- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
+++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
@@ -9,7 +9,5 @@
 value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is
 set when a target is created.
 
+.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`
 .. include:: PDB_NOTE.txt
-
-This property is not implemented by the :generator:`Visual Studio 6`
-generator.
diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
index caec2de..6037fa0 100644
--- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
+++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
@@ -11,5 +11,5 @@
 :variable:`CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable if it is
 set when a target is created.
 
-This property is not implemented by the :generator:`Visual Studio 6`
-generator.
+.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
+.. include:: PDB_NOTE.txt
diff --git a/Help/prop_tgt/SOURCES.rst b/Help/prop_tgt/SOURCES.rst
index 833b65a..493643e 100644
--- a/Help/prop_tgt/SOURCES.rst
+++ b/Help/prop_tgt/SOURCES.rst
@@ -3,5 +3,4 @@
 
 Source names specified for a target.
 
-Read-only list of sources specified for a target.  The names returned
-are suitable for passing to the set_source_files_properties command.
+List of sources specified for a target.
diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst
new file mode 100644
index 0000000..e4cc01e
--- /dev/null
+++ b/Help/release/dev/0-sample-topic.rst
@@ -0,0 +1,7 @@
+0-sample-topic
+--------------
+
+* This is a sample release note for the change in a topic.
+  Developers should add similar notes for each topic branch
+  making a noteworthy change.  Each document should be named
+  and titled to match the topic name to avoid merge conflicts.
diff --git a/Help/release/dev/CMP0052.rst b/Help/release/dev/CMP0052.rst
new file mode 100644
index 0000000..adb3d44
--- /dev/null
+++ b/Help/release/dev/CMP0052.rst
@@ -0,0 +1,5 @@
+CMP0052
+-------
+
+* Policy :policy:`CMP0052` introduced to control directories in the
+  :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of exported targets.
diff --git a/Help/release/dev/CMP0053.rst b/Help/release/dev/CMP0053.rst
new file mode 100644
index 0000000..3b835fb
--- /dev/null
+++ b/Help/release/dev/CMP0053.rst
@@ -0,0 +1,6 @@
+CMP0053
+-------
+
+* The :manual:`cmake-language(7)` syntax for :ref:`Variable References` and
+  :ref:`Escape Sequences` was simplified in order to allow a much faster
+  implementation.  See policy :policy:`CMP0053`.
diff --git a/Help/release/dev/CMakeDetermineVSServicePack.rst b/Help/release/dev/CMakeDetermineVSServicePack.rst
new file mode 100644
index 0000000..d9d7b41
--- /dev/null
+++ b/Help/release/dev/CMakeDetermineVSServicePack.rst
@@ -0,0 +1,6 @@
+CMakeDetermineVSServicePack
+---------------------------
+
+* The :module:`CMakeDetermineVSServicePack` module now warns that
+  it is deprecated and should not longer be used.  Use the
+  :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable instead.
diff --git a/Help/release/dev/ExternalData-missing-not-fatal.rst b/Help/release/dev/ExternalData-missing-not-fatal.rst
new file mode 100644
index 0000000..e9f1f04
--- /dev/null
+++ b/Help/release/dev/ExternalData-missing-not-fatal.rst
@@ -0,0 +1,8 @@
+ExternalData-missing-not-fatal
+------------------------------
+
+* The :module:`ExternalData` module learned to tolerate a ``DATA{}``
+  reference to a missing source file with a warning instead of
+  rejecting it with an error.  This helps developers write new
+  ``DATA{}`` references to test reference outputs that have not
+  yet been created.
diff --git a/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst b/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst
new file mode 100644
index 0000000..5384671
--- /dev/null
+++ b/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst
@@ -0,0 +1,6 @@
+ExternalProject-BUILD_ALWAYS
+----------------------------
+
+* The :module:`ExternalProject` module ``ExternalProject_Add`` command
+  learned a new ``BUILD_ALWAYS`` option to cause the external project
+  build step to run every time the host project is built.
diff --git a/Help/release/dev/ExternalProject-no-download-progress.rst b/Help/release/dev/ExternalProject-no-download-progress.rst
new file mode 100644
index 0000000..41db55d
--- /dev/null
+++ b/Help/release/dev/ExternalProject-no-download-progress.rst
@@ -0,0 +1,6 @@
+ExternalProject-no-download-progress
+------------------------------------
+
+* The :module:`ExternalProject` module ``ExternalProject_Add`` command
+  learned a new ``DOWNLOAD_NO_PROGRESS`` option to disable progress
+  output while downloading the source tarball.
diff --git a/Help/release/dev/ExternalProject_exclude-from-all.rst b/Help/release/dev/ExternalProject_exclude-from-all.rst
new file mode 100644
index 0000000..1d62b3a
--- /dev/null
+++ b/Help/release/dev/ExternalProject_exclude-from-all.rst
@@ -0,0 +1,11 @@
+ExternalProject_exclude-from-all
+--------------------------------
+
+* The :module:`ExternalProject` module ``ExternalProject_Add`` command
+  learned a new ``EXCLUDE_FROM_ALL`` option to cause the external
+  project target to have the :prop_tgt:`EXCLUDE_FROM_ALL` target
+  property set.
+
+* The :module:`ExternalProject` module ``ExternalProject_Add_Step`` command
+  learned a new ``EXCLUDE_FROM_MAIN`` option to cause the step to not be
+  a direct dependency of the main external project target.
diff --git a/Help/release/dev/FeatureSummary_combine_WHAT_values.rst b/Help/release/dev/FeatureSummary_combine_WHAT_values.rst
new file mode 100644
index 0000000..174ef15
--- /dev/null
+++ b/Help/release/dev/FeatureSummary_combine_WHAT_values.rst
@@ -0,0 +1,6 @@
+FeatureSummary_combine_WHAT_values
+----------------------------------
+
+* The :module:`FeatureSummary` module ``feature_summary`` API
+  learned to accept multiple values for the ``WHAT`` option and
+  combine them appropriately.
diff --git a/Help/release/dev/FindCUDA-cubin-fatbin.rst b/Help/release/dev/FindCUDA-cubin-fatbin.rst
new file mode 100644
index 0000000..d44da8e
--- /dev/null
+++ b/Help/release/dev/FindCUDA-cubin-fatbin.rst
@@ -0,0 +1,5 @@
+FindCUDA-cubin-fatbin
+---------------------
+
+* The :module:`FindCUDA` module learned to support ``fatbin`` and ``cubin``
+  modules.
diff --git a/Help/release/dev/FindGTest-AUTO-SOURCES.rst b/Help/release/dev/FindGTest-AUTO-SOURCES.rst
new file mode 100644
index 0000000..17b2a1b
--- /dev/null
+++ b/Help/release/dev/FindGTest-AUTO-SOURCES.rst
@@ -0,0 +1,7 @@
+FindGTest-AUTO-SOURCES
+----------------------
+
+* The :module:`FindGTest` module ``gtest_add_tests`` macro learned
+  a new ``AUTO`` option to automatically read the :prop_tgt:`SOURCES`
+  target property of the test executable and scan the source files
+  for tests to be added.
diff --git a/Help/release/dev/FindHg-WC_INFO.rst b/Help/release/dev/FindHg-WC_INFO.rst
new file mode 100644
index 0000000..0caf2b3
--- /dev/null
+++ b/Help/release/dev/FindHg-WC_INFO.rst
@@ -0,0 +1,5 @@
+FindHg-WC_INFO
+--------------
+
+* The :module:`FindHg` module gained a new ``Hg_WC_INFO`` macro to
+  help run ``hg`` to extract information about a Mercurial work copy.
diff --git a/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst b/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst
new file mode 100644
index 0000000..c0f6471
--- /dev/null
+++ b/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst
@@ -0,0 +1,5 @@
+FindPkgConfig-PKG_CONFIG
+------------------------
+
+* The :module:`FindPkgConfig` module learned to use the ``PKG_CONFIG``
+  environment variable value as the ``pkg-config`` executable, if set.
diff --git a/Help/release/dev/OpenWatcom.rst b/Help/release/dev/OpenWatcom.rst
new file mode 100644
index 0000000..63f6e8c
--- /dev/null
+++ b/Help/release/dev/OpenWatcom.rst
@@ -0,0 +1,9 @@
+OpenWatcom
+----------
+
+* Support for the Open Watcom compiler has been overhauled.
+  The :variable:`CMAKE_<LANG>_COMPILER_ID` is now ``OpenWatcom``,
+  and the :variable:`CMAKE_<LANG>_COMPILER_VERSION` now uses
+  the Open Watcom external version numbering.  The external
+  version numbers are lower than the internal version number
+  by 11.
diff --git a/Help/release/dev/UseSWIG-guess_module_name.rst b/Help/release/dev/UseSWIG-guess_module_name.rst
new file mode 100644
index 0000000..c895046
--- /dev/null
+++ b/Help/release/dev/UseSWIG-guess_module_name.rst
@@ -0,0 +1,6 @@
+UseSWIG-guess_module_name
+-------------------------
+
+* The :module:`UseSWIG` module learned to detect the module name
+  from ``.i`` source files if possible to avoid the need to set
+  the ``SWIG_MODULE_NAME`` source file property explicitly.
diff --git a/Help/release/dev/add-FindOpenCL.rst b/Help/release/dev/add-FindOpenCL.rst
new file mode 100644
index 0000000..e1e30d1
--- /dev/null
+++ b/Help/release/dev/add-FindOpenCL.rst
@@ -0,0 +1,4 @@
+add-FindOpenCL
+--------------
+
+* The :module:`FindOpenCL` module was introduced.
diff --git a/Help/release/dev/add_custom_command-DEPENDS-genex.rst b/Help/release/dev/add_custom_command-DEPENDS-genex.rst
new file mode 100644
index 0000000..1e528e6
--- /dev/null
+++ b/Help/release/dev/add_custom_command-DEPENDS-genex.rst
@@ -0,0 +1,5 @@
+add_custom_command-DEPENDS-genex
+--------------------------------
+
+* The :command:`add_custom_command` command learned to interpret
+  :manual:`cmake-generator-expressions(7)` in arguments to ``DEPENDS``.
diff --git a/Help/release/dev/cmake-gui-capture-output.rst b/Help/release/dev/cmake-gui-capture-output.rst
new file mode 100644
index 0000000..40cd25e
--- /dev/null
+++ b/Help/release/dev/cmake-gui-capture-output.rst
@@ -0,0 +1,6 @@
+cmake-gui-capture-output
+------------------------
+
+* The :manual:`cmake-gui(1)` learned to capture output from child
+  processes started by the :command:`execute_process` command
+  and display it in the output window.
diff --git a/Help/release/dev/compile-language-features.rst b/Help/release/dev/compile-language-features.rst
new file mode 100644
index 0000000..d10e22b
--- /dev/null
+++ b/Help/release/dev/compile-language-features.rst
@@ -0,0 +1,28 @@
+target-language-features
+------------------------
+
+* New :prop_tgt:`CXX_STANDARD` and :prop_tgt:`CXX_EXTENSIONS` target
+  properties may specify values which CMake uses to compute required
+  compile options such as ``-std=c++11`` or ``-std=gnu++11``. The
+  :variable:`CMAKE_CXX_STANDARD` and :variable:`CMAKE_CXX_EXTENSIONS`
+  variables may be set to initialize the target properties.
+
+* New :prop_tgt:`C_STANDARD` and :prop_tgt:`C_EXTENSIONS` target
+  properties may specify values which CMake uses to compute required
+  compile options such as ``-std=c11`` or ``-std=gnu11``. The
+  :variable:`CMAKE_C_STANDARD` and :variable:`CMAKE_C_EXTENSIONS`
+  variables may be set to initialize the target properties.
+
+* New :prop_tgt:`COMPILE_FEATURES` target property may contain a list
+  of features required to compile a target.  CMake uses this
+  information to ensure that the compiler in use is capable of building
+  the target, and to add any necessary compile flags to support language
+  features.
+
+* New :command:`target_compile_features` command allows populating the
+  :prop_tgt:`COMPILE_FEATURES` target property, just like any other
+  build variable.
+
+* New ``COMPILE_FEATURES``
+  :manual:`generator expression <cmake-generator-expressions(7)>` allows
+  setting build properties based on available compiler features.
diff --git a/Help/release/dev/cpack-deb-compression-types.rst b/Help/release/dev/cpack-deb-compression-types.rst
new file mode 100644
index 0000000..a33e333
--- /dev/null
+++ b/Help/release/dev/cpack-deb-compression-types.rst
@@ -0,0 +1,6 @@
+cpack-deb-compression-types
+---------------------------
+
+* The :module:`CPackDeb` module learned a new
+  :variable:`CPACK_DEBIAN_COMPRESSION_TYPE` variable to set the
+  tarball compression type.
diff --git a/Help/release/dev/ctest-coverage-extra.rst b/Help/release/dev/ctest-coverage-extra.rst
new file mode 100644
index 0000000..85d023b
--- /dev/null
+++ b/Help/release/dev/ctest-coverage-extra.rst
@@ -0,0 +1,5 @@
+ctest-coverage-extra
+--------------------
+
+* The :command:`ctest_coverage` command learned to read variable
+  ``CTEST_COVERAGE_EXTRA_FLAGS`` to set ``CoverageExtraFlags``.
diff --git a/Help/release/dev/ctest-intel-coverage.rst b/Help/release/dev/ctest-intel-coverage.rst
new file mode 100644
index 0000000..11455a5
--- /dev/null
+++ b/Help/release/dev/ctest-intel-coverage.rst
@@ -0,0 +1,5 @@
+ctest-intel-coverage
+--------------------
+
+* The :command:`ctest_coverage` command learned to support
+  Intel coverage files with the ``codecov`` tool.
diff --git a/Help/release/dev/custom-ninja-deptypes.rst b/Help/release/dev/custom-ninja-deptypes.rst
new file mode 100644
index 0000000..7750da8
--- /dev/null
+++ b/Help/release/dev/custom-ninja-deptypes.rst
@@ -0,0 +1,5 @@
+custom-ninja-deptypes
+---------------------
+
+* Add a `CMAKE_NINJA_DEPTYPE_<LANG>` variable so that compilers may set the
+  deptype for use in Ninja other than those CMake itself knows about.
diff --git a/Help/release/dev/delay-generator-toolset.rst b/Help/release/dev/delay-generator-toolset.rst
new file mode 100644
index 0000000..0512834
--- /dev/null
+++ b/Help/release/dev/delay-generator-toolset.rst
@@ -0,0 +1,8 @@
+delay-generator-toolset
+-----------------------
+
+* The :variable:`CMAKE_GENERATOR_TOOLSET` variable may now be
+  initialized in a toolchain file specified by the
+  :variable:`CMAKE_TOOLCHAIN_FILE` variable.  This is useful
+  when cross-compiling with the Xcode or Visual Studio
+  generators.
diff --git a/Help/release/dev/faster-parsers.rst b/Help/release/dev/faster-parsers.rst
new file mode 100644
index 0000000..c2a8bfb
--- /dev/null
+++ b/Help/release/dev/faster-parsers.rst
@@ -0,0 +1,6 @@
+faster-parsers
+--------------
+
+* The :manual:`cmake-language(7)` internal implementation of generator
+  expression and list expansion parsers have been optimized and shows
+  non-trivial speedup on large projects.
diff --git a/Help/release/dev/link-libraries-response-files.rst b/Help/release/dev/link-libraries-response-files.rst
new file mode 100644
index 0000000..cecf7f6
--- /dev/null
+++ b/Help/release/dev/link-libraries-response-files.rst
@@ -0,0 +1,5 @@
+link-libraries-response-files
+-----------------------------
+
+* The Makefile generators learned to use response files with GNU tools
+  on Windows to pass library directories and names to the linker.
diff --git a/Help/release/dev/module-WriteCompilerDetectionHeader.rst b/Help/release/dev/module-WriteCompilerDetectionHeader.rst
new file mode 100644
index 0000000..10e7b86
--- /dev/null
+++ b/Help/release/dev/module-WriteCompilerDetectionHeader.rst
@@ -0,0 +1,5 @@
+module-WriteCompilerDetectionHeader
+-----------------------------------
+
+* The :module:`WriteCompilerDetectionHeader` module was added to allow
+  creation of a portable header file for compiler optional feature detection.
diff --git a/Help/release/dev/msvc-compiler-pdb-files.rst b/Help/release/dev/msvc-compiler-pdb-files.rst
new file mode 100644
index 0000000..d06d202
--- /dev/null
+++ b/Help/release/dev/msvc-compiler-pdb-files.rst
@@ -0,0 +1,10 @@
+msvc-compiler-pdb-files
+-----------------------
+
+* New :prop_tgt:`COMPILE_PDB_NAME` and
+  :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` target properties
+  were introduced to specify the MSVC compiler program database
+  file location (``cl /Fd``).  This complements the existing
+  :prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY`
+  target properties that specify the linker program database
+  file location (``link /pdb``).
diff --git a/Help/release/dev/package-disable-registry.rst b/Help/release/dev/package-disable-registry.rst
new file mode 100644
index 0000000..1b23fde
--- /dev/null
+++ b/Help/release/dev/package-disable-registry.rst
@@ -0,0 +1,11 @@
+package-disable-registry
+------------------------
+
+* The :command:`export(PACKAGE)` command learned to check the
+  :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable to skip
+  exporting the package.
+
+* The :command:`find_package` command learned to check the
+  :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` and
+  :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY`
+  variables to skip searching the package registries.
diff --git a/Help/release/dev/string-GENEX_STRIP.rst b/Help/release/dev/string-GENEX_STRIP.rst
new file mode 100644
index 0000000..b5b1074
--- /dev/null
+++ b/Help/release/dev/string-GENEX_STRIP.rst
@@ -0,0 +1,6 @@
+string-GENEX_STRIP
+------------------
+
+* The :command:`string` command learned a new ``GENEX_STRIP`` subcommand
+  which removes
+  :manual:`generator expression <cmake-generator-expressions(7)>`.
diff --git a/Help/release/dev/target-INTERFACE_SOURCES.rst b/Help/release/dev/target-INTERFACE_SOURCES.rst
new file mode 100644
index 0000000..4e34943
--- /dev/null
+++ b/Help/release/dev/target-INTERFACE_SOURCES.rst
@@ -0,0 +1,5 @@
+target-INTERFACE_SOURCES
+------------------------
+
+* A new :prop_tgt:`INTERFACE_SOURCES` target property was introduced. This is
+  consumed by dependent targets, which compile and link the listed sources.
diff --git a/Help/release/dev/target-SOURCES-genex.rst b/Help/release/dev/target-SOURCES-genex.rst
new file mode 100644
index 0000000..9a65101
--- /dev/null
+++ b/Help/release/dev/target-SOURCES-genex.rst
@@ -0,0 +1,12 @@
+target-SOURCES-genex
+--------------------
+
+* The :prop_tgt:`SOURCES` target property now contains
+  :manual:`generator expression <cmake-generator-expressions(7)>`
+  such as ``TARGET_OBJECTS`` when read at configure time, if
+  policy :policy:`CMP0051` is ``NEW``.
+
+* The :prop_tgt:`SOURCES` target property now generally supports
+  :manual:`generator expression <cmake-generator-expressions(7)>`.  The
+  generator expressions may be used in the :command:`add_library` and
+  :command:`add_executable` commands.
diff --git a/Help/release/dev/target-SOURCES-write.rst b/Help/release/dev/target-SOURCES-write.rst
new file mode 100644
index 0000000..a754a73
--- /dev/null
+++ b/Help/release/dev/target-SOURCES-write.rst
@@ -0,0 +1,6 @@
+target-SOURCES-write.rst
+------------------------
+
+* It is now possible to write and append to the :prop_tgt:`SOURCES` target
+  property.  The :variable:`CMAKE_DEBUG_TARGET_PROPERTIES` variable may be
+  used to trace the origin of sources.
diff --git a/Help/release/dev/target_sources-command.rst b/Help/release/dev/target_sources-command.rst
new file mode 100644
index 0000000..abfb303
--- /dev/null
+++ b/Help/release/dev/target_sources-command.rst
@@ -0,0 +1,5 @@
+target_sources-command
+----------------------
+
+* The :command:`target_sources` command was added to add to the
+  :prop_tgt:`SOURCES` target property.
diff --git a/Help/release/dev/variable_watch-no-allowed-access.rst b/Help/release/dev/variable_watch-no-allowed-access.rst
new file mode 100644
index 0000000..ba7b4a5
--- /dev/null
+++ b/Help/release/dev/variable_watch-no-allowed-access.rst
@@ -0,0 +1,8 @@
+variable_watch-no-allowed-access
+--------------------------------
+
+* Callbacks established by the :command:`variable_watch` command will no
+  longer receive the ``ALLOWED_UNKNOWN_READ_ACCESS`` access type when
+  the undocumented ``CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS`` variable is
+  set.  Uninitialized variable accesses will always be reported as
+  ``UNKNOWN_READ_ACCESS``.
diff --git a/Help/release/dev/xcode-file-type.rst b/Help/release/dev/xcode-file-type.rst
new file mode 100644
index 0000000..6f637f7
--- /dev/null
+++ b/Help/release/dev/xcode-file-type.rst
@@ -0,0 +1,7 @@
+xcode-file-type
+---------------
+
+* The :generator:`Xcode` generator learned to check source
+  file properties  :prop_sf:`XCODE_EXPLICIT_FILE_TYPE` and
+  :prop_sf:`XCODE_LAST_KNOWN_FILE_TYPE` for a custom Xcode
+  file reference type.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 752c568..15ce065 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -5,6 +5,8 @@
   This file should include the adjacent "dev.txt" file
   in development versions but not in release versions.
 
+.. include:: dev.txt
+
 Releases
 ========
 
diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst
new file mode 100644
index 0000000..ea33c7d
--- /dev/null
+++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst
@@ -0,0 +1,8 @@
+CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
+----------------------------------
+
+Output directory for MS debug symbol ``.pdb`` files
+generated by the compiler while building source files.
+
+This variable is used to initialize the
+:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` property on all the targets.
diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
new file mode 100644
index 0000000..fdeb9ab
--- /dev/null
+++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
@@ -0,0 +1,11 @@
+CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
+-------------------------------------------
+
+Per-configuration output directory for MS debug symbol ``.pdb`` files
+generated by the compiler while building source files.
+
+This is a per-configuration version of
+:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY`.
+This variable is used to initialize the
+:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
+property on all the targets.
diff --git a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
new file mode 100644
index 0000000..460c78c
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
@@ -0,0 +1,11 @@
+CMAKE_CXX_COMPILE_FEATURES
+--------------------------
+
+List of features known to the C++ compiler
+
+These features are known to be available for use with the C++ compiler. This
+list is a subset of the features listed in the :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES`
+global property.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
diff --git a/Help/variable/CMAKE_CXX_EXTENSIONS.rst b/Help/variable/CMAKE_CXX_EXTENSIONS.rst
new file mode 100644
index 0000000..6448371
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_EXTENSIONS.rst
@@ -0,0 +1,11 @@
+CMAKE_CXX_EXTENSIONS
+--------------------
+
+Default value for ``CXX_EXTENSIONS`` property of targets.
+
+This variable is used to initialize the :prop_tgt:`CXX_EXTENSIONS`
+property on all targets.  See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
diff --git a/Help/variable/CMAKE_CXX_STANDARD.rst b/Help/variable/CMAKE_CXX_STANDARD.rst
new file mode 100644
index 0000000..963a42a
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_STANDARD.rst
@@ -0,0 +1,11 @@
+CMAKE_CXX_STANDARD
+------------------
+
+Default value for ``CXX_STANDARD`` property of targets.
+
+This variable is used to initialize the :prop_tgt:`CXX_STANDARD`
+property on all targets.  See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
diff --git a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst
new file mode 100644
index 0000000..f7750fa
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst
@@ -0,0 +1,11 @@
+CMAKE_CXX_STANDARD_REQUIRED
+---------------------------
+
+Default value for ``CXX_STANDARD_REQUIRED`` property of targets.
+
+This variable is used to initialize the :prop_tgt:`CXX_STANDARD_REQUIRED`
+property on all targets.  See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
diff --git a/Help/variable/CMAKE_C_COMPILE_FEATURES.rst b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst
new file mode 100644
index 0000000..1106246
--- /dev/null
+++ b/Help/variable/CMAKE_C_COMPILE_FEATURES.rst
@@ -0,0 +1,11 @@
+CMAKE_C_COMPILE_FEATURES
+------------------------
+
+List of features known to the C compiler
+
+These features are known to be available for use with the C compiler. This
+list is a subset of the features listed in the :prop_gbl:`CMAKE_C_KNOWN_FEATURES`
+global property.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
diff --git a/Help/variable/CMAKE_C_EXTENSIONS.rst b/Help/variable/CMAKE_C_EXTENSIONS.rst
new file mode 100644
index 0000000..5e935fc
--- /dev/null
+++ b/Help/variable/CMAKE_C_EXTENSIONS.rst
@@ -0,0 +1,11 @@
+CMAKE_C_EXTENSIONS
+------------------
+
+Default value for ``C_EXTENSIONS`` property of targets.
+
+This variable is used to initialize the :prop_tgt:`C_EXTENSIONS`
+property on all targets.  See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
diff --git a/Help/variable/CMAKE_C_STANDARD.rst b/Help/variable/CMAKE_C_STANDARD.rst
new file mode 100644
index 0000000..3098ce5
--- /dev/null
+++ b/Help/variable/CMAKE_C_STANDARD.rst
@@ -0,0 +1,11 @@
+CMAKE_C_STANDARD
+----------------
+
+Default value for ``C_STANDARD`` property of targets.
+
+This variable is used to initialize the :prop_tgt:`C_STANDARD`
+property on all targets.  See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
diff --git a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst
new file mode 100644
index 0000000..c24eea4
--- /dev/null
+++ b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst
@@ -0,0 +1,11 @@
+CMAKE_C_STANDARD_REQUIRED
+-------------------------
+
+Default value for ``C_STANDARD_REQUIRED`` property of targets.
+
+This variable is used to initialize the :prop_tgt:`C_STANDARD_REQUIRED`
+property on all targets.  See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
index 11aed0c..e200b86 100644
--- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
+++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
@@ -6,7 +6,8 @@
 This variable can be populated with a list of properties to generate
 debug output for when evaluating target properties.  Currently it can
 only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`,
-:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`,
+:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`,
+:prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, :prop_tgt:`COMPILE_FEATURES`,
 :prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property
 listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_``
 properties.  It outputs an origin for each entry in the target property.
diff --git a/Help/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY.rst
new file mode 100644
index 0000000..ee109ba
--- /dev/null
+++ b/Help/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY.rst
@@ -0,0 +1,11 @@
+CMAKE_EXPORT_NO_PACKAGE_REGISTRY
+--------------------------------
+
+Disable the :command:`export(PACKAGE)` command.
+
+In some cases, for example for packaging and for system wide
+installations, it is not desirable to write the user package registry.
+If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable is enabled,
+the :command:`export(PACKAGE)` command will do nothing.
+
+See also :ref:`Disabling the Package Registry`.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst
new file mode 100644
index 0000000..9058471
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst
@@ -0,0 +1,13 @@
+CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
+--------------------------------------
+
+Skip :ref:`User Package Registry` in :command:`find_package` calls.
+
+In some cases, for example to locate only system wide installations, it
+is not desirable to use the :ref:`User Package Registry` when searching
+for packages. If the :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
+variable is enabled, all the :command:`find_package` commands will skip
+the :ref:`User Package Registry` as if they were called with the
+``NO_CMAKE_PACKAGE_REGISTRY`` argument.
+
+See also :ref:`Disabling the Package Registry`.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY.rst
new file mode 100644
index 0000000..44588b1
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY.rst
@@ -0,0 +1,13 @@
+CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
+---------------------------------------------
+
+Skip :ref:`System Package Registry` in :command:`find_package` calls.
+
+In some cases, it is not desirable to use the
+:ref:`System Package Registry` when searching for packages. If the
+:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` variable is
+enabled, all the :command:`find_package` commands will skip
+the :ref:`System Package Registry` as if they were called with the
+``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` argument.
+
+See also :ref:`Disabling the Package Registry`.
diff --git a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
index 4540eaa..9ccc8b3 100644
--- a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
+++ b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
@@ -7,3 +7,9 @@
 build system to choose a compiler.  If the user specifies a toolset
 name (e.g.  via the cmake -T option) the value will be available in
 this variable.
+
+The value of this variable should never be modified by project code.
+A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE`
+variable may initialize ``CMAKE_GENERATOR_TOOLSET``.  Once a given
+build tree has been initialized with a particular value for this
+variable, changing the value has undefined behavior.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM.rst b/Help/variable/CMAKE_HOST_SYSTEM.rst
index 4366ee3..c2a8f1a 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM.rst
@@ -1,7 +1,10 @@
 CMAKE_HOST_SYSTEM
 -----------------
 
-Name of system cmake is being run on.
+Composit Name of OS CMake is being run on.
 
-The same as CMAKE_SYSTEM but for the host system instead of the target
-system when cross compiling.
+This variable is the composite of :variable:`CMAKE_HOST_SYSTEM_NAME` and
+:variable:`CMAKE_HOST_SYSTEM_VERSION`, e.g.
+``${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_VERSION}``.  If
+:variable:`CMAKE_HOST_SYSTEM_VERSION` is not set, then this variable is
+the same as :variable:`CMAKE_HOST_SYSTEM_NAME`.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
index 718208a..a221de9 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
@@ -3,5 +3,6 @@
 
 Name of the OS CMake is running on.
 
-The same as CMAKE_SYSTEM_NAME but for the host system instead of the
-target system when cross compiling.
+On systems that have the uname command, this variable is set to the
+output of uname -s.  ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X
+are the values found on the big three operating systems.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst
index 2700b66..790565a 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst
@@ -3,5 +3,6 @@
 
 The name of the CPU CMake is running on.
 
-The same as CMAKE_SYSTEM_PROCESSOR but for the host system instead of
-the target system when cross compiling.
+On systems that support uname, this variable is set to the output of
+uname -p, on windows it is set to the value of the environment variable
+``PROCESSOR_ARCHITECTURE``.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst
index a8451e8..e7e0052 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst
@@ -1,7 +1,8 @@
 CMAKE_HOST_SYSTEM_VERSION
 -------------------------
 
-OS version CMake is running on.
+The OS version CMake is running on.
 
-The same as CMAKE_SYSTEM_VERSION but for the host system instead of
-the target system when cross compiling.
+A numeric version string for the system.  On systems that support
+uname, this variable is set to the output of uname -r. On other
+systems this is set to major-minor version numbers.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
index cf9c386..f554f4e 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
@@ -20,13 +20,13 @@
   Intel = Intel Compiler (intel.com)
   MIPSpro = SGI MIPSpro (sgi.com)
   MSVC = Microsoft Visual Studio (microsoft.com)
+  OpenWatcom = Open Watcom (openwatcom.org)
   PGI = The Portland Group (pgroup.com)
   PathScale = PathScale (pathscale.com)
   SDCC = Small Device C Compiler (sdcc.sourceforge.net)
   SunPro = Oracle Solaris Studio (oracle.com)
   TI = Texas Instruments (ti.com)
   TinyCC = Tiny C Compiler (tinycc.org)
-  Watcom = Open Watcom (openwatcom.org)
   XL, VisualAge, zOS = IBM XL (ibm.com)
 
 This variable is not guaranteed to be defined for all compilers or
diff --git a/Help/variable/CMAKE_SYSTEM.rst b/Help/variable/CMAKE_SYSTEM.rst
index 283d0be..23f5980 100644
--- a/Help/variable/CMAKE_SYSTEM.rst
+++ b/Help/variable/CMAKE_SYSTEM.rst
@@ -1,9 +1,10 @@
 CMAKE_SYSTEM
 ------------
 
-Name of system cmake is compiling for.
+Composit Name of OS CMake is compiling for.
 
-This variable is the composite of CMAKE_SYSTEM_NAME and
-CMAKE_SYSTEM_VERSION, like this
-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}.  If CMAKE_SYSTEM_VERSION
-is not set, then CMAKE_SYSTEM is the same as CMAKE_SYSTEM_NAME.
+This variable is the composite of :variable:`CMAKE_SYSTEM_NAME` and
+:variable:`CMAKE_SYSTEM_VERSION`, e.g.
+``${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}``.  If
+:variable:`CMAKE_SYSTEM_VERSION` is not set, then this variable is
+the same as :variable:`CMAKE_SYSTEM_NAME`.
diff --git a/Help/variable/CMAKE_SYSTEM_NAME.rst b/Help/variable/CMAKE_SYSTEM_NAME.rst
index 9871dd9..189dc18 100644
--- a/Help/variable/CMAKE_SYSTEM_NAME.rst
+++ b/Help/variable/CMAKE_SYSTEM_NAME.rst
@@ -3,7 +3,6 @@
 
 Name of the OS CMake is building for.
 
-This is the name of the operating system on which CMake is targeting.
-On systems that have the uname command, this variable is set to the
-output of uname -s.  Linux, Windows, and Darwin for Mac OS X are the
-values found on the big three operating systems.
+This is the name of the OS on which CMake is targeting.  This variable
+is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the
+host system instead of the target system when cross compiling.
diff --git a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
index 1655ada..8ad89f1 100644
--- a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
+++ b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
@@ -3,6 +3,6 @@
 
 The name of the CPU CMake is building for.
 
-On systems that support uname, this variable is set to the output of
-uname -p, on windows it is set to the value of the environment
-variable PROCESSOR_ARCHITECTURE
+This variable is the same as :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` if
+you build for the host system instead of the target system when
+cross compiling.
diff --git a/Help/variable/CMAKE_SYSTEM_VERSION.rst b/Help/variable/CMAKE_SYSTEM_VERSION.rst
index 61bb40e..33510bb 100644
--- a/Help/variable/CMAKE_SYSTEM_VERSION.rst
+++ b/Help/variable/CMAKE_SYSTEM_VERSION.rst
@@ -1,8 +1,8 @@
 CMAKE_SYSTEM_VERSION
 --------------------
 
-OS version CMake is building for.
+The OS version CMake is building for.
 
-A numeric version string for the system, on systems that support
-uname, this variable is set to the output of uname -r.  On other
-systems this is set to major-minor version numbers.
+This variable is the same as :variable:`CMAKE_HOST_SYSTEM_VERSION` if
+you build for the host system instead of the target system when
+cross compiling.
diff --git a/Help/variable/CTEST_BINARY_DIRECTORY.rst b/Help/variable/CTEST_BINARY_DIRECTORY.rst
new file mode 100644
index 0000000..fd8461f
--- /dev/null
+++ b/Help/variable/CTEST_BINARY_DIRECTORY.rst
@@ -0,0 +1,5 @@
+CTEST_BINARY_DIRECTORY
+----------------------
+
+Specify the CTest ``BuildDirectory`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_BUILD_COMMAND.rst b/Help/variable/CTEST_BUILD_COMMAND.rst
new file mode 100644
index 0000000..7b13ba0
--- /dev/null
+++ b/Help/variable/CTEST_BUILD_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_BUILD_COMMAND
+-------------------
+
+Specify the CTest ``MakeCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_BUILD_NAME.rst b/Help/variable/CTEST_BUILD_NAME.rst
new file mode 100644
index 0000000..d25d84c
--- /dev/null
+++ b/Help/variable/CTEST_BUILD_NAME.rst
@@ -0,0 +1,5 @@
+CTEST_BUILD_NAME
+----------------
+
+Specify the CTest ``BuildName`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_BZR_COMMAND.rst b/Help/variable/CTEST_BZR_COMMAND.rst
new file mode 100644
index 0000000..474d621
--- /dev/null
+++ b/Help/variable/CTEST_BZR_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_BZR_COMMAND
+-----------------
+
+Specify the CTest ``BZRCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_BZR_UPDATE_OPTIONS.rst b/Help/variable/CTEST_BZR_UPDATE_OPTIONS.rst
new file mode 100644
index 0000000..d0f9579
--- /dev/null
+++ b/Help/variable/CTEST_BZR_UPDATE_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_BZR_UPDATE_OPTIONS
+------------------------
+
+Specify the CTest ``BZRUpdateOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_CHECKOUT_COMMAND.rst b/Help/variable/CTEST_CHECKOUT_COMMAND.rst
new file mode 100644
index 0000000..da256f2
--- /dev/null
+++ b/Help/variable/CTEST_CHECKOUT_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_CHECKOUT_COMMAND
+----------------------
+
+Tell the :command:`ctest_start` command how to checkout or initialize
+the source directory in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_CONFIGURATION_TYPE.rst b/Help/variable/CTEST_CONFIGURATION_TYPE.rst
new file mode 100644
index 0000000..c905480
--- /dev/null
+++ b/Help/variable/CTEST_CONFIGURATION_TYPE.rst
@@ -0,0 +1,5 @@
+CTEST_CONFIGURATION_TYPE
+------------------------
+
+Specify the CTest ``DefaultCTestConfigurationType`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_CONFIGURE_COMMAND.rst b/Help/variable/CTEST_CONFIGURE_COMMAND.rst
new file mode 100644
index 0000000..5561b6d
--- /dev/null
+++ b/Help/variable/CTEST_CONFIGURE_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_CONFIGURE_COMMAND
+-----------------------
+
+Specify the CTest ``ConfigureCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_COVERAGE_COMMAND.rst b/Help/variable/CTEST_COVERAGE_COMMAND.rst
new file mode 100644
index 0000000..a669dd7
--- /dev/null
+++ b/Help/variable/CTEST_COVERAGE_COMMAND.rst
@@ -0,0 +1,60 @@
+CTEST_COVERAGE_COMMAND
+----------------------
+
+Specify the CTest ``CoverageCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
+
+Cobertura
+'''''''''
+
+Using `Cobertura`_ as the coverage generation within your multi-module
+Java project can generate a series of XML files.
+
+The Cobertura Coverage parser expects to read the coverage data from a
+single XML file which contains the coverage data for all modules.
+Cobertura has a program with the ability to merge given cobertura.ser files
+and then another program to generate a combined XML file from the previous
+merged file.  For command line testing, this can be done by hand prior to
+CTest looking for the coverage files. For script builds,
+set the ``CTEST_COVERAGE_COMMAND`` variable to point to a file which will
+perform these same steps, such as a .sh or .bat file.
+
+.. code-block:: cmake
+
+  set(CTEST_COVERAGE_COMMAND .../run-coverage-and-consolidate.sh)
+
+where the ``run-coverage-and-consolidate.sh`` script is perhaps created by
+the :command:`configure_file` command and might contain the following code:
+
+.. code-block:: bash
+
+  #!/usr/bin/env bash
+  CoberturaFiles="$(find "/path/to/source" -name "cobertura.ser")"
+  SourceDirs="$(find "/path/to/source" -name "java" -type d)"
+  cobertura-merge --datafile coberturamerge.ser $CoberturaFiles
+  cobertura-report --datafile coberturamerge.ser --destination . \
+                   --format xml $SourceDirs
+
+The script uses ``find`` to capture the paths to all of the cobertura.ser files
+found below the project's source directory.  It keeps the list of files and
+supplies it as an argument to the ``cobertura-merge`` program. The ``--datafile``
+argument signifies where the result of the merge will be kept.
+
+The combined ``coberturamerge.ser`` file is then used to generate the XML report
+using the ``cobertura-report`` program.  The call to the cobertura-report program
+requires some named arguments.
+
+``--datafila``
+  path to the merged .ser file
+
+``--destination``
+  path to put the output files(s)
+
+``--format``
+  file format to write output in: xml or html
+
+The rest of the supplied arguments consist of the full paths to the
+/src/main/java directories of each module within the souce tree. These
+directories are needed and should not be forgotten.
+
+.. _`Cobertura`: http://cobertura.github.io/cobertura/
diff --git a/Help/variable/CTEST_COVERAGE_EXTRA_FLAGS.rst b/Help/variable/CTEST_COVERAGE_EXTRA_FLAGS.rst
new file mode 100644
index 0000000..2981955
--- /dev/null
+++ b/Help/variable/CTEST_COVERAGE_EXTRA_FLAGS.rst
@@ -0,0 +1,5 @@
+CTEST_COVERAGE_EXTRA_FLAGS
+--------------------------
+
+Specify the CTest ``CoverageExtraFlags`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_CURL_OPTIONS.rst b/Help/variable/CTEST_CURL_OPTIONS.rst
new file mode 100644
index 0000000..fc5dfc4
--- /dev/null
+++ b/Help/variable/CTEST_CURL_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_CURL_OPTIONS
+------------------
+
+Specify the CTest ``CurlOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_CVS_CHECKOUT.rst b/Help/variable/CTEST_CVS_CHECKOUT.rst
new file mode 100644
index 0000000..6431c02
--- /dev/null
+++ b/Help/variable/CTEST_CVS_CHECKOUT.rst
@@ -0,0 +1,4 @@
+CTEST_CVS_CHECKOUT
+------------------
+
+Deprecated.  Use :variable:`CTEST_CHECKOUT_COMMAND` instead.
diff --git a/Help/variable/CTEST_CVS_COMMAND.rst b/Help/variable/CTEST_CVS_COMMAND.rst
new file mode 100644
index 0000000..049700b
--- /dev/null
+++ b/Help/variable/CTEST_CVS_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_CVS_COMMAND
+-----------------
+
+Specify the CTest ``CVSCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_CVS_UPDATE_OPTIONS.rst b/Help/variable/CTEST_CVS_UPDATE_OPTIONS.rst
new file mode 100644
index 0000000..d7f2f7c
--- /dev/null
+++ b/Help/variable/CTEST_CVS_UPDATE_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_CVS_UPDATE_OPTIONS
+------------------------
+
+Specify the CTest ``CVSUpdateOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_DROP_LOCATION.rst b/Help/variable/CTEST_DROP_LOCATION.rst
new file mode 100644
index 0000000..c0f2215
--- /dev/null
+++ b/Help/variable/CTEST_DROP_LOCATION.rst
@@ -0,0 +1,5 @@
+CTEST_DROP_LOCATION
+-------------------
+
+Specify the CTest ``DropLocation`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_DROP_METHOD.rst b/Help/variable/CTEST_DROP_METHOD.rst
new file mode 100644
index 0000000..50fbd4d
--- /dev/null
+++ b/Help/variable/CTEST_DROP_METHOD.rst
@@ -0,0 +1,5 @@
+CTEST_DROP_METHOD
+-----------------
+
+Specify the CTest ``DropMethod`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_DROP_SITE.rst b/Help/variable/CTEST_DROP_SITE.rst
new file mode 100644
index 0000000..d15d99b
--- /dev/null
+++ b/Help/variable/CTEST_DROP_SITE.rst
@@ -0,0 +1,5 @@
+CTEST_DROP_SITE
+---------------
+
+Specify the CTest ``DropSite`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_DROP_SITE_CDASH.rst b/Help/variable/CTEST_DROP_SITE_CDASH.rst
new file mode 100644
index 0000000..22b9776
--- /dev/null
+++ b/Help/variable/CTEST_DROP_SITE_CDASH.rst
@@ -0,0 +1,5 @@
+CTEST_DROP_SITE_CDASH
+---------------------
+
+Specify the CTest ``IsCDash`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_DROP_SITE_PASSWORD.rst b/Help/variable/CTEST_DROP_SITE_PASSWORD.rst
new file mode 100644
index 0000000..904d2c8
--- /dev/null
+++ b/Help/variable/CTEST_DROP_SITE_PASSWORD.rst
@@ -0,0 +1,5 @@
+CTEST_DROP_SITE_PASSWORD
+------------------------
+
+Specify the CTest ``DropSitePassword`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_DROP_SITE_USER.rst b/Help/variable/CTEST_DROP_SITE_USER.rst
new file mode 100644
index 0000000..a860a03
--- /dev/null
+++ b/Help/variable/CTEST_DROP_SITE_USER.rst
@@ -0,0 +1,5 @@
+CTEST_DROP_SITE_USER
+--------------------
+
+Specify the CTest ``DropSiteUser`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_GIT_COMMAND.rst b/Help/variable/CTEST_GIT_COMMAND.rst
new file mode 100644
index 0000000..eb83792
--- /dev/null
+++ b/Help/variable/CTEST_GIT_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_GIT_COMMAND
+-----------------
+
+Specify the CTest ``GITCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_GIT_UPDATE_CUSTOM.rst b/Help/variable/CTEST_GIT_UPDATE_CUSTOM.rst
new file mode 100644
index 0000000..0c479e6
--- /dev/null
+++ b/Help/variable/CTEST_GIT_UPDATE_CUSTOM.rst
@@ -0,0 +1,5 @@
+CTEST_GIT_UPDATE_CUSTOM
+-----------------------
+
+Specify the CTest ``GITUpdateCustom`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_GIT_UPDATE_OPTIONS.rst b/Help/variable/CTEST_GIT_UPDATE_OPTIONS.rst
new file mode 100644
index 0000000..4590a78
--- /dev/null
+++ b/Help/variable/CTEST_GIT_UPDATE_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_GIT_UPDATE_OPTIONS
+------------------------
+
+Specify the CTest ``GITUpdateOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_HG_COMMAND.rst b/Help/variable/CTEST_HG_COMMAND.rst
new file mode 100644
index 0000000..3854950
--- /dev/null
+++ b/Help/variable/CTEST_HG_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_HG_COMMAND
+----------------
+
+Specify the CTest ``HGCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_HG_UPDATE_OPTIONS.rst b/Help/variable/CTEST_HG_UPDATE_OPTIONS.rst
new file mode 100644
index 0000000..9049c1f
--- /dev/null
+++ b/Help/variable/CTEST_HG_UPDATE_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_HG_UPDATE_OPTIONS
+-----------------------
+
+Specify the CTest ``HGUpdateOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_MEMORYCHECK_COMMAND.rst b/Help/variable/CTEST_MEMORYCHECK_COMMAND.rst
new file mode 100644
index 0000000..8c199ba
--- /dev/null
+++ b/Help/variable/CTEST_MEMORYCHECK_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_MEMORYCHECK_COMMAND
+-------------------------
+
+Specify the CTest ``MemoryCheckCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_MEMORYCHECK_COMMAND_OPTIONS.rst b/Help/variable/CTEST_MEMORYCHECK_COMMAND_OPTIONS.rst
new file mode 100644
index 0000000..3e26ab5
--- /dev/null
+++ b/Help/variable/CTEST_MEMORYCHECK_COMMAND_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_MEMORYCHECK_COMMAND_OPTIONS
+---------------------------------
+
+Specify the CTest ``MemoryCheckCommandOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_MEMORYCHECK_SUPPRESSIONS_FILE.rst b/Help/variable/CTEST_MEMORYCHECK_SUPPRESSIONS_FILE.rst
new file mode 100644
index 0000000..1147ee8
--- /dev/null
+++ b/Help/variable/CTEST_MEMORYCHECK_SUPPRESSIONS_FILE.rst
@@ -0,0 +1,5 @@
+CTEST_MEMORYCHECK_SUPPRESSIONS_FILE
+-----------------------------------
+
+Specify the CTest ``MemoryCheckSuppressionFile`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_NIGHTLY_START_TIME.rst b/Help/variable/CTEST_NIGHTLY_START_TIME.rst
new file mode 100644
index 0000000..bc80276
--- /dev/null
+++ b/Help/variable/CTEST_NIGHTLY_START_TIME.rst
@@ -0,0 +1,5 @@
+CTEST_NIGHTLY_START_TIME
+------------------------
+
+Specify the CTest ``NightlyStartTime`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_P4_CLIENT.rst b/Help/variable/CTEST_P4_CLIENT.rst
new file mode 100644
index 0000000..347ea54
--- /dev/null
+++ b/Help/variable/CTEST_P4_CLIENT.rst
@@ -0,0 +1,5 @@
+CTEST_P4_CLIENT
+---------------
+
+Specify the CTest ``P4Client`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_P4_COMMAND.rst b/Help/variable/CTEST_P4_COMMAND.rst
new file mode 100644
index 0000000..defab12
--- /dev/null
+++ b/Help/variable/CTEST_P4_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_P4_COMMAND
+----------------
+
+Specify the CTest ``P4Command`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_P4_OPTIONS.rst b/Help/variable/CTEST_P4_OPTIONS.rst
new file mode 100644
index 0000000..fee4ce2
--- /dev/null
+++ b/Help/variable/CTEST_P4_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_P4_OPTIONS
+----------------
+
+Specify the CTest ``P4Options`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_P4_UPDATE_OPTIONS.rst b/Help/variable/CTEST_P4_UPDATE_OPTIONS.rst
new file mode 100644
index 0000000..0e2790f
--- /dev/null
+++ b/Help/variable/CTEST_P4_UPDATE_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_P4_UPDATE_OPTIONS
+-----------------------
+
+Specify the CTest ``P4UpdateOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_SCP_COMMAND.rst b/Help/variable/CTEST_SCP_COMMAND.rst
new file mode 100644
index 0000000..0f128b1
--- /dev/null
+++ b/Help/variable/CTEST_SCP_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_SCP_COMMAND
+-----------------
+
+Specify the CTest ``SCPCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_SITE.rst b/Help/variable/CTEST_SITE.rst
new file mode 100644
index 0000000..8a5ec25
--- /dev/null
+++ b/Help/variable/CTEST_SITE.rst
@@ -0,0 +1,5 @@
+CTEST_SITE
+----------
+
+Specify the CTest ``Site`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_SOURCE_DIRECTORY.rst b/Help/variable/CTEST_SOURCE_DIRECTORY.rst
new file mode 100644
index 0000000..b6837d1
--- /dev/null
+++ b/Help/variable/CTEST_SOURCE_DIRECTORY.rst
@@ -0,0 +1,5 @@
+CTEST_SOURCE_DIRECTORY
+----------------------
+
+Specify the CTest ``SourceDirectory`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_SVN_COMMAND.rst b/Help/variable/CTEST_SVN_COMMAND.rst
new file mode 100644
index 0000000..af90143
--- /dev/null
+++ b/Help/variable/CTEST_SVN_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_SVN_COMMAND
+-----------------
+
+Specify the CTest ``SVNCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_SVN_OPTIONS.rst b/Help/variable/CTEST_SVN_OPTIONS.rst
new file mode 100644
index 0000000..76551dc
--- /dev/null
+++ b/Help/variable/CTEST_SVN_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_SVN_OPTIONS
+-----------------
+
+Specify the CTest ``SVNOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_SVN_UPDATE_OPTIONS.rst b/Help/variable/CTEST_SVN_UPDATE_OPTIONS.rst
new file mode 100644
index 0000000..5f01a19
--- /dev/null
+++ b/Help/variable/CTEST_SVN_UPDATE_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_SVN_UPDATE_OPTIONS
+------------------------
+
+Specify the CTest ``SVNUpdateOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_TEST_TIMEOUT.rst b/Help/variable/CTEST_TEST_TIMEOUT.rst
new file mode 100644
index 0000000..c031437
--- /dev/null
+++ b/Help/variable/CTEST_TEST_TIMEOUT.rst
@@ -0,0 +1,5 @@
+CTEST_TEST_TIMEOUT
+------------------
+
+Specify the CTest ``TimeOut`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_TRIGGER_SITE.rst b/Help/variable/CTEST_TRIGGER_SITE.rst
new file mode 100644
index 0000000..de92428
--- /dev/null
+++ b/Help/variable/CTEST_TRIGGER_SITE.rst
@@ -0,0 +1,5 @@
+CTEST_TRIGGER_SITE
+------------------
+
+Specify the CTest ``TriggerSite`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_UPDATE_COMMAND.rst b/Help/variable/CTEST_UPDATE_COMMAND.rst
new file mode 100644
index 0000000..90155d0
--- /dev/null
+++ b/Help/variable/CTEST_UPDATE_COMMAND.rst
@@ -0,0 +1,5 @@
+CTEST_UPDATE_COMMAND
+--------------------
+
+Specify the CTest ``UpdateCommand`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_UPDATE_OPTIONS.rst b/Help/variable/CTEST_UPDATE_OPTIONS.rst
new file mode 100644
index 0000000..e43d61d
--- /dev/null
+++ b/Help/variable/CTEST_UPDATE_OPTIONS.rst
@@ -0,0 +1,5 @@
+CTEST_UPDATE_OPTIONS
+--------------------
+
+Specify the CTest ``UpdateOptions`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_USE_LAUNCHERS.rst b/Help/variable/CTEST_USE_LAUNCHERS.rst
new file mode 100644
index 0000000..9f48a2e
--- /dev/null
+++ b/Help/variable/CTEST_USE_LAUNCHERS.rst
@@ -0,0 +1,5 @@
+CTEST_USE_LAUNCHERS
+-------------------
+
+Specify the CTest ``UseLaunchers`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in
index b6f9791..602b065 100644
--- a/Modules/AutogenInfo.cmake.in
+++ b/Modules/AutogenInfo.cmake.in
@@ -16,6 +16,7 @@
 set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
 set(AM_QT_VERSION_MAJOR "@_target_qt_version@")
 set(AM_TARGET_NAME @_moc_target_name@)
+set(AM_ORIGIN_TARGET_NAME @_origin_target_name@)
 set(AM_RELAXED_MODE "@_moc_relaxed_mode@")
 set(AM_UIC_TARGET_OPTIONS @_uic_target_options@)
 set(AM_UIC_OPTIONS_FILES @_qt_uic_options_files@)
diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in
index 63f3f03..9fd0136 100644
--- a/Modules/BasicConfigVersion-ExactVersion.cmake.in
+++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in
@@ -11,13 +11,13 @@
 
 set(PACKAGE_VERSION "@CVF_VERSION@")
 
-if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version
+if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version
   set(CVF_VERSION_NO_TWEAK "${CMAKE_MATCH_1}")
 else()
   set(CVF_VERSION_NO_TWEAK "@CVF_VERSION@")
 endif()
 
-if("${PACKAGE_FIND_VERSION}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version
+if("${PACKAGE_FIND_VERSION}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version
   set(REQUESTED_VERSION_NO_TWEAK "${CMAKE_MATCH_1}")
 else()
   set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}")
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index b896de2..0c733fa 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -235,8 +235,8 @@
     #
     set(eol_char "E")
     file(READ "${bundle}/Contents/Info.plist" info_plist)
-    string(REGEX REPLACE ";" "\\\\;" info_plist "${info_plist}")
-    string(REGEX REPLACE "\n" "${eol_char};" info_plist "${info_plist}")
+    string(REPLACE ";" "\\;" info_plist "${info_plist}")
+    string(REPLACE "\n" "${eol_char};" info_plist "${info_plist}")
 
     # Scan the lines for "<key>CFBundleExecutable</key>" - the line after that
     # is the name of the main executable.
@@ -247,7 +247,7 @@
         break()
       endif()
 
-      if(line MATCHES "^.*<key>CFBundleExecutable</key>.*$")
+      if(line MATCHES "<key>CFBundleExecutable</key>")
         set(line_is_main_executable 1)
       endif()
     endforeach()
@@ -287,7 +287,7 @@
 function(get_dotapp_dir exe dotapp_dir_var)
   set(s "${exe}")
 
-  if(s MATCHES "^.*/.*\\.app/.*$")
+  if(s MATCHES "/.*\\.app/")
     # If there is a ".app" parent directory,
     # ascend until we hit it:
     #   (typical of a Mac bundle executable)
@@ -394,7 +394,7 @@
   if(WIN32)
     string(TOLOWER "${item_name}" item_name)
   endif()
-  string(REGEX REPLACE "\\." "_" ${key_var} "${item_name}")
+  string(REPLACE "." "_" ${key_var} "${item_name}")
   set(${key_var} ${${key_var}} PARENT_SCOPE)
 endfunction()
 
diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake
index 343fdb2..f1db46e 100644
--- a/Modules/CMakeBackwardCompatibilityCXX.cmake
+++ b/Modules/CMakeBackwardCompatibilityCXX.cmake
@@ -31,15 +31,15 @@
   if(NOT CMAKE_COMPILER_IS_GNUCXX)
     include(TestCXXAcceptsFlag)
     set(CMAKE_TRY_ANSI_CXX_FLAGS "")
-    if(CMAKE_SYSTEM MATCHES "IRIX.*")
+    if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
       set(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std")
     endif()
-    if(CMAKE_SYSTEM MATCHES "OSF.*")
+    if(CMAKE_SYSTEM_NAME MATCHES "OSF")
       set(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname")
     endif()
     # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see
     # if the compiler accepts it
-    if( CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+")
+    if(NOT CMAKE_TRY_ANSI_CXX_FLAGS STREQUAL "")
       CHECK_CXX_ACCEPTS_FLAG(${CMAKE_TRY_ANSI_CXX_FLAGS} CMAKE_CXX_ACCEPTS_FLAGS)
       # if the compiler liked the flag then set CMAKE_ANSI_CXXFLAGS
       # to the flag
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in
index 804cce2..86cd894 100644
--- a/Modules/CMakeCCompiler.cmake.in
+++ b/Modules/CMakeCCompiler.cmake.in
@@ -2,6 +2,11 @@
 set(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@")
 set(CMAKE_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@")
 set(CMAKE_C_COMPILER_VERSION "@CMAKE_C_COMPILER_VERSION@")
+set(CMAKE_C_COMPILE_FEATURES "@CMAKE_C_COMPILE_FEATURES@")
+set(CMAKE_C90_COMPILE_FEATURES "@CMAKE_C90_COMPILE_FEATURES@")
+set(CMAKE_C99_COMPILE_FEATURES "@CMAKE_C99_COMPILE_FEATURES@")
+set(CMAKE_C11_COMPILE_FEATURES "@CMAKE_C11_COMPILE_FEATURES@")
+
 set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@")
 set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@")
 set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@")
@@ -26,7 +31,7 @@
   set(MINGW 1)
 endif()
 set(CMAKE_C_COMPILER_ID_RUN 1)
-set(CMAKE_C_SOURCE_FILE_EXTENSIONS c)
+set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
 set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
 set(CMAKE_C_LINKER_PREFERENCE 10)
 
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index 561ccf2..0221cbd 100644
--- a/Modules/CMakeCCompilerId.c.in
+++ b/Modules/CMakeCCompilerId.c.in
@@ -2,225 +2,11 @@
 # error "A C++ compiler has been selected for C."
 #endif
 
-/* Version number components: V=Version, R=Revision, P=Patch
-   Version date components:   YYYY=Year, MM=Month,   DD=Day  */
-
 #if defined(__18CXX)
 # define ID_VOID_MAIN
 #endif
 
-#if defined(__INTEL_COMPILER) || defined(__ICC)
-# define COMPILER_ID "Intel"
-  /* __INTEL_COMPILER = VRP */
-# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
-# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
-# if defined(__INTEL_COMPILER_UPDATE)
-#  define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
-# else
-#  define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER   % 10)
-# endif
-# if defined(__INTEL_COMPILER_BUILD_DATE)
-  /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
-#  define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
-# endif
-# if defined(_MSC_VER)
-#  define SIMULATE_ID "MSVC"
-   /* _MSC_VER = VVRR */
-#  define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
-#  define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
-# endif
-
-#elif defined(__PATHCC__)
-# define COMPILER_ID "PathScale"
-# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
-# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
-# if defined(__PATHCC_PATCHLEVEL__)
-#  define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
-# endif
-
-#elif defined(__clang__)
-# if defined(__apple_build_version__)
-#  define COMPILER_ID "AppleClang"
-#  define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
-# else
-#  define COMPILER_ID "Clang"
-# endif
-# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
-# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
-# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
-# if defined(_MSC_VER)
-#  define SIMULATE_ID "MSVC"
-   /* _MSC_VER = VVRR */
-#  define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
-#  define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
-# endif
-
-#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
-# define COMPILER_ID "Embarcadero"
-# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
-# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
-# define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__     & 0xFFFF)
-
-#elif defined(__BORLANDC__)
-# define COMPILER_ID "Borland"
-  /* __BORLANDC__ = 0xVRR */
-# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
-# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
-
-#elif defined(__WATCOMC__)
-# define COMPILER_ID "Watcom"
-  /* __WATCOMC__ = VVRR */
-# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
-# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
-
-#elif defined(__SUNPRO_C)
-# define COMPILER_ID "SunPro"
-# if __SUNPRO_C >= 0x5100
-   /* __SUNPRO_C = 0xVRRP */
-#  define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
-#  define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
-#  define COMPILER_VERSION_PATCH HEX(__SUNPRO_C    & 0xF)
-# else
-   /* __SUNPRO_C = 0xVRP */
-#  define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
-#  define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
-#  define COMPILER_VERSION_PATCH HEX(__SUNPRO_C    & 0xF)
-# endif
-
-#elif defined(__HP_cc)
-# define COMPILER_ID "HP"
-  /* __HP_cc = VVRRPP */
-# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
-# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
-# define COMPILER_VERSION_PATCH DEC(__HP_cc     % 100)
-
-#elif defined(__DECC)
-# define COMPILER_ID "Compaq"
-  /* __DECC_VER = VVRRTPPPP */
-# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
-# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000  % 100)
-# define COMPILER_VERSION_PATCH DEC(__DECC_VER         % 10000)
-
-#elif defined(__IBMC__)
-# if defined(__COMPILER_VER__)
-#  define COMPILER_ID "zOS"
-# else
-#  if __IBMC__ >= 800
-#   define COMPILER_ID "XL"
-#  else
-#   define COMPILER_ID "VisualAge"
-#  endif
-   /* __IBMC__ = VRP */
-#  define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
-#  define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
-#  define COMPILER_VERSION_PATCH DEC(__IBMC__    % 10)
-# endif
-
-#elif defined(__PGI)
-# define COMPILER_ID "PGI"
-# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
-# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
-# if defined(__PGIC_PATCHLEVEL__)
-#  define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
-# endif
-
-#elif defined(_CRAYC)
-# define COMPILER_ID "Cray"
-# define COMPILER_VERSION_MAJOR DEC(_RELEASE)
-# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
-
-#elif defined(__TI_COMPILER_VERSION__)
-# define COMPILER_ID "TI"
-  /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
-# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
-# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000   % 1000)
-# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__        % 1000)
-
-#elif defined(__TINYC__)
-# define COMPILER_ID "TinyCC"
-
-#elif defined(__SCO_VERSION__)
-# define COMPILER_ID "SCO"
-
-#elif defined(__GNUC__)
-# define COMPILER_ID "GNU"
-# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
-# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
-# if defined(__GNUC_PATCHLEVEL__)
-#  define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
-# endif
-
-#elif defined(_MSC_VER)
-# define COMPILER_ID "MSVC"
-  /* _MSC_VER = VVRR */
-# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
-# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
-# if defined(_MSC_FULL_VER)
-#  if _MSC_VER >= 1400
-    /* _MSC_FULL_VER = VVRRPPPPP */
-#   define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
-#  else
-    /* _MSC_FULL_VER = VVRRPPPP */
-#   define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
-#  endif
-# endif
-# if defined(_MSC_BUILD)
-#  define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
-# endif
-
-/* Analog VisualDSP++ >= 4.5.6 */
-#elif defined(__VISUALDSPVERSION__)
-# define COMPILER_ID "ADSP"
-  /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
-# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
-# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
-# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8  & 0xFF)
-
-/* Analog VisualDSP++ < 4.5.6 */
-#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
-# define COMPILER_ID "ADSP"
-
-/* IAR Systems compiler for embedded systems.
-   http://www.iar.com */
-#elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
-# define COMPILER_ID "IAR"
-
-/* sdcc, the small devices C compiler for embedded systems,
-   http://sdcc.sourceforge.net  */
-#elif defined(SDCC)
-# define COMPILER_ID "SDCC"
-  /* SDCC = VRP */
-#  define COMPILER_VERSION_MAJOR DEC(SDCC/100)
-#  define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
-#  define COMPILER_VERSION_PATCH DEC(SDCC    % 10)
-
-#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
-# define COMPILER_ID "MIPSpro"
-# if defined(_SGI_COMPILER_VERSION)
-  /* _SGI_COMPILER_VERSION = VRP */
-#  define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
-#  define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
-#  define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION    % 10)
-# else
-  /* _COMPILER_VERSION = VRP */
-#  define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
-#  define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
-#  define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION    % 10)
-# endif
-
-/* This compiler is either not known or is too old to define an
-   identification macro.  Try to identify the platform and guess that
-   it is the native compiler.  */
-#elif defined(__sgi)
-# define COMPILER_ID "MIPSpro"
-
-#elif defined(__hpux) || defined(__hpua)
-# define COMPILER_ID "HP"
-
-#else /* unknown compiler */
-# define COMPILER_ID ""
-
-#endif
+@CMAKE_C_COMPILER_ID_CONTENT@
 
 /* Construct the string literal in pieces to prevent the source from
    getting matched.  Store it in a pointer rather than an array
diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake
index e0cce45..332b26e 100644
--- a/Modules/CMakeCInformation.cmake
+++ b/Modules/CMakeCInformation.cmake
@@ -175,10 +175,10 @@
 # Create a static archive incrementally for large object file counts.
 # If CMAKE_C_CREATE_STATIC_LIBRARY is set it will override these.
 if(NOT DEFINED CMAKE_C_ARCHIVE_CREATE)
-  set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+  set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
 endif()
 if(NOT DEFINED CMAKE_C_ARCHIVE_APPEND)
-  set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> r  <TARGET> <LINK_FLAGS> <OBJECTS>")
+  set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> q  <TARGET> <LINK_FLAGS> <OBJECTS>")
 endif()
 if(NOT DEFINED CMAKE_C_ARCHIVE_FINISH)
   set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in
index 35aa6c4..af79a31 100644
--- a/Modules/CMakeCXXCompiler.cmake.in
+++ b/Modules/CMakeCXXCompiler.cmake.in
@@ -2,6 +2,11 @@
 set(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@")
 set(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@")
 set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@")
+set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@")
+set(CMAKE_CXX98_COMPILE_FEATURES "@CMAKE_CXX98_COMPILE_FEATURES@")
+set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@")
+set(CMAKE_CXX14_COMPILE_FEATURES "@CMAKE_CXX14_COMPILE_FEATURES@")
+
 set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@")
 set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@")
 set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@")
@@ -27,7 +32,7 @@
 endif()
 set(CMAKE_CXX_COMPILER_ID_RUN 1)
 set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP)
+set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
 set(CMAKE_CXX_LINKER_PREFERENCE 30)
 set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
 
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index 6c602d4..9ece26d 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -5,215 +5,7 @@
 # error "A C compiler has been selected for C++."
 #endif
 
-/* Version number components: V=Version, R=Revision, P=Patch
-   Version date components:   YYYY=Year, MM=Month,   DD=Day  */
-
-#if defined(__COMO__)
-# define COMPILER_ID "Comeau"
-  /* __COMO_VERSION__ = VRR */
-# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
-# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
-
-#elif defined(__INTEL_COMPILER) || defined(__ICC)
-# define COMPILER_ID "Intel"
-  /* __INTEL_COMPILER = VRP */
-# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
-# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
-# if defined(__INTEL_COMPILER_UPDATE)
-#  define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
-# else
-#  define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER   % 10)
-# endif
-# if defined(__INTEL_COMPILER_BUILD_DATE)
-  /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
-#  define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
-# endif
-# if defined(_MSC_VER)
-#  define SIMULATE_ID "MSVC"
-   /* _MSC_VER = VVRR */
-#  define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
-#  define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
-# endif
-
-#elif defined(__PATHCC__)
-# define COMPILER_ID "PathScale"
-# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
-# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
-# if defined(__PATHCC_PATCHLEVEL__)
-#  define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
-# endif
-
-#elif defined(__clang__)
-# if defined(__apple_build_version__)
-#  define COMPILER_ID "AppleClang"
-#  define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
-# else
-#  define COMPILER_ID "Clang"
-# endif
-# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
-# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
-# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
-# if defined(_MSC_VER)
-#  define SIMULATE_ID "MSVC"
-   /* _MSC_VER = VVRR */
-#  define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
-#  define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
-# endif
-
-#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
-# define COMPILER_ID "Embarcadero"
-# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
-# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
-# define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__     & 0xFFFF)
-
-#elif defined(__BORLANDC__)
-# define COMPILER_ID "Borland"
-  /* __BORLANDC__ = 0xVRR */
-# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
-# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
-
-#elif defined(__WATCOMC__)
-# define COMPILER_ID "Watcom"
-  /* __WATCOMC__ = VVRR */
-# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
-# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
-
-#elif defined(__SUNPRO_CC)
-# define COMPILER_ID "SunPro"
-# if __SUNPRO_CC >= 0x5100
-   /* __SUNPRO_CC = 0xVRRP */
-#  define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
-#  define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
-#  define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC    & 0xF)
-# else
-   /* __SUNPRO_CC = 0xVRP */
-#  define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
-#  define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
-#  define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC    & 0xF)
-# endif
-
-#elif defined(__HP_aCC)
-# define COMPILER_ID "HP"
-  /* __HP_aCC = VVRRPP */
-# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
-# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
-# define COMPILER_VERSION_PATCH DEC(__HP_aCC     % 100)
-
-#elif defined(__DECCXX)
-# define COMPILER_ID "Compaq"
-  /* __DECCXX_VER = VVRRTPPPP */
-# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
-# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000  % 100)
-# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER         % 10000)
-
-#elif defined(__IBMCPP__)
-# if defined(__COMPILER_VER__)
-#  define COMPILER_ID "zOS"
-# else
-#  if __IBMCPP__ >= 800
-#   define COMPILER_ID "XL"
-#  else
-#   define COMPILER_ID "VisualAge"
-#  endif
-   /* __IBMCPP__ = VRP */
-#  define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
-#  define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
-#  define COMPILER_VERSION_PATCH DEC(__IBMCPP__    % 10)
-# endif
-
-#elif defined(__PGI)
-# define COMPILER_ID "PGI"
-# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
-# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
-# if defined(__PGIC_PATCHLEVEL__)
-#  define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
-# endif
-
-#elif defined(_CRAYC)
-# define COMPILER_ID "Cray"
-# define COMPILER_VERSION_MAJOR DEC(_RELEASE)
-# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
-
-#elif defined(__TI_COMPILER_VERSION__)
-# define COMPILER_ID "TI"
-  /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
-# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
-# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000   % 1000)
-# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__        % 1000)
-
-#elif defined(__SCO_VERSION__)
-# define COMPILER_ID "SCO"
-
-#elif defined(__GNUC__)
-# define COMPILER_ID "GNU"
-# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
-# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
-# if defined(__GNUC_PATCHLEVEL__)
-#  define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
-# endif
-
-#elif defined(_MSC_VER)
-# define COMPILER_ID "MSVC"
-  /* _MSC_VER = VVRR */
-# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
-# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
-# if defined(_MSC_FULL_VER)
-#  if _MSC_VER >= 1400
-    /* _MSC_FULL_VER = VVRRPPPPP */
-#   define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
-#  else
-    /* _MSC_FULL_VER = VVRRPPPP */
-#   define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
-#  endif
-# endif
-# if defined(_MSC_BUILD)
-#  define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
-# endif
-
-/* Analog VisualDSP++ >= 4.5.6 */
-#elif defined(__VISUALDSPVERSION__)
-# define COMPILER_ID "ADSP"
-  /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
-# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
-# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
-# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8  & 0xFF)
-
-/* Analog VisualDSP++ < 4.5.6 */
-#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
-# define COMPILER_ID "ADSP"
-
-/* IAR Systems compiler for embedded systems.
-   http://www.iar.com */
-#elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
-# define COMPILER_ID "IAR"
-
-#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
-# define COMPILER_ID "MIPSpro"
-# if defined(_SGI_COMPILER_VERSION)
-  /* _SGI_COMPILER_VERSION = VRP */
-#  define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
-#  define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
-#  define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION    % 10)
-# else
-  /* _COMPILER_VERSION = VRP */
-#  define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
-#  define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
-#  define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION    % 10)
-# endif
-
-/* This compiler is either not known or is too old to define an
-   identification macro.  Try to identify the platform and guess that
-   it is the native compiler.  */
-#elif defined(__sgi)
-# define COMPILER_ID "MIPSpro"
-
-#elif defined(__hpux) || defined(__hpua)
-# define COMPILER_ID "HP"
-
-#else /* unknown compiler */
-# define COMPILER_ID ""
-
-#endif
+@CMAKE_CXX_COMPILER_ID_CONTENT@
 
 /* Construct the string literal in pieces to prevent the source from
    getting matched.  Store it in a pointer rather than an array
diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake
index 3010a48..72b2857 100644
--- a/Modules/CMakeCXXInformation.cmake
+++ b/Modules/CMakeCXXInformation.cmake
@@ -266,10 +266,10 @@
 # Create a static archive incrementally for large object file counts.
 # If CMAKE_CXX_CREATE_STATIC_LIBRARY is set it will override these.
 if(NOT DEFINED CMAKE_CXX_ARCHIVE_CREATE)
-  set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+  set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
 endif()
 if(NOT DEFINED CMAKE_CXX_ARCHIVE_APPEND)
-  set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> r  <TARGET> <LINK_FLAGS> <OBJECTS>")
+  set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> q  <TARGET> <LINK_FLAGS> <OBJECTS>")
 endif()
 if(NOT DEFINED CMAKE_CXX_ARCHIVE_FINISH)
   set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake
index 38a6d35..fa025a8 100644
--- a/Modules/CMakeCommonLanguageInclude.cmake
+++ b/Modules/CMakeCommonLanguageInclude.cmake
@@ -16,9 +16,11 @@
 # cache values that can be initialized in the platform-compiler.cmake file
 # it may be included by more than one language.
 
-set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
-     CACHE STRING "Flags used by the linker.")
-
+if(NOT "x$ENV{LDFLAGS}" STREQUAL "x")
+  set (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}")
+  set (CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}")
+  set (CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}")
+endif()
 
 if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
 # default build type is none
@@ -82,12 +84,17 @@
      ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
      "Flags used by the linker during Release with Debug Info builds.")
 endif()
+
+# executable linker flags
+set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT}"
+     CACHE STRING "Flags used by the linker.")
+
 # shared linker flags
-set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
+set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT}"
      CACHE STRING "Flags used by the linker during the creation of dll's.")
 
 # module linker flags
-set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
+set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT}"
      CACHE STRING "Flags used by the linker during the creation of modules.")
 
 # static linker flags
@@ -124,4 +131,3 @@
 CMAKE_STATIC_LINKER_FLAGS_RELEASE
 CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
 )
-
diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake
new file mode 100644
index 0000000..d8a0d67
--- /dev/null
+++ b/Modules/CMakeCompilerIdDetection.cmake
@@ -0,0 +1,151 @@
+
+#=============================================================================
+# Copyright 2014 Stephen Kelly <steveire@gmail.com>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+function(_readFile file)
+  include(${file})
+  get_filename_component(name ${file} NAME_WE)
+  string(REGEX REPLACE "-.*" "" CompilerId ${name})
+  set(_compiler_id_version_compute_${CompilerId} ${_compiler_id_version_compute} PARENT_SCOPE)
+  set(_compiler_id_pp_test_${CompilerId} ${_compiler_id_pp_test} PARENT_SCOPE)
+endfunction()
+
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
+
+function(compiler_id_detection outvar lang)
+
+  if (NOT lang STREQUAL Fortran)
+    file(GLOB lang_files
+      "${CMAKE_ROOT}/Modules/Compiler/*-DetermineCompiler.cmake")
+    set(nonlang CXX)
+    if (lang STREQUAL CXX)
+      set(nonlang C)
+    endif()
+
+    file(GLOB nonlang_files
+      "${CMAKE_ROOT}/Modules/Compiler/*-${nonlang}-DetermineCompiler.cmake")
+    list(REMOVE_ITEM lang_files ${nonlang_files})
+  endif()
+
+  set(files ${lang_files})
+  if (files)
+    foreach(file ${files})
+      _readFile(${file})
+    endforeach()
+
+    set(options ID_STRING VERSION_STRINGS ID_DEFINE PLATFORM_DEFAULT_COMPILER)
+    set(oneValueArgs PREFIX)
+    cmake_parse_arguments(CID "${options}" "${oneValueArgs}" "${multiValueArgs}"  ${ARGN})
+    if (CID_UNPARSED_ARGUMENTS)
+      message(FATAL_ERROR "Unrecognized arguments: \"${CID_UNPARSED_ARGUMENTS}\"")
+    endif()
+
+    # Order is relevant here. For example, compilers which pretend to be
+    # GCC must appear before the actual GCC.
+    if (lang STREQUAL CXX)
+      list(APPEND ordered_compilers
+        Comeau
+      )
+    endif()
+    list(APPEND ordered_compilers
+      Intel
+      PathScale
+      AppleClang
+      Clang
+      Embarcadero
+      Borland
+      Watcom
+      OpenWatcom
+      SunPro
+      HP
+      Compaq
+      zOS
+      XL
+      VisualAge
+      PGI
+      Cray
+      TI
+    )
+    if (lang STREQUAL C)
+      list(APPEND ordered_compilers
+        TinyCC
+      )
+    endif()
+    list(APPEND ordered_compilers
+      SCO
+      GNU
+      MSVC
+      ADSP
+      IAR
+    )
+    if (lang STREQUAL C)
+      list(APPEND ordered_compilers
+        SDCC
+      )
+    endif()
+    list(APPEND ordered_compilers
+      MIPSpro)
+
+    if(CID_ID_DEFINE)
+      foreach(Id ${ordered_compilers})
+        set(CMAKE_${lang}_COMPILER_ID_CONTENT "${CMAKE_${lang}_COMPILER_ID_CONTENT}# define ${CID_PREFIX}COMPILER_IS_${Id} 0\n")
+      endforeach()
+    endif()
+
+    set(pp_if "#if")
+    if (CID_VERSION_STRINGS)
+      set(CMAKE_${lang}_COMPILER_ID_CONTENT "${CMAKE_${lang}_COMPILER_ID_CONTENT}\n/* Version number components: V=Version, R=Revision, P=Patch
+   Version date components:   YYYY=Year, MM=Month,   DD=Day  */\n")
+    endif()
+
+    foreach(Id ${ordered_compilers})
+      if (NOT _compiler_id_pp_test_${Id})
+        message(FATAL_ERROR "No preprocessor test for \"${Id}\"")
+      endif()
+      set(id_content "${pp_if} ${_compiler_id_pp_test_${Id}}\n")
+      if (CID_ID_STRING)
+        set(id_content "${id_content}# define ${CID_PREFIX}COMPILER_ID \"${Id}\"")
+      endif()
+      if (CID_ID_DEFINE)
+        set(id_content "${id_content}# undef ${CID_PREFIX}COMPILER_IS_${Id}\n")
+        set(id_content "${id_content}# define ${CID_PREFIX}COMPILER_IS_${Id} 1\n")
+      endif()
+      if (CID_VERSION_STRINGS)
+        set(PREFIX ${CID_PREFIX})
+        string(CONFIGURE "${_compiler_id_version_compute_${Id}}" VERSION_BLOCK @ONLY)
+        set(id_content "${id_content}${VERSION_BLOCK}\n")
+      endif()
+      set(CMAKE_${lang}_COMPILER_ID_CONTENT "${CMAKE_${lang}_COMPILER_ID_CONTENT}\n${id_content}")
+      set(pp_if "#elif")
+    endforeach()
+
+    if (CID_PLATFORM_DEFAULT_COMPILER)
+      set(platform_compiler_detection "
+/* These compilers are either not known or too old to define an
+  identification macro.  Try to identify the platform and guess that
+  it is the native compiler.  */
+#elif defined(__sgi)
+# define ${CID_PREFIX}COMPILER_ID \"MIPSpro\"
+
+#elif defined(__hpux) || defined(__hpua)
+# define ${CID_PREFIX}COMPILER_ID \"HP\"
+
+#else /* unknown compiler */
+# define ${CID_PREFIX}COMPILER_ID \"\"")
+    endif()
+
+    set(CMAKE_${lang}_COMPILER_ID_CONTENT "${CMAKE_${lang}_COMPILER_ID_CONTENT}\n${platform_compiler_detection}\n#endif")
+  endif()
+
+  set(${outvar} ${CMAKE_${lang}_COMPILER_ID_CONTENT} PARENT_SCOPE)
+endfunction()
diff --git a/Modules/CMakeConfigurableFile.in b/Modules/CMakeConfigurableFile.in
index 4cf74a1..df2c382 100644
--- a/Modules/CMakeConfigurableFile.in
+++ b/Modules/CMakeConfigurableFile.in
@@ -1,2 +1 @@
 @CMAKE_CONFIGURABLE_FILE_CONTENT@
-
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake
index 1d9617f..25af3e3 100644
--- a/Modules/CMakeDetermineASMCompiler.cmake
+++ b/Modules/CMakeDetermineASMCompiler.cmake
@@ -18,7 +18,7 @@
 
 if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
   # prefer the environment variable ASM
-  if($ENV{ASM${ASM_DIALECT}} MATCHES ".+")
+  if(NOT $ENV{ASM${ASM_DIALECT}} STREQUAL "")
     set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT "$ENV{ASM${ASM_DIALECT}}")
   endif()
 
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index aa4cdc9..3847b75 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -48,7 +48,7 @@
     set(CMAKE_C_COMPILER_INIT NOTFOUND)
 
     # prefer the environment variable CC
-    if($ENV{CC} MATCHES ".+")
+    if(NOT $ENV{CC} STREQUAL "")
       get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT)
       if(CMAKE_C_FLAGS_ENV_INIT)
         set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler")
@@ -138,7 +138,7 @@
     elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
       set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-)
     elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$")
-      if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$")
+      if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?")
         set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
       endif()
     endif ()
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index ef8445e..e6a9d9a 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -47,7 +47,7 @@
     set(CMAKE_CXX_COMPILER_INIT NOTFOUND)
 
     # prefer the environment variable CXX
-    if($ENV{CXX} MATCHES ".+")
+    if(NOT $ENV{CXX} STREQUAL "")
       get_filename_component(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT)
       if(CMAKE_CXX_FLAGS_ENV_INIT)
         set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler")
@@ -135,7 +135,7 @@
     elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
       set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-)
     elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$")
-      if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$")
+      if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?")
         set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
       endif()
     endif ()
diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake
new file mode 100644
index 0000000..2bb7a74
--- /dev/null
+++ b/Modules/CMakeDetermineCompileFeatures.cmake
@@ -0,0 +1,94 @@
+
+#=============================================================================
+# Copyright 2013 Stephen Kelly <steveire@gmail.com>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+function(cmake_determine_compile_features lang)
+
+  if(lang STREQUAL C AND COMMAND cmake_record_c_compile_features)
+    message(STATUS "Detecting ${lang} compile features")
+
+    set(CMAKE_C90_COMPILE_FEATURES)
+    set(CMAKE_C99_COMPILE_FEATURES)
+    set(CMAKE_C11_COMPILE_FEATURES)
+
+    include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
+
+    cmake_record_c_compile_features()
+
+    if(NOT _result EQUAL 0)
+      message(STATUS "Detecting ${lang} compile features - failed")
+      return()
+    endif()
+
+    if (CMAKE_C99_COMPILE_FEATURES AND CMAKE_C11_COMPILE_FEATURES)
+      list(REMOVE_ITEM CMAKE_C11_COMPILE_FEATURES ${CMAKE_C99_COMPILE_FEATURES})
+    endif()
+    if (CMAKE_C90_COMPILE_FEATURES AND CMAKE_C99_COMPILE_FEATURES)
+      list(REMOVE_ITEM CMAKE_C99_COMPILE_FEATURES ${CMAKE_C90_COMPILE_FEATURES})
+    endif()
+
+    if(NOT CMAKE_C_COMPILE_FEATURES)
+      set(CMAKE_C_COMPILE_FEATURES
+        ${CMAKE_C90_COMPILE_FEATURES}
+        ${CMAKE_C99_COMPILE_FEATURES}
+        ${CMAKE_C11_COMPILE_FEATURES}
+      )
+    endif()
+
+    set(CMAKE_C_COMPILE_FEATURES ${CMAKE_C_COMPILE_FEATURES} PARENT_SCOPE)
+    set(CMAKE_C90_COMPILE_FEATURES ${CMAKE_C90_COMPILE_FEATURES} PARENT_SCOPE)
+    set(CMAKE_C99_COMPILE_FEATURES ${CMAKE_C99_COMPILE_FEATURES} PARENT_SCOPE)
+    set(CMAKE_C11_COMPILE_FEATURES ${CMAKE_C11_COMPILE_FEATURES} PARENT_SCOPE)
+
+    message(STATUS "Detecting ${lang} compile features - done")
+
+  elseif(lang STREQUAL CXX AND COMMAND cmake_record_cxx_compile_features)
+    message(STATUS "Detecting ${lang} compile features")
+
+    set(CMAKE_CXX98_COMPILE_FEATURES)
+    set(CMAKE_CXX11_COMPILE_FEATURES)
+    set(CMAKE_CXX14_COMPILE_FEATURES)
+
+    include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
+
+    cmake_record_cxx_compile_features()
+
+    if(NOT _result EQUAL 0)
+      message(STATUS "Detecting ${lang} compile features - failed")
+      return()
+    endif()
+
+    if (CMAKE_CXX11_COMPILE_FEATURES AND CMAKE_CXX14_COMPILE_FEATURES)
+      list(REMOVE_ITEM CMAKE_CXX14_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES})
+    endif()
+    if (CMAKE_CXX98_COMPILE_FEATURES AND CMAKE_CXX11_COMPILE_FEATURES)
+      list(REMOVE_ITEM CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES})
+    endif()
+
+    if(NOT CMAKE_CXX_COMPILE_FEATURES)
+      set(CMAKE_CXX_COMPILE_FEATURES
+        ${CMAKE_CXX98_COMPILE_FEATURES}
+        ${CMAKE_CXX11_COMPILE_FEATURES}
+        ${CMAKE_CXX14_COMPILE_FEATURES}
+      )
+    endif()
+
+    set(CMAKE_CXX_COMPILE_FEATURES ${CMAKE_CXX_COMPILE_FEATURES} PARENT_SCOPE)
+    set(CMAKE_CXX98_COMPILE_FEATURES ${CMAKE_CXX98_COMPILE_FEATURES} PARENT_SCOPE)
+    set(CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES} PARENT_SCOPE)
+    set(CMAKE_CXX14_COMPILE_FEATURES ${CMAKE_CXX14_COMPILE_FEATURES} PARENT_SCOPE)
+
+    message(STATUS "Detecting ${lang} compile features - done")
+  endif()
+
+endfunction()
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index 5d35ce3..8595b97 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -52,11 +52,11 @@
         "Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n")
       file(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 2 REGEX "INFO:[^[]*\\[")
       foreach(info ${ABI_STRINGS})
-        if("${info}" MATCHES ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*")
-          string(REGEX REPLACE ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*" "\\1" ABI_SIZEOF_DPTR "${info}")
+        if("${info}" MATCHES "INFO:sizeof_dptr\\[0*([^]]*)\\]")
+          set(ABI_SIZEOF_DPTR "${CMAKE_MATCH_1}")
         endif()
-        if("${info}" MATCHES ".*INFO:abi\\[([^]]*)\\].*")
-          string(REGEX REPLACE ".*INFO:abi\\[([^]]*)\\].*" "\\1" ABI_NAME "${info}")
+        if("${info}" MATCHES "INFO:abi\\[([^]]*)\\]")
+          set(ABI_NAME "${CMAKE_MATCH_1}")
         endif()
       endforeach()
 
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 067892d..025d296 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -27,7 +27,7 @@
   else()
     set(CMAKE_${lang}_COMPILER_ID_FLAGS $ENV{${flagvar}})
   endif()
-  string(REGEX REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}")
+  string(REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}")
 
   # Compute the directory in which to run the test.
   set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang})
@@ -97,11 +97,20 @@
   set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
 endfunction()
 
+include(CMakeCompilerIdDetection)
+
 #-----------------------------------------------------------------------------
 # Function to write the compiler id source file.
 function(CMAKE_DETERMINE_COMPILER_ID_WRITE lang src)
   find_file(src_in ${src}.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
   file(READ ${src_in} ID_CONTENT_IN)
+
+  compiler_id_detection(CMAKE_${lang}_COMPILER_ID_CONTENT ${lang}
+    ID_STRING
+    VERSION_STRINGS
+    PLATFORM_DEFAULT_COMPILER
+  )
+
   unset(src_in CACHE)
   string(CONFIGURE "${ID_CONTENT_IN}" ID_CONTENT_OUT @ONLY)
   file(WRITE ${CMAKE_${lang}_COMPILER_ID_DIR}/${src} "${ID_CONTENT_OUT}")
@@ -215,6 +224,17 @@
     else()
       set(id_toolset "")
     endif()
+    if(CMAKE_OSX_DEPLOYMENT_TARGET)
+      set(id_deployment_target
+        "MACOSX_DEPLOYMENT_TARGET = \"${CMAKE_OSX_DEPLOYMENT_TARGET}\";")
+    else()
+      set(id_deployment_target "")
+    endif()
+    if(CMAKE_OSX_SYSROOT)
+      set(id_sdkroot "SDKROOT = \"${CMAKE_OSX_SYSROOT}\";")
+    else()
+      set(id_sdkroot "")
+    endif()
     if(NOT ${XCODE_VERSION} VERSION_LESS 3)
       set(v 3)
       set(ext xcodeproj)
@@ -356,35 +376,30 @@
       CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 6 REGEX "INFO:")
     set(COMPILER_ID_TWICE)
     foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS})
-      if("${info}" MATCHES ".*INFO:compiler\\[([^]\"]*)\\].*")
+      if("${info}" MATCHES "INFO:compiler\\[([^]\"]*)\\]")
         if(COMPILER_ID)
           set(COMPILER_ID_TWICE 1)
         endif()
-        string(REGEX REPLACE ".*INFO:compiler\\[([^]]*)\\].*" "\\1"
-          COMPILER_ID "${info}")
+        set(COMPILER_ID "${CMAKE_MATCH_1}")
       endif()
-      if("${info}" MATCHES ".*INFO:platform\\[([^]\"]*)\\].*")
-        string(REGEX REPLACE ".*INFO:platform\\[([^]]*)\\].*" "\\1"
-          PLATFORM_ID "${info}")
+      if("${info}" MATCHES "INFO:platform\\[([^]\"]*)\\]")
+        set(PLATFORM_ID "${CMAKE_MATCH_1}")
       endif()
-      if("${info}" MATCHES ".*INFO:arch\\[([^]\"]*)\\].*")
-        string(REGEX REPLACE ".*INFO:arch\\[([^]]*)\\].*" "\\1"
-          ARCHITECTURE_ID "${info}")
+      if("${info}" MATCHES "INFO:arch\\[([^]\"]*)\\]")
+        set(ARCHITECTURE_ID "${CMAKE_MATCH_1}")
       endif()
-      if("${info}" MATCHES ".*INFO:compiler_version\\[([^]\"]*)\\].*")
-        string(REGEX REPLACE ".*INFO:compiler_version\\[([^]]*)\\].*" "\\1" COMPILER_VERSION "${info}")
-        string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${COMPILER_VERSION}")
+      if("${info}" MATCHES "INFO:compiler_version\\[([^]\"]*)\\]")
+        string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}")
         string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}")
       endif()
-      if("${info}" MATCHES ".*INFO:simulate\\[([^]\"]*)\\].*")
+      if("${info}" MATCHES "INFO:simulate\\[([^]\"]*)\\]")
         set(SIMULATE_ID "${CMAKE_MATCH_1}")
       endif()
-      if("${info}" MATCHES ".*INFO:simulate_version\\[([^]\"]*)\\].*")
-        set(SIMULATE_VERSION "${CMAKE_MATCH_1}")
-        string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${SIMULATE_VERSION}")
+      if("${info}" MATCHES "INFO:simulate_version\\[([^]\"]*)\\]")
+        string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${CMAKE_MATCH_1}")
         string(REGEX REPLACE "\\.0+([0-9])" ".\\1" SIMULATE_VERSION "${SIMULATE_VERSION}")
       endif()
-      if("${info}" MATCHES ".*INFO:qnxnto")
+      if("${info}" MATCHES "INFO:qnxnto")
         set(COMPILER_QNXNTO 1)
       endif()
     endforeach()
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index d38bf25..96df6a2 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -32,7 +32,7 @@
 else()
   if(NOT CMAKE_Fortran_COMPILER)
     # prefer the environment variable CC
-    if($ENV{FC} MATCHES ".+")
+    if(NOT $ENV{FC} STREQUAL "")
       get_filename_component(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT)
       if(CMAKE_Fortran_FLAGS_ENV_INIT)
         set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler")
@@ -130,7 +130,7 @@
       ARGS ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\""
       OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN)
     if(NOT CMAKE_COMPILER_RETURN)
-      if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
+      if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_GNU")
         set(CMAKE_Fortran_COMPILER_ID "GNU")
         file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
           "Determining if the Fortran compiler is GNU succeeded with "
@@ -141,10 +141,10 @@
           "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
       endif()
       if(NOT CMAKE_Fortran_PLATFORM_ID)
-        if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" )
+        if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_MINGW")
           set(CMAKE_Fortran_PLATFORM_ID "MinGW")
         endif()
-        if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" )
+        if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_CYGWIN")
           set(CMAKE_Fortran_PLATFORM_ID "Cygwin")
         endif()
       endif()
diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake
index 7ae7856..f657801 100644
--- a/Modules/CMakeDetermineJavaCompiler.cmake
+++ b/Modules/CMakeDetermineJavaCompiler.cmake
@@ -18,7 +18,7 @@
 
 if(NOT CMAKE_Java_COMPILER)
   # prefer the environment variable CC
-  if($ENV{JAVA_COMPILER} MATCHES ".+")
+  if(NOT $ENV{JAVA_COMPILER} STREQUAL "")
     get_filename_component(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
     if(CMAKE_Java_FLAGS_ENV_INIT)
       set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "First argument to Java compiler")
@@ -28,14 +28,14 @@
     endif()
   endif()
 
-  if($ENV{JAVA_RUNTIME} MATCHES ".+")
+  if(NOT $ENV{JAVA_RUNTIME} STREQUAL "")
     get_filename_component(CMAKE_Java_RUNTIME_INIT $ENV{JAVA_RUNTIME} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
     if(NOT EXISTS ${CMAKE_Java_RUNTIME_INIT})
       message(SEND_ERROR "Could not find compiler set in environment variable JAVA_RUNTIME:\n$ENV{JAVA_RUNTIME}.")
     endif()
   endif()
 
-  if($ENV{JAVA_ARCHIVE} MATCHES ".+")
+  if(NOT $ENV{JAVA_ARCHIVE} STREQUAL "")
     get_filename_component(CMAKE_Java_ARCHIVE_INIT $ENV{JAVA_ARCHIVE} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
     if(NOT EXISTS ${CMAKE_Java_ARCHIVE_INIT})
       message(SEND_ERROR "Could not find compiler set in environment variable JAVA_ARCHIVE:\n$ENV{JAVA_ARCHIVE}.")
diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake
index f23846e..e5414eb 100644
--- a/Modules/CMakeDetermineRCCompiler.cmake
+++ b/Modules/CMakeDetermineRCCompiler.cmake
@@ -20,7 +20,7 @@
 # as a default compiler
 if(NOT CMAKE_RC_COMPILER)
   # prefer the environment variable RC
-  if($ENV{RC} MATCHES ".+")
+  if(NOT $ENV{RC} STREQUAL "")
     get_filename_component(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
     if(CMAKE_RC_FLAGS_ENV_INIT)
       set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler")
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index f1bad99..1c0941a 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -72,8 +72,8 @@
     endif()
     set(CMAKE_UNAME ${CMAKE_UNAME} CACHE INTERNAL "uname command")
     # processor may have double quote in the name, and that needs to be removed
-    string(REGEX REPLACE "\"" "" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
-    string(REGEX REPLACE "/" "_" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
+    string(REPLACE "\"" "" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
+    string(REPLACE "/" "_" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
   endif()
 else()
   if(CMAKE_HOST_WIN32)
diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake
index 2854387..6886084 100644
--- a/Modules/CMakeDetermineVSServicePack.cmake
+++ b/Modules/CMakeDetermineVSServicePack.cmake
@@ -43,6 +43,13 @@
 # (To distribute this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
+if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8)
+  message(DEPRECATION
+    "This module is deprecated and should not be used.  "
+    "Use the CMAKE_<LANG>_COMPILER_VERSION variable instead."
+    )
+endif()
+
 # [INTERNAL]
 # Please do not call this function directly
 function(_DetermineVSServicePackFromCompiler _OUT_VAR _cl_version)
diff --git a/Modules/CMakeExportBuildSettings.cmake b/Modules/CMakeExportBuildSettings.cmake
index 90a7a89..a8dd8c2 100644
--- a/Modules/CMakeExportBuildSettings.cmake
+++ b/Modules/CMakeExportBuildSettings.cmake
@@ -27,7 +27,7 @@
 # loaded by another project using CMAKE_IMPORT_BUILD_SETTINGS.  Now it
 # creates a file that refuses to load (with comment explaining why).
 macro(CMAKE_EXPORT_BUILD_SETTINGS SETTINGS_FILE)
-  if(${SETTINGS_FILE} MATCHES ".+")
+  if(NOT ${SETTINGS_FILE} STREQUAL "")
     configure_file(${CMAKE_ROOT}/Modules/CMakeBuildSettings.cmake.in
                    ${SETTINGS_FILE} @ONLY)
   else()
diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake
index 080dc68..d638207 100644
--- a/Modules/CMakeFortranInformation.cmake
+++ b/Modules/CMakeFortranInformation.cmake
@@ -194,10 +194,10 @@
 # Create a static archive incrementally for large object file counts.
 # If CMAKE_Fortran_CREATE_STATIC_LIBRARY is set it will override these.
 if(NOT DEFINED CMAKE_Fortran_ARCHIVE_CREATE)
-  set(CMAKE_Fortran_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+  set(CMAKE_Fortran_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
 endif()
 if(NOT DEFINED CMAKE_Fortran_ARCHIVE_APPEND)
-  set(CMAKE_Fortran_ARCHIVE_APPEND "<CMAKE_AR> r  <TARGET> <LINK_FLAGS> <OBJECTS>")
+  set(CMAKE_Fortran_ARCHIVE_APPEND "<CMAKE_AR> q  <TARGET> <LINK_FLAGS> <OBJECTS>")
 endif()
 if(NOT DEFINED CMAKE_Fortran_ARCHIVE_FINISH)
   set(CMAKE_Fortran_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
diff --git a/Modules/CMakeImportBuildSettings.cmake b/Modules/CMakeImportBuildSettings.cmake
index 60b887a..edecc1f 100644
--- a/Modules/CMakeImportBuildSettings.cmake
+++ b/Modules/CMakeImportBuildSettings.cmake
@@ -17,8 +17,7 @@
 # This macro used to load build settings from another project that
 # stored settings using the CMAKE_EXPORT_BUILD_SETTINGS macro.
 macro(CMAKE_IMPORT_BUILD_SETTINGS SETTINGS_FILE)
-  if(${SETTINGS_FILE} MATCHES ".+")
-  else()
+  if("${SETTINGS_FILE}" STREQUAL "")
     message(SEND_ERROR "CMAKE_IMPORT_BUILD_SETTINGS called with no argument.")
   endif()
 endmacro()
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 4724a8c..bfcf455 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -64,10 +64,9 @@
           string(REGEX REPLACE "^-L" "" dir "${arg}")
           list(APPEND implicit_dirs_tmp ${dir})
           set(log "${log}    arg [${arg}] ==> dir [${dir}]\n")
-        elseif("${arg}" MATCHES "^-l[^:]")
+        elseif("${arg}" MATCHES "^-l([^:].*)$")
           # Unix library.
-          string(REGEX REPLACE "^-l" "" lib "${arg}")
-          list(APPEND implicit_libs_tmp ${lib})
+          list(APPEND implicit_libs_tmp ${CMAKE_MATCH_1})
           set(log "${log}    arg [${arg}] ==> lib [${lib}]\n")
         elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$")
           # Unix library full path.
@@ -97,11 +96,10 @@
         endif()
       endforeach()
       break()
-    elseif("${line}" MATCHES "LPATH(=| is:? )")
+    elseif("${line}" MATCHES "LPATH(=| is:? *)(.*)$")
       set(log "${log}  LPATH line: [${line}]\n")
       # HP search path.
-      string(REGEX REPLACE ".*LPATH(=| is:? *)" "" paths "${line}")
-      string(REPLACE ":" ";" paths "${paths}")
+      string(REPLACE ":" ";" paths "${CMAKE_MATCH_2}")
       list(APPEND implicit_dirs_tmp ${paths})
       set(log "${log}    dirs [${paths}]\n")
     else()
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index 1e41fec..bc26c07 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -74,6 +74,23 @@
 #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
 # define PLATFORM_ID "Xenix"
 
+#elif defined(__WATCOMC__)
+# if defined(__LINUX__)
+#  define PLATFORM_ID "Linux"
+
+# elif defined(__DOS__)
+#  define PLATFORM_ID "DOS"
+
+# elif defined(__OS2__)
+#  define PLATFORM_ID "OS2"
+
+# elif defined(__WINDOWS__)
+#  define PLATFORM_ID "Windows3x"
+
+# else /* unknown platform */
+#  define PLATFORM_ID ""
+# endif
+
 #else /* unknown platform */
 # define PLATFORM_ID ""
 
@@ -107,6 +124,17 @@
 #  define ARCHITECTURE_ID ""
 # endif
 
+#elif defined(__WATCOMC__)
+# if defined(_M_I86)
+#  define ARCHITECTURE_ID "I86"
+
+# elif defined(_M_IX86)
+#  define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+#  define ARCHITECTURE_ID ""
+# endif
+
 #else
 #  define ARCHITECTURE_ID ""
 #endif
diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake
index 39f0023..bf4ec0e 100644
--- a/Modules/CMakePushCheckState.cmake
+++ b/Modules/CMakePushCheckState.cmake
@@ -53,6 +53,7 @@
    set(CMAKE_REQUIRED_DEFINITIONS)
    set(CMAKE_REQUIRED_LIBRARIES)
    set(CMAKE_REQUIRED_FLAGS)
+   set(CMAKE_REQUIRED_QUIET)
 
 endmacro()
 
@@ -68,6 +69,7 @@
    set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
    set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}   ${CMAKE_REQUIRED_LIBRARIES})
    set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}       ${CMAKE_REQUIRED_FLAGS})
+   set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}       ${CMAKE_REQUIRED_QUIET})
 
    if (ARGC GREATER 0 AND ARGV0 STREQUAL "RESET")
       cmake_reset_check_state()
@@ -84,6 +86,7 @@
       set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
       set(CMAKE_REQUIRED_LIBRARIES   ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
       set(CMAKE_REQUIRED_FLAGS       ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+      set(CMAKE_REQUIRED_QUIET       ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
 
       math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1")
    endif()
diff --git a/Modules/CMakeRCCompiler.cmake.in b/Modules/CMakeRCCompiler.cmake.in
index 0fc3142..8257cd6 100644
--- a/Modules/CMakeRCCompiler.cmake.in
+++ b/Modules/CMakeRCCompiler.cmake.in
@@ -1,6 +1,6 @@
 set(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@")
 set(CMAKE_RC_COMPILER_ARG1 "@CMAKE_RC_COMPILER_ARG1@")
 set(CMAKE_RC_COMPILER_LOADED 1)
-set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc)
+set(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc;RC)
 set(CMAKE_RC_OUTPUT_EXTENSION @CMAKE_RC_OUTPUT_EXTENSION@)
 set(CMAKE_RC_COMPILER_ENV_VAR "RC")
diff --git a/Modules/CMakeSystemSpecificInitialize.cmake b/Modules/CMakeSystemSpecificInitialize.cmake
new file mode 100644
index 0000000..5327ac1
--- /dev/null
+++ b/Modules/CMakeSystemSpecificInitialize.cmake
@@ -0,0 +1,20 @@
+
+#=============================================================================
+# Copyright 2002-2014 Kitware, Inc.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+# This file is included by cmGlobalGenerator::EnableLanguage.
+# It is included before the compiler has been determined.
+
+include(Platform/${CMAKE_SYSTEM_NAME}-Initialize OPTIONAL)
+
+set(CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED 1)
diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake
index d133042..29a58bd 100644
--- a/Modules/CMakeTestCCompiler.cmake
+++ b/Modules/CMakeTestCCompiler.cmake
@@ -73,6 +73,9 @@
   # Try to identify the ABI and configure it into CMakeCCompiler.cmake
   include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
   CMAKE_DETERMINE_COMPILER_ABI(C ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c)
+  # Try to identify the compiler features
+  include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
+  CMAKE_DETERMINE_COMPILE_FEATURES(C)
 
   # Re-configure to save learned information.
   configure_file(
diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake
index a06c92a..81561b2 100644
--- a/Modules/CMakeTestCXXCompiler.cmake
+++ b/Modules/CMakeTestCXXCompiler.cmake
@@ -66,6 +66,9 @@
   # Try to identify the ABI and configure it into CMakeCXXCompiler.cmake
   include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
   CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp)
+  # Try to identify the compiler features
+  include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
+  CMAKE_DETERMINE_COMPILE_FEATURES(CXX)
 
   # Re-configure to save learned information.
   configure_file(
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index c79ef06..8a4fa49 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -67,7 +67,12 @@
 #  * Mandatory : YES
 #  * Default   : 'devel'
 #
-#  The debian package section
+# .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
+#
+#  * Mandatory : YES
+#  * Default   : 'gzip'
+#
+#     Possible values are: lzma, xz, bzip2 and gzip.
 #
 # .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
 #
@@ -235,7 +240,7 @@
 
   # Check version of the dpkg-shlibdeps tool using CPackRPM method
   if(SHLIBDEPS_EXECUTABLE)
-    execute_process(COMMAND ${SHLIBDEPS_EXECUTABLE} --version
+    execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version
       OUTPUT_VARIABLE _TMP_VERSION
       ERROR_QUIET
       OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -254,7 +259,7 @@
       OUTPUT_VARIABLE CPACK_DEB_INSTALL_FILES)
 
     # Convert to CMake list
-    string(REGEX REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES})
+    string(REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES})
 
     # Only dynamically linked ELF files are included
     # Extract only file name infront of ":"
@@ -390,6 +395,12 @@
   set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
 endif()
 
+# Compression: (recommended)
+if(NOT CPACK_DEBIAN_COMPRESSION_TYPE)
+  set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
+endif()
+
+
 # Recommends:
 # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
 
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index a13a46f..2864b21 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -384,7 +384,7 @@
                     OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
                     ERROR_QUIET
                     OUTPUT_STRIP_TRAILING_WHITESPACE)
-    string(REGEX REPLACE "\n" ", "
+    string(REPLACE "\n" ", "
            LSB_RELEASE_OUTPUT
            ${_TMP_LSB_RELEASE_OUTPUT})
   else ()
@@ -397,7 +397,7 @@
 # to shut down warning about space in buildtree
 # some recent RPM version should support space in different places.
 # not checked [yet].
-if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*")
+if(CPACK_TOPLEVEL_DIRECTORY MATCHES " ")
   message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.")
 endif()
 
diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake
index 39183c6..0a47e19 100644
--- a/Modules/CPackWIX.cmake
+++ b/Modules/CPackWIX.cmake
@@ -216,9 +216,24 @@
 #  allow other CMake projects to find your package with
 #  the :command:`find_package` command.
 #
+# .. variable:: CPACK_WIX_PROPERTY_<PROPERTY>
+#
+#  This variable can be used to provide a value for
+#  the Windows Installer property ``<PROPERTY>``
+#
+#  The follwing list contains some example properties that can be used to
+#  customize information under
+#  "Programs and Features" (also known as "Add or Remove Programs")
+#
+#  * ARPCOMMENTS - Comments
+#  * ARPHELPLINK - Help and support information URL
+#  * ARPURLINFOABOUT - General information URL
+#  * URLUPDATEINFO - Update information URL
+#  * ARPHELPTELEPHONE - Help and support telephone number
+#  * ARPSIZE - Size (in kilobytes) of the application
 
 #=============================================================================
-# Copyright 2013 Kitware, Inc.
+# Copyright 2014 Kitware, Inc.
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake
index c2f6915..8721d55 100644
--- a/Modules/CheckCSourceCompiles.cmake
+++ b/Modules/CheckCSourceCompiles.cmake
@@ -21,6 +21,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2005-2009 Kitware, Inc.
@@ -67,7 +68,9 @@
     file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
       "${SOURCE}\n")
 
-    message(STATUS "Performing Test ${VAR}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Performing Test ${VAR}")
+    endif()
     try_compile(${VAR}
       ${CMAKE_BINARY_DIR}
       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
@@ -85,13 +88,17 @@
 
     if(${VAR})
       set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
-      message(STATUS "Performing Test ${VAR} - Success")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Success")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
         "${OUTPUT}\n"
         "Source file was:\n${SOURCE}\n")
     else()
-      message(STATUS "Performing Test ${VAR} - Failed")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Failed")
+      endif()
       set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
diff --git a/Modules/CheckCSourceRuns.cmake b/Modules/CheckCSourceRuns.cmake
index 2e68454..a4fa57e 100644
--- a/Modules/CheckCSourceRuns.cmake
+++ b/Modules/CheckCSourceRuns.cmake
@@ -21,6 +21,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2006-2009 Kitware, Inc.
@@ -56,7 +57,9 @@
     file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
       "${SOURCE}\n")
 
-    message(STATUS "Performing Test ${VAR}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Performing Test ${VAR}")
+    endif()
     try_run(${VAR}_EXITCODE ${VAR}_COMPILED
       ${CMAKE_BINARY_DIR}
       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
@@ -73,7 +76,9 @@
     # if the return value was 0 then it worked
     if("${${VAR}_EXITCODE}" EQUAL 0)
       set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
-      message(STATUS "Performing Test ${VAR} - Success")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Success")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
         "${OUTPUT}\n"
@@ -86,7 +91,9 @@
         set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
       endif()
 
-      message(STATUS "Performing Test ${VAR} - Failed")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Failed")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
         "${OUTPUT}\n"
diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake
index c7ef5ec..6ce64a1 100644
--- a/Modules/CheckCXXSourceCompiles.cmake
+++ b/Modules/CheckCXXSourceCompiles.cmake
@@ -21,6 +21,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2005-2009 Kitware, Inc.
@@ -68,7 +69,9 @@
     file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx"
       "${SOURCE}\n")
 
-    message(STATUS "Performing Test ${VAR}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Performing Test ${VAR}")
+    endif()
     try_compile(${VAR}
       ${CMAKE_BINARY_DIR}
       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
@@ -86,13 +89,17 @@
 
     if(${VAR})
       set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
-      message(STATUS "Performing Test ${VAR} - Success")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Success")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n"
         "${OUTPUT}\n"
         "Source file was:\n${SOURCE}\n")
     else()
-      message(STATUS "Performing Test ${VAR} - Failed")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Failed")
+      endif()
       set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n"
diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake
index 4e3ff6c..c655863 100644
--- a/Modules/CheckCXXSourceRuns.cmake
+++ b/Modules/CheckCXXSourceRuns.cmake
@@ -21,6 +21,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2006-2009 Kitware, Inc.
@@ -56,7 +57,9 @@
     file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx"
       "${SOURCE}\n")
 
-    message(STATUS "Performing Test ${VAR}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Performing Test ${VAR}")
+    endif()
     try_run(${VAR}_EXITCODE ${VAR}_COMPILED
       ${CMAKE_BINARY_DIR}
       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
@@ -74,7 +77,9 @@
     # if the return value was 0 then it worked
     if("${${VAR}_EXITCODE}" EQUAL 0)
       set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
-      message(STATUS "Performing Test ${VAR} - Success")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Success")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n"
         "${OUTPUT}\n"
@@ -87,7 +92,9 @@
         set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
       endif()
 
-      message(STATUS "Performing Test ${VAR} - Failed")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Performing Test ${VAR} - Failed")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n"
         "${OUTPUT}\n"
diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake
index aa62fbf..084fbb4 100644
--- a/Modules/CheckCXXSymbolExists.cmake
+++ b/Modules/CheckCXXSymbolExists.cmake
@@ -27,6 +27,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2003-2011 Kitware, Inc.
diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake
index e232bd7..bfd1836 100644
--- a/Modules/CheckFunctionExists.cmake
+++ b/Modules/CheckFunctionExists.cmake
@@ -20,6 +20,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2002-2011 Kitware, Inc.
@@ -40,7 +41,9 @@
   if("${VARIABLE}" MATCHES "^${VARIABLE}$")
     set(MACRO_CHECK_FUNCTION_DEFINITIONS
       "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
-    message(STATUS "Looking for ${FUNCTION}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Looking for ${FUNCTION}")
+    endif()
     if(CMAKE_REQUIRED_LIBRARIES)
       set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
         LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -63,12 +66,16 @@
       OUTPUT_VARIABLE OUTPUT)
     if(${VARIABLE})
       set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
-      message(STATUS "Looking for ${FUNCTION} - found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${FUNCTION} - found")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the function ${FUNCTION} exists passed with the following output:\n"
         "${OUTPUT}\n\n")
     else()
-      message(STATUS "Looking for ${FUNCTION} - not found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${FUNCTION} - not found")
+      endif()
       set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the function ${FUNCTION} exists failed with the following output:\n"
diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake
index 9dc1648..ea73267 100644
--- a/Modules/CheckIncludeFile.cmake
+++ b/Modules/CheckIncludeFile.cmake
@@ -24,6 +24,7 @@
 #   CMAKE_REQUIRED_FLAGS = string of compile command line flags
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2002-2009 Kitware, Inc.
@@ -49,7 +50,9 @@
     set(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
     configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in
       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c)
-    message(STATUS "Looking for ${INCLUDE}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Looking for ${INCLUDE}")
+    endif()
     if(${ARGC} EQUAL 3)
       set(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS})
       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGV2}")
@@ -69,14 +72,18 @@
     endif()
 
     if(${VARIABLE})
-      message(STATUS "Looking for ${INCLUDE} - found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${INCLUDE} - found")
+      endif()
       set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the include file ${INCLUDE} "
         "exists passed with the following output:\n"
         "${OUTPUT}\n\n")
     else()
-      message(STATUS "Looking for ${INCLUDE} - not found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${INCLUDE} - not found")
+      endif()
       set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the include file ${INCLUDE} "
diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake
index fa36a3f..39abeff 100644
--- a/Modules/CheckIncludeFileCXX.cmake
+++ b/Modules/CheckIncludeFileCXX.cmake
@@ -28,6 +28,7 @@
 #   CMAKE_REQUIRED_FLAGS = string of compile command line flags
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2002-2009 Kitware, Inc.
@@ -53,7 +54,9 @@
     set(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
     configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
-    message(STATUS "Looking for C++ include ${INCLUDE}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Looking for C++ include ${INCLUDE}")
+    endif()
     if(${ARGC} EQUAL 3)
       set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
@@ -73,14 +76,18 @@
     endif()
 
     if(${VARIABLE})
-      message(STATUS "Looking for C++ include ${INCLUDE} - found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for C++ include ${INCLUDE} - found")
+      endif()
       set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the include file ${INCLUDE} "
         "exists passed with the following output:\n"
         "${OUTPUT}\n\n")
     else()
-      message(STATUS "Looking for C++ include ${INCLUDE} - not found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for C++ include ${INCLUDE} - not found")
+      endif()
       set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the include file ${INCLUDE} "
diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake
index 182067f..6aa0f2b 100644
--- a/Modules/CheckIncludeFiles.cmake
+++ b/Modules/CheckIncludeFiles.cmake
@@ -23,6 +23,7 @@
 #   CMAKE_REQUIRED_FLAGS = string of compile command line flags
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2003-2012 Kitware, Inc.
@@ -66,7 +67,9 @@
       set(_description "include file ${_INCLUDE}")
     endif()
 
-    message(STATUS "Looking for ${_description}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Looking for ${_description}")
+    endif()
     try_compile(${VARIABLE}
       ${CMAKE_BINARY_DIR}
       ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c
@@ -76,14 +79,18 @@
       "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}"
       OUTPUT_VARIABLE OUTPUT)
     if(${VARIABLE})
-      message(STATUS "Looking for ${_description} - found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${_description} - found")
+      endif()
       set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if files ${INCLUDE} "
         "exist passed with the following output:\n"
         "${OUTPUT}\n\n")
     else()
-      message(STATUS "Looking for ${_description} - not found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${_description} - not found")
+      endif()
       set(${VARIABLE} "" CACHE INTERNAL "Have includes ${INCLUDE}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if files ${INCLUDE} "
diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake
index 3bd126a..99c809b 100644
--- a/Modules/CheckLanguage.cmake
+++ b/Modules/CheckLanguage.cmake
@@ -47,7 +47,7 @@
     message(STATUS ${_desc})
     file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang})
     file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt"
-      "cmake_minimum_required(VERSION 2.8)
+      "cmake_minimum_required(VERSION ${CMAKE_VERSION})
 project(Check${lang} ${lang})
 file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
   \"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\"
diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake
index f5c563c..2b41379 100644
--- a/Modules/CheckLibraryExists.cmake
+++ b/Modules/CheckLibraryExists.cmake
@@ -23,6 +23,7 @@
 #   CMAKE_REQUIRED_FLAGS = string of compile command line flags
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2002-2009 Kitware, Inc.
@@ -43,7 +44,9 @@
   if("${VARIABLE}" MATCHES "^${VARIABLE}$")
     set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
       "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
-    message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
+    endif()
     set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
     if(CMAKE_REQUIRED_LIBRARIES)
       set(CHECK_LIBRARY_EXISTS_LIBRARIES
@@ -60,14 +63,18 @@
       OUTPUT_VARIABLE OUTPUT)
 
     if(${VARIABLE})
-      message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
+      endif()
       set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
         "passed with the following output:\n"
         "${OUTPUT}\n\n")
     else()
-      message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
+      endif()
       set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake
index 25ea7f4..fe00074 100644
--- a/Modules/CheckPrototypeDefinition.cmake
+++ b/Modules/CheckPrototypeDefinition.cmake
@@ -33,6 +33,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2005-2009 Kitware, Inc.
@@ -97,12 +98,16 @@
 
     if (${_VARIABLE})
       set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
-      message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
         "${OUTPUT}\n\n")
     else ()
-      message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
+      endif()
       set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
diff --git a/Modules/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake
index a864e82..880a688 100644
--- a/Modules/CheckStructHasMember.cmake
+++ b/Modules/CheckStructHasMember.cmake
@@ -28,6 +28,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 #
 #
 #
diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index e1ca412..bf2e797 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -28,6 +28,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2003-2011 Kitware, Inc.
@@ -74,7 +75,9 @@
     configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
       "${SOURCEFILE}" @ONLY)
 
-    message(STATUS "Looking for ${SYMBOL}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Looking for ${SYMBOL}")
+    endif()
     try_compile(${VARIABLE}
       ${CMAKE_BINARY_DIR}
       "${SOURCEFILE}"
@@ -85,7 +88,9 @@
       "${CMAKE_SYMBOL_EXISTS_INCLUDES}"
       OUTPUT_VARIABLE OUTPUT)
     if(${VARIABLE})
-      message(STATUS "Looking for ${SYMBOL} - found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${SYMBOL} - found")
+      endif()
       set(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the ${SYMBOL} "
@@ -93,7 +98,9 @@
         "${OUTPUT}\nFile ${SOURCEFILE}:\n"
         "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n")
     else()
-      message(STATUS "Looking for ${SYMBOL} - not found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${SYMBOL} - not found")
+      endif()
       set(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}")
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the ${SYMBOL} "
diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake
index ec28d8b..8ce6b88 100644
--- a/Modules/CheckTypeSize.cmake
+++ b/Modules/CheckTypeSize.cmake
@@ -59,6 +59,7 @@
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_INCLUDES = list of include directories
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 #   CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include
 
 #=============================================================================
@@ -75,16 +76,19 @@
 #  License text for the above reference.)
 
 include(CheckIncludeFile)
+include(CheckIncludeFileCXX)
 
 cmake_policy(PUSH)
-cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
+cmake_policy(VERSION 3.0)
 
 get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
 
 #-----------------------------------------------------------------------------
 # Helper function.  DO NOT CALL DIRECTLY.
 function(__check_type_size_impl type var map builtin language)
-  message(STATUS "Check size of ${type}")
+  if(NOT CMAKE_REQUIRED_QUIET)
+    message(STATUS "Check size of ${type}")
+  endif()
 
   # Include header files.
   set(headers)
@@ -138,7 +142,7 @@
     foreach(info ${strings})
       if("${info}" MATCHES "${regex_size}")
         # Get the type size.
-        string(REGEX REPLACE "${regex_size}" "\\1" size "${info}")
+        set(size "${CMAKE_MATCH_1}")
         if(first)
           set(${var} ${size})
         elseif(NOT "${size}" STREQUAL "${${var}}")
@@ -168,13 +172,17 @@
       message(SEND_ERROR "CHECK_TYPE_SIZE found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !")
     endif()
 
-    message(STATUS "Check size of ${type} - done")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Check size of ${type} - done")
+    endif()
     file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
       "Determining size of ${type} passed with the following output:\n${output}\n\n")
     set(${var} "${${var}}" CACHE INTERNAL "CHECK_TYPE_SIZE: sizeof(${type})")
   else()
     # The check failed to compile.
-    message(STATUS "Check size of ${type} - failed")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Check size of ${type} - failed")
+    endif()
     file(READ ${src} content)
     file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
       "Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${content}\n\n")
@@ -218,9 +226,15 @@
     set(_builtin 0)
   else()
     set(_builtin 1)
-    check_include_file(sys/types.h HAVE_SYS_TYPES_H)
-    check_include_file(stdint.h HAVE_STDINT_H)
-    check_include_file(stddef.h HAVE_STDDEF_H)
+    if("${_language}" STREQUAL "C")
+      check_include_file(sys/types.h HAVE_SYS_TYPES_H)
+      check_include_file(stdint.h HAVE_STDINT_H)
+      check_include_file(stddef.h HAVE_STDDEF_H)
+    elseif("${_language}" STREQUAL "CXX")
+      check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
+      check_include_file_cxx(stdint.h HAVE_STDINT_H)
+      check_include_file_cxx(stddef.h HAVE_STDDEF_H)
+    endif()
   endif()
   unset(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY)
   unset(_CHECK_TYPE_SIZE_LANGUAGE)
diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake
index 4861ff0..3a7ef13 100644
--- a/Modules/CheckVariableExists.cmake
+++ b/Modules/CheckVariableExists.cmake
@@ -27,6 +27,7 @@
 #   CMAKE_REQUIRED_FLAGS = string of compile command line flags
 #   CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
 #   CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#   CMAKE_REQUIRED_QUIET = execute quietly without messages
 
 #=============================================================================
 # Copyright 2002-2009 Kitware, Inc.
@@ -47,7 +48,9 @@
   if("${VARIABLE}" MATCHES "^${VARIABLE}$")
     set(MACRO_CHECK_VARIABLE_DEFINITIONS
       "-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}")
-    message(STATUS "Looking for ${VAR}")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Looking for ${VAR}")
+    endif()
     if(CMAKE_REQUIRED_LIBRARIES)
       set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES
         LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -63,13 +66,17 @@
       OUTPUT_VARIABLE OUTPUT)
     if(${VARIABLE})
       set(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}")
-      message(STATUS "Looking for ${VAR} - found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${VAR} - found")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Determining if the variable ${VAR} exists passed with the following output:\n"
         "${OUTPUT}\n\n")
     else()
       set(${VARIABLE} "" CACHE INTERNAL "Have variable ${VAR}")
-      message(STATUS "Looking for ${VAR} - not found")
+      if(NOT CMAKE_REQUIRED_QUIET)
+        message(STATUS "Looking for ${VAR} - not found")
+      endif()
       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Determining if the variable ${VAR} exists failed with the following output:\n"
         "${OUTPUT}\n\n")
diff --git a/Modules/Compiler/ADSP-DetermineCompiler.cmake b/Modules/Compiler/ADSP-DetermineCompiler.cmake
new file mode 100644
index 0000000..0b5af0d
--- /dev/null
+++ b/Modules/Compiler/ADSP-DetermineCompiler.cmake
@@ -0,0 +1,10 @@
+
+set(_compiler_id_pp_test "defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)")
+
+set(_compiler_id_version_compute "
+#if defined(__VISUALDSPVERSION__)
+  /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
+# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
+# define @PREFIX@COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
+# define @PREFIX@COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8  & 0xFF)
+#endif")
diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake
index 680f720..0372e18 100644
--- a/Modules/Compiler/AppleClang-CXX.cmake
+++ b/Modules/Compiler/AppleClang-CXX.cmake
@@ -1 +1,6 @@
-include(Compiler/Clang-CXX)
+include(Compiler/Clang)
+__compiler_clang(CXX)
+
+if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+  set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
+endif()
diff --git a/Modules/Compiler/AppleClang-DetermineCompiler.cmake b/Modules/Compiler/AppleClang-DetermineCompiler.cmake
new file mode 100644
index 0000000..d293b7b
--- /dev/null
+++ b/Modules/Compiler/AppleClang-DetermineCompiler.cmake
@@ -0,0 +1,7 @@
+
+set(_compiler_id_pp_test "defined(__clang__) && defined(__apple_build_version__)")
+
+include("${CMAKE_CURRENT_LIST_DIR}/Clang-DetermineCompilerInternal.cmake")
+
+set(_compiler_id_version_compute "${_compiler_id_version_compute}
+# define @PREFIX@COMPILER_VERSION_TWEAK DEC(__apple_build_version__)")
diff --git a/Modules/Compiler/Borland-DetermineCompiler.cmake b/Modules/Compiler/Borland-DetermineCompiler.cmake
new file mode 100644
index 0000000..2e8a948
--- /dev/null
+++ b/Modules/Compiler/Borland-DetermineCompiler.cmake
@@ -0,0 +1,7 @@
+
+set(_compiler_id_pp_test "defined(__BORLANDC__)")
+
+set(_compiler_id_version_compute "
+  /* __BORLANDC__ = 0xVRR */
+# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
+# define @PREFIX@COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)")
diff --git a/Modules/Compiler/Clang-C-FeatureTests.cmake b/Modules/Compiler/Clang-C-FeatureTests.cmake
new file mode 100644
index 0000000..4a72e87
--- /dev/null
+++ b/Modules/Compiler/Clang-C-FeatureTests.cmake
@@ -0,0 +1,11 @@
+
+set(_cmake_oldestSupported "((__clang_major__ * 100) + __clang_minor__) >= 304")
+
+set(Clang_C11 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 201112L")
+set(_cmake_feature_test_c_static_assert "${Clang_C11}")
+set(Clang_C99 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 199901L")
+set(_cmake_feature_test_c_restrict "${Clang_C99}")
+set(_cmake_feature_test_c_variadic_macros "${Clang_C99}")
+
+set(Clang_C90 "${_cmake_oldestSupported} && !defined(__STDC_VERSION__)")
+set(_cmake_feature_test_c_function_prototypes "${Clang_C90}")
diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake
index 98fcd0b..05d3c0b 100644
--- a/Modules/Compiler/Clang-C.cmake
+++ b/Modules/Compiler/Clang-C.cmake
@@ -1,2 +1,38 @@
 include(Compiler/Clang)
 __compiler_clang(C)
+
+cmake_policy(GET CMP0025 appleClangPolicy)
+if(WIN32 OR (APPLE AND NOT appleClangPolicy STREQUAL NEW))
+  return()
+endif()
+
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
+  set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
+  set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+
+  set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
+  set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+
+  set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
+  set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+endif()
+
+set(CMAKE_C_STANDARD_DEFAULT 90)
+
+macro(cmake_record_c_compile_features)
+  macro(_get_clang_features std_version list)
+    record_compiler_features(C "-std=${std_version}" ${list})
+  endmacro()
+
+  if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
+    _get_clang_features(c11 CMAKE_C11_COMPILE_FEATURES)
+    if (_result EQUAL 0)
+      _get_clang_features(c99 CMAKE_C99_COMPILE_FEATURES)
+    endif()
+    if (_result EQUAL 0)
+      _get_clang_features(c90 CMAKE_C90_COMPILE_FEATURES)
+    endif()
+  else()
+    set(_result 0)
+  endif()
+endmacro()
diff --git a/Modules/Compiler/Clang-CXX-FeatureTests.cmake b/Modules/Compiler/Clang-CXX-FeatureTests.cmake
new file mode 100644
index 0000000..4c532fb
--- /dev/null
+++ b/Modules/Compiler/Clang-CXX-FeatureTests.cmake
@@ -0,0 +1,86 @@
+
+# Reference: http://clang.llvm.org/cxx_status.html
+# http://clang.llvm.org/docs/LanguageExtensions.html
+
+set(testable_features
+  cxx_alias_templates
+  cxx_alignas
+  cxx_attributes
+  cxx_auto_type
+  cxx_binary_literals
+  cxx_constexpr
+  cxx_contextual_conversions
+  cxx_decltype
+  cxx_decltype_incomplete_return_types
+  cxx_default_function_template_args
+  cxx_defaulted_functions
+  cxx_delegating_constructors
+  cxx_deleted_functions
+  cxx_explicit_conversions
+  cxx_generalized_initializers
+  cxx_inheriting_constructors
+  cxx_lambdas
+  cxx_local_type_template_args
+  cxx_noexcept
+  cxx_nonstatic_member_init
+  cxx_nullptr
+  cxx_range_for
+  cxx_raw_string_literals
+  cxx_reference_qualified_functions
+  cxx_relaxed_constexpr
+  cxx_return_type_deduction
+  cxx_rvalue_references
+  cxx_static_assert
+  cxx_strong_enums
+  cxx_thread_local
+  cxx_unicode_literals
+  cxx_unrestricted_unions
+  cxx_user_literals
+  cxx_variable_templates
+  cxx_variadic_templates
+)
+
+set(_cmake_oldestSupported "((__clang_major__ * 100) + __clang_minor__) >= 304")
+
+foreach(feature ${testable_features})
+  set(_cmake_feature_test_${feature} "${_cmake_oldestSupported} && __has_feature(${feature})")
+endforeach()
+
+unset(testable_features)
+
+set(_cmake_feature_test_cxx_aggregate_default_initializers "${_cmake_oldestSupported} && __has_feature(cxx_aggregate_nsdmi)")
+
+set(_cmake_feature_test_cxx_trailing_return_types "${_cmake_oldestSupported} && __has_feature(cxx_trailing_return)")
+set(_cmake_feature_test_cxx_alignof "${_cmake_oldestSupported} && __has_feature(cxx_alignas)")
+set(_cmake_feature_test_cxx_final "${_cmake_oldestSupported} && __has_feature(cxx_override_control)")
+set(_cmake_feature_test_cxx_override "${_cmake_oldestSupported} && __has_feature(cxx_override_control)")
+set(_cmake_feature_test_cxx_uniform_initialization "${_cmake_oldestSupported} && __has_feature(cxx_generalized_initializers)")
+set(_cmake_feature_test_cxx_defaulted_move_initializers "${_cmake_oldestSupported} && __has_feature(cxx_defaulted_functions)")
+set(_cmake_feature_test_cxx_lambda_init_captures "${_cmake_oldestSupported} && __has_feature(cxx_init_captures)")
+
+set(Clang34_CXX14 "((__clang_major__ * 100) + __clang_minor__) >= 304 && __cplusplus > 201103L")
+# http://llvm.org/bugs/show_bug.cgi?id=19242
+set(_cmake_feature_test_cxx_attribute_deprecated "${Clang34_CXX14}")
+# http://llvm.org/bugs/show_bug.cgi?id=19698
+set(_cmake_feature_test_cxx_decltype_auto "${Clang34_CXX14}")
+set(_cmake_feature_test_cxx_digit_separators "${Clang34_CXX14}")
+# http://llvm.org/bugs/show_bug.cgi?id=19674
+set(_cmake_feature_test_cxx_generic_lambdas "${Clang34_CXX14}")
+
+# TODO: Should be supported by Clang 3.1
+set(Clang31_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_enum_forward_declarations "${Clang31_CXX11}")
+set(_cmake_feature_test_cxx_sizeof_member "${Clang31_CXX11}")
+# TODO: Should be supported by Clang 2.9
+set(Clang29_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_extended_friend_declarations "${Clang29_CXX11}")
+set(_cmake_feature_test_cxx_extern_templates "${Clang29_CXX11}")
+set(_cmake_feature_test_cxx_func_identifier "${Clang29_CXX11}")
+set(_cmake_feature_test_cxx_inline_namespaces "${Clang29_CXX11}")
+set(_cmake_feature_test_cxx_long_long_type "${Clang29_CXX11}")
+set(_cmake_feature_test_cxx_right_angle_brackets "${Clang29_CXX11}")
+set(_cmake_feature_test_cxx_variadic_macros "${Clang29_CXX11}")
+
+# TODO: Should be supported forever?
+set(Clang_CXX98 "${_cmake_oldestSupported} && __cplusplus >= 199711L")
+set(_cmake_feature_test_cxx_template_template_parameters "${Clang_CXX98}")
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index 0372e18..bdb6d69 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -4,3 +4,46 @@
 if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
   set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
 endif()
+
+cmake_policy(GET CMP0025 appleClangPolicy)
+if(WIN32 OR (APPLE AND NOT appleClangPolicy STREQUAL NEW))
+  return()
+endif()
+
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
+  set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
+  set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+endif()
+
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
+  set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+  set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
+  set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
+  set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+endif()
+
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
+  set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++1y")
+  set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+endif()
+
+set(CMAKE_CXX_STANDARD_DEFAULT 98)
+
+macro(cmake_record_cxx_compile_features)
+  macro(_get_clang_features std_version list)
+    record_compiler_features(CXX "-std=${std_version}" ${list})
+  endmacro()
+
+  if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
+    _get_clang_features(c++1y CMAKE_CXX14_COMPILE_FEATURES)
+    if (_result EQUAL 0)
+      _get_clang_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
+    endif()
+    if (_result EQUAL 0)
+      _get_clang_features(c++98 CMAKE_CXX98_COMPILE_FEATURES)
+    endif()
+  else()
+    set(_result 0)
+  endif()
+endmacro()
diff --git a/Modules/Compiler/Clang-DetermineCompiler.cmake b/Modules/Compiler/Clang-DetermineCompiler.cmake
new file mode 100644
index 0000000..89df1b6
--- /dev/null
+++ b/Modules/Compiler/Clang-DetermineCompiler.cmake
@@ -0,0 +1,4 @@
+
+set(_compiler_id_pp_test "defined(__clang__)")
+
+include("${CMAKE_CURRENT_LIST_DIR}/Clang-DetermineCompilerInternal.cmake")
diff --git a/Modules/Compiler/Clang-DetermineCompilerInternal.cmake b/Modules/Compiler/Clang-DetermineCompilerInternal.cmake
new file mode 100644
index 0000000..9a37a63
--- /dev/null
+++ b/Modules/Compiler/Clang-DetermineCompilerInternal.cmake
@@ -0,0 +1,11 @@
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__clang_major__)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__clang_minor__)
+# define @PREFIX@COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
+# if defined(_MSC_VER)
+#  define @PREFIX@SIMULATE_ID \"MSVC\"
+   /* _MSC_VER = VVRR */
+#  define @PREFIX@SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+#  define @PREFIX@SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif")
diff --git a/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake b/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake
new file mode 100644
index 0000000..e4def4d
--- /dev/null
+++ b/Modules/Compiler/Comeau-CXX-DetermineCompiler.cmake
@@ -0,0 +1,7 @@
+
+set(_compiler_id_pp_test "defined(__COMO__)")
+
+set(_compiler_id_version_compute "
+  /* __COMO_VERSION__ = VRR */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)")
diff --git a/Modules/Compiler/Compaq-C-DetermineCompiler.cmake b/Modules/Compiler/Compaq-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..56fedb1
--- /dev/null
+++ b/Modules/Compiler/Compaq-C-DetermineCompiler.cmake
@@ -0,0 +1,8 @@
+
+set(_compiler_id_pp_test "defined(__DECC)")
+
+set(_compiler_id_version_compute "
+  /* __DECC_VER = VVRRTPPPP */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__DECC_VER/100000  % 100)
+# define @PREFIX@COMPILER_VERSION_PATCH DEC(__DECC_VER         % 10000)")
diff --git a/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake b/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake
new file mode 100644
index 0000000..5855c24
--- /dev/null
+++ b/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake
@@ -0,0 +1,8 @@
+
+set(_compiler_id_pp_test "defined(__DECCXX)")
+
+set(_compiler_id_version_compute "
+  /* __DECCXX_VER = VVRRTPPPP */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000  % 100)
+# define @PREFIX@COMPILER_VERSION_PATCH DEC(__DECCXX_VER         % 10000)")
diff --git a/Modules/Compiler/Cray-DetermineCompiler.cmake b/Modules/Compiler/Cray-DetermineCompiler.cmake
new file mode 100644
index 0000000..6e4eaf9
--- /dev/null
+++ b/Modules/Compiler/Cray-DetermineCompiler.cmake
@@ -0,0 +1,6 @@
+
+set(_compiler_id_pp_test "defined(_CRAYC)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(_RELEASE)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)")
diff --git a/Modules/Compiler/Embarcadero-DetermineCompiler.cmake b/Modules/Compiler/Embarcadero-DetermineCompiler.cmake
new file mode 100644
index 0000000..f52d79b
--- /dev/null
+++ b/Modules/Compiler/Embarcadero-DetermineCompiler.cmake
@@ -0,0 +1,7 @@
+
+set(_compiler_id_pp_test "defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
+# define @PREFIX@COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
+# define @PREFIX@COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__     & 0xFFFF)")
diff --git a/Modules/Compiler/GNU-C-FeatureTests.cmake b/Modules/Compiler/GNU-C-FeatureTests.cmake
new file mode 100644
index 0000000..dc1695c
--- /dev/null
+++ b/Modules/Compiler/GNU-C-FeatureTests.cmake
@@ -0,0 +1,12 @@
+
+set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
+
+set(GNU46_C11 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 201112L")
+set(_cmake_feature_test_c_static_assert "${GNU46_C11}")
+# Since 4.4 at least:
+set(GNU44_C99 "${_cmake_oldestSupported} && __STDC_VERSION__ >= 199901L")
+set(_cmake_feature_test_c_restrict "${GNU44_C99}")
+set(_cmake_feature_test_c_variadic_macros "${GNU44_C99}")
+
+set(GNU_C90 "${_cmake_oldestSupported} && !defined(__STDC_VERSION__)")
+set(_cmake_feature_test_c_function_prototypes "${GNU_C90}")
diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake
index 9a5137a..35954be 100644
--- a/Modules/Compiler/GNU-C.cmake
+++ b/Modules/Compiler/GNU-C.cmake
@@ -1,2 +1,34 @@
 include(Compiler/GNU)
 __compiler_gnu(C)
+
+if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
+  set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
+  set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+
+  set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
+  set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+
+  set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
+  set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+endif()
+
+# This may change in a future GNU version.
+set(CMAKE_C_STANDARD_DEFAULT 90)
+
+macro(cmake_record_c_compile_features)
+  macro(_get_gcc_features std_version list)
+    record_compiler_features(C "-std=${std_version}" ${list})
+  endmacro()
+
+  if (UNIX AND NOT APPLE AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
+    _get_gcc_features(c90 CMAKE_C90_COMPILE_FEATURES)
+    if (_result EQUAL 0)
+      _get_gcc_features(c99 CMAKE_C99_COMPILE_FEATURES)
+    endif()
+    if (_result EQUAL 0)
+      _get_gcc_features(c11 CMAKE_C11_COMPILE_FEATURES)
+    endif()
+  else()
+    set(_result 0)
+  endif()
+endmacro()
diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
new file mode 100644
index 0000000..9c98e44
--- /dev/null
+++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
@@ -0,0 +1,98 @@
+
+# Reference: http://gcc.gnu.org/projects/cxx0x.html
+
+set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
+
+set(GNU49_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L")
+set(_cmake_feature_test_cxx_contextual_conversions "${GNU49_CXX14}")
+set(_cmake_feature_test_cxx_attribute_deprecated "${GNU49_CXX14}")
+set(_cmake_feature_test_cxx_decltype_auto "${GNU49_CXX14}")
+set(_cmake_feature_test_cxx_digit_separators "${GNU49_CXX14}")
+set(_cmake_feature_test_cxx_generic_lambdas "${GNU49_CXX14}")
+set(_cmake_feature_test_cxx_lambda_init_captures "${GNU49_CXX14}")
+# GNU 4.3 supports binary literals as an extension, but may warn about
+# use of extensions prior to GNU 4.9
+# http://stackoverflow.com/questions/16334024/difference-between-gcc-binary-literals-and-c14-ones
+set(_cmake_feature_test_cxx_binary_literals "${GNU49_CXX14}")
+# The feature below is documented as available in GNU 4.8 (by implementing an
+# earlier draft of the standard paper), but that version of the compiler
+# does not set __cplusplus to a value greater than 201103L until GNU 4.9:
+# http://gcc.gnu.org/onlinedocs/gcc-4.8.2/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
+# http://gcc.gnu.org/onlinedocs/gcc-4.9.0/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
+# So, CMake only reports availability for it with GNU 4.9 or later.
+set(_cmake_feature_test_cxx_return_type_deduction "${GNU49_CXX14}")
+
+# Introduced in GCC 4.8.1
+set(GNU481_CXX11 "((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
+set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}")
+set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}")
+# The alignof feature works with GNU 4.7 and -std=c++11, but it is documented
+# as available with GNU 4.8, so treat that as true.
+set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}")
+set(GNU47_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_final "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_noexcept "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_override "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}")
+# NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor
+# release following that (March 2012), and the first minor release to
+# support -std=c++11. Prior to that, support for C++11 features is technically
+# experiemental and possibly incomplete (see for example the note below about
+# cxx_variadic_template_template_parameters)
+# TODO: Should be supported by GNU 4.6
+set(GNU46_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}")
+# TODO: Should be supported by GNU 4.5
+set(GNU45_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}")
+# TODO: Should be supported by GNU 4.4
+set(GNU44_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_inline_namespaces "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_sizeof_member "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_uniform_initialization "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}")
+# TODO: If features are ever recorded for GNU 4.3, there should possibly
+# be a new feature added like cxx_variadic_template_template_parameters,
+# which is implemented by GNU 4.4, but not 4.3. cxx_variadic_templates is
+# actually implemented by GNU 4.3, but variadic template template parameters
+# 'completes' it, so that is the version we record as having the variadic
+# templates capability in CMake. See
+# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf
+# TODO: Should be supported by GNU 4.3
+set(GNU43_CXX11 "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_long_long_type "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}")
+# TODO: Should be supported since GNU 3.4?
+set(_cmake_feature_test_cxx_extern_templates "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+# TODO: Should be supported forever?
+set(_cmake_feature_test_cxx_func_identifier "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_variadic_macros "${_cmake_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_template_template_parameters "${_cmake_oldestSupported} && __cplusplus >= 199711L")
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index 33d6093..14dc76a 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -10,3 +10,44 @@
     set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
   endif()
 endif()
+
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3)
+  set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
+  set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+endif()
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
+  set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+  set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3)
+  set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
+  set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+endif()
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
+  set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
+  set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+endif()
+
+set(CMAKE_CXX_STANDARD_DEFAULT 98)
+
+macro(cmake_record_cxx_compile_features)
+  macro(_get_gcc_features std_version list)
+    record_compiler_features(CXX "-std=${std_version}" ${list})
+  endmacro()
+
+  set(_result 0)
+  if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
+    _get_gcc_features(c++1y CMAKE_CXX14_COMPILE_FEATURES)
+  endif()
+  if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
+    if (_result EQUAL 0)
+      _get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
+    endif()
+    if (_result EQUAL 0)
+      _get_gcc_features(c++98 CMAKE_CXX98_COMPILE_FEATURES)
+    endif()
+  else()
+    set(_result 0)
+  endif()
+endmacro()
diff --git a/Modules/Compiler/GNU-DetermineCompiler.cmake b/Modules/Compiler/GNU-DetermineCompiler.cmake
new file mode 100644
index 0000000..f0c25dd
--- /dev/null
+++ b/Modules/Compiler/GNU-DetermineCompiler.cmake
@@ -0,0 +1,9 @@
+
+set(_compiler_id_pp_test "defined(__GNUC__)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__GNUC__)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
+# if defined(__GNUC_PATCHLEVEL__)
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
+# endif")
diff --git a/Modules/Compiler/HP-C-DetermineCompiler.cmake b/Modules/Compiler/HP-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..024a658
--- /dev/null
+++ b/Modules/Compiler/HP-C-DetermineCompiler.cmake
@@ -0,0 +1,8 @@
+
+set(_compiler_id_pp_test "defined(__HP_cc)")
+
+set(_compiler_id_version_compute "
+  /* __HP_cc = VVRRPP */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
+# define @PREFIX@COMPILER_VERSION_PATCH DEC(__HP_cc     % 100)")
diff --git a/Modules/Compiler/HP-CXX-DetermineCompiler.cmake b/Modules/Compiler/HP-CXX-DetermineCompiler.cmake
new file mode 100644
index 0000000..6999492
--- /dev/null
+++ b/Modules/Compiler/HP-CXX-DetermineCompiler.cmake
@@ -0,0 +1,8 @@
+
+set(_compiler_id_pp_test "defined(__HP_aCC)")
+
+set(_compiler_id_version_compute "
+  /* __HP_aCC = VVRRPP */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
+# define @PREFIX@COMPILER_VERSION_PATCH DEC(__HP_aCC     % 100)")
diff --git a/Modules/Compiler/HP-CXX.cmake b/Modules/Compiler/HP-CXX.cmake
index 44470ca..6411dac 100644
--- a/Modules/Compiler/HP-CXX.cmake
+++ b/Modules/Compiler/HP-CXX.cmake
@@ -2,3 +2,12 @@
 
 set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
 set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
+
+# HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98
+# template support. It is known that version 6.25 doesn't need that flag.
+# Current assumption: the flag is needed for every version from 3.80 to 4
+# to get it working.
+if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4 AND
+   NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.80)
+  set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "+hpxstd98")
+endif()
diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake
new file mode 100644
index 0000000..c39810a
--- /dev/null
+++ b/Modules/Compiler/IAR-DetermineCompiler.cmake
@@ -0,0 +1,4 @@
+
+# IAR Systems compiler for embedded systems.
+#   http://www.iar.com
+set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)")
diff --git a/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake
new file mode 100644
index 0000000..6169ab4
--- /dev/null
+++ b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake
@@ -0,0 +1,6 @@
+
+set(_compiler_id_version_compute "
+  /* __IBMC__ = VRP */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH DEC(__IBMC__    % 10)")
diff --git a/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake
new file mode 100644
index 0000000..f673d72
--- /dev/null
+++ b/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake
@@ -0,0 +1,6 @@
+
+set(_compiler_id_version_compute "
+  /* __IBMCPP__ = VRP */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH DEC(__IBMCPP__    % 10)")
diff --git a/Modules/Compiler/Intel-DetermineCompiler.cmake b/Modules/Compiler/Intel-DetermineCompiler.cmake
new file mode 100644
index 0000000..6fada1c
--- /dev/null
+++ b/Modules/Compiler/Intel-DetermineCompiler.cmake
@@ -0,0 +1,22 @@
+
+set(_compiler_id_pp_test "defined(__INTEL_COMPILER) || defined(__ICC)")
+
+set(_compiler_id_version_compute "
+  /* __INTEL_COMPILER = VRP */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
+# if defined(__INTEL_COMPILER_UPDATE)
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
+# else
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER   % 10)
+# endif
+# if defined(__INTEL_COMPILER_BUILD_DATE)
+  /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
+#  define @PREFIX@COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
+# endif
+# if defined(_MSC_VER)
+#  define @PREFIX@SIMULATE_ID \"MSVC\"
+   /* _MSC_VER = VVRR */
+#  define @PREFIX@SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
+#  define @PREFIX@SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
+# endif")
diff --git a/Modules/Compiler/MIPSpro-DetermineCompiler.cmake b/Modules/Compiler/MIPSpro-DetermineCompiler.cmake
new file mode 100644
index 0000000..31eb345
--- /dev/null
+++ b/Modules/Compiler/MIPSpro-DetermineCompiler.cmake
@@ -0,0 +1,15 @@
+
+set(_compiler_id_pp_test "defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)")
+
+set(_compiler_id_version_compute "
+# if defined(_SGI_COMPILER_VERSION)
+  /* _SGI_COMPILER_VERSION = VRP */
+#  define @PREFIX@COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
+#  define @PREFIX@COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION    % 10)
+# else
+  /* _COMPILER_VERSION = VRP */
+#  define @PREFIX@COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
+#  define @PREFIX@COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION    % 10)
+# endif")
diff --git a/Modules/Compiler/MSVC-DetermineCompiler.cmake b/Modules/Compiler/MSVC-DetermineCompiler.cmake
new file mode 100644
index 0000000..d462d07
--- /dev/null
+++ b/Modules/Compiler/MSVC-DetermineCompiler.cmake
@@ -0,0 +1,19 @@
+
+set(_compiler_id_pp_test "defined(_MSC_VER)")
+
+set(_compiler_id_version_compute "
+  /* _MSC_VER = VVRR */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
+# if defined(_MSC_FULL_VER)
+#  if _MSC_VER >= 1400
+    /* _MSC_FULL_VER = VVRRPPPPP */
+#   define @PREFIX@COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
+#  else
+    /* _MSC_FULL_VER = VVRRPPPP */
+#   define @PREFIX@COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
+#  endif
+# endif
+# if defined(_MSC_BUILD)
+#  define @PREFIX@COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
+# endif")
diff --git a/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake b/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake
new file mode 100644
index 0000000..6d416c1
--- /dev/null
+++ b/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake
@@ -0,0 +1,10 @@
+
+set(_compiler_id_pp_test "defined(__WATCOMC__)")
+
+set(_compiler_id_version_compute "
+   /* __WATCOMC__ = VVRP + 1100 */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif")
diff --git a/Modules/Compiler/PGI-DetermineCompiler.cmake b/Modules/Compiler/PGI-DetermineCompiler.cmake
new file mode 100644
index 0000000..8e68bd6
--- /dev/null
+++ b/Modules/Compiler/PGI-DetermineCompiler.cmake
@@ -0,0 +1,9 @@
+
+set(_compiler_id_pp_test "defined(__PGI)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__PGIC__)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
+# if defined(__PGIC_PATCHLEVEL__)
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
+# endif")
diff --git a/Modules/Compiler/PathScale-DetermineCompiler.cmake b/Modules/Compiler/PathScale-DetermineCompiler.cmake
new file mode 100644
index 0000000..3335e26
--- /dev/null
+++ b/Modules/Compiler/PathScale-DetermineCompiler.cmake
@@ -0,0 +1,9 @@
+
+set(_compiler_id_pp_test "defined(__PATHCC__)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__PATHCC__)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
+# if defined(__PATHCC_PATCHLEVEL__)
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
+# endif")
diff --git a/Modules/Compiler/SCO-DetermineCompiler.cmake b/Modules/Compiler/SCO-DetermineCompiler.cmake
new file mode 100644
index 0000000..a44b22b
--- /dev/null
+++ b/Modules/Compiler/SCO-DetermineCompiler.cmake
@@ -0,0 +1,2 @@
+
+set(_compiler_id_pp_test "defined(__SCO_VERSION__)")
diff --git a/Modules/Compiler/SDCC-C-DetermineCompiler.cmake b/Modules/Compiler/SDCC-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..8fe60d9
--- /dev/null
+++ b/Modules/Compiler/SDCC-C-DetermineCompiler.cmake
@@ -0,0 +1,10 @@
+
+# sdcc, the small devices C compiler for embedded systems,
+#   http://sdcc.sourceforge.net  */
+set(_compiler_id_pp_test "defined(SDCC)")
+
+set(_compiler_id_version_compute "
+  /* SDCC = VRP */
+#  define COMPILER_VERSION_MAJOR DEC(SDCC/100)
+#  define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
+#  define COMPILER_VERSION_PATCH DEC(SDCC    % 10)")
diff --git a/Modules/Compiler/SunPro-C-DetermineCompiler.cmake b/Modules/Compiler/SunPro-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..7db1a97
--- /dev/null
+++ b/Modules/Compiler/SunPro-C-DetermineCompiler.cmake
@@ -0,0 +1,15 @@
+
+set(_compiler_id_pp_test "defined(__SUNPRO_C)")
+
+set(_compiler_id_version_compute "
+# if __SUNPRO_C >= 0x5100
+   /* __SUNPRO_C = 0xVRRP */
+#  define @PREFIX@COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
+#  define @PREFIX@COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
+#  define @PREFIX@COMPILER_VERSION_PATCH HEX(__SUNPRO_C    & 0xF)
+# else
+   /* __SUNPRO_CC = 0xVRP */
+#  define @PREFIX@COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
+#  define @PREFIX@COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
+#  define @PREFIX@COMPILER_VERSION_PATCH HEX(__SUNPRO_C    & 0xF)
+# endif")
diff --git a/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake b/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake
new file mode 100644
index 0000000..0a48cc6
--- /dev/null
+++ b/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake
@@ -0,0 +1,15 @@
+
+set(_compiler_id_pp_test "defined(__SUNPRO_CC)")
+
+set(_compiler_id_version_compute "
+# if __SUNPRO_CC >= 0x5100
+   /* __SUNPRO_CC = 0xVRRP */
+#  define @PREFIX@COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
+#  define @PREFIX@COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
+#  define @PREFIX@COMPILER_VERSION_PATCH HEX(__SUNPRO_CC    & 0xF)
+# else
+   /* __SUNPRO_CC = 0xVRP */
+#  define @PREFIX@COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
+#  define @PREFIX@COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
+#  define @PREFIX@COMPILER_VERSION_PATCH HEX(__SUNPRO_CC    & 0xF)
+# endif")
diff --git a/Modules/Compiler/TI-DetermineCompiler.cmake b/Modules/Compiler/TI-DetermineCompiler.cmake
new file mode 100644
index 0000000..1856c9b
--- /dev/null
+++ b/Modules/Compiler/TI-DetermineCompiler.cmake
@@ -0,0 +1,8 @@
+
+set(_compiler_id_pp_test "defined(__TI_COMPILER_VERSION__)")
+
+set(_compiler_id_version_compute "
+  /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000   % 1000)
+# define @PREFIX@COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__        % 1000)")
diff --git a/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake b/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..8d6de7e
--- /dev/null
+++ b/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake
@@ -0,0 +1,2 @@
+
+set(_compiler_id_pp_test "defined(__TINYC__)")
diff --git a/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake b/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..97c2263
--- /dev/null
+++ b/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake
@@ -0,0 +1,4 @@
+
+set(_compiler_id_pp_test "defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800")
+
+include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-C-DetermineVersionInternal.cmake")
diff --git a/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake b/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake
new file mode 100644
index 0000000..cd53499
--- /dev/null
+++ b/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake
@@ -0,0 +1,4 @@
+
+set(_compiler_id_pp_test "defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800")
+
+include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-CXX-DetermineVersionInternal.cmake")
diff --git a/Modules/Compiler/Watcom-DetermineCompiler.cmake b/Modules/Compiler/Watcom-DetermineCompiler.cmake
new file mode 100644
index 0000000..cc59abf
--- /dev/null
+++ b/Modules/Compiler/Watcom-DetermineCompiler.cmake
@@ -0,0 +1,10 @@
+
+set(_compiler_id_pp_test "defined(__WATCOMC__) && __WATCOMC__ < 1200")
+
+set(_compiler_id_version_compute "
+   /* __WATCOMC__ = VVRR */
+# define @PREFIX@COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+#  define @PREFIX@COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif")
diff --git a/Modules/Compiler/XL-C-DetermineCompiler.cmake b/Modules/Compiler/XL-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..3f4e05c
--- /dev/null
+++ b/Modules/Compiler/XL-C-DetermineCompiler.cmake
@@ -0,0 +1,4 @@
+
+set(_compiler_id_pp_test "defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800")
+
+include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-C-DetermineVersionInternal.cmake")
diff --git a/Modules/Compiler/XL-CXX-DetermineCompiler.cmake b/Modules/Compiler/XL-CXX-DetermineCompiler.cmake
new file mode 100644
index 0000000..dffa4bc
--- /dev/null
+++ b/Modules/Compiler/XL-CXX-DetermineCompiler.cmake
@@ -0,0 +1,4 @@
+
+set(_compiler_id_pp_test "defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800")
+
+include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-CXX-DetermineVersionInternal.cmake")
diff --git a/Modules/Compiler/zOS-C-DetermineCompiler.cmake b/Modules/Compiler/zOS-C-DetermineCompiler.cmake
new file mode 100644
index 0000000..daa3781
--- /dev/null
+++ b/Modules/Compiler/zOS-C-DetermineCompiler.cmake
@@ -0,0 +1,4 @@
+
+set(_compiler_id_pp_test "defined(__IBMC__) && defined(__COMPILER_VER__)")
+
+include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-C-DetermineVersionInternal.cmake")
diff --git a/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake b/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake
new file mode 100644
index 0000000..a08ff57
--- /dev/null
+++ b/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake
@@ -0,0 +1,4 @@
+
+set(_compiler_id_pp_test "defined(__IBMCPP__) && defined(__COMPILER_VER__)")
+
+include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-CXX-DetermineVersionInternal.cmake")
diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in
index 6f861eb..eabfc6b 100644
--- a/Modules/CompilerId/Xcode-3.pbxproj.in
+++ b/Modules/CompilerId/Xcode-3.pbxproj.in
@@ -84,6 +84,8 @@
 				CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
 				SYMROOT = .;
 				@id_toolset@
+				@id_deployment_target@
+				@id_sdkroot@
 			};
 			name = Debug;
 		};
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index 1e2698c..73a4990 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -292,8 +292,7 @@
       foreach(piece IN LISTS pieces)
         if("x${piece}" MATCHES "^x${data_regex}$")
           # Replace this DATA{}-piece with a file path.
-          string(REGEX REPLACE "${data_regex}" "\\1" data "${piece}")
-          _ExternalData_arg("${target}" "${piece}" "${data}" file)
+          _ExternalData_arg("${target}" "${piece}" "${CMAKE_MATCH_1}" file)
           set(outArg "${outArg}${file}")
         else()
           # No replacement needed for this piece.
@@ -422,16 +421,16 @@
   set(external "") # Entries external to the source tree.
   set(internal "") # Entries internal to the source tree.
   set(have_original ${data_is_directory})
+  set(have_original_as_dir 0)
 
   # Process options.
   set(series_option "")
   set(associated_files "")
   set(associated_regex "")
   foreach(opt ${options})
-    if("x${opt}" MATCHES "^xREGEX:[^:/]+$")
-      # Regular expression to match associated files.
-      string(REGEX REPLACE "^REGEX:" "" regex "${opt}")
-      list(APPEND associated_regex "${regex}")
+    # Regular expression to match associated files.
+    if("x${opt}" MATCHES "^xREGEX:([^:/]+)$")
+      list(APPEND associated_regex "${CMAKE_MATCH_1}")
     elseif(opt STREQUAL ":")
       # Activate series matching.
       set(series_option "${opt}")
@@ -472,11 +471,18 @@
   endif()
 
   if(NOT have_original)
-    message(FATAL_ERROR "Data file referenced by argument\n"
+    if(have_original_as_dir)
+      set(msg_kind FATAL_ERROR)
+      set(msg "that is directory instead of a file!")
+    else()
+      set(msg_kind AUTHOR_WARNING)
+      set(msg "that does not exist as a file (with or without an extension)!")
+    endif()
+    message(${msg_kind} "Data file referenced by argument\n"
       "  ${arg}\n"
       "corresponds to source tree path\n"
       "  ${reldata}\n"
-      "that does not exist as a file (with or without an extension)!")
+      "${msg}")
   endif()
 
   if(external)
@@ -593,27 +599,33 @@
       set(alg "")
     endif()
     if("x${relname}" MATCHES "^x${regex}$" # matches
-        AND NOT IS_DIRECTORY "${top_src}/${entry}" # not a directory
         AND NOT "x${relname}" MATCHES "(^x|/)\\.ExternalData_" # not staged obj
         )
-      set(name "${top_src}/${relname}")
-      set(file "${top_bin}/${relname}")
-      if(alg)
-        list(APPEND external "${file}|${name}|${alg}")
-      elseif(ExternalData_LINK_CONTENT)
-        _ExternalData_link_content("${name}" alg)
-        list(APPEND external "${file}|${name}|${alg}")
-      elseif(NOT top_same)
-        list(APPEND internal "${file}|${name}")
-      endif()
-      if("${relname}" STREQUAL "${reldata}")
-        set(have_original 1)
+      if(IS_DIRECTORY "${top_src}/${entry}")
+        if("${relname}" STREQUAL "${reldata}")
+          set(have_original_as_dir 1)
+        endif()
+      else()
+        set(name "${top_src}/${relname}")
+        set(file "${top_bin}/${relname}")
+        if(alg)
+          list(APPEND external "${file}|${name}|${alg}")
+        elseif(ExternalData_LINK_CONTENT)
+          _ExternalData_link_content("${name}" alg)
+          list(APPEND external "${file}|${name}|${alg}")
+        elseif(NOT top_same)
+          list(APPEND internal "${file}|${name}")
+        endif()
+        if("${relname}" STREQUAL "${reldata}")
+          set(have_original 1)
+        endif()
       endif()
     endif()
   endforeach()
   set(external "${external}" PARENT_SCOPE)
   set(internal "${internal}" PARENT_SCOPE)
   set(have_original "${have_original}" PARENT_SCOPE)
+  set(have_original_as_dir "${have_original_as_dir}" PARENT_SCOPE)
 endfunction()
 
 #-----------------------------------------------------------------------------
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 17cb866..0d35cca 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -16,10 +16,12 @@
 #    [LIST_SEPARATOR sep]        # Sep to be replaced by ; in cmd lines
 #    [TMP_DIR dir]               # Directory to store temporary files
 #    [STAMP_DIR dir]             # Directory to store step timestamps
+#    [EXCLUDE_FROM_ALL 1]        # The "all" target does not depend on this
 #   #--Download step--------------
 #    [DOWNLOAD_NAME fname]       # File name to store (if not end of URL)
 #    [DOWNLOAD_DIR dir]          # Directory to store downloaded files
 #    [DOWNLOAD_COMMAND cmd...]   # Command to download source tree
+#    [DOWNLOAD_NO_PROGRESS 1]    # Disable download progress reports
 #    [CVS_REPOSITORY cvsroot]    # CVSROOT of CVS repository
 #    [CVS_MODULE mod]            # Module to checkout from CVS repo
 #    [CVS_TAG tag]               # Tag to checkout from CVS repo
@@ -54,6 +56,7 @@
 #    [BINARY_DIR dir]            # Specify build dir location
 #    [BUILD_COMMAND cmd...]      # Command to drive the native build
 #    [BUILD_IN_SOURCE 1]         # Use source dir for build dir
+#    [BUILD_ALWAYS 1]            # No stamp file, build step always runs
 #   #--Install step---------------
 #    [INSTALL_DIR dir]           # Installation prefix
 #    [INSTALL_COMMAND cmd...]    # Command to drive install after build
@@ -117,6 +120,7 @@
 #    [DEPENDERS steps...]    # Steps that depend on this step
 #    [DEPENDS files...]      # Files on which this step depends
 #    [ALWAYS 1]              # No stamp file, step always runs
+#    [EXCLUDE_FROM_MAIN 1]   # Main target does not depend on this step
 #    [WORKING_DIRECTORY dir] # Working directory for command
 #    [LOG 1]                 # Wrap step in script to log output
 #    )
@@ -197,11 +201,11 @@
      LIMIT_COUNT ${_ep_documentation_line_count}
      REGEX "^#  (  \\[[A-Z0-9_]+ [^]]*\\] +#.*$|[A-Za-z0-9_]+\\()")
 foreach(line IN LISTS lines)
-  if("${line}" MATCHES "^#  [A-Za-z0-9_]+\\(")
+  if("${line}" MATCHES "^#  ([A-Za-z0-9_]+)\\(")
     if(_ep_func)
       set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
     endif()
-    string(REGEX REPLACE "^#  ([A-Za-z0-9_]+)\\(.*" "\\1" _ep_func "${line}")
+    set(_ep_func "${CMAKE_MATCH_1}")
     #message("function [${_ep_func}]")
     set(_ep_keywords_${_ep_func} "^(")
     set(_ep_keyword_sep)
@@ -452,6 +456,7 @@
   WORKING_DIRECTORY \"${work_dir}\"
   RESULT_VARIABLE error_code
   OUTPUT_VARIABLE head_sha
+  OUTPUT_STRIP_TRAILING_WHITESPACE
   )
 if(error_code)
   message(FATAL_ERROR \"Failed to get the hash for HEAD\")
@@ -470,6 +475,17 @@
   set(is_remote_ref 0)
 endif()
 
+# Tag is in the form <remote>/<tag> (i.e. origin/master) we must strip
+# the remote from the tag.
+if(\"\${show_ref_output}\" MATCHES \"refs/remotes/${git_tag}\")
+  string(REGEX MATCH \"^([^/]+)/(.+)$\" _unused \"${git_tag}\")
+  set(git_remote \"\${CMAKE_MATCH_1}\")
+  set(git_tag \"\${CMAKE_MATCH_2}\")
+else()
+  set(git_remote \"origin\")
+  set(git_tag \"${git_tag}\")
+endif()
+
 # This will fail if the tag does not exist (it probably has not been fetched
 # yet).
 execute_process(
@@ -477,6 +493,7 @@
   WORKING_DIRECTORY \"${work_dir}\"
   RESULT_VARIABLE error_code
   OUTPUT_VARIABLE tag_sha
+  OUTPUT_STRIP_TRAILING_WHITESPACE
   )
 
 # Is the hash checkout out that we want?
@@ -490,13 +507,94 @@
     message(FATAL_ERROR \"Failed to fetch repository '${git_repository}'\")
   endif()
 
-  execute_process(
-    COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag}
-    WORKING_DIRECTORY \"${work_dir}\"
-    RESULT_VARIABLE error_code
-    )
-  if(error_code)
-    message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
+  if(is_remote_ref)
+    # Check if stash is needed
+    execute_process(
+      COMMAND \"${git_EXECUTABLE}\" status --porcelain
+      WORKING_DIRECTORY \"${work_dir}\"
+      RESULT_VARIABLE error_code
+      OUTPUT_VARIABLE repo_status
+      )
+    if(error_code)
+      message(FATAL_ERROR \"Failed to get the status\")
+    endif()
+    string(LENGTH \"\${repo_status}\" need_stash)
+
+    # If not in clean state, stash changes in order to be able to be able to
+    # perform git pull --rebase
+    if(need_stash)
+      execute_process(
+        COMMAND \"${git_EXECUTABLE}\" stash save --all --quiet
+        WORKING_DIRECTORY \"${work_dir}\"
+        RESULT_VARIABLE error_code
+        )
+      if(error_code)
+        message(FATAL_ERROR \"Failed to stash changes\")
+      endif()
+    endif()
+
+    # Pull changes from the remote branch
+    execute_process(
+      COMMAND \"${git_EXECUTABLE}\" rebase \${git_remote}/\${git_tag}
+      WORKING_DIRECTORY \"${work_dir}\"
+      RESULT_VARIABLE error_code
+      )
+    if(error_code)
+      # Rebase failed: Restore previous state.
+      execute_process(
+        COMMAND \"${git_EXECUTABLE}\" rebase --abort
+        WORKING_DIRECTORY \"${work_dir}\"
+      )
+      if(need_stash)
+        execute_process(
+          COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
+          WORKING_DIRECTORY \"${work_dir}\"
+          )
+      endif()
+      message(FATAL_ERROR \"\\nFailed to rebase in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\")
+    endif()
+
+    if(need_stash)
+      execute_process(
+        COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
+        WORKING_DIRECTORY \"${work_dir}\"
+        RESULT_VARIABLE error_code
+        )
+      if(error_code)
+        # Stash pop --index failed: Try again dropping the index
+        execute_process(
+          COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet
+          WORKING_DIRECTORY \"${work_dir}\"
+          RESULT_VARIABLE error_code
+          )
+        execute_process(
+          COMMAND \"${git_EXECUTABLE}\" stash pop --quiet
+          WORKING_DIRECTORY \"${work_dir}\"
+          RESULT_VARIABLE error_code
+          )
+        if(error_code)
+          # Stash pop failed: Restore previous state.
+          execute_process(
+            COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet \${head_sha}
+            WORKING_DIRECTORY \"${work_dir}\"
+          )
+          execute_process(
+            COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
+            WORKING_DIRECTORY \"${work_dir}\"
+          )
+          message(FATAL_ERROR \"\\nFailed to unstash changes in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\")
+        endif()
+      endif()
+    endif()
+  else()
+    execute_process(
+      COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag}
+      WORKING_DIRECTORY \"${work_dir}\"
+      RESULT_VARIABLE error_code
+      )
+    if(error_code)
+      message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
+    endif()
   endif()
 
   execute_process(
@@ -514,7 +612,7 @@
 
 endfunction(_ep_write_gitupdate_script)
 
-function(_ep_write_downloadfile_script script_filename remote local timeout hash tls_verify tls_cainfo)
+function(_ep_write_downloadfile_script script_filename remote local timeout no_progress hash tls_verify tls_cainfo)
   if(timeout)
     set(timeout_args TIMEOUT ${timeout})
     set(timeout_msg "${timeout} seconds")
@@ -523,6 +621,12 @@
     set(timeout_msg "none")
   endif()
 
+  if(no_progress)
+    set(show_progress "")
+  else()
+    set(show_progress "SHOW_PROGRESS")
+  endif()
+
   if("${hash}" MATCHES "${_ep_hash_regex}")
     set(hash_args EXPECTED_HASH ${CMAKE_MATCH_1}=${CMAKE_MATCH_2})
   else()
@@ -562,7 +666,7 @@
 file(DOWNLOAD
   \"${remote}\"
   \"${local}\"
-  SHOW_PROGRESS
+  ${show_progress}
   ${hash_args}
   ${timeout_args}
   STATUS status
@@ -803,7 +907,8 @@
   set(regex "^([^:]+):([^=]+)=(.*)$")
   set(setArg "")
   foreach(line ${args})
-    if("${line}" MATCHES "^-D")
+    if("${line}" MATCHES "^-D(.*)")
+      set(line "${CMAKE_MATCH_1}")
       if(setArg)
         # This is required to build up lists in variables, or complete an entry
         set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)")
@@ -811,9 +916,7 @@
         set(accumulator "")
         set(setArg "")
       endif()
-      string(REGEX REPLACE "^-D" "" line ${line})
       if("${line}" MATCHES "${regex}")
-        string(REGEX MATCH "${regex}" match "${line}")
         set(name "${CMAKE_MATCH_1}")
         set(type "${CMAKE_MATCH_2}")
         set(value "${CMAKE_MATCH_3}")
@@ -1073,6 +1176,8 @@
     _ep_get_step_stampfile(${name} ${step} stamp_file)
     add_custom_target(${name}-${step}
       DEPENDS ${stamp_file})
+    set_property(TARGET ${name}-${step} PROPERTY LABELS ${name})
+    set_property(TARGET ${name}-${step} PROPERTY FOLDER "ExternalProjectTargets/${name}")
 
     # Depend on other external projects (target-level).
     get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS)
@@ -1090,14 +1195,17 @@
   set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
   _ep_get_step_stampfile(${name} ${step} stamp_file)
 
-  add_custom_command(APPEND
-    OUTPUT ${complete_stamp_file}
-    DEPENDS ${stamp_file}
-    )
-
   _ep_parse_arguments(ExternalProject_Add_Step
                       ${name} _EP_${step}_ "${ARGN}")
 
+  get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN)
+  if(NOT exclude_from_main)
+    add_custom_command(APPEND
+      OUTPUT ${complete_stamp_file}
+      DEPENDS ${stamp_file}
+      )
+  endif()
+
   # Steps depending on this step.
   get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS)
   foreach(depender IN LISTS dependers)
@@ -1245,7 +1353,7 @@
   if(cmd_set)
     set(work_dir ${download_dir})
   elseif(cvs_repository)
-    find_package(CVS)
+    find_package(CVS QUIET)
     if(NOT CVS_EXECUTABLE)
       message(FATAL_ERROR "error: could not find cvs for checkout of ${name}")
     endif()
@@ -1272,7 +1380,7 @@
     set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q co ${cvs_tag} -d ${src_name} ${cvs_module})
     list(APPEND depends ${stamp_dir}/${name}-cvsinfo.txt)
   elseif(svn_repository)
-    find_package(Subversion)
+    find_package(Subversion QUIET)
     if(NOT Subversion_SVN_EXECUTABLE)
       message(FATAL_ERROR "error: could not find svn for checkout of ${name}")
     endif()
@@ -1308,7 +1416,7 @@
       --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name})
     list(APPEND depends ${stamp_dir}/${name}-svninfo.txt)
   elseif(git_repository)
-    find_package(Git)
+    find_package(Git QUIET)
     if(NOT GIT_EXECUTABLE)
       message(FATAL_ERROR "error: could not find git for clone of ${name}")
     endif()
@@ -1356,7 +1464,7 @@
     set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake)
     list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt)
   elseif(hg_repository)
-    find_package(Hg)
+    find_package(Hg QUIET)
     if(NOT HG_EXECUTABLE)
       message(FATAL_ERROR "error: could not find hg for clone of ${name}")
     endif()
@@ -1442,10 +1550,11 @@
         string(REPLACE ";" "-" fname "${fname}")
         set(file ${download_dir}/${fname})
         get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
+        get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS)
         get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY)
         get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO)
         set(download_script "${stamp_dir}/download-${name}.cmake")
-        _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}")
+        _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}")
         set(cmd ${CMAKE_COMMAND} -P "${download_script}"
           COMMAND)
         set(retries 3)
@@ -1716,10 +1825,18 @@
     set(log "")
   endif()
 
+  get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS)
+  if(build_always)
+    set(always 1)
+  else()
+    set(always 0)
+  endif()
+
   ExternalProject_Add_Step(${name} build
     COMMAND ${cmd}
     WORKING_DIRECTORY ${binary_dir}
     DEPENDEES configure
+    ALWAYS ${always}
     ${log}
     )
 endfunction()
@@ -1798,13 +1915,25 @@
   set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
   set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
 
+  # The "ALL" option to add_custom_target just tells it to not set the
+  # EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL
+  # argument was passed, we explicitly set it for the target.
   add_custom_target(${name} ALL DEPENDS ${complete_stamp_file})
   set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1)
+  set_property(TARGET ${name} PROPERTY LABELS ${name})
+  set_property(TARGET ${name} PROPERTY FOLDER "ExternalProjectTargets/${name}")
+
   _ep_parse_arguments(ExternalProject_Add ${name} _EP_ "${ARGN}")
   _ep_set_directories(${name})
   _ep_get_step_stampfile(${name} "done" done_stamp_file)
   _ep_get_step_stampfile(${name} "install" install_stamp_file)
 
+  # Set the EXCLUDE_FROM_ALL target property if required.
+  get_property(exclude_from_all TARGET ${name} PROPERTY _EP_EXCLUDE_FROM_ALL)
+  if(exclude_from_all)
+    set_property(TARGET ${name} PROPERTY EXCLUDE_FROM_ALL TRUE)
+  endif()
+
   # The 'complete' step depends on all other steps and creates a
   # 'done' mark.  A dependent external project's 'configure' step
   # depends on the 'done' mark so that it rebuilds when this project
diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake
index c0e63d5..12ea384 100644
--- a/Modules/FeatureSummary.cmake
+++ b/Modules/FeatureSummary.cmake
@@ -71,6 +71,13 @@
 #     RUNTIME_PACKAGES_FOUND: only those packages which have been found which have the type RUNTIME
 #     RUNTIME_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type RUNTIME
 #
+# With the exception of the ``ALL`` value, these values can be combined
+# in order to customize the output. For example:
+#
+# ::
+#
+#    feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
+#
 #
 #
 # If a FILENAME is given, the information is printed into this file.  If
@@ -417,8 +424,8 @@
 function(FEATURE_SUMMARY)
 # CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
   set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
-  set(oneValueArgs FILENAME VAR DESCRIPTION WHAT)
-  set(multiValueArgs ) # none
+  set(oneValueArgs FILENAME VAR DESCRIPTION)
+  set(multiValueArgs WHAT)
 
   CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}"  ${_FIRST_ARG} ${ARGN})
 
@@ -451,23 +458,42 @@
       set(requiredPackagesNotFound TRUE)
     endif()
 
-  elseif("${_FS_WHAT}" STREQUAL "ALL")
+  else()
+    if("${_FS_WHAT}" STREQUAL "ALL")
 
-    set(allWhatParts "ENABLED_FEATURES"
-                     "RUNTIME_PACKAGES_FOUND"
-                     "OPTIONAL_PACKAGES_FOUND"
-                     "RECOMMENDED_PACKAGES_FOUND"
-                     "REQUIRED_PACKAGES_FOUND"
+      set(allWhatParts "ENABLED_FEATURES"
+                       "RUNTIME_PACKAGES_FOUND"
+                       "OPTIONAL_PACKAGES_FOUND"
+                       "RECOMMENDED_PACKAGES_FOUND"
+                       "REQUIRED_PACKAGES_FOUND"
 
-                     "DISABLED_FEATURES"
-                     "RUNTIME_PACKAGES_NOT_FOUND"
-                     "OPTIONAL_PACKAGES_NOT_FOUND"
-                     "RECOMMENDED_PACKAGES_NOT_FOUND"
-                     "REQUIRED_PACKAGES_NOT_FOUND"
-       )
+                       "DISABLED_FEATURES"
+                       "RUNTIME_PACKAGES_NOT_FOUND"
+                       "OPTIONAL_PACKAGES_NOT_FOUND"
+                       "RECOMMENDED_PACKAGES_NOT_FOUND"
+                       "REQUIRED_PACKAGES_NOT_FOUND"
+      )
+
+    else()
+      set(allWhatParts)
+      foreach(part ${_FS_WHAT})
+        list(FIND validWhatParts "${part}" indexInList)
+        if(NOT "${indexInList}" STREQUAL "-1")
+          list(APPEND allWhatParts "${part}")
+        else()
+          if("${part}" STREQUAL "ALL")
+            message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ALL, which cannot be combined with other values.")
+          else()
+            message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ${part}, which is not a valid value.")
+          endif()
+        endif()
+      endforeach()
+    endif()
 
     set(title_ENABLED_FEATURES               "The following features have been enabled:")
     set(title_DISABLED_FEATURES              "The following features have been disabled:")
+    set(title_PACKAGES_FOUND                 "The following packages have been found:")
+    set(title_PACKAGES_NOT_FOUND             "The following packages have not been found:")
     set(title_OPTIONAL_PACKAGES_FOUND        "The following OPTIONAL packages have been found:")
     set(title_OPTIONAL_PACKAGES_NOT_FOUND    "The following OPTIONAL packages have not been found:")
     set(title_RECOMMENDED_PACKAGES_FOUND     "The following RECOMMENDED packages have been found:")
@@ -488,8 +514,6 @@
         endif()
       endif()
     endforeach()
-  else()
-    message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() is set to ${_FS_WHAT}, which is not a valid value.")
   endif()
 
   if(_FS_FILENAME)
@@ -522,10 +546,10 @@
   set(_url "${ARGV2}")
   set(_purpose "${ARGV3}")
   set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
-  if(_url MATCHES ".+")
+  if(NOT _url STREQUAL "")
     set_property(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_url}" )
   endif()
-  if(_purpose MATCHES ".+")
+  if(NOT _purpose STREQUAL "")
     set_property(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_purpose}" )
   endif()
 endfunction()
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake
index 9ca428e..ec3ee78 100644
--- a/Modules/FindBISON.cmake
+++ b/Modules/FindBISON.cmake
@@ -92,16 +92,13 @@
     message(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}")
   else()
     # Bison++
-    if("${BISON_version_output}" MATCHES "^bison\\+\\+")
-      string(REGEX REPLACE "^bison\\+\\+ Version ([^,]+).*" "\\1"
-        BISON_VERSION "${BISON_version_output}")
+    if("${BISON_version_output}" MATCHES "^bison\\+\\+ Version ([^,]+)")
+      set(BISON_VERSION "${CMAKE_MATCH_1}")
     # GNU Bison
-    elseif("${BISON_version_output}" MATCHES "^bison[^+]")
-      string(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1"
-        BISON_VERSION "${BISON_version_output}")
-    elseif("${BISON_version_output}" MATCHES "^GNU Bison ")
-      string(REGEX REPLACE "^GNU Bison (version )?([^\n]+).*" "\\2"
-        BISON_VERSION "${BISON_version_output}")
+    elseif("${BISON_version_output}" MATCHES "^bison \\(GNU Bison\\) ([^\n]+)\n")
+      set(BISON_VERSION "${CMAKE_MATCH_1}")
+    elseif("${BISON_version_output}" MATCHES "^GNU Bison (version )?([^\n]+)")
+      set(BISON_VERSION "${CMAKE_MATCH_2}")
     endif()
   endif()
 
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 3b658ef..6a583d9 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -52,6 +52,9 @@
 
 include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+cmake_push_check_state()
+set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY})
 
 set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
 
@@ -147,7 +150,7 @@
 set(BLAS_LINKER_FLAGS)
 set(BLAS_LIBRARIES)
 set(BLAS95_LIBRARIES)
-if ($ENV{BLA_VENDOR} MATCHES ".+")
+if (NOT $ENV{BLA_VENDOR} STREQUAL "")
   set(BLA_VENDOR $ENV{BLA_VENDOR})
 else ()
   if(NOT BLA_VENDOR)
@@ -285,7 +288,7 @@
 endif ()
 
 #BLAS in acml library?
-if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
+if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
  if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
      ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
      ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
@@ -462,7 +465,7 @@
 endif ()
 
 #BLAS in intel mkl 10 library? (em64t 64bit)
-if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
+if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
  if (NOT WIN32)
   set(LM "-lm")
  endif ()
@@ -529,7 +532,7 @@
           "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide")
 
         # mkl >= 10.3
-        if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
+        if (CMAKE_C_COMPILER MATCHES ".+gcc")
           list(APPEND BLAS_SEARCH_LIBS
             "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
         else ()
@@ -597,7 +600,7 @@
           "mkl_intel_lp64 mkl_intel_thread mkl_core guide")
 
         # mkl >= 10.3
-        if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
+        if (CMAKE_C_COMPILER MATCHES ".+gcc")
           list(APPEND BLAS_SEARCH_LIBS
             "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
         else ()
@@ -687,4 +690,5 @@
   endif()
 endif()
 
+cmake_pop_check_state()
 set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake
index 3883877..b479332 100644
--- a/Modules/FindBZip2.cmake
+++ b/Modules/FindBZip2.cmake
@@ -57,7 +57,11 @@
 
 if (BZIP2_FOUND)
    include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+   include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+   cmake_push_check_state()
+   set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY})
    CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX)
+   cmake_pop_check_state()
 endif ()
 
 mark_as_advanced(BZIP2_INCLUDE_DIR)
diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake
index 83789cc..5620661 100644
--- a/Modules/FindBacktrace.cmake
+++ b/Modules/FindBacktrace.cmake
@@ -62,6 +62,7 @@
   # First, check if we already have backtrace(), e.g., in libc
   cmake_push_check_state(RESET)
   set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS})
+  set(CMAKE_REQUIRED_QUIET ${Backtrace_FIND_QUIETLY})
   check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND)
   cmake_pop_check_state()
 endif()
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index a57e12c..dfd4460 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -631,12 +631,12 @@
     set(_boost_BOOSTIFIED_VERSION)
 
     # Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
-    if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
-        string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
-          _boost_BOOSTIFIED_VERSION ${_boost_VER})
-    elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
-        string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
-          _boost_BOOSTIFIED_VERSION ${_boost_VER})
+    if(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
+        set(_boost_BOOSTIFIED_VERSION
+          "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}_${CMAKE_MATCH_3}")
+    elseif(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)")
+        set(_boost_BOOSTIFIED_VERSION
+          "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
     endif()
 
     list(APPEND _boost_PATH_SUFFIXES
@@ -684,7 +684,7 @@
   set(_Boost_VERSION_REGEX "([0-9]+)")
   set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"")
   foreach(v VERSION LIB_VERSION)
-    if("${_boost_VERSION_HPP_CONTENTS}" MATCHES ".*#define BOOST_${v} ${_Boost_${v}_REGEX}.*")
+    if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_${v} ${_Boost_${v}_REGEX}")
       set(Boost_${v} "${CMAKE_MATCH_1}")
     endif()
   endforeach()
@@ -954,7 +954,8 @@
 
   # Compute component-specific hints.
   set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
-  if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python")
+  if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR
+     ${COMPONENT} STREQUAL "graph_parallel")
     foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES})
       if(IS_ABSOLUTE "${lib}")
         get_filename_component(libdir "${lib}" PATH)
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index d50e960..d9809ad 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -31,8 +31,8 @@
 # The following variables affect the behavior of the macros in the
 # script (in alphebetical order).  Note that any of these flags can be
 # changed multiple times in the same directory before calling
-# CUDA_ADD_EXECUTABLE, CUDA_ADD_LIBRARY, CUDA_COMPILE, CUDA_COMPILE_PTX
-# or CUDA_WRAP_SRCS::
+# CUDA_ADD_EXECUTABLE, CUDA_ADD_LIBRARY, CUDA_COMPILE, CUDA_COMPILE_PTX,
+# CUDA_COMPILE_FATBIN, CUDA_COMPILE_CUBIN or CUDA_WRAP_SRCS::
 #
 #   CUDA_64_BIT_DEVICE_CODE (Default matches host bit size)
 #   -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code.
@@ -152,6 +152,12 @@
 #   CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] )
 #   -- Returns a list of PTX files generated from the input source files.
 #
+#   CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] )
+#   -- Returns a list of FATBIN files generated from the input source files.
+#
+#   CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] )
+#   -- Returns a list of CUBIN files generated from the input source files.
+#
 #   CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var
 #                                                        cuda_target
 #                                                        object_files )
@@ -324,11 +330,6 @@
 
 # FindCUDA.cmake
 
-# We need to have at least this version to support the VERSION_LESS argument to 'if' (2.6.2) and unset (2.6.3)
-cmake_policy(PUSH)
-cmake_minimum_required(VERSION 2.6.3)
-cmake_policy(POP)
-
 # This macro helps us find the location of helper files we will need the full path to
 macro(CUDA_FIND_HELPER_FILE _name _extension)
   set(_full_name "${_name}.${_extension}")
@@ -987,7 +988,7 @@
     endif()
   endif()
 
-  # This recipie is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the
+  # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the
   # CMake source.
 
   # Remove leading /
@@ -1016,7 +1017,7 @@
 # a .cpp or .ptx file.
 # INPUT:
 #   cuda_target         - Target name
-#   format              - PTX or OBJ
+#   format              - PTX, CUBIN, FATBIN or OBJ
 #   FILE1 .. FILEN      - The remaining arguments are the sources to be wrapped.
 #   OPTIONS             - Extra options to NVCC
 # OUTPUT:
@@ -1194,7 +1195,7 @@
   foreach(file ${ARGN})
     # Ignore any file marked as a HEADER_FILE_ONLY
     get_source_file_property(_is_header ${file} HEADER_FILE_ONLY)
-    if(${file} MATCHES ".*\\.cu$" AND NOT _is_header)
+    if(${file} MATCHES "\\.cu$" AND NOT _is_header)
 
       # Allow per source file overrides of the format.
       get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT)
@@ -1202,16 +1203,22 @@
         set(_cuda_source_format ${format})
       endif()
 
-      if( ${_cuda_source_format} MATCHES "PTX" )
-        set( compile_to_ptx ON )
-      elseif( ${_cuda_source_format} MATCHES "OBJ")
-        set( compile_to_ptx OFF )
+      if( ${_cuda_source_format} MATCHES "OBJ")
+        set( cuda_compile_to_external_module OFF )
       else()
-        message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS for file '${file}': '${_cuda_source_format}'.  Use OBJ or PTX.")
+        set( cuda_compile_to_external_module ON )
+        if( ${_cuda_source_format} MATCHES "PTX" )
+          set( cuda_compile_to_external_module_type "ptx" )
+        elseif( ${_cuda_source_format} MATCHES "CUBIN")
+          set( cuda_compile_to_external_module_type "cubin" )
+        elseif( ${_cuda_source_format} MATCHES "FATBIN")
+          set( cuda_compile_to_external_module_type "fatbin" )
+        else()
+          message( FATAL_ERROR "Invalid format flag passed to CUDA_WRAP_SRCS for file '${file}': '${_cuda_source_format}'.  Use OBJ, PTX, CUBIN or FATBIN.")
+        endif()
       endif()
 
-
-      if(compile_to_ptx)
+      if(cuda_compile_to_external_module)
         # Don't use any of the host compilation flags for PTX targets.
         set(CUDA_HOST_FLAGS)
         set(CUDA_NVCC_FLAGS_CONFIG)
@@ -1226,7 +1233,7 @@
       if(CUDA_GENERATED_OUTPUT_DIR)
         set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}")
       else()
-        if ( compile_to_ptx )
+        if ( cuda_compile_to_external_module )
           set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}")
         else()
           set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}")
@@ -1236,10 +1243,10 @@
       # Add a custom target to generate a c or ptx file. ######################
 
       get_filename_component( basename ${file} NAME )
-      if( compile_to_ptx )
+      if( cuda_compile_to_external_module )
         set(generated_file_path "${cuda_compile_output_dir}")
-        set(generated_file_basename "${cuda_target}_generated_${basename}.ptx")
-        set(format_flag "-ptx")
+        set(generated_file_basename "${cuda_target}_generated_${basename}.${cuda_compile_to_external_module_type}")
+        set(format_flag "-${cuda_compile_to_external_module_type}")
         file(MAKE_DIRECTORY "${cuda_compile_output_dir}")
       else()
         set(generated_file_path "${cuda_compile_output_dir}/${CMAKE_CFG_INTDIR}")
@@ -1262,7 +1269,7 @@
       set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake")
 
       # Setup properties for obj files:
-      if( NOT compile_to_ptx )
+      if( NOT cuda_compile_to_external_module )
         set_source_files_properties("${generated_file}"
           PROPERTIES
           EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked.
@@ -1277,7 +1284,7 @@
         set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
       endif()
 
-      if( NOT compile_to_ptx AND CUDA_SEPARABLE_COMPILATION)
+      if( NOT cuda_compile_to_external_module AND CUDA_SEPARABLE_COMPILATION)
         list(APPEND ${cuda_target}_SEPARABLE_COMPILATION_OBJECTS "${generated_file}")
       endif()
 
@@ -1294,7 +1301,7 @@
       # Build the NVCC made dependency file ###################################
       set(build_cubin OFF)
       if ( NOT CUDA_BUILD_EMULATION AND CUDA_BUILD_CUBIN )
-         if ( NOT compile_to_ptx )
+         if ( NOT cuda_compile_to_external_module )
            set ( build_cubin ON )
          endif()
       endif()
@@ -1321,8 +1328,8 @@
 
       # Create up the comment string
       file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}")
-      if(compile_to_ptx)
-        set(cuda_build_comment_string "Building NVCC ptx file ${generated_file_relative_path}")
+      if(cuda_compile_to_external_module)
+        set(cuda_build_comment_string "Building NVCC ${cuda_compile_to_external_module_type} file ${generated_file_relative_path}")
       else()
         set(cuda_build_comment_string "Building NVCC (${cuda_build_type}) object ${generated_file_relative_path}")
       endif()
@@ -1561,21 +1568,29 @@
 
 ###############################################################################
 ###############################################################################
-# CUDA COMPILE
+# (Internal) helper for manually added cuda source files with specific targets
 ###############################################################################
 ###############################################################################
-macro(CUDA_COMPILE generated_files)
+macro(cuda_compile_base cuda_target format generated_files)
 
   # Separate the sources from the options
   CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN})
   # Create custom commands and targets for each file.
-  CUDA_WRAP_SRCS( cuda_compile OBJ _generated_files ${_sources} ${_cmake_options}
+  CUDA_WRAP_SRCS( ${cuda_target} ${format} _generated_files ${_sources} ${_cmake_options}
     OPTIONS ${_options} )
 
   set( ${generated_files} ${_generated_files})
 
 endmacro()
 
+###############################################################################
+###############################################################################
+# CUDA COMPILE
+###############################################################################
+###############################################################################
+macro(CUDA_COMPILE generated_files)
+  cuda_compile_base(cuda_compile OBJ ${generated_files} ${ARGN})
+endmacro()
 
 ###############################################################################
 ###############################################################################
@@ -1583,19 +1598,30 @@
 ###############################################################################
 ###############################################################################
 macro(CUDA_COMPILE_PTX generated_files)
-
-  # Separate the sources from the options
-  CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN})
-  # Create custom commands and targets for each file.
-  CUDA_WRAP_SRCS( cuda_compile_ptx PTX _generated_files ${_sources} ${_cmake_options}
-    OPTIONS ${_options} )
-
-  set( ${generated_files} ${_generated_files})
-
+  cuda_compile_base(cuda_compile_ptx PTX ${generated_files} ${ARGN})
 endmacro()
 
 ###############################################################################
 ###############################################################################
+# CUDA COMPILE FATBIN
+###############################################################################
+###############################################################################
+macro(CUDA_COMPILE_FATBIN generated_files)
+  cuda_compile_base(cuda_compile_fatbin FATBIN ${generated_files} ${ARGN})
+endmacro()
+
+###############################################################################
+###############################################################################
+# CUDA COMPILE CUBIN
+###############################################################################
+###############################################################################
+macro(CUDA_COMPILE_CUBIN generated_files)
+  cuda_compile_base(cuda_compile_cubin CUBIN ${generated_files} ${ARGN})
+endmacro()
+
+
+###############################################################################
+###############################################################################
 # CUDA ADD CUFFT TO TARGET
 ###############################################################################
 ###############################################################################
diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake
index 1b53d17..c433fa8 100644
--- a/Modules/FindCUDA/make2cmake.cmake
+++ b/Modules/FindCUDA/make2cmake.cmake
@@ -37,12 +37,11 @@
 
 file(READ ${input_file} depend_text)
 
-if (${depend_text} MATCHES ".+")
+if (NOT "${depend_text}" STREQUAL "")
 
   # message("FOUND DEPENDS")
 
-  # Remember, four backslashes is escaped to one backslash in the string.
-  string(REGEX REPLACE "\\\\ " " " depend_text ${depend_text})
+  string(REPLACE "\\ " " " depend_text ${depend_text})
 
   # This works for the nvcc -M generated dependency files.
   string(REGEX REPLACE "^.* : " "" depend_text ${depend_text})
diff --git a/Modules/FindCUDA/parse_cubin.cmake b/Modules/FindCUDA/parse_cubin.cmake
index 94be7e2..626c8a2 100644
--- a/Modules/FindCUDA/parse_cubin.cmake
+++ b/Modules/FindCUDA/parse_cubin.cmake
@@ -37,11 +37,10 @@
 
 file(READ ${input_file} file_text)
 
-if (${file_text} MATCHES ".+")
+if (NOT "${file_text}" STREQUAL "")
 
-  # Remember, four backslashes is escaped to one backslash in the string.
-  string(REGEX REPLACE ";" "\\\\;" file_text ${file_text})
-  string(REGEX REPLACE "\ncode" ";code" file_text ${file_text})
+  string(REPLACE ";" "\\;" file_text ${file_text})
+  string(REPLACE "\ncode" ";code" file_text ${file_text})
 
   list(LENGTH file_text len)
 
@@ -57,7 +56,7 @@
 
         # Extract kernel names.
         if (${entry} MATCHES "[^g]name = ([^ ]+)")
-          string(REGEX REPLACE ".* = ([^ ]+)" "\\1" entry ${entry})
+          set(entry "${CMAKE_MATCH_1}")
 
           # Check to see if the kernel name starts with "_"
           set(skip FALSE)
@@ -76,19 +75,19 @@
 
           # Registers
           if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)")
-            string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
+            set(entry "${CMAKE_MATCH_3}")
             message("Registers: ${entry}")
           endif()
 
           # Local memory
           if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)")
-            string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
+            set(entry "${CMAKE_MATCH_3}")
             message("Local:     ${entry}")
           endif()
 
           # Shared memory
           if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)")
-            string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
+            set(entry "${CMAKE_MATCH_3}")
             message("Shared:    ${entry}")
           endif()
 
diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake
index 4b55d6a..51eb7c5 100644
--- a/Modules/FindCups.cmake
+++ b/Modules/FindCups.cmake
@@ -36,9 +36,13 @@
 
 if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE)
     include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+    include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+    cmake_push_check_state()
+    set(CMAKE_REQUIRED_QUIET ${Cups_FIND_QUIETLY})
 
     # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint)
     CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE)
+    cmake_pop_check_state()
 endif ()
 
 if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h")
@@ -48,9 +52,8 @@
     unset(CUPS_VERSION_STRING)
     foreach(VPART MAJOR MINOR PATCH)
         foreach(VLINE ${cups_version_str})
-            if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}")
-                string(REGEX REPLACE "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$" "\\1"
-                       CUPS_VERSION_PART "${VLINE}")
+            if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$")
+                set(CUPS_VERSION_PART "${CMAKE_MATCH_1}")
                 if(CUPS_VERSION_STRING)
                     set(CUPS_VERSION_STRING "${CUPS_VERSION_STRING}.${CUPS_VERSION_PART}")
                 else()
diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake
index a453a67..9b633c7 100644
--- a/Modules/FindCurses.cmake
+++ b/Modules/FindCurses.cmake
@@ -67,6 +67,9 @@
 # default search paths.
 if(CURSES_CURSES_LIBRARY  AND  CURSES_NEED_NCURSES)
   include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+  include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+  cmake_push_check_state()
+  set(CMAKE_REQUIRED_QUIET ${Curses_FIND_QUIETLY})
   CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}"
     wsyncup "" CURSES_CURSES_HAS_WSYNCUP)
 
@@ -77,6 +80,7 @@
       set(CURSES_USE_NCURSES TRUE)
     endif()
   endif()
+  cmake_pop_check_state()
 
 endif()
 
diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake
index a456d9c..d34941a 100644
--- a/Modules/FindDoxygen.cmake
+++ b/Modules/FindDoxygen.cmake
@@ -30,7 +30,16 @@
 #
 #    DOXYGEN_DOT_EXECUTABLE = The path to the dot program used by doxygen.
 #    DOXYGEN_DOT_FOUND      = Was Dot found or not?
-#    DOXYGEN_DOT_PATH       = The path to dot not including the executable
+#
+# For compatibility with older versions of CMake, the now-deprecated
+# variable ``DOXYGEN_DOT_PATH`` is set to the path to the directory
+# containing ``dot`` as reported in ``DOXYGEN_DOT_EXECUTABLE``.
+# The path may have forward slashes even on Windows and is not
+# suitable for direct substitution into a ``Doxyfile.in`` template.
+# If you need this value, use :command:`get_filename_component`
+# to compute it from ``DOXYGEN_DOT_EXECUTABLE`` directly, and
+# perhaps the :command:`file(TO_NATIVE_PATH)` command to prepare
+# the path for a Doxygen configuration file.
 
 #=============================================================================
 # Copyright 2001-2009 Kitware, Inc.
@@ -101,12 +110,18 @@
 # Find Dot...
 #
 
+set(_x86 "(x86)")
+file(GLOB _Doxygen_GRAPHVIZ_BIN_DIRS
+  "$ENV{ProgramFiles}/Graphviz*/bin"
+  "$ENV{ProgramFiles${_x86}}/Graphviz*/bin"
+  )
+unset(_x86)
+
 if(NOT DOXYGEN_SKIP_DOT)
   find_program(DOXYGEN_DOT_EXECUTABLE
     NAMES dot
     PATHS
-      "$ENV{ProgramFiles}/Graphviz 2.21/bin"
-      "C:/Program Files/Graphviz 2.21/bin"
+      ${_Doxygen_GRAPHVIZ_BIN_DIRS}
       "$ENV{ProgramFiles}/ATT/Graphviz/bin"
       "C:/Program Files/ATT/Graphviz/bin"
       [HKEY_LOCAL_MACHINE\\SOFTWARE\\ATT\\Graphviz;InstallPath]/bin
@@ -119,7 +134,7 @@
   if(DOXYGEN_DOT_EXECUTABLE)
     set(DOXYGEN_DOT_FOUND TRUE)
     # The Doxyfile wants the path to Dot, not the entire path and executable
-    get_filename_component(DOXYGEN_DOT_PATH "${DOXYGEN_DOT_EXECUTABLE}" PATH CACHE)
+    get_filename_component(DOXYGEN_DOT_PATH "${DOXYGEN_DOT_EXECUTABLE}" PATH)
   endif()
 
 endif()
@@ -153,5 +168,4 @@
 mark_as_advanced(
   DOXYGEN_EXECUTABLE
   DOXYGEN_DOT_EXECUTABLE
-  DOXYGEN_DOT_PATH
   )
diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake
index 6183af8..653094c 100644
--- a/Modules/FindEXPAT.cmake
+++ b/Modules/FindEXPAT.cmake
@@ -38,9 +38,8 @@
     unset(EXPAT_VERSION_STRING)
     foreach(VPART MAJOR MINOR MICRO)
         foreach(VLINE ${expat_version_str})
-            if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION")
-                string(REGEX REPLACE "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$" "\\1"
-                       EXPAT_VERSION_PART "${VLINE}")
+            if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
+                set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
                 if(EXPAT_VERSION_STRING)
                     set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}")
                 else()
diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake
index b87bc7f..76f702e 100644
--- a/Modules/FindFLTK.cmake
+++ b/Modules/FindFLTK.cmake
@@ -285,9 +285,7 @@
           OUTPUT_VARIABLE FLTK_IMAGES_LDFLAGS)
         set(FLTK_LIBS_EXTRACT_REGEX ".*-lfltk_images (.*) -lfltk.*")
         if("${FLTK_IMAGES_LDFLAGS}" MATCHES "${FLTK_LIBS_EXTRACT_REGEX}")
-          string(REGEX REPLACE "${FLTK_LIBS_EXTRACT_REGEX}" "\\1"
-            FLTK_IMAGES_LIBS "${FLTK_IMAGES_LDFLAGS}")
-          string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}")
+          string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${CMAKE_MATCH_1}")
           # The EXEC_PROGRAM will not be inherited into subdirectories from
           # the file that originally included this module.  Save the answer.
           set(FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}" CACHE INTERNAL
diff --git a/Modules/FindFLTK2.cmake b/Modules/FindFLTK2.cmake
index 4deffda..930acca 100644
--- a/Modules/FindFLTK2.cmake
+++ b/Modules/FindFLTK2.cmake
@@ -226,9 +226,7 @@
           OUTPUT_VARIABLE FLTK2_IMAGES_LDFLAGS)
         set(FLTK2_LIBS_EXTRACT_REGEX ".*-lfltk2_images (.*) -lfltk2.*")
         if("${FLTK2_IMAGES_LDFLAGS}" MATCHES "${FLTK2_LIBS_EXTRACT_REGEX}")
-          string(REGEX REPLACE "${FLTK2_LIBS_EXTRACT_REGEX}" "\\1"
-            FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LDFLAGS}")
-          string(REGEX REPLACE " +" ";" FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}")
+          string(REGEX REPLACE " +" ";" FLTK2_IMAGES_LIBS "${CMAKE_MATCH_1}")
           # The EXEC_PROGRAM will not be inherited into subdirectories from
           # the file that originally included this module.  Save the answer.
           set(FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}" CACHE INTERNAL
diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake
index 6f03c86..7d46d15 100644
--- a/Modules/FindFreetype.cmake
+++ b/Modules/FindFreetype.cmake
@@ -51,7 +51,9 @@
 # wants explicit full paths and this trickery doesn't work too well.
 # I'm going to attempt to cut out the middleman and hope
 # everything still works.
-find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
+find_path(
+  FREETYPE_INCLUDE_DIR_ft2build
+  ft2build.h
   HINTS
     ENV FREETYPE_DIR
   PATHS
@@ -62,10 +64,14 @@
     ENV GTKMM_BASEPATH
     [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
-  PATH_SUFFIXES include/freetype2 include
+  PATH_SUFFIXES
+    include/freetype2
+    include
+    freetype2
 )
 
-find_path(FREETYPE_INCLUDE_DIR_freetype2
+find_path(
+  FREETYPE_INCLUDE_DIR_freetype2
   NAMES
     freetype/config/ftheader.h
     config/ftheader.h
@@ -79,14 +85,19 @@
     ENV GTKMM_BASEPATH
     [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
-  PATH_SUFFIXES include/freetype2 include
+  PATH_SUFFIXES
+    include/freetype2
+    include
+    freetype2
 )
 
 find_library(FREETYPE_LIBRARY
-  NAMES freetype libfreetype freetype219
+  NAMES
+    freetype
+    libfreetype
+    freetype219
   HINTS
     ENV FREETYPE_DIR
-  PATH_SUFFIXES lib
   PATHS
     /usr/X11R6
     /usr/local/X11R6
@@ -95,6 +106,8 @@
     ENV GTKMM_BASEPATH
     [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
+  PATH_SUFFIXES
+    lib
 )
 
 # set the user variables
@@ -111,32 +124,41 @@
 endif()
 
 if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H)
-    file(STRINGS "${FREETYPE_H}" freetype_version_str
-         REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
+  file(STRINGS "${FREETYPE_H}" freetype_version_str
+       REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$")
 
-    unset(FREETYPE_VERSION_STRING)
-    foreach(VPART MAJOR MINOR PATCH)
-        foreach(VLINE ${freetype_version_str})
-            if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}")
-                string(REGEX REPLACE "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$" "\\1"
-                       FREETYPE_VERSION_PART "${VLINE}")
-                if(FREETYPE_VERSION_STRING)
-                    set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}")
-                else()
-                    set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}")
-                endif()
-                unset(FREETYPE_VERSION_PART)
-            endif()
-        endforeach()
+  unset(FREETYPE_VERSION_STRING)
+  foreach(VPART MAJOR MINOR PATCH)
+    foreach(VLINE ${freetype_version_str})
+      if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$")
+        set(FREETYPE_VERSION_PART "${CMAKE_MATCH_1}")
+        if(FREETYPE_VERSION_STRING)
+          set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}")
+        else()
+          set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}")
+        endif()
+        unset(FREETYPE_VERSION_PART)
+      endif()
     endforeach()
+  endforeach()
 endif()
 
 
 # handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if
 # all listed variables are TRUE
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype
-                                  REQUIRED_VARS FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS
-                                  VERSION_VAR FREETYPE_VERSION_STRING)
 
-mark_as_advanced(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)
+find_package_handle_standard_args(
+  Freetype
+  REQUIRED_VARS
+    FREETYPE_LIBRARY
+    FREETYPE_INCLUDE_DIRS
+  VERSION_VAR
+    FREETYPE_VERSION_STRING
+)
+
+mark_as_advanced(
+  FREETYPE_LIBRARY
+  FREETYPE_INCLUDE_DIR_freetype2
+  FREETYPE_INCLUDE_DIR_ft2build
+)
diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake
index 4e04c31..bf374f9 100644
--- a/Modules/FindGDAL.cmake
+++ b/Modules/FindGDAL.cmake
@@ -90,9 +90,9 @@
         exec_program(${GDAL_CONFIG} ARGS --libs OUTPUT_VARIABLE GDAL_CONFIG_LIBS)
         if(GDAL_CONFIG_LIBS)
             string(REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_LIBS})
-            string(REGEX REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
+            string(REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
             string(REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_LIBS})
-            string(REGEX REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
+            string(REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
         endif()
     endif()
 endif()
diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake
index 117ded7..7bbb8cf 100644
--- a/Modules/FindGIF.cmake
+++ b/Modules/FindGIF.cmake
@@ -66,6 +66,7 @@
   include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
   include(${CMAKE_CURRENT_LIST_DIR}/CheckStructHasMember.cmake)
   CMAKE_PUSH_CHECK_STATE()
+  set(CMAKE_REQUIRED_QUIET ${GIF_FIND_QUIETLY})
   set(GIF_VERSION 3)
   set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}")
   CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData )
diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake
index a91da33..eaa5e55 100644
--- a/Modules/FindGTK2.cmake
+++ b/Modules/FindGTK2.cmake
@@ -267,6 +267,8 @@
             /usr/local/lib
             /usr/lib64
             /usr/lib
+            /usr/X11R6/include
+            /usr/X11R6/lib
             /opt/gnome/include
             /opt/gnome/lib
             /opt/openwin/include
@@ -570,7 +572,6 @@
 # If specified, enforce version number
 #
 if(GTK2_FIND_VERSION)
-    cmake_minimum_required(VERSION 2.6.2)
     set(GTK2_FAILED_VERSION_CHECK true)
     if(GTK2_DEBUG)
         message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
@@ -641,6 +642,10 @@
 
 foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
     if(_GTK2_component STREQUAL "gtk")
+        # Left for compatibility with previous versions.
+        _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h)
+        _GTK2_FIND_INCLUDE_DIR(X11 X11/Xlib.h)
+
         _GTK2_FIND_INCLUDE_DIR(GLIB glib.h)
         _GTK2_FIND_INCLUDE_DIR(GLIBCONFIG glibconfig.h)
         _GTK2_FIND_LIBRARY    (GLIB glib false true)
@@ -680,11 +685,15 @@
 
         _GTK2_FIND_LIBRARY    (PANGOFT2 pangoft2 false true)
         _GTK2_ADD_TARGET      (PANGOFT2 GTK2_DEPENDS pango gobject glib
-                                        OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+                                        OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+                                                          ${GTK2_FONTCONFIG_INCLUDE_DIR}
+                                                          ${GTK2_X11_INCLUDE_DIR})
 
         _GTK2_FIND_LIBRARY    (PANGOXFT pangoxft false true)
         _GTK2_ADD_TARGET      (PANGOXFT GTK2_DEPENDS pangoft2 pango gobject glib
-                                        OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+                                        OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+                                                          ${GTK2_FONTCONFIG_INCLUDE_DIR}
+                                                          ${GTK2_X11_INCLUDE_DIR})
 
         _GTK2_FIND_INCLUDE_DIR(GDK gdk/gdk.h)
         _GTK2_FIND_INCLUDE_DIR(GDKCONFIG gdkconfig.h)
@@ -715,9 +724,6 @@
         _GTK2_ADD_TARGET (GTK GTK2_DEPENDS gdk atk pangoft2 pango gdk_pixbuf gthread gobject glib
                               GTK2_OPTIONAL_DEPENDS gio pangocairo cairo)
 
-        # Left for compatibility with previous versions. It doesn't seem to be required
-        _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h)
-
     elseif(_GTK2_component STREQUAL "gtkmm")
 
         _GTK2_FIND_INCLUDE_DIR(SIGC++ sigc++/sigc++.h)
@@ -743,29 +749,36 @@
         _GTK2_FIND_INCLUDE_DIR(CAIROMMCONFIG cairommconfig.h)
         _GTK2_FIND_LIBRARY    (CAIROMM cairomm true true)
         _GTK2_ADD_TARGET      (CAIROMM GTK2_DEPENDS cairo sigc++
-                                       OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+                                       OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+                                                         ${GTK2_FONTCONFIG_INCLUDE_DIR}
+                                                         ${GTK2_X11_INCLUDE_DIR})
 
         _GTK2_FIND_INCLUDE_DIR(PANGOMM pangomm.h)
         _GTK2_FIND_INCLUDE_DIR(PANGOMMCONFIG pangommconfig.h)
         _GTK2_FIND_LIBRARY    (PANGOMM pangomm true true)
         _GTK2_ADD_TARGET      (PANGOMM GTK2_DEPENDS glibmm sigc++ pango gobject glib
                                        GTK2_OPTIONAL_DEPENDS cairomm pangocairo cairo
-                                       OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
-
+                                       OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+                                                         ${GTK2_FONTCONFIG_INCLUDE_DIR}
+                                                         ${GTK2_X11_INCLUDE_DIR})
 
         _GTK2_FIND_INCLUDE_DIR(GDKMM gdkmm.h)
         _GTK2_FIND_INCLUDE_DIR(GDKMMCONFIG gdkmmconfig.h)
         _GTK2_FIND_LIBRARY    (GDKMM gdkmm true true)
         _GTK2_ADD_TARGET      (GDKMM GTK2_DEPENDS pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gobject glib
                                      GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
-                                     OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+                                     OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+                                                       ${GTK2_FONTCONFIG_INCLUDE_DIR}
+                                                       ${GTK2_X11_INCLUDE_DIR})
 
         _GTK2_FIND_INCLUDE_DIR(GTKMM gtkmm.h)
         _GTK2_FIND_INCLUDE_DIR(GTKMMCONFIG gtkmmconfig.h)
         _GTK2_FIND_LIBRARY    (GTKMM gtkmm true true)
         _GTK2_ADD_TARGET      (GTKMM GTK2_DEPENDS atkmm gdkmm pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib
                                      GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
-                                     OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+                                     OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+                                                       ${GTK2_FONTCONFIG_INCLUDE_DIR}
+                                                       ${GTK2_X11_INCLUDE_DIR})
 
     elseif(_GTK2_component STREQUAL "glade")
 
@@ -773,7 +786,9 @@
         _GTK2_FIND_LIBRARY    (GLADE glade false true)
         _GTK2_ADD_TARGET      (GLADE GTK2_DEPENDS gtk gdk atk gio pangoft2 gdk_pixbuf pango gobject glib
                                      GTK2_OPTIONAL_DEPENDS pangocairo cairo
-                                     OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+                                     OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+                                                       ${GTK2_FONTCONFIG_INCLUDE_DIR}
+                                                       ${GTK2_X11_INCLUDE_DIR})
 
     elseif(_GTK2_component STREQUAL "glademm")
 
@@ -782,7 +797,9 @@
         _GTK2_FIND_LIBRARY    (GLADEMM glademm true true)
         _GTK2_ADD_TARGET      (GLADEMM GTK2_DEPENDS gtkmm glade atkmm gdkmm giomm pangomm glibmm sigc++ gtk gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib
                                        GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
-                                       OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+                                       OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+                                                         ${GTK2_FONTCONFIG_INCLUDE_DIR}
+                                                         ${GTK2_X11_INCLUDE_DIR})
 
     else()
         message(FATAL_ERROR "Unknown GTK2 component ${_component}")
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index c00a750..e6b5b0a 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -79,7 +79,7 @@
 #     extra_args = Pass a list of extra arguments to be passed to
 #                  executable enclosed in quotes (or "" for none)
 #     ARGN =       A list of source files to search for tests & test
-#                  fixtures.
+#                  fixtures. Or AUTO to find them from executable target.
 #
 #
 #
@@ -88,7 +88,7 @@
 #   Example:
 #      set(FooTestArgs --foo 1 --bar 2)
 #      add_executable(FooTest FooUnitTest.cc)
-#      GTEST_ADD_TESTS(FooTest "${FooTestArgs}" FooUnitTest.cc)
+#      GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO)
 
 #=============================================================================
 # Copyright 2009 Kitware, Inc.
@@ -111,12 +111,30 @@
     if(NOT ARGN)
         message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS")
     endif()
+    if(ARGN STREQUAL "AUTO")
+        # obtain sources used for building that executable
+        get_property(ARGN TARGET ${executable} PROPERTY SOURCES)
+    endif()
+    set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*")
+    set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
     foreach(source ${ARGN})
         file(READ "${source}" contents)
-        string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
+        string(REGEX MATCHALL "${gtest_test_type_regex}\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
         foreach(hit ${found_tests})
-            string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit})
-            add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args})
+          string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
+
+          # Parameterized tests have a different signature for the filter
+          if(${test_type} STREQUAL "TEST_P")
+            string(REGEX REPLACE ${gtest_case_name_regex}  "*/\\1.\\2/*" test_name ${hit})
+          elseif(${test_type} STREQUAL "TEST_F" OR ${test_type} STREQUAL "TEST")
+            string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit})
+          elseif(${test_type} STREQUAL "TYPED_TEST")
+            string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" test_name ${hit})
+          else()
+            message(WARNING "Could not parse GTest ${hit} for adding to CTest.")
+            continue()
+          endif()
+          add_test(NAME ${test_name} COMMAND ${executable} --gtest_filter=${test_name} ${extra_args})
         endforeach()
     endforeach()
 endfunction()
diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake
index 6a1e36e..7ab867b 100644
--- a/Modules/FindGettext.cmake
+++ b/Modules/FindGettext.cmake
@@ -71,8 +71,8 @@
                   OUTPUT_VARIABLE gettext_version
                   ERROR_QUIET
                   OUTPUT_STRIP_TRAILING_WHITESPACE)
-   if (gettext_version MATCHES "^msgmerge \\(.*\\) [0-9]")
-      string(REGEX REPLACE "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1" GETTEXT_VERSION_STRING "${gettext_version}")
+   if (gettext_version MATCHES "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
+      set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_1}")
    endif()
    unset(gettext_version)
 endif()
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index 2903bf8..0d58e13 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -162,7 +162,7 @@
     )
     foreach( IPATH ${include_path_flags} )
         string( REGEX REPLACE "^-I" "" IPATH ${IPATH} )
-        string( REGEX REPLACE "//" "/" IPATH ${IPATH} )
+        string( REPLACE "//" "/" IPATH ${IPATH} )
         list( APPEND ${include_paths} ${IPATH} )
     endforeach()
 
@@ -179,7 +179,7 @@
 
     foreach( LPATH ${library_path_flags} )
         string( REGEX REPLACE "^-L" "" LPATH ${LPATH} )
-        string( REGEX REPLACE "//" "/" LPATH ${LPATH} )
+        string( REPLACE "//" "/" LPATH ${LPATH} )
         list( APPEND ${library_paths} ${LPATH} )
     endforeach()
 
@@ -253,7 +253,7 @@
         list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} )
 
         # find the HDF5 include directories
-        if(${LANGUAGE} MATCHES "Fortran.*")
+        if(${LANGUAGE} MATCHES "Fortran")
             set(HDF5_INCLUDE_FILENAME hdf5.mod)
         else()
             set(HDF5_INCLUDE_FILENAME hdf5.h)
diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake
index a1fb33f..c418afd 100644
--- a/Modules/FindHg.cmake
+++ b/Modules/FindHg.cmake
@@ -2,7 +2,7 @@
 # FindHg
 # ------
 #
-#
+# Extract information from a mercurial working copy.
 #
 # The module defines the following variables:
 #
@@ -12,6 +12,20 @@
 #    HG_FOUND - true if the command line client was found
 #    HG_VERSION_STRING - the version of mercurial found
 #
+# If the command line client executable is found the following macro is defined:
+#
+# ::
+#
+#   HG_WC_INFO(<dir> <var-prefix>)
+#
+# Hg_WC_INFO extracts information of a mercurial working copy
+# at a given location.  This macro defines the following variables:
+#
+# ::
+#
+#   <var-prefix>_WC_CHANGESET - current changeset
+#   <var-prefix>_WC_REVISION - current revision
+#
 # Example usage:
 #
 # ::
@@ -19,11 +33,15 @@
 #    find_package(Hg)
 #    if(HG_FOUND)
 #      message("hg found: ${HG_EXECUTABLE}")
+#      HG_WC_INFO(${PROJECT_SOURCE_DIR} Project)
+#      message("Current revision is ${Project_WC_REVISION}")
+#      message("Current changeset is ${Project_WC_CHANGESET}")
 #    endif()
 
 #=============================================================================
 # Copyright 2010-2012 Kitware, Inc.
 # Copyright 2012      Rolf Eike Beer <eike@sf-mail.de>
+# Copyright 2014      Matthaeus G. Chajdas
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -37,6 +55,8 @@
 
 find_program(HG_EXECUTABLE
   NAMES hg
+  PATHS
+    [HKEY_LOCAL_MACHINE\\Software\\TortoiseHG]
   PATH_SUFFIXES Mercurial
   DOC "hg command line client"
   )
@@ -51,6 +71,21 @@
     set(HG_VERSION_STRING "${CMAKE_MATCH_1}")
   endif()
   unset(hg_version)
+
+  macro(HG_WC_INFO dir prefix)
+    execute_process(COMMAND ${HG_EXECUTABLE} id -i -n
+      WORKING_DIRECTORY ${dir}
+      RESULT_VARIABLE hg_id_result
+      ERROR_VARIABLE hg_id_error
+      OUTPUT_VARIABLE ${prefix}_WC_DATA
+      OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(NOT ${hg_id_result} EQUAL 0)
+      message(SEND_ERROR "Command \"${HG_EXECUTBALE} id -n\" in directory ${dir} failed with output:\n${hg_id_error}")
+    endif()
+
+    string(REGEX REPLACE "([0-9a-f]+)\\+? [0-9]+\\+?" "\\1" ${prefix}_WC_CHANGESET ${${prefix}_WC_DATA})
+    string(REGEX REPLACE "[0-9a-f]+\\+? ([0-9]+)\\+?" "\\1" ${prefix}_WC_REVISION ${${prefix}_WC_DATA})
+  endmacro(HG_WC_INFO)
 endif()
 
 # Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if
diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake
index e29fe2e..a7c5a64 100644
--- a/Modules/FindIcotool.cmake
+++ b/Modules/FindIcotool.cmake
@@ -37,7 +37,7 @@
     ERROR_QUIET
     OUTPUT_STRIP_TRAILING_WHITESPACE
   )
-  if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*")
+  if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
     set( ICOTOOL_VERSION_STRING
       "${CMAKE_MATCH_1}"
     )
diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake
index 1e7bda5..4f0e687 100644
--- a/Modules/FindImageMagick.cmake
+++ b/Modules/FindImageMagick.cmake
@@ -221,8 +221,8 @@
                   OUTPUT_VARIABLE imagemagick_version
                   ERROR_QUIET
                   OUTPUT_STRIP_TRAILING_WHITESPACE)
-  if(imagemagick_version MATCHES "^Version: ImageMagick [0-9]")
-    string(REGEX REPLACE "^Version: ImageMagick ([-0-9\\.]+).*" "\\1" ImageMagick_VERSION_STRING "${imagemagick_version}")
+  if(imagemagick_version MATCHES "^Version: ImageMagick ([-0-9\\.]+)")
+    set(ImageMagick_VERSION_STRING "${CMAKE_MATCH_1}")
   endif()
   unset(imagemagick_version)
 endif()
diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake
index a488c46..0bd7eb0 100644
--- a/Modules/FindJava.cmake
+++ b/Modules/FindJava.cmake
@@ -128,18 +128,15 @@
       # 3. GCJ 1.5
       # 4. Kaffe 1.4.2
       # 5. OpenJDK 1.7.x on OpenBSD
-      if(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_.]+.*\".*")
+      if(var MATCHES "java version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\"")
         # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer
-        string( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\".*"
-                "\\1" Java_VERSION_STRING "${var}" )
-      elseif(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*")
+        set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+      elseif(var MATCHES "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+)\"")
         # Kaffe style
-        string( REGEX REPLACE "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+).*"
-                "\\1" Java_VERSION_STRING "${var}" )
-      elseif(var MATCHES "openjdk version \"[0-9]+\\.[0-9]+\\.[0-9_]+\".*")
+        set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+      elseif(var MATCHES "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+)\"")
         # OpenJDK ver 1.7.x on OpenBSD
-        string( REGEX REPLACE "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+).*"
-                "\\1" Java_VERSION_STRING "${var}" )
+        set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
       else()
         if(NOT Java_FIND_QUIETLY)
           message(WARNING "regex not supported: ${var}. Please report")
diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake
index 159e29c..ea898a6 100644
--- a/Modules/FindKDE3.cmake
+++ b/Modules/FindKDE3.cmake
@@ -192,7 +192,7 @@
    if ("${kde_version}" MATCHES "KDE: 3\\.")
       execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --prefix
                         OUTPUT_VARIABLE kdedir )
-      string(REGEX REPLACE "\n" "" KDE3PREFIX "${kdedir}")
+      string(REPLACE "\n" "" KDE3PREFIX "${kdedir}")
 
     endif ()
 endif()
diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake
index 69da4cd..b11edc3 100644
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -54,6 +54,10 @@
 else ()
 include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
 endif ()
+include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+
+cmake_push_check_state()
+set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY})
 
 set(LAPACK_FOUND FALSE)
 set(LAPACK95_FOUND FALSE)
@@ -155,7 +159,7 @@
 
 if(BLAS_FOUND)
   set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
-  if ($ENV{BLA_VENDOR} MATCHES ".+")
+  if (NOT $ENV{BLA_VENDOR} STREQUAL "")
     set(BLA_VENDOR $ENV{BLA_VENDOR})
   else ()
     if(NOT BLA_VENDOR)
@@ -179,7 +183,7 @@
 
 
 #acml lapack
- if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
+ if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
    if (BLAS_LIBRARIES MATCHES ".+acml.+")
      set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
    endif ()
@@ -229,7 +233,7 @@
   endif ()
 endif ()
 #intel lapack
-if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
+if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
   if (NOT WIN32)
     set(LM "-lm")
   endif ()
@@ -347,4 +351,5 @@
  endif()
 endif()
 
+cmake_pop_check_state()
 set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake
index be01594..742b851 100644
--- a/Modules/FindLibLZMA.cmake
+++ b/Modules/FindLibLZMA.cmake
@@ -55,9 +55,12 @@
 # Avoid using old codebase
 if (LIBLZMA_LIBRARY)
    include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+   set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+   set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
    CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER)
    CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER)
    CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET)
+   set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
 endif ()
 
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index c8d46ba..6e15f3b 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -330,7 +330,7 @@
         string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}")
         foreach(IPATH ${MPI_ALL_INCLUDE_PATHS})
           string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH})
-          string(REGEX REPLACE "//" "/" IPATH ${IPATH})
+          string(REPLACE "//" "/" IPATH ${IPATH})
           list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH})
         endforeach()
 
@@ -354,7 +354,7 @@
         set(MPI_LINK_PATH)
         foreach(LPATH ${MPI_ALL_LINK_PATHS})
           string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH})
-          string(REGEX REPLACE "//" "/" LPATH ${LPATH})
+          string(REPLACE "//" "/" LPATH ${LPATH})
           list(APPEND MPI_LINK_PATH ${LPATH})
         endforeach()
 
@@ -378,19 +378,14 @@
         # Extract the set of libraries to link against from the link command
         # line
         string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
+
         # add the compiler implicit directories because some compilers
         # such as the intel compiler have libraries that show up
         # in the showme list that can only be found in the implicit
-        # link directories of the compiler. Do this for C++ and C
-        # compilers if the implicit link directories are defined.
-        if (DEFINED CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES)
+        # link directories of the compiler.
+        if (DEFINED CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES)
           set(MPI_LINK_PATH
-            "${MPI_LINK_PATH};${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}")
-        endif ()
-
-        if (DEFINED CMAKE_C_IMPLICIT_LINK_DIRECTORIES)
-          set(MPI_LINK_PATH
-            "${MPI_LINK_PATH};${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
+            "${MPI_LINK_PATH};${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}")
         endif ()
 
         # Determine full path names for all of the libraries that one needs
diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake
new file mode 100644
index 0000000..b5eed9a
--- /dev/null
+++ b/Modules/FindOpenCL.cmake
@@ -0,0 +1,135 @@
+#.rst:
+# FindOpenCL
+# ----------
+#
+# Try to find OpenCL
+#
+# Once done this will define::
+#
+#   OpenCL_FOUND          - True if OpenCL was found
+#   OpenCL_INCLUDE_DIRS   - include directories for OpenCL
+#   OpenCL_LIBRARIES      - link against this library to use OpenCL
+#   OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2)
+#   OpenCL_VERSION_MAJOR  - The major version of the OpenCL implementation
+#   OpenCL_VERSION_MINOR  - The minor version of the OpenCL implementation
+#
+# The module will also define two cache variables::
+#
+#   OpenCL_INCLUDE_DIR    - the OpenCL include directory
+#   OpenCL_LIBRARY        - the path to the OpenCL library
+#
+
+#=============================================================================
+# Copyright 2014 Matthaeus G. Chajdas
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+function(_FIND_OPENCL_VERSION)
+  include(CheckSymbolExists)
+  include(CMakePushCheckState)
+  set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY})
+
+  CMAKE_PUSH_CHECK_STATE()
+  foreach(VERSION "2_0" "1_2" "1_1" "1_0")
+    set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}")
+
+    if(APPLE)
+      CHECK_SYMBOL_EXISTS(
+        CL_VERSION_${VERSION}
+        "${OpenCL_INCLUDE_DIR}/OpenCL/cl.h"
+        OPENCL_VERSION_${VERSION})
+    else()
+      CHECK_SYMBOL_EXISTS(
+        CL_VERSION_${VERSION}
+        "${OpenCL_INCLUDE_DIR}/CL/cl.h"
+        OPENCL_VERSION_${VERSION})
+    endif()
+
+    if(OPENCL_VERSION_${VERSION})
+      string(REPLACE "_" "." VERSION "${VERSION}")
+      set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE)
+      string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}")
+      list(GET version_components 0 major_version)
+      list(GET version_components 1 minor_version)
+      set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE)
+      set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE)
+      break()
+    endif()
+  endforeach()
+  CMAKE_POP_CHECK_STATE()
+endfunction()
+
+find_path(OpenCL_INCLUDE_DIR
+  NAMES
+    CL/cl.h OpenCL/cl.h
+  PATHS ENV
+    "PROGRAMFILES(X86)"
+    AMDAPPSDKROOT
+    INTELOCLSDKROOT
+    NVSDKCOMPUTE_ROOT
+    CUDA_PATH
+    ATISTREAMSDKROOT
+  PATH_SUFFIXES
+    OpenCL/common/inc
+    "AMD APP/include")
+
+_FIND_OPENCL_VERSION()
+
+if(WIN32)
+  if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    find_library(OpenCL_LIBRARY
+      NAMES OpenCL
+      PATHS ENV
+        "PROGRAMFILES(X86)"
+        AMDAPPSDKROOT
+        INTELOCLSDKROOT
+        CUDA_PATH
+        NVSDKCOMPUTE_ROOT
+        ATISTREAMSDKROOT
+      PATH_SUFFIXES
+        "AMD APP/lib/x86"
+        lib/x86
+        lib/Win32
+        OpenCL/common/lib/Win32)
+  elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
+    find_library(OpenCL_LIBRARY
+      NAMES OpenCL
+      PATHS ENV
+        "PROGRAMFILES(X86)"
+        AMDAPPSDKROOT
+        INTELOCLSDKROOT
+        CUDA_PATH
+        NVSDKCOMPUTE_ROOT
+        ATISTREAMSDKROOT
+      PATH_SUFFIXES
+        "AMD APP/lib/x86_64"
+        lib/x86_64
+        lib/x64
+        OpenCL/common/lib/x64)
+  endif()
+else()
+  find_library(OpenCL_LIBRARY
+    NAMES OpenCL)
+endif()
+
+set(OpenCL_LIBRARIES ${OpenCL_LIBRARY})
+set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR})
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(
+  OpenCL
+  FOUND_VAR OpenCL_FOUND
+  REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR
+  VERSION_VAR OpenCL_VERSION_STRING)
+
+mark_as_advanced(
+  OpenCL_INCLUDE_DIR
+  OpenCL_LIBRARY)
diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake
index 21c2198..2b3bd14 100644
--- a/Modules/FindOpenGL.cmake
+++ b/Modules/FindOpenGL.cmake
@@ -2,32 +2,48 @@
 # FindOpenGL
 # ----------
 #
-# Try to find OpenGL
+# FindModule for OpenGL and GLU.
 #
-# Once done this will define
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
 #
-# ::
+# This module defines the :prop_tgt:`IMPORTED` targets:
 #
-#   OPENGL_FOUND        - system has OpenGL
-#   OPENGL_XMESA_FOUND  - system has XMESA
-#   OPENGL_GLU_FOUND    - system has GLU
-#   OPENGL_INCLUDE_DIR  - the GL include directory
-#   OPENGL_LIBRARIES    - Link these to use OpenGL and GLU
+# ``OpenGL::GL``
+#  Defined if the system has OpenGL.
+# ``OpenGL::GLU``
+#  Defined if the system has GLU.
 #
+# Result Variables
+# ^^^^^^^^^^^^^^^^
 #
+# This module sets the following variables:
 #
-# If you want to use just GL you can use these values
+# ``OPENGL_FOUND``
+#  True, if the system has OpenGL.
+# ``OPENGL_XMESA_FOUND``
+#  True, if the system has XMESA.
+# ``OPENGL_GLU_FOUND``
+#  True, if the system has GLU.
+# ``OPENGL_INCLUDE_DIR``
+#  Path to the OpenGL include directory.
+# ``OPENGL_LIBRARIES``
+#  Paths to the OpenGL and GLU libraries.
 #
-# ::
+# If you want to use just GL you can use these values:
 #
-#   OPENGL_gl_LIBRARY   - Path to OpenGL Library
-#   OPENGL_glu_LIBRARY  - Path to GLU Library
+# ``OPENGL_gl_LIBRARY``
+#  Path to the OpenGL library.
+# ``OPENGL_glu_LIBRARY``
+#  Path to the GLU library.
 #
+# OSX Specific
+# ^^^^^^^^^^^^
 #
-#
-# On OSX default to using the framework version of opengl People will
+# On OSX default to using the framework version of OpenGL. People will
 # have to change the cache values of OPENGL_glu_LIBRARY and
-# OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX
+# OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX.
+
 
 #=============================================================================
 # Copyright 2001-2009 Kitware, Inc.
@@ -175,6 +191,36 @@
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS})
 unset(_OpenGL_REQUIRED_VARS)
 
+# OpenGL:: targets
+if(OPENGL_FOUND)
+  if(NOT TARGET OpenGL::GL)
+    add_library(OpenGL::GL UNKNOWN IMPORTED)
+    set_target_properties(OpenGL::GL PROPERTIES
+      INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}")
+    if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$")
+      set_target_properties(OpenGL::GL PROPERTIES
+        IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}/${CMAKE_MATCH_1}")
+    else()
+      set_target_properties(OpenGL::GL PROPERTIES
+        IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}")
+    endif()
+  endif()
+
+  if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU)
+    add_library(OpenGL::GLU UNKNOWN IMPORTED)
+    set_target_properties(OpenGL::GLU PROPERTIES
+      INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
+      INTERFACE_LINK_LIBRARIES OpenGL::GL)
+    if(OPENGL_glu_LIBRARY MATCHES "/([^/]+)\\.framework$")
+      set_target_properties(OpenGL::GLU PROPERTIES
+        IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}/${CMAKE_MATCH_1}")
+    else()
+      set_target_properties(OpenGL::GLU PROPERTIES
+        IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}")
+    endif()
+  endif()
+endif()
+
 mark_as_advanced(
   OPENGL_INCLUDE_DIR
   OPENGL_xmesa_INCLUDE_DIR
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index fead4a6..30972ae 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -39,6 +39,8 @@
 #  License text for the above reference.)
 
 set(_OPENMP_REQUIRED_VARS)
+set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+set(CMAKE_REQUIRED_QUIET ${OpenMP_FIND_QUIETLY})
 
 function(_OPENMP_FLAG_CANDIDATES LANG)
   set(OpenMP_FLAG_CANDIDATES
@@ -116,7 +118,9 @@
     set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
     set(CMAKE_REQUIRED_FLAGS "${FLAG}")
     unset(OpenMP_FLAG_DETECTED CACHE)
-    message(STATUS "Try OpenMP C flag = [${FLAG}]")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Try OpenMP C flag = [${FLAG}]")
+    endif()
     check_c_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
     set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
     if(OpenMP_FLAG_DETECTED)
@@ -150,7 +154,9 @@
     set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
     set(CMAKE_REQUIRED_FLAGS "${FLAG}")
     unset(OpenMP_FLAG_DETECTED CACHE)
-    message(STATUS "Try OpenMP CXX flag = [${FLAG}]")
+    if(NOT CMAKE_REQUIRED_QUIET)
+      message(STATUS "Try OpenMP CXX flag = [${FLAG}]")
+    endif()
     check_cxx_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
     set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
     if(OpenMP_FLAG_DETECTED)
@@ -167,6 +173,8 @@
   unset(OpenMP_CXX_TEST_SOURCE)
 endif()
 
+set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
+
 if(_OPENMP_REQUIRED_VARS)
   include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake
index 873c3de..fa04bf0 100644
--- a/Modules/FindPNG.cmake
+++ b/Modules/FindPNG.cmake
@@ -56,10 +56,8 @@
   list(APPEND PNG_NAMES png libpng)
   unset(PNG_NAMES_DEBUG)
   set(_PNG_VERSION_SUFFIXES 17 16 15 14 12)
-  if (PNG_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\..*)?$")
-    string(REGEX REPLACE
-        "^([0-9]+)\\.([0-9]+).*" "\\1\\2"
-        _PNG_VERSION_SUFFIX_MIN "${PNG_FIND_VERSION}")
+  if (PNG_FIND_VERSION MATCHES "^([0-9]+)\\.([0-9]+)(\\..*)?$")
+    set(_PNG_VERSION_SUFFIX_MIN "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
     if (PNG_FIND_VERSION_EXACT)
       set(_PNG_VERSION_SUFFIXES ${_PNG_VERSION_SUFFIX_MIN})
     else ()
diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake
index b6a58e4..a0349d3 100644
--- a/Modules/FindPackageMessage.cmake
+++ b/Modules/FindPackageMessage.cmake
@@ -42,7 +42,7 @@
 function(FIND_PACKAGE_MESSAGE pkg msg details)
   # Avoid printing a message repeatedly for the same find result.
   if(NOT ${pkg}_FIND_QUIETLY)
-    string(REGEX REPLACE "[\n]" "" details "${details}")
+    string(REPLACE "\n" "" details "${details}")
     set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
     if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
       # The message has not yet been printed.
diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake
index 3fd5d8e..70284b6 100644
--- a/Modules/FindPerl.cmake
+++ b/Modules/FindPerl.cmake
@@ -70,9 +70,9 @@
       OUTPUT_STRIP_TRAILING_WHITESPACE
     )
     if(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl.*[ \\(]v([0-9\\._]+)[ \\)]")
-      string(REGEX REPLACE ".*This is perl.*[ \\(]v([0-9\\._]+)[ \\)].*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE})
+      set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
     elseif(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl, version ([0-9\\._]+) +")
-      string(REGEX REPLACE ".*This is perl, version ([0-9\\._]+) +.*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE})
+      set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
     endif()
   endif()
 endif()
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index e6fdefe..d728324 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -2,140 +2,20 @@
 # FindPkgConfig
 # -------------
 #
-# a pkg-config module for CMake
+# A `pkg-config` module for CMake.
 #
+# Finds the ``pkg-config`` executable and add the
+# :command:`pkg_check_modules` and :command:`pkg_search_module`
+# commands.
 #
-#
-# Usage:
-#
-# ::
-#
-#    pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
-#      checks for all the given modules
-#
-#
-#
-# ::
-#
-#    pkg_search_module(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
-#      checks for given modules and uses the first working one
-#
-#
-#
-# When the 'REQUIRED' argument was set, macros will fail with an error
-# when module(s) could not be found
-#
-# When the 'QUIET' argument is set, no status messages will be printed.
-#
-# It sets the following variables:
-#
-# ::
-#
-#    PKG_CONFIG_FOUND          ... if pkg-config executable was found
-#    PKG_CONFIG_EXECUTABLE     ... pathname of the pkg-config program
-#    PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found
-#                                  (since CMake 2.8.8)
-#
-#
-#
-# For the following variables two sets of values exist; first one is the
-# common one and has the given PREFIX.  The second set contains flags
-# which are given out when pkgconfig was called with the '--static'
-# option.
-#
-# ::
-#
-#    <XPREFIX>_FOUND          ... set to 1 if module(s) exist
-#    <XPREFIX>_LIBRARIES      ... only the libraries (w/o the '-l')
-#    <XPREFIX>_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
-#    <XPREFIX>_LDFLAGS        ... all required linker flags
-#    <XPREFIX>_LDFLAGS_OTHER  ... all other linker flags
-#    <XPREFIX>_INCLUDE_DIRS   ... the '-I' preprocessor flags (w/o the '-I')
-#    <XPREFIX>_CFLAGS         ... all required cflags
-#    <XPREFIX>_CFLAGS_OTHER   ... the other compiler flags
-#
-#
-#
-# ::
-#
-#    <XPREFIX> = <PREFIX>        for common case
-#    <XPREFIX> = <PREFIX>_STATIC for static linking
-#
-#
-#
-# There are some special variables whose prefix depends on the count of
-# given modules.  When there is only one module, <PREFIX> stays
-# unchanged.  When there are multiple modules, the prefix will be
-# changed to <PREFIX>_<MODNAME>:
-#
-# ::
-#
-#    <XPREFIX>_VERSION    ... version of the module
-#    <XPREFIX>_PREFIX     ... prefix-directory of the module
-#    <XPREFIX>_INCLUDEDIR ... include-dir of the module
-#    <XPREFIX>_LIBDIR     ... lib-dir of the module
-#
-#
-#
-# ::
-#
-#    <XPREFIX> = <PREFIX>  when |MODULES| == 1, else
-#    <XPREFIX> = <PREFIX>_<MODNAME>
-#
-#
-#
-# A <MODULE> parameter can have the following formats:
-#
-# ::
-#
-#    {MODNAME}            ... matches any version
-#    {MODNAME}>={VERSION} ... at least version <VERSION> is required
-#    {MODNAME}={VERSION}  ... exactly version <VERSION> is required
-#    {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
-#
-#
-#
-# Examples
-#
-# ::
-#
-#    pkg_check_modules (GLIB2   glib-2.0)
-#
-#
-#
-# ::
-#
-#    pkg_check_modules (GLIB2   glib-2.0>=2.10)
-#      requires at least version 2.10 of glib2 and defines e.g.
-#        GLIB2_VERSION=2.10.3
-#
-#
-#
-# ::
-#
-#    pkg_check_modules (FOO     glib-2.0>=2.10 gtk+-2.0)
-#      requires both glib2 and gtk2, and defines e.g.
-#        FOO_glib-2.0_VERSION=2.10.3
-#        FOO_gtk+-2.0_VERSION=2.8.20
-#
-#
-#
-# ::
-#
-#    pkg_check_modules (XRENDER REQUIRED xrender)
-#      defines e.g.:
-#        XRENDER_LIBRARIES=Xrender;X11
-#        XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
-#
-#
-#
-# ::
-#
-#    pkg_search_module (BAR     libxml-2.0 libxml2 libxml>=2)
+# In order to find the ``pkg-config`` executable, it uses the
+# :variable:`PKG_CONFIG_EXECUTABLE` variable or the ``PKG_CONFIG``
+# environment variable first.
 
 #=============================================================================
-# Copyright 2006-2009 Kitware, Inc.
-# Copyright 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+# Copyright 2006-2014 Kitware, Inc.
+# Copyright 2014      Christoph Grüninger <foss@grueninger.de>
+# Copyright 2006      Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
 #
 # Distributed under the OSI-approved BSD License (the "License");
 # see accompanying file Copyright.txt for details.
@@ -150,6 +30,10 @@
 ### Common stuff ####
 set(PKG_CONFIG_VERSION 1)
 
+# find pkg-config, use PKG_CONFIG if set
+if((NOT PKG_CONFIG_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG}" STREQUAL ""))
+  set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}" CACHE FILEPATH "pkg-config executable")
+endif()
 find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
 mark_as_advanced(PKG_CONFIG_EXECUTABLE)
 
@@ -215,9 +99,20 @@
 endmacro()
 
 # Splits given arguments into options and a package list
-macro(_pkgconfig_parse_options _result _is_req _is_silent)
+macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path)
   set(${_is_req} 0)
   set(${_is_silent} 0)
+  set(${_no_cmake_path} 0)
+  set(${_no_cmake_environment_path} 0)
+  if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
+    if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
+      set(${_no_cmake_path} 1)
+      set(${_no_cmake_environment_path} 1)
+    endif()
+  elseif(${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_LESS 3.1)
+    set(${_no_cmake_path} 1)
+    set(${_no_cmake_environment_path} 1)
+  endif()
 
   foreach(_pkg ${ARGN})
     if (_pkg STREQUAL "REQUIRED")
@@ -226,15 +121,48 @@
     if (_pkg STREQUAL "QUIET")
       set(${_is_silent} 1)
     endif ()
+    if (_pkg STREQUAL "NO_CMAKE_PATH")
+      set(${_no_cmake_path} 1)
+    endif()
+    if (_pkg STREQUAL "NO_CMAKE_ENVIRONMENT_PATH")
+      set(${_no_cmake_environment_path} 1)
+    endif()
   endforeach()
 
   set(${_result} ${ARGN})
   list(REMOVE_ITEM ${_result} "REQUIRED")
   list(REMOVE_ITEM ${_result} "QUIET")
+  list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH")
+  list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH")
 endmacro()
 
+# Add the content of a variable or an environment variable to a list of
+# paths
+# Usage:
+#  - _pkgconfig_add_extra_path(_extra_paths VAR)
+#  - _pkgconfig_add_extra_path(_extra_paths ENV VAR)
+function(_pkgconfig_add_extra_path _extra_paths_var _var)
+  set(_is_env 0)
+  if(_var STREQUAL "ENV")
+    set(_var ${ARGV2})
+    set(_is_env 1)
+  endif()
+  if(NOT _is_env)
+    if(NOT "${${_var}}" STREQUAL "")
+      list(APPEND ${_extra_paths_var} ${CMAKE_PREFIX_PATH})
+    endif()
+  else()
+    if(NOT "$ENV{${_var}}" STREQUAL "")
+      file(TO_CMAKE_PATH "$ENV{${_var}}" _path)
+      list(APPEND ${_extra_paths_var} ${_path})
+      unset(_path)
+    endif()
+  endif()
+  set(${_extra_paths_var} ${${_extra_paths_var}} PARENT_SCOPE)
+endfunction()
+
 ###
-macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
+macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix)
   _pkgconfig_unset(${_prefix}_FOUND)
   _pkgconfig_unset(${_prefix}_VERSION)
   _pkgconfig_unset(${_prefix}_PREFIX)
@@ -273,15 +201,86 @@
     set(_pkg_check_modules_packages)
     set(_pkg_check_modules_failed)
 
+    set(_extra_paths)
+
+    if(NOT _no_cmake_path)
+      _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH)
+      _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH)
+      _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH)
+    endif()
+
+    if(NOT _no_cmake_environment_path)
+      _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH)
+      _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH)
+      _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH)
+    endif()
+
+    if(NOT "${_extra_paths}" STREQUAL "")
+      # Save the PKG_CONFIG_PATH environment variable, and add paths
+      # from the CMAKE_PREFIX_PATH variables
+      set(_pkgconfig_path_old $ENV{PKG_CONFIG_PATH})
+      set(_pkgconfig_path ${_pkgconfig_path_old})
+      if(NOT "${_pkgconfig_path}" STREQUAL "")
+        file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path)
+      endif()
+
+      # Create a list of the possible pkgconfig subfolder (depending on
+      # the system
+      set(_lib_dirs)
+      if(NOT DEFINED CMAKE_SYSTEM_NAME
+          OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+              AND NOT CMAKE_CROSSCOMPILING))
+        if(EXISTS "/etc/debian_version") # is this a debian system ?
+          if(CMAKE_LIBRARY_ARCHITECTURE)
+            list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
+          endif()
+        else()
+          # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
+          get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+          if(uselib64)
+            list(APPEND _lib_dirs "lib64/pkgconfig")
+          endif()
+        endif()
+      endif()
+      list(APPEND _lib_dirs "lib/pkgconfig")
+
+      # Check if directories exist and eventually append them to the
+      # pkgconfig path list
+      foreach(_prefix_dir ${_extra_paths})
+        foreach(_lib_dir ${_lib_dirs})
+          if(EXISTS "${_prefix_dir}/${_lib_dir}")
+            list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}")
+            list(REMOVE_DUPLICATES _pkgconfig_path)
+          endif()
+        endforeach()
+      endforeach()
+
+      # Prepare and set the environment variable
+      if(NOT "${_pkgconfig_path}" STREQUAL "")
+        # remove empty values from the list
+        list(REMOVE_ITEM _pkgconfig_path "")
+        file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
+        if(UNIX)
+          string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}")
+          string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}")
+        endif()
+        set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path})
+      endif()
+
+      # Unset variables
+      unset(_lib_dirs)
+      unset(_pkgconfig_path)
+    endif()
+
     # iterate through module list and check whether they exist and match the required version
     foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
       set(_pkg_check_modules_exist_query)
 
       # check whether version is given
-      if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
-        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
-        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op   "${_pkg_check_modules_pkg}")
-        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver  "${_pkg_check_modules_pkg}")
+      if (_pkg_check_modules_pkg MATCHES "(.*[^><])(>=|=|<=)(.*)")
+        set(_pkg_check_modules_pkg_name "${CMAKE_MATCH_1}")
+        set(_pkg_check_modules_pkg_op "${CMAKE_MATCH_2}")
+        set(_pkg_check_modules_pkg_ver "${CMAKE_MATCH_3}")
       else()
         set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
         set(_pkg_check_modules_pkg_op)
@@ -338,7 +337,7 @@
     if(_pkg_check_modules_failed)
       # fail when requested
       if (${_is_required})
-        message(SEND_ERROR "A required package was not found")
+        message(FATAL_ERROR "A required package was not found")
       endif ()
     else()
       # when we are here, we checked whether requested modules
@@ -376,6 +375,14 @@
       _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS              ""        --cflags )
       _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER        ""        --cflags-only-other )
     endif()
+
+    if(NOT "${_extra_paths}" STREQUAL "")
+      # Restore the environment variable
+      set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path})
+    endif()
+
+    unset(_extra_paths)
+    unset(_pkgconfig_path_old)
   else()
     if (${_is_required})
       message(SEND_ERROR "pkg-config tool not found")
@@ -387,23 +394,138 @@
 ### User visible macros start here
 ###
 
-###
+#[========================================[.rst:
+.. command:: pkg_check_modules
+
+ Checks for all the given modules. ::
+
+    pkg_check_modules(<PREFIX> [REQUIRED] [QUIET]
+                      [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
+                      <MODULE> [<MODULE>]*)
+
+
+ When the ``REQUIRED`` argument was set, macros will fail with an error
+ when module(s) could not be found.
+
+ When the ``QUIET`` argument is set, no status messages will be printed.
+
+ By default, if :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or
+ later, or if :variable:`PKG_CONFIG_USE_CMAKE_PREFIX_PATH` is set, the
+ :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_FRAMEWORK_PATH`, and
+ :variable:`CMAKE_APPBUNDLE_PATH` cache and environment variables will
+ be added to ``pkg-config`` search path.
+ The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments
+ disable this behavior for the cache variables and the environment
+ variables, respectively.
+
+ It sets the following variables: ::
+
+    PKG_CONFIG_FOUND          ... if pkg-config executable was found
+    PKG_CONFIG_EXECUTABLE     ... pathname of the pkg-config program
+    PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found
+                                  (since CMake 2.8.8)
+
+ For the following variables two sets of values exist; first one is the
+ common one and has the given PREFIX.  The second set contains flags
+ which are given out when ``pkg-config`` was called with the ``--static``
+ option. ::
+
+    <XPREFIX>_FOUND          ... set to 1 if module(s) exist
+    <XPREFIX>_LIBRARIES      ... only the libraries (w/o the '-l')
+    <XPREFIX>_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
+    <XPREFIX>_LDFLAGS        ... all required linker flags
+    <XPREFIX>_LDFLAGS_OTHER  ... all other linker flags
+    <XPREFIX>_INCLUDE_DIRS   ... the '-I' preprocessor flags (w/o the '-I')
+    <XPREFIX>_CFLAGS         ... all required cflags
+    <XPREFIX>_CFLAGS_OTHER   ... the other compiler flags
+
+ ::
+
+    <XPREFIX> = <PREFIX>        for common case
+    <XPREFIX> = <PREFIX>_STATIC for static linking
+
+ There are some special variables whose prefix depends on the count of
+ given modules.  When there is only one module, <PREFIX> stays
+ unchanged.  When there are multiple modules, the prefix will be
+ changed to <PREFIX>_<MODNAME>: ::
+
+    <XPREFIX>_VERSION    ... version of the module
+    <XPREFIX>_PREFIX     ... prefix-directory of the module
+    <XPREFIX>_INCLUDEDIR ... include-dir of the module
+    <XPREFIX>_LIBDIR     ... lib-dir of the module
+
+ ::
+
+    <XPREFIX> = <PREFIX>  when |MODULES| == 1, else
+    <XPREFIX> = <PREFIX>_<MODNAME>
+
+ A <MODULE> parameter can have the following formats: ::
+
+    {MODNAME}            ... matches any version
+    {MODNAME}>={VERSION} ... at least version <VERSION> is required
+    {MODNAME}={VERSION}  ... exactly version <VERSION> is required
+    {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
+
+ Examples
+
+ .. code-block:: cmake
+
+    pkg_check_modules (GLIB2   glib-2.0)
+
+ .. code-block:: cmake
+
+    pkg_check_modules (GLIB2   glib-2.0>=2.10)
+
+ Requires at least version 2.10 of glib2 and defines e.g.
+ ``GLIB2_VERSION=2.10.3``
+
+ .. code-block:: cmake
+
+    pkg_check_modules (FOO     glib-2.0>=2.10 gtk+-2.0)
+
+ Requires both glib2 and gtk2, and defines e.g.
+ ``FOO_glib-2.0_VERSION=2.10.3`` and ``FOO_gtk+-2.0_VERSION=2.8.20``
+
+ .. code-block:: cmake
+
+    pkg_check_modules (XRENDER REQUIRED xrender)
+
+ Defines e.g.:
+ ``XRENDER_LIBRARIES=Xrender;X11`` and
+ ``XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp``
+#]========================================]
 macro(pkg_check_modules _prefix _module0)
   # check cached value
   if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
-    _pkgconfig_parse_options   (_pkg_modules _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN})
-    _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" "${_prefix}" ${_pkg_modules})
+    _pkgconfig_parse_options   (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN})
+    _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" ${_pkg_modules})
 
     _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
   endif()
 endmacro()
 
-###
+
+#[========================================[.rst:
+.. command:: pkg_search_module
+
+ Same as :command:`pkg_check_modules`, but instead it checks for given
+ modules and uses the first working one. ::
+
+    pkg_search_module(<PREFIX> [REQUIRED] [QUIET]
+                      [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
+                      <MODULE> [<MODULE>]*)
+
+ Examples
+
+ .. code-block:: cmake
+
+    pkg_search_module (BAR     libxml-2.0 libxml2 libxml>=2)
+#]========================================]
 macro(pkg_search_module _prefix _module0)
   # check cached value
   if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
     set(_pkg_modules_found 0)
-    _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN})
+    _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN})
 
     if (NOT ${_pkg_is_silent})
       message(STATUS "checking for one of the modules '${_pkg_modules_alt}'")
@@ -412,7 +534,7 @@
     # iterate through all modules and stop at the first working one.
     foreach(_pkg_alt ${_pkg_modules_alt})
       if(NOT _pkg_modules_found)
-        _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}")
+        _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" "${_pkg_alt}")
       endif()
 
       if (${_prefix}_FOUND)
@@ -430,6 +552,26 @@
   endif()
 endmacro()
 
+
+#[========================================[.rst:
+.. variable:: PKG_CONFIG_EXECUTABLE
+
+ Path to the pkg-config executable.
+
+
+.. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH
+
+ Whether :command:`pkg_check_modules` and :command:`pkg_search_module`
+ should add the paths in :variable:`CMAKE_PREFIX_PATH`,
+ :variable:`CMAKE_FRAMEWORK_PATH`, and :variable:`CMAKE_APPBUNDLE_PATH`
+ cache and environment variables to ``pkg-config`` search path.
+
+ If this variable is not set, this behavior is enabled by default if
+ :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or later, disabled
+ otherwise.
+#]========================================]
+
+
 ### Local Variables:
 ### mode: cmake
 ### End:
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake
index e23a58b..5e5c7b9 100644
--- a/Modules/FindPythonInterp.cmake
+++ b/Modules/FindPythonInterp.cmake
@@ -27,6 +27,10 @@
 # of version numbers that should be taken into account when searching
 # for Python.  You need to set this variable before calling
 # find_package(PythonInterp).
+#
+# If also calling find_package(PythonLibs), call find_package(PythonInterp)
+# first to get the currently active Python version by default with a consistent
+# version of PYTHON_LIBRARIES.
 
 #=============================================================================
 # Copyright 2005-2010 Kitware, Inc.
@@ -71,18 +75,23 @@
 else()
     set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
 endif()
-
-list(APPEND _Python_NAMES python)
-
-# Search for the current active python version first
 find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES})
 
 # Set up the versions we know about, in the order we will search. Always add
 # the user supplied additional versions to the front.
-set(_Python_VERSIONS
-  ${Python_ADDITIONAL_VERSIONS}
-  ${_PYTHON_FIND_OTHER_VERSIONS}
-  )
+set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
+# If FindPythonInterp has already found the major and minor version,
+# insert that version next to get consistent versions of the interpreter and
+# library.
+if(DEFINED PYTHONLIBS_VERSION_STRING)
+  string(REPLACE "." ";" _PYTHONLIBS_VERSION "${PYTHONLIBS_VERSION_STRING}")
+  list(GET _PYTHONLIBS_VERSION 0 _PYTHONLIBS_VERSION_MAJOR)
+  list(GET _PYTHONLIBS_VERSION 1 _PYTHONLIBS_VERSION_MINOR)
+  list(APPEND _Python_VERSIONS ${_PYTHONLIBS_VERSION_MAJOR}.${_PYTHONLIBS_VERSION_MINOR})
+endif()
+# Search for the current active python version first
+list(APPEND _Python_VERSIONS ";")
+list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
 
 unset(_PYTHON_FIND_OTHER_VERSIONS)
 unset(_PYTHON1_VERSIONS)
@@ -91,7 +100,7 @@
 
 # Search for newest python version if python executable isn't found
 if(NOT PYTHON_EXECUTABLE)
-    foreach(_CURRENT_VERSION ${_Python_VERSIONS})
+    foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS)
       set(_Python_NAMES python${_CURRENT_VERSION})
       if(WIN32)
         list(APPEND _Python_NAMES python)
@@ -129,8 +138,8 @@
             string(REGEX REPLACE " .*" "" PYTHON_VERSION_STRING "${_VERSION}")
             string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}")
             string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}")
-            if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+.*")
-                string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}")
+            if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.([0-9]+)")
+                set(PYTHON_VERSION_PATCH "${CMAKE_MATCH_1}")
             else()
                 set(PYTHON_VERSION_PATCH "0")
             endif()
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 1dbc967..cc875ad 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -31,6 +31,10 @@
 #
 #   PYTHON_LIBRARY             - path to the python library
 #   PYTHON_INCLUDE_DIR         - path to where Python.h is found
+#
+# If also calling find_package(PythonInterp), call find_package(PythonInterp)
+# first to get the currently active Python version by default with a consistent
+# version of PYTHON_LIBRARIES.
 
 #=============================================================================
 # Copyright 2001-2009 Kitware, Inc.
@@ -80,10 +84,14 @@
 
 # Set up the versions we know about, in the order we will search. Always add
 # the user supplied additional versions to the front.
-set(_Python_VERSIONS
-  ${Python_ADDITIONAL_VERSIONS}
-  ${_PYTHON_FIND_OTHER_VERSIONS}
-  )
+# If FindPythonInterp has already found the major and minor version,
+# insert that version between the user supplied versions and the stock
+# version list.
+set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
+if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR)
+  list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
+endif()
+list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
 
 unset(_PYTHON_FIND_OTHER_VERSIONS)
 unset(_PYTHON1_VERSIONS)
diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake
index e893c7a..1bc0940 100644
--- a/Modules/FindQt.cmake
+++ b/Modules/FindQt.cmake
@@ -87,7 +87,7 @@
 if(QT_QMAKE_EXECUTABLE_FINDQT)
   exec_program(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION"
     OUTPUT_VARIABLE QTVERSION)
-  if(QTVERSION MATCHES "4.*")
+  if(QTVERSION MATCHES "4")
     set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt4 qmake program.")
     set(QT4_INSTALLED TRUE)
   endif()
@@ -154,12 +154,12 @@
   endif()
 endif()
 
-if(DESIRED_QT_VERSION MATCHES 3)
+if(DESIRED_QT_VERSION EQUAL 3)
   set(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED})
   set(Qt3_FIND_QUIETLY  ${Qt_FIND_QUIETLY})
   include(${CMAKE_CURRENT_LIST_DIR}/FindQt3.cmake)
 endif()
-if(DESIRED_QT_VERSION MATCHES 4)
+if(DESIRED_QT_VERSION EQUAL 4)
   set(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED})
   set(Qt4_FIND_QUIETLY  ${Qt_FIND_QUIETLY})
   include(${CMAKE_CURRENT_LIST_DIR}/FindQt4.cmake)
diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake
index 6cd12c6..86997ba 100644
--- a/Modules/FindQt3.cmake
+++ b/Modules/FindQt3.cmake
@@ -161,7 +161,7 @@
 
 # Qt 3 should prefer QTDIR over the PATH
 find_program(QT_MOC_EXECUTABLE
-  NAMES moc-qt3 moc moc3 moc3-mt
+  NAMES moc-qt3 moc3 moc3-mt moc
   HINTS
     ENV QTDIR
   PATHS
@@ -186,7 +186,7 @@
 
 # Qt 3 should prefer QTDIR over the PATH
 find_program(QT_UIC_EXECUTABLE
-  NAMES uic-qt3 uic uic3 uic3-mt
+  NAMES uic-qt3 uic3 uic3-mt uic
   HINTS
     ENV QTDIR
   PATHS
@@ -295,12 +295,12 @@
 endif()
 
 set(_QT_UIC_VERSION_3 FALSE)
-if("${QTVERSION_UIC}" MATCHES ".* 3..*")
+if("${QTVERSION_UIC}" MATCHES " 3.")
   set(_QT_UIC_VERSION_3 TRUE)
 endif()
 
 set(_QT_MOC_VERSION_3 FALSE)
-if("${QTVERSION_MOC}" MATCHES ".* 3..*")
+if("${QTVERSION_MOC}" MATCHES " 3.")
   set(_QT_MOC_VERSION_3 TRUE)
 endif()
 
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index d0515c6..c930042 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -1,9 +1,9 @@
 #.rst:
 # FindQt4
-# *******
+# -------
 #
 # Finding and Using Qt4
-# =====================
+# ^^^^^^^^^^^^^^^^^^^^^
 #
 # This module can be used to find Qt4.  The most important issue is that
 # the Qt4 qmake is available via the system path.  This qmake is then
@@ -30,7 +30,7 @@
 #  property to ``TRUE`` on the executable.
 #
 # Qt Build Tools
-# ==============
+# ^^^^^^^^^^^^^^
 #
 # Qt relies on some bundled tools for code generation, such as ``moc`` for
 # meta-object code generation,``uic`` for widget layout and population,
@@ -39,7 +39,7 @@
 # are met.  See :manual:`cmake-qt(7)` for more.
 #
 # Qt Macros
-# =========
+# ^^^^^^^^^
 #
 # In some cases it can be necessary or useful to invoke the Qt build tools in a
 # more-manual way. Several macros are available to add targets for such uses.
@@ -194,7 +194,7 @@
 #
 #
 # IMPORTED Targets
-# ================
+# ^^^^^^^^^^^^^^^^
 #
 # A particular Qt library may be used by using the corresponding
 # :prop_tgt:`IMPORTED` target with the :command:`target_link_libraries`
@@ -271,7 +271,7 @@
 #  The phonon target
 #
 # Result Variables
-# ================
+# ^^^^^^^^^^^^^^^^
 #
 #   Below is a detailed list of variables that FindQt4.cmake sets.
 #
@@ -335,6 +335,7 @@
 include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSymbolExists.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/MacroAddFileDependencies.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
 
 set(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
 
@@ -613,9 +614,13 @@
     set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE)
     set(QT_QTCORE_FOUND 1)
   else()
-    message(WARNING "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as \"${QT_LIBRARY_DIR_TMP}\" "
-                    "but QtCore could not be found there.  "
-                    "Qt is NOT installed correctly for the target build environment.")
+    if(NOT Qt4_FIND_QUIETLY)
+      message(WARNING
+        "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as "
+        "\"${QT_LIBRARY_DIR_TMP}\" "
+        "but QtCore could not be found there.  "
+        "Qt is NOT installed correctly for the target build environment.")
+    endif()
     set(Qt4_FOUND FALSE)
     if(Qt4_FIND_REQUIRED)
       message( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
@@ -747,11 +752,10 @@
   # Find out what window system we're using
   #
   #############################################
-  # Save required variable
-  set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
-  set(CMAKE_REQUIRED_FLAGS_SAVE    ${CMAKE_REQUIRED_FLAGS})
+  cmake_push_check_state()
   # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
   set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
+  set(CMAKE_REQUIRED_QUIET ${Qt4_FIND_QUIETLY})
   # Check for Window system symbols (note: only one should end up being set)
   CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
   CHECK_CXX_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
@@ -771,9 +775,7 @@
      endif ()
   endif ()
 
-  # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
-  set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
-  set(CMAKE_REQUIRED_FLAGS    ${CMAKE_REQUIRED_FLAGS_SAVE})
+  cmake_pop_check_state()
   #
   #############################################
 
@@ -1135,17 +1137,17 @@
     endif()
   endmacro()
 
-  _find_qt4_program(QT_MOC_EXECUTABLE Qt4::moc moc-qt4 moc moc4)
-  _find_qt4_program(QT_UIC_EXECUTABLE Qt4::uic uic-qt4 uic uic4)
+  _find_qt4_program(QT_MOC_EXECUTABLE Qt4::moc moc-qt4 moc4 moc)
+  _find_qt4_program(QT_UIC_EXECUTABLE Qt4::uic uic-qt4 uic4 uic)
   _find_qt4_program(QT_UIC3_EXECUTABLE Qt4::uic3 uic3)
   _find_qt4_program(QT_RCC_EXECUTABLE Qt4::rcc rcc)
   _find_qt4_program(QT_DBUSCPP2XML_EXECUTABLE Qt4::qdbuscpp2xml qdbuscpp2xml)
   _find_qt4_program(QT_DBUSXML2CPP_EXECUTABLE Qt4::qdbusxml2cpp qdbusxml2cpp)
-  _find_qt4_program(QT_LUPDATE_EXECUTABLE Qt4::lupdate lupdate-qt4 lupdate lupdate4)
-  _find_qt4_program(QT_LRELEASE_EXECUTABLE Qt4::lrelease lrelease-qt4 lrelease lrelease4)
+  _find_qt4_program(QT_LUPDATE_EXECUTABLE Qt4::lupdate lupdate-qt4 lupdate4 lupdate)
+  _find_qt4_program(QT_LRELEASE_EXECUTABLE Qt4::lrelease lrelease-qt4 lrelease4 lrelease)
   _find_qt4_program(QT_QCOLLECTIONGENERATOR_EXECUTABLE Qt4::qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator)
-  _find_qt4_program(QT_DESIGNER_EXECUTABLE Qt4::designer designer-qt4 designer designer4)
-  _find_qt4_program(QT_LINGUIST_EXECUTABLE Qt4::linguist linguist-qt4 linguist linguist4)
+  _find_qt4_program(QT_DESIGNER_EXECUTABLE Qt4::designer designer-qt4 designer4 designer)
+  _find_qt4_program(QT_LINGUIST_EXECUTABLE Qt4::linguist linguist-qt4 linguist4 linguist)
 
   if (NOT TARGET Qt4::qmake)
     add_executable(Qt4::qmake IMPORTED)
diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake
index e5173e3..fc2c043 100644
--- a/Modules/FindSDL_image.cmake
+++ b/Modules/FindSDL_image.cmake
@@ -54,7 +54,9 @@
   HINTS
     ENV SDLIMAGEDIR
     ENV SDLDIR
-  PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+  PATH_SUFFIXES SDL
+                # path suffixes to search inside ENV{SDLDIR}
+                include/SDL include/SDL12 include/SDL11 include
 )
 
 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake
index 8f2f066..176fee6 100644
--- a/Modules/FindSDL_mixer.cmake
+++ b/Modules/FindSDL_mixer.cmake
@@ -54,7 +54,9 @@
   HINTS
     ENV SDLMIXERDIR
     ENV SDLDIR
-  PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+  PATH_SUFFIXES SDL
+                # path suffixes to search inside ENV{SDLDIR}
+                include/SDL include/SDL12 include/SDL11 include
 )
 
 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake
index e5c2cdb..ef23573 100644
--- a/Modules/FindSDL_net.cmake
+++ b/Modules/FindSDL_net.cmake
@@ -54,7 +54,9 @@
   HINTS
     ENV SDLNETDIR
     ENV SDLDIR
-  PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+  PATH_SUFFIXES SDL
+                # path suffixes to search inside ENV{SDLDIR}
+                include/SDL include/SDL12 include/SDL11 include
 )
 
 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake
index 3a6ab7b..5fa40a5 100644
--- a/Modules/FindSDL_sound.cmake
+++ b/Modules/FindSDL_sound.cmake
@@ -98,7 +98,9 @@
   HINTS
     ENV SDLSOUNDDIR
     ENV SDLDIR
-  PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+  PATH_SUFFIXES SDL
+                # path suffixes to search inside ENV{SDLDIR}
+                include/SDL include/SDL12 include/SDL11 include
   )
 
 find_library(SDL_SOUND_LIBRARY
@@ -181,7 +183,7 @@
    # in the SDL_LIBRARY string after the "-framework".
    # But if I quote the stuff in INCLUDE_DIRECTORIES, it doesn't work.
    file(WRITE ${PROJECT_BINARY_DIR}/CMakeTmp/CMakeLists.txt
-     "cmake_minimum_required(VERSION 2.8)
+     "cmake_minimum_required(VERSION ${CMAKE_VERSION})
         project(DetermineSoundLibs)
         include_directories(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
         add_executable(DetermineSoundLibs DetermineSoundLibs.c)
diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake
index 3f58ac1..4b527fa 100644
--- a/Modules/FindSDL_ttf.cmake
+++ b/Modules/FindSDL_ttf.cmake
@@ -54,7 +54,9 @@
   HINTS
     ENV SDLTTFDIR
     ENV SDLDIR
-  PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+  PATH_SUFFIXES SDL
+                # path suffixes to search inside ENV{SDLDIR}
+                include/SDL include/SDL12 include/SDL11 include
 )
 
 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake
index 5cff122..4076521 100644
--- a/Modules/FindSquish.cmake
+++ b/Modules/FindSquish.cmake
@@ -184,7 +184,7 @@
   execute_process(COMMAND "${SQUISH_CLIENT_EXECUTABLE}" --version
                   OUTPUT_VARIABLE _squishVersionOutput
                   ERROR_QUIET )
-  if("${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+).*$")
+  if("${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
     set(SQUISH_VERSION_MAJOR "${CMAKE_MATCH_1}")
     set(SQUISH_VERSION_MINOR "${CMAKE_MATCH_2}")
     set(SQUISH_VERSION_PATCH "${CMAKE_MATCH_3}")
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index ec671bf..6050dcd 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -37,9 +37,11 @@
 include (CheckLibraryExists)
 include (CheckSymbolExists)
 set(Threads_FOUND FALSE)
+set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY})
 
 # Do we have sproc?
-if(CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD)
+if(CMAKE_SYSTEM_NAME MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD)
   CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h"  CMAKE_HAVE_SPROC_H)
 endif()
 
@@ -63,32 +65,31 @@
         set(CMAKE_THREAD_LIBS_INIT "")
         set(CMAKE_HAVE_THREADS_LIBRARY 1)
         set(Threads_FOUND TRUE)
-      endif()
+      else()
 
-      if(NOT CMAKE_HAVE_THREADS_LIBRARY)
         # Do we have -lpthreads
         CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
         if(CMAKE_HAVE_PTHREADS_CREATE)
           set(CMAKE_THREAD_LIBS_INIT "-lpthreads")
           set(CMAKE_HAVE_THREADS_LIBRARY 1)
           set(Threads_FOUND TRUE)
-        endif()
+        else()
 
-        # Ok, how about -lpthread
-        CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
-        if(CMAKE_HAVE_PTHREAD_CREATE)
-          set(CMAKE_THREAD_LIBS_INIT "-lpthread")
-          set(CMAKE_HAVE_THREADS_LIBRARY 1)
-          set(Threads_FOUND TRUE)
-        endif()
-
-        if(CMAKE_SYSTEM MATCHES "SunOS.*")
-          # On sun also check for -lthread
-          CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
-          if(CMAKE_HAVE_THR_CREATE)
-            set(CMAKE_THREAD_LIBS_INIT "-lthread")
+          # Ok, how about -lpthread
+          CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
+          if(CMAKE_HAVE_PTHREAD_CREATE)
+            set(CMAKE_THREAD_LIBS_INIT "-lpthread")
             set(CMAKE_HAVE_THREADS_LIBRARY 1)
             set(Threads_FOUND TRUE)
+
+          elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+            # On sun also check for -lthread
+            CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
+            if(CMAKE_HAVE_THR_CREATE)
+              set(CMAKE_THREAD_LIBS_INIT "-lthread")
+              set(CMAKE_HAVE_THREADS_LIBRARY 1)
+              set(Threads_FOUND TRUE)
+            endif()
           endif()
         endif()
       endif()
@@ -96,7 +97,7 @@
 
     if(NOT CMAKE_HAVE_THREADS_LIBRARY)
       # If we did not found -lpthread, -lpthread, or -lthread, look for -pthread
-      if("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
+      if("x${THREADS_HAVE_PTHREAD_ARG}" STREQUAL "x")
         message(STATUS "Check if compiler accepts -pthread")
         try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
           ${CMAKE_BINARY_DIR}
@@ -137,13 +138,13 @@
   set(Threads_FOUND TRUE)
 endif()
 
-if(CMAKE_SYSTEM MATCHES "Windows")
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
   set(CMAKE_USE_WIN32_THREADS_INIT 1)
   set(Threads_FOUND TRUE)
 endif()
 
 if(CMAKE_USE_PTHREADS_INIT)
-  if(CMAKE_SYSTEM MATCHES "HP-UX-*")
+  if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
     # Use libcma if it exists and can be used.  It provides more
     # symbols than the plain pthread library.  CMA threads
     # have actually been deprecated:
@@ -161,12 +162,12 @@
     set(CMAKE_USE_PTHREADS_INIT 1)
   endif()
 
-  if(CMAKE_SYSTEM MATCHES "OSF1-V*")
+  if(CMAKE_SYSTEM MATCHES "OSF1-V")
     set(CMAKE_USE_PTHREADS_INIT 0)
     set(CMAKE_THREAD_LIBS_INIT )
   endif()
 
-  if(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
+  if(CMAKE_SYSTEM MATCHES "CYGWIN_NT")
     set(CMAKE_USE_PTHREADS_INIT 1)
     set(Threads_FOUND TRUE)
     set(CMAKE_THREAD_LIBS_INIT )
@@ -174,5 +175,6 @@
   endif()
 endif()
 
+set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND)
diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake
index 67cecc2..3a31cf0 100644
--- a/Modules/FindX11.cmake
+++ b/Modules/FindX11.cmake
@@ -73,6 +73,8 @@
   # found in tcl on the mac
   set(CMAKE_FIND_FRAMEWORK_SAVE ${CMAKE_FIND_FRAMEWORK})
   set(CMAKE_FIND_FRAMEWORK NEVER)
+  set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+  set(CMAKE_REQUIRED_QUIET ${X11_FIND_QUIETLY})
   set(X11_INC_SEARCH_PATH
     /usr/pkg/xorg/include
     /usr/X11R6/include
@@ -507,6 +509,7 @@
     X11_XSync_INCLUDE_PATH
   )
   set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE})
+  set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
 endif ()
 
 # X11_FIND_REQUIRED_<component> could be checked too
diff --git a/Modules/FindXMLRPC.cmake b/Modules/FindXMLRPC.cmake
index e855050..1491754 100644
--- a/Modules/FindXMLRPC.cmake
+++ b/Modules/FindXMLRPC.cmake
@@ -77,10 +77,9 @@
     # Look for -I options.
     set(XMLRPC_INCLUDE_DIRS)
     foreach(flag ${XMLRPC_C_CONFIG_CFLAGS})
-      if("${flag}" MATCHES "^-I")
-        string(REGEX REPLACE "^-I" "" DIR "${flag}")
-        file(TO_CMAKE_PATH "${DIR}" DIR)
-        set(XMLRPC_INCLUDE_DIRS ${XMLRPC_INCLUDE_DIRS} "${DIR}")
+      if("${flag}" MATCHES "^-I(.+)")
+        file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR)
+        list(APPEND XMLRPC_INCLUDE_DIRS "${DIR}")
       endif()
     endforeach()
   else()
@@ -115,13 +114,11 @@
     set(XMLRPC_LIBRARY_DIRS)
     set(XMLRPC_LIBRARY_NAMES)
     foreach(flag ${XMLRPC_C_CONFIG_LIBS})
-      if("${flag}" MATCHES "^-L")
-        string(REGEX REPLACE "^-L" "" DIR "${flag}")
-        file(TO_CMAKE_PATH "${DIR}" DIR)
-        set(XMLRPC_LIBRARY_DIRS ${XMLRPC_LIBRARY_DIRS} "${DIR}")
-      elseif("${flag}" MATCHES "^-l")
-        string(REGEX REPLACE "^-l" "" NAME "${flag}")
-        set(XMLRPC_LIBRARY_NAMES ${XMLRPC_LIBRARY_NAMES} "${NAME}")
+      if("${flag}" MATCHES "^-L(.+)")
+        file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR)
+        list(APPEND XMLRPC_LIBRARY_DIRS "${DIR}")
+      elseif("${flag}" MATCHES "^-l(.+)")
+        list(APPEND XMLRPC_LIBRARY_NAMES "${CMAKE_MATCH_1}")
       endif()
     endforeach()
 
diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake
index 75b0076..8cc382c 100644
--- a/Modules/FindZLIB.cmake
+++ b/Modules/FindZLIB.cmake
@@ -85,7 +85,7 @@
 
     # only append a TWEAK version if it exists:
     set(ZLIB_VERSION_TWEAK "")
-    if( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
+    if( "${ZLIB_H}" MATCHES "ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+)")
         set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}")
         set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}")
     endif()
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
index 3c664e7..45596a0 100644
--- a/Modules/FindwxWidgets.cmake
+++ b/Modules/FindwxWidgets.cmake
@@ -560,7 +560,7 @@
 
     if(WX_LIB_DIR)
       # If building shared libs, define WXUSINGDLL to use dllimport.
-      if(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
+      if(WX_LIB_DIR MATCHES "[dD][lL][lL]")
         set(wxWidgets_DEFINITIONS WXUSINGDLL)
         DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}")
       endif()
@@ -668,7 +668,7 @@
       if(_wx_result EQUAL 0)
         foreach(_opt_name debug static unicode universal)
           string(TOUPPER ${_opt_name} _upper_opt_name)
-          if(_wx_selected_config MATCHES ".*${_opt_name}.*")
+          if(_wx_selected_config MATCHES "${_opt_name}")
             set(wxWidgets_DEFAULT_${_upper_opt_name} ON)
           else()
             set(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake
index dccb26f..27f8a82 100644
--- a/Modules/FortranCInterface.cmake
+++ b/Modules/FortranCInterface.cmake
@@ -328,7 +328,7 @@
   # Error if compilers are incompatible.
   if(NOT FortranCInterface_VERIFIED_${lang} AND NOT quiet)
     file(READ "${FortranCInterface_BINARY_DIR}/Verify${lang}/output.txt" _output)
-    string(REGEX REPLACE "\n" "\n  " _output "${_output}")
+    string(REPLACE "\n" "\n  " _output "${_output}")
     message(FATAL_ERROR
       "The Fortran compiler:\n  ${CMAKE_Fortran_COMPILER}\n"
       "and the ${lang} compiler:\n  ${CMAKE_${lang}_COMPILER}\n"
diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt
index d35a72c..b6232ed 100644
--- a/Modules/FortranCInterface/CMakeLists.txt
+++ b/Modules/FortranCInterface/CMakeLists.txt
@@ -9,7 +9,7 @@
 # See the License for more information.
 #=============================================================================
 
-cmake_minimum_required(VERSION 2.6.3)
+cmake_minimum_required(VERSION ${CMAKE_VERSION})
 project(FortranCInterface C Fortran)
 include(${FortranCInterface_BINARY_DIR}/Input.cmake OPTIONAL)
 
diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake
index afeb9c5..ceb1db4 100644
--- a/Modules/FortranCInterface/Detect.cmake
+++ b/Modules/FortranCInterface/Detect.cmake
@@ -69,9 +69,8 @@
   file(STRINGS "${FortranCInterface_EXE}" _info_strings
     LIMIT_COUNT 8 REGEX "INFO:[^[]*\\[")
   foreach(info ${_info_strings})
-    if("${info}" MATCHES ".*INFO:symbol\\[([^]]*)\\].*")
-      string(REGEX REPLACE ".*INFO:symbol\\[([^]]*)\\].*" "\\1" symbol "${info}")
-      list(APPEND FortranCInterface_SYMBOLS ${symbol})
+    if("${info}" MATCHES "INFO:symbol\\[([^]]*)\\]")
+      list(APPEND FortranCInterface_SYMBOLS ${CMAKE_MATCH_1})
     endif()
   endforeach()
 elseif(NOT _result)
diff --git a/Modules/FortranCInterface/Verify/CMakeLists.txt b/Modules/FortranCInterface/Verify/CMakeLists.txt
index e969f24..cde3c53 100644
--- a/Modules/FortranCInterface/Verify/CMakeLists.txt
+++ b/Modules/FortranCInterface/Verify/CMakeLists.txt
@@ -9,7 +9,7 @@
 # See the License for more information.
 #=============================================================================
 
-cmake_minimum_required(VERSION 2.7)
+cmake_minimum_required(VERSION ${CMAKE_VERSION})
 project(VerifyFortranC C Fortran)
 
 option(VERIFY_CXX "Whether to verify C++ and Fortran" OFF)
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake
index d868cb3..eac553d 100644
--- a/Modules/GNUInstallDirs.cmake
+++ b/Modules/GNUInstallDirs.cmake
@@ -192,9 +192,26 @@
   set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}")
 endif()
 
-if(NOT CMAKE_INSTALL_INFODIR)
-  set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)")
-  set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info")
+if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
+  if(NOT CMAKE_INSTALL_INFODIR)
+    set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (info)")
+    set(CMAKE_INSTALL_INFODIR "info")
+  endif()
+
+  if(NOT CMAKE_INSTALL_MANDDIR)
+    set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (man)")
+    set(CMAKE_INSTALL_MANDIR "man")
+  endif()
+else()
+  if(NOT CMAKE_INSTALL_INFODIR)
+    set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)")
+    set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info")
+  endif()
+
+  if(NOT CMAKE_INSTALL_MANDDIR)
+    set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)")
+    set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man")
+  endif()
 endif()
 
 if(NOT CMAKE_INSTALL_LOCALEDIR)
@@ -202,11 +219,6 @@
   set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale")
 endif()
 
-if(NOT CMAKE_INSTALL_MANDIR)
-  set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)")
-  set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man")
-endif()
-
 if(NOT CMAKE_INSTALL_DOCDIR)
   set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
   set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index ac649e9..05c2edb 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -509,10 +509,10 @@
 
     if(WIN32)
       string(TOLOWER "$ENV{SystemRoot}" sysroot)
-      string(REGEX REPLACE "\\\\" "/" sysroot "${sysroot}")
+      file(TO_CMAKE_PATH "${sysroot}" sysroot)
 
       string(TOLOWER "$ENV{windir}" windir)
-      string(REGEX REPLACE "\\\\" "/" windir "${windir}")
+      file(TO_CMAKE_PATH "${windir}" windir)
 
       if(lower MATCHES "^(${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)")
         set(is_system 1)
@@ -772,8 +772,8 @@
 
   # Convert to a list of lines:
   #
-  string(REGEX REPLACE ";" "\\\\;" candidates "${gp_cmd_ov}")
-  string(REGEX REPLACE "\n" "${eol_char};" candidates "${candidates}")
+  string(REPLACE ";" "\\;" candidates "${gp_cmd_ov}")
+  string(REPLACE "\n" "${eol_char};" candidates "${candidates}")
 
   # check for install id and remove it from list, since otool -L can include a
   # reference to itself
diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake
index 86033e6..5c439e9 100644
--- a/Modules/InstallRequiredSystemLibraries.cmake
+++ b/Modules/InstallRequiredSystemLibraries.cmake
@@ -157,7 +157,8 @@
         "${msvc_install_dir}/../../VC/redist"
         "${base_dir}/VC/redist"
         "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist"
-        "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio ${v}.0/VC/redist"
+        set(programfilesx86 "ProgramFiles(x86)")
+        "$ENV{${programfilesx86}}/Microsoft Visual Studio ${v}.0/VC/redist"
       )
     mark_as_advanced(MSVC${v}_REDIST_DIR)
     set(MSVC${v}_CRT_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT")
@@ -383,18 +384,18 @@
 
 if(WATCOM)
   get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
-  if(WATCOM17)
-     set( __install__libs ${CompilerPath}/clbr17.dll
-       ${CompilerPath}/mt7r17.dll ${CompilerPath}/plbr17.dll )
+  if(CMAKE_C_COMPILER_VERSION)
+    set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
+  else()
+    set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
   endif()
-  if(WATCOM18)
-     set( __install__libs ${CompilerPath}/clbr18.dll
-       ${CompilerPath}/mt7r18.dll ${CompilerPath}/plbr18.dll )
-  endif()
-  if(WATCOM19)
-     set( __install__libs ${CompilerPath}/clbr19.dll
-       ${CompilerPath}/mt7r19.dll ${CompilerPath}/plbr19.dll )
-  endif()
+  string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}")
+  list(GET _watcom_version_list 0 _watcom_major)
+  list(GET _watcom_version_list 1 _watcom_minor)
+  set( __install__libs
+    ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll
+    ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll
+    ${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll )
   foreach(lib
       ${__install__libs}
       )
diff --git a/Modules/IntelVSImplicitPath/CMakeLists.txt b/Modules/IntelVSImplicitPath/CMakeLists.txt
index 96dc4e6..d115704 100644
--- a/Modules/IntelVSImplicitPath/CMakeLists.txt
+++ b/Modules/IntelVSImplicitPath/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required(VERSION ${CMAKE_VERSION})
 project(IntelFortranImplicit Fortran)
 add_custom_command(
   OUTPUT output.cmake
diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake
new file mode 100644
index 0000000..abd9a26
--- /dev/null
+++ b/Modules/Internal/FeatureTesting.cmake
@@ -0,0 +1,60 @@
+
+macro(record_compiler_features lang compile_flags feature_list)
+  include("${CMAKE_ROOT}/Modules/Compiler/${CMAKE_${lang}_COMPILER_ID}-${lang}-FeatureTests.cmake" OPTIONAL)
+
+  string(TOLOWER ${lang} lang_lc)
+  file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin")
+  file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" "
+  const char features[] = {\"\"\n")
+
+  get_property(known_features GLOBAL PROPERTY CMAKE_${lang}_KNOWN_FEATURES)
+
+  foreach(feature ${known_features})
+    if (_cmake_feature_test_${feature})
+      if (${_cmake_feature_test_${feature}} STREQUAL 1)
+        set(_feature_condition "\"1\" ")
+      else()
+        set(_feature_condition "#if ${_cmake_feature_test_${feature}}\n\"1\"\n#else\n\"0\"\n#endif\n")
+      endif()
+      file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" "\"${lang}_FEATURE:\"\n${_feature_condition}\"${feature}\\n\"\n")
+    endif()
+  endforeach()
+  file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}"
+    "\n};\n\nint main(int argc, char** argv) { (void)argv; return features[argc]; }\n")
+
+  try_compile(CMAKE_${lang}_FEATURE_TEST
+    ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}"
+    COMPILE_DEFINITIONS "${compile_flags}"
+    OUTPUT_VARIABLE _output
+    COPY_FILE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin"
+    COPY_FILE_ERROR _copy_error
+    )
+  if(CMAKE_${lang}_FEATURE_TEST AND NOT _copy_error)
+    set(_result 0)
+  else()
+    set(_result 255)
+  endif()
+  unset(CMAKE_${lang}_FEATURE_TEST CACHE)
+
+  if (_result EQUAL 0)
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+      "\n\nDetecting ${lang} [${compile_flags}] compiler features compiled with the following output:\n${_output}\n\n")
+    if(EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin")
+      file(STRINGS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin"
+        features REGEX "${lang}_FEATURE:.*")
+      foreach(info ${features})
+        file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+          "    Feature record: ${info}\n")
+        string(REPLACE "${lang}_FEATURE:" "" info ${info})
+        string(SUBSTRING ${info} 0 1 has_feature)
+        if(has_feature)
+          string(REGEX REPLACE "^1" "" feature ${info})
+          list(APPEND ${feature_list} ${feature})
+        endif()
+      endforeach()
+    endif()
+  else()
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+      "Detecting ${lang} [${compile_flags}] compiler features failed to compile with the following output:\n${_output}\n${_copy_error}\n\n")
+  endif()
+endmacro()
diff --git a/Modules/Platform/Darwin-Clang.cmake b/Modules/Platform/Darwin-Clang.cmake
index 528873c..4cded47 100644
--- a/Modules/Platform/Darwin-Clang.cmake
+++ b/Modules/Platform/Darwin-Clang.cmake
@@ -24,4 +24,7 @@
   set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
   set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
   set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
+  if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.1)
+    set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
+  endif()
 endmacro()
diff --git a/Modules/Platform/Darwin-GNU.cmake b/Modules/Platform/Darwin-GNU.cmake
index 5fee7e3..87d1d23 100644
--- a/Modules/Platform/Darwin-GNU.cmake
+++ b/Modules/Platform/Darwin-GNU.cmake
@@ -23,6 +23,10 @@
   # GNU does not have -shared on OS X
   set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
   set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
+
+  if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.3)
+    set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
+  endif()
 endmacro()
 
 macro(cmake_gnu_set_sysroot_flag lang)
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake
new file mode 100644
index 0000000..62fb985
--- /dev/null
+++ b/Modules/Platform/Darwin-Initialize.cmake
@@ -0,0 +1,151 @@
+# Ask xcode-select where to find /Developer or fall back to ancient location.
+execute_process(COMMAND xcode-select -print-path
+  OUTPUT_VARIABLE _stdout
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+  ERROR_VARIABLE _stderr
+  RESULT_VARIABLE _failed)
+if(NOT _failed AND IS_DIRECTORY ${_stdout})
+  set(OSX_DEVELOPER_ROOT ${_stdout})
+elseif(IS_DIRECTORY "/Developer")
+  set(OSX_DEVELOPER_ROOT "/Developer")
+else()
+  set(OSX_DEVELOPER_ROOT "")
+endif()
+
+execute_process(COMMAND sw_vers -productVersion
+  OUTPUT_VARIABLE CURRENT_OSX_VERSION
+  OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+# Save CMAKE_OSX_ARCHITECTURES from the environment.
+set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING
+  "Build architectures for OSX")
+
+#----------------------------------------------------------------------------
+# _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ...
+#
+string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1"
+  _CURRENT_OSX_VERSION "${CURRENT_OSX_VERSION}")
+
+#----------------------------------------------------------------------------
+# CMAKE_OSX_DEPLOYMENT_TARGET
+
+# Set cache variable - end user may change this during ccmake or cmake-gui configure.
+if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3)
+  set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING
+    "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
+endif()
+
+#----------------------------------------------------------------------------
+# CMAKE_OSX_SYSROOT
+
+if(CMAKE_OSX_SYSROOT)
+  # Use the existing value without further computation to choose a default.
+  set(_CMAKE_OSX_SYSROOT_DEFAULT "${CMAKE_OSX_SYSROOT}")
+elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND
+        (NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}"))
+  # Use the value of SDKROOT from the environment.
+  set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}")
+elseif("${CMAKE_GENERATOR}" MATCHES Xcode
+       OR CMAKE_OSX_DEPLOYMENT_TARGET
+       OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]"
+       OR NOT EXISTS "/usr/include/sys/types.h")
+  # Find installed SDKs in either Xcode-4.3+ or pre-4.3 SDKs directory.
+  set(_CMAKE_OSX_SDKS_DIR "")
+  if(OSX_DEVELOPER_ROOT)
+    foreach(d Platforms/MacOSX.platform/Developer/SDKs SDKs)
+      file(GLOB _CMAKE_OSX_SDKS ${OSX_DEVELOPER_ROOT}/${d}/*)
+      if(_CMAKE_OSX_SDKS)
+        set(_CMAKE_OSX_SDKS_DIR ${OSX_DEVELOPER_ROOT}/${d})
+        break()
+      endif()
+    endforeach()
+  endif()
+
+  if(_CMAKE_OSX_SDKS_DIR)
+    # Select SDK for current OSX version accounting for the known
+    # specially named SDKs.
+    set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.4 "u")
+    set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9")
+
+    # find the latest SDK
+    set(_CMAKE_OSX_LATEST_SDK_VERSION "0.0")
+    file(GLOB _CMAKE_OSX_SDKS RELATIVE "${_CMAKE_OSX_SDKS_DIR}" "${_CMAKE_OSX_SDKS_DIR}/MacOSX*.sdk")
+    foreach(_SDK ${_CMAKE_OSX_SDKS})
+      if(_SDK MATCHES "MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk" AND CMAKE_MATCH_1 VERSION_GREATER ${_CMAKE_OSX_LATEST_SDK_VERSION})
+        set(_CMAKE_OSX_LATEST_SDK_VERSION "${CMAKE_MATCH_1}")
+      endif()
+    endforeach()
+
+    # pick an SDK that works
+    set(_CMAKE_OSX_SYSROOT_DEFAULT)
+    foreach(ver ${CMAKE_OSX_DEPLOYMENT_TARGET}
+                ${_CURRENT_OSX_VERSION}
+                ${_CMAKE_OSX_LATEST_SDK_VERSION})
+      set(_CMAKE_OSX_DEPLOYMENT_TARGET ${ver})
+      set(_CMAKE_OSX_SDKS_VER ${_CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CMAKE_OSX_DEPLOYMENT_TARGET}})
+      set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
+      if(IS_DIRECTORY "${_CMAKE_OSX_SYSROOT_CHECK}")
+        set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SYSROOT_CHECK}")
+        break()
+      endif()
+    endforeach()
+
+    if(CMAKE_OSX_DEPLOYMENT_TARGET AND
+        NOT CMAKE_OSX_DEPLOYMENT_TARGET VERSION_EQUAL ${_CMAKE_OSX_DEPLOYMENT_TARGET})
+      set(_CMAKE_OSX_SDKS_VER ${CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${CMAKE_OSX_DEPLOYMENT_TARGET}})
+      set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
+      message(WARNING
+        "CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' "
+        "but the matching SDK does not exist at:\n \"${_CMAKE_OSX_SYSROOT_CHECK}\"\n"
+        "Instead using SDK:\n \"${_CMAKE_OSX_SYSROOT_DEFAULT}\"."
+        )
+    endif()
+  else()
+    # Assume developer files are in root (such as Xcode 4.5 command-line tools).
+    set(_CMAKE_OSX_SYSROOT_DEFAULT "")
+  endif()
+endif()
+
+# Set cache variable - end user may change this during ccmake or cmake-gui configure.
+# Choose the type based on the current value.
+set(_CMAKE_OSX_SYSROOT_TYPE STRING)
+foreach(v CMAKE_OSX_SYSROOT _CMAKE_OSX_SYSROOT_DEFAULT)
+  if("x${${v}}" MATCHES "/")
+    set(_CMAKE_OSX_SYSROOT_TYPE PATH)
+    break()
+  endif()
+endforeach()
+set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE}
+  "The product will be built against the headers and libraries located inside the indicated SDK.")
+
+# Transform the cached value to something we can use.
+set(_CMAKE_OSX_SYSROOT_ORIG "${CMAKE_OSX_SYSROOT}")
+set(_CMAKE_OSX_SYSROOT_PATH "")
+if(CMAKE_OSX_SYSROOT)
+  if("x${CMAKE_OSX_SYSROOT}" MATCHES "/")
+    # This is a path to the SDK.  Make sure it exists.
+    if(NOT IS_DIRECTORY "${CMAKE_OSX_SYSROOT}")
+      message(WARNING "Ignoring CMAKE_OSX_SYSROOT value:\n ${CMAKE_OSX_SYSROOT}\n"
+        "because the directory does not exist.")
+      set(CMAKE_OSX_SYSROOT "")
+      set(_CMAKE_OSX_SYSROOT_ORIG "")
+    endif()
+    set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}")
+  else()
+    # Transform the sdk name into a path.
+    execute_process(
+      COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path
+      OUTPUT_VARIABLE _stdout
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+      ERROR_VARIABLE _stderr
+      RESULT_VARIABLE _failed
+      )
+    if(NOT _failed AND IS_DIRECTORY "${_stdout}")
+      set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}")
+      # For non-Xcode generators use the path.
+      if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
+        set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
+      endif()
+    endif()
+  endif()
+endif()
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index fc3f87e..e25df1e 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -64,146 +64,9 @@
   mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)
 endif()
 
-# Ask xcode-select where to find /Developer or fall back to ancient location.
-execute_process(COMMAND xcode-select -print-path
-  OUTPUT_VARIABLE _stdout
-  OUTPUT_STRIP_TRAILING_WHITESPACE
-  ERROR_VARIABLE _stderr
-  RESULT_VARIABLE _failed)
-if(NOT _failed AND IS_DIRECTORY ${_stdout})
-  set(OSX_DEVELOPER_ROOT ${_stdout})
-elseif(IS_DIRECTORY "/Developer")
-  set(OSX_DEVELOPER_ROOT "/Developer")
-else()
-  set(OSX_DEVELOPER_ROOT "")
-endif()
-
-execute_process(COMMAND sw_vers -productVersion
-  OUTPUT_VARIABLE CURRENT_OSX_VERSION
-  OUTPUT_STRIP_TRAILING_WHITESPACE)
-
-# Save CMAKE_OSX_ARCHITECTURES from the environment.
-set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING
-  "Build architectures for OSX")
-
-#----------------------------------------------------------------------------
-# _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ...
-#
-string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1"
-  _CURRENT_OSX_VERSION "${CURRENT_OSX_VERSION}")
-
-#----------------------------------------------------------------------------
-# CMAKE_OSX_DEPLOYMENT_TARGET
-
-# Set cache variable - end user may change this during ccmake or cmake-gui configure.
-if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3)
-  set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING
-    "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
-endif()
-
-#----------------------------------------------------------------------------
-# CMAKE_OSX_SYSROOT
-
-if(CMAKE_OSX_SYSROOT)
-  # Use the existing value without further computation to choose a default.
-  set(_CMAKE_OSX_SYSROOT_DEFAULT "${CMAKE_OSX_SYSROOT}")
-elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND
-        (NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}"))
-  # Use the value of SDKROOT from the environment.
-  set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}")
-elseif("${CMAKE_GENERATOR}" MATCHES Xcode
-       OR CMAKE_OSX_DEPLOYMENT_TARGET
-       OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]"
-       OR NOT EXISTS "/usr/include/sys/types.h")
-  # Find installed SDKs in either Xcode-4.3+ or pre-4.3 SDKs directory.
-  set(_CMAKE_OSX_SDKS_DIR "")
-  if(OSX_DEVELOPER_ROOT)
-    foreach(d Platforms/MacOSX.platform/Developer/SDKs SDKs)
-      file(GLOB _CMAKE_OSX_SDKS ${OSX_DEVELOPER_ROOT}/${d}/*)
-      if(_CMAKE_OSX_SDKS)
-        set(_CMAKE_OSX_SDKS_DIR ${OSX_DEVELOPER_ROOT}/${d})
-        break()
-      endif()
-    endforeach()
-  endif()
-
-  if(_CMAKE_OSX_SDKS_DIR)
-    # Select SDK for current OSX version accounting for the known
-    # specially named SDKs.
-    set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.4 "u")
-    set(_CMAKE_OSX_SDKS_VER_SUFFIX_10.3 ".9")
-    if(CMAKE_OSX_DEPLOYMENT_TARGET)
-      set(_CMAKE_OSX_SDKS_VER ${CMAKE_OSX_DEPLOYMENT_TARGET}${_CMAKE_OSX_SDKS_VER_SUFFIX_${CMAKE_OSX_DEPLOYMENT_TARGET}})
-      set(_CMAKE_OSX_SYSROOT_CHECK "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
-      if(IS_DIRECTORY "${_CMAKE_OSX_SYSROOT_CHECK}")
-        set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SYSROOT_CHECK}")
-      else()
-        set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}})
-        set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
-        message(WARNING
-          "CMAKE_OSX_DEPLOYMENT_TARGET is '${CMAKE_OSX_DEPLOYMENT_TARGET}' "
-          "but the matching SDK does not exist at:\n \"${_CMAKE_OSX_SYSROOT_CHECK}\"\n"
-          "Instead using SDK:\n \"${_CMAKE_OSX_SYSROOT_DEFAULT}\"\n"
-          "matching the host OS X version."
-          )
-      endif()
-    else()
-      set(_CMAKE_OSX_SDKS_VER ${_CURRENT_OSX_VERSION}${_CMAKE_OSX_SDKS_VER_SUFFIX_${_CURRENT_OSX_VERSION}})
-      set(_CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS_DIR}/MacOSX${_CMAKE_OSX_SDKS_VER}.sdk")
-    endif()
-  else()
-    # Assume developer files are in root (such as Xcode 4.5 command-line tools).
-    set(_CMAKE_OSX_SYSROOT_DEFAULT "")
-  endif()
-endif()
-
-# Set cache variable - end user may change this during ccmake or cmake-gui configure.
-# Choose the type based on the current value.
-set(_CMAKE_OSX_SYSROOT_TYPE STRING)
-foreach(v CMAKE_OSX_SYSROOT _CMAKE_OSX_SYSROOT_DEFAULT)
-  if("x${${v}}" MATCHES "/")
-    set(_CMAKE_OSX_SYSROOT_TYPE PATH)
-    break()
-  endif()
-endforeach()
-set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE}
-  "The product will be built against the headers and libraries located inside the indicated SDK.")
-
-# Transform the cached value to something we can use.
-set(_CMAKE_OSX_SYSROOT_ORIG "${CMAKE_OSX_SYSROOT}")
-set(_CMAKE_OSX_SYSROOT_PATH "")
-if(CMAKE_OSX_SYSROOT)
-  if("x${CMAKE_OSX_SYSROOT}" MATCHES "/")
-    # This is a path to the SDK.  Make sure it exists.
-    if(NOT IS_DIRECTORY "${CMAKE_OSX_SYSROOT}")
-      message(WARNING "Ignoring CMAKE_OSX_SYSROOT value:\n ${CMAKE_OSX_SYSROOT}\n"
-        "because the directory does not exist.")
-      set(CMAKE_OSX_SYSROOT "")
-      set(_CMAKE_OSX_SYSROOT_ORIG "")
-    endif()
-    set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}")
-  else()
-    # Transform the sdk name into a path.
-    execute_process(
-      COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path
-      OUTPUT_VARIABLE _stdout
-      OUTPUT_STRIP_TRAILING_WHITESPACE
-      ERROR_VARIABLE _stderr
-      RESULT_VARIABLE _failed
-      )
-    if(NOT _failed AND IS_DIRECTORY "${_stdout}")
-      set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}")
-      # For non-Xcode generators use the path.
-      if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
-        set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
-      endif()
-    endif()
-  endif()
-endif()
-
 # Make sure the combination of SDK and Deployment Target are allowed
 if(CMAKE_OSX_DEPLOYMENT_TARGET)
-  if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "^.*/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk")
+  if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk")
     set(_sdk_ver "${CMAKE_MATCH_1}")
   elseif("${_CMAKE_OSX_SYSROOT_ORIG}" MATCHES "^macosx([0-9]+\\.[0-9]+)$")
     set(_sdk_ver "${CMAKE_MATCH_1}")
diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake
index 825f851..dfc2664 100644
--- a/Modules/Platform/Haiku.cmake
+++ b/Modules/Platform/Haiku.cmake
@@ -21,18 +21,26 @@
 # "/boot/system/develop/lib/<subdir>/", which we assume to be the secondary
 # architecture specific subdirectory and extract the name of the architecture
 # accordingly.
-set(__HAIKU_COMPILER ${CMAKE_C_COMPILER})
 
-if(NOT __HAIKU_COMPILER)
+# First of all, find a C or C++ compiler we can run. The "arg1" is necessary
+# here for compilers such as "distcc gcc-x86" or "ccache gcc-x86"
+# TODO See CMakeDetermineCompilerId.cmake for some more things we may want to do.
+if(CMAKE_C_COMPILER)
+  set(__HAIKU_COMPILER ${CMAKE_C_COMPILER})
+  string (STRIP "${CMAKE_C_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS)
+else()
   set(__HAIKU_COMPILER ${CMAKE_CXX_COMPILER})
+  string (STRIP "${CMAKE_CXX_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS)
 endif()
 
+
 execute_process(
-  COMMAND ${__HAIKU_COMPILER} -print-search-dirs
+  COMMAND ${__HAIKU_COMPILER} ${__HAIKU_COMPILER_FLAGS} -print-search-dirs
   OUTPUT_VARIABLE _HAIKU_SEARCH_DIRS
+  RESULT_VARIABLE _HAIKU_SEARCH_DIRS_FOUND
   OUTPUT_STRIP_TRAILING_WHITESPACE)
 
-string(REGEX MATCH ".*\nlibraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/(:[^\n]*)?\n.*" _dummy "\n${_HAIKU_SEARCH_DIRS}\n")
+string(REGEX MATCH "libraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/?(:?\n+)" _dummy "${_HAIKU_SEARCH_DIRS}\n")
 set(CMAKE_HAIKU_SECONDARY_ARCH "${CMAKE_MATCH_2}")
 
 if(NOT CMAKE_HAIKU_SECONDARY_ARCH)
@@ -53,14 +61,12 @@
 endif()
 
 list(APPEND CMAKE_SYSTEM_PREFIX_PATH
-  /boot/common/non-packaged
-  /boot/common
+  /boot/system/non-packaged
   /boot/system
   )
 
 LIST(APPEND CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES
-  /boot/common/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
-  /boot/common/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
+  /boot/system/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
   /boot/system/develop/headers/os
   /boot/system/develop/headers/os/app
   /boot/system/develop/headers/os/device
@@ -108,8 +114,7 @@
 LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_HAIKU_C_INCLUDE_DIRECTORIES})
 
 LIST(APPEND CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES
-  /boot/common/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
-  /boot/common/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
+  /boot/system/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
   /boot/system/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
   )
 
@@ -120,6 +125,6 @@
 LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES})
 
 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
-  set(CMAKE_INSTALL_PREFIX "/boot/common" CACHE PATH
+  set(CMAKE_INSTALL_PREFIX "/boot/system" CACHE PATH
     "Install path prefix, prepended onto install directories." FORCE)
 endif()
diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake
index 9c3255e..f2ad612 100644
--- a/Modules/Platform/OSF1.cmake
+++ b/Modules/Platform/OSF1.cmake
@@ -2,7 +2,7 @@
 
 if(CMAKE_SYSTEM MATCHES "OSF1-1.[012]")
 endif()
-if(CMAKE_SYSTEM MATCHES "OSF1-1.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-1")
   # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
   set(CMAKE_C_COMPILE_OPTIONS_PIC "-fpic")
   set(CMAKE_C_COMPILE_OPTIONS_PIE "-fpie")
@@ -12,7 +12,7 @@
 
 
 
-if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-V")
   set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-expect_unresolved,\\*")       # -shared
   if(CMAKE_COMPILER_IS_GNUCXX)
     set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,-rpath,")
diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake
index 53cabed..7ac6c7e 100644
--- a/Modules/Platform/OpenBSD.cmake
+++ b/Modules/Platform/OpenBSD.cmake
@@ -10,13 +10,29 @@
                   ERROR_QUIET)
   string(REGEX REPLACE ".*search\\ directories:\\ ([^\n]*).*" "\\1"
          LDCONFIG_HINTS "${LDCONFIG_HINTS}")
-  string(REGEX REPLACE ":" ";"
+  string(REPLACE ":" ";"
          CMAKE_PLATFORM_RUNTIME_PATH
          "${LDCONFIG_HINTS}")
 endif()
 
 set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1)
 
+# OpenBSD has no multilib
+set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
+
 # OpenBSD policy requires that shared libraries be installed without
 # executable permission.
 set(CMAKE_INSTALL_SO_NO_EXE 1)
+
+if($ENV{LOCALBASE})
+  set(OPENBSD_LOCALBASE $ENV{LOCALBASE})
+else()
+  set(OPENBSD_LOCALBASE /usr/local)
+endif()
+if($ENV{X11BASE})
+  set(OPENBSD_X11BASE $ENV{X11BASE})
+else()
+  set(OPENBSD_X11BASE /usr/X11R6)
+endif()
+
+list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${OPENBSD_LOCALBASE})
diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake
index da20f97..aaa79c4 100644
--- a/Modules/Platform/SunOS.cmake
+++ b/Modules/Platform/SunOS.cmake
@@ -1,4 +1,4 @@
-if(CMAKE_SYSTEM MATCHES "SunOS-4.*")
+if(CMAKE_SYSTEM MATCHES "SunOS-4")
    set(CMAKE_C_COMPILE_OPTIONS_PIC "-PIC")
    set(CMAKE_C_COMPILE_OPTIONS_PIE "-PIE")
    set(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC")
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index 872755c..ffc5657 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -67,8 +67,8 @@
 
   if(MSYS OR MINGW)
     # Create archiving rules to support large object file lists for static libraries.
-    set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
-    set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> r  <TARGET> <LINK_FLAGS> <OBJECTS>")
+    set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
+    set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q  <TARGET> <LINK_FLAGS> <OBJECTS>")
     set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
 
     # Initialize C link type selection flags.  These flags are used when
@@ -87,6 +87,7 @@
   set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
 
   set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE})
+  set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES ${__WINDOWS_GNU_LD_RESPONSE})
   set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
 
   # We prefer "@" for response files but it is not supported by gcc 3.
@@ -103,16 +104,18 @@
     endif()
     # The GNU 3.x compilers do not support response files (only linkers).
     set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 0)
-  elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS)
+    # Link libraries are generated only for the front-end.
+    set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 0)
+  else()
     # Use "@" to pass the response file to the front-end.
     set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@")
   endif()
 
   # Binary link rules.
   set(CMAKE_${lang}_CREATE_SHARED_MODULE
-    "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_MODULE_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
+    "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_MODULE_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
   set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
-    "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
+    "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
   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>")
 
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index e29aaf4..5732170 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -241,7 +241,7 @@
   set(CMAKE_${lang}_CREATE_STATIC_LIBRARY  "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ")
 
   set(CMAKE_${lang}_COMPILE_OBJECT
-    "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<OBJECT_DIR>/${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB>${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}")
   set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE
     "<CMAKE_${lang}_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> -E <SOURCE>${CMAKE_END_TEMP_FILE}")
   set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE
diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake
index 8a03b29..ac410de 100644
--- a/Modules/Platform/Windows-wcl386.cmake
+++ b/Modules/Platform/Windows-wcl386.cmake
@@ -12,13 +12,15 @@
   set(CMAKE_LIB_QUIET "-q")
 endif()
 
+set(CMAKE_EXE_LINKER_FLAGS_INIT)
 set(CMAKE_CREATE_WIN32_EXE "system nt_win" )
 set(CMAKE_CREATE_CONSOLE_EXE "system nt" )
-
-set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "debug all" )
-set (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "debug all" )
-set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" )
-set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" )
+set(CMAKE_SHARED_LINKER_FLAGS_INIT "system nt_dll")
+set(CMAKE_MODULE_LINKER_FLAGS_INIT "system nt_dll")
+foreach(type SHARED MODULE EXE)
+  set(CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT "debug all opt map, symfile")
+  set(CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all opt map, symfile")
+endforeach()
 
 set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list
 set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string.
@@ -26,50 +28,54 @@
 set(CMAKE_RC_COMPILER "rc" )
 
 set(CMAKE_BUILD_TYPE_INIT Debug)
-set (CMAKE_CXX_FLAGS_INIT "-w=3 -xs")
-set (CMAKE_CXX_FLAGS_DEBUG_INIT "-br -bm -d2")
-set (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG")
-set (CMAKE_CXX_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG")
-set (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-br -bm  -d2 -ot -dNDEBUG")
-set (CMAKE_C_FLAGS_INIT "-w=3 ")
-set (CMAKE_C_FLAGS_DEBUG_INIT "-br -bm -d2 -od")
-set (CMAKE_C_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG")
-set (CMAKE_C_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG")
-set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG")
-set (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib  library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib")
-set (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
+
+# single/multi-threaded                 /-bm
+# static/DLL run-time libraries         /-br
+# default is setup for multi-threaded + DLL run-time libraries
+set (CMAKE_C_FLAGS_INIT "-bt=nt -w3 -dWIN32 -br -bm")
+set (CMAKE_CXX_FLAGS_INIT "-bt=nt -xs -w3 -dWIN32 -br -bm")
+foreach(lang C CXX)
+  set (CMAKE_${lang}_FLAGS_DEBUG_INIT "-d2")
+  set (CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-s -os -d0 -dNDEBUG")
+  set (CMAKE_${lang}_FLAGS_RELEASE_INIT "-s -ot -d0 -dNDEBUG")
+  set (CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-s -ot -d1 -dNDEBUG")
+endforeach()
+
+foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE)
+  set(CMAKE_C_${type}_USE_WATCOM_QUOTE 1)
+  set(CMAKE_CXX_${type}_USE_WATCOM_QUOTE 1)
+endforeach()
 
 set(CMAKE_C_CREATE_IMPORT_LIBRARY
-  "wlib -c -q -n -b <TARGET_IMPLIB> +'<TARGET_UNQUOTED>'")
+  "wlib -c -q -n -b <TARGET_IMPLIB> +<TARGET_QUOTED>")
 set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY})
 
 set(CMAKE_C_LINK_EXECUTABLE
-    "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+    "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
 
 
 set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE})
 
 # compile a C++ file into an object file
 set(CMAKE_CXX_COMPILE_OBJECT
-    "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<OBJECT> -c -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<OBJECT> -c -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
 
 # compile a C file into an object file
 set(CMAKE_C_COMPILE_OBJECT
-    "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<OBJECT> -c -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<OBJECT> -c -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
 
 # preprocess a C source file
 set(CMAKE_C_CREATE_PREPROCESSED_SOURCE
-    "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
 
 # preprocess a C++ source file
 set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
-    "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
+    "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
 
-set(CMAKE_CXX_CREATE_SHARED_MODULE
- "wlink ${CMAKE_START_TEMP_FILE} system nt_dll  ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact  file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
 set(CMAKE_CXX_CREATE_SHARED_LIBRARY
-  ${CMAKE_CXX_CREATE_SHARED_MODULE}
-  ${CMAKE_CXX_CREATE_IMPORT_LIBRARY})
+ "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+string(REPLACE " option implib=<TARGET_IMPLIB>" ""
+  CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
 
 # create a C shared library
 set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
@@ -78,7 +84,7 @@
 set(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE})
 
 # create a C++ static library
-set(CMAKE_CXX_CREATE_STATIC_LIBRARY  "wlib ${CMAKE_LIB_QUIET} -c -n -b '<TARGET_UNQUOTED>' <LINK_FLAGS> <OBJECTS> ")
+set(CMAKE_CXX_CREATE_STATIC_LIBRARY  "wlib ${CMAKE_LIB_QUIET} -c -n -b <TARGET_QUOTED> <LINK_FLAGS> <OBJECTS> ")
 
 # create a C static library
 set(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY})
@@ -87,23 +93,27 @@
   set(_CMAKE_WATCOM_VERSION 1)
   if(CMAKE_C_COMPILER_VERSION)
     set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
+    set(_compiler_id ${CMAKE_C_COMPILER_ID})
   else()
     set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
+    set(_compiler_id ${CMAKE_CXX_COMPILER_ID})
   endif()
   set(WATCOM16)
   set(WATCOM17)
   set(WATCOM18)
   set(WATCOM19)
-  if("${_compiler_version}" LESS 12.70)
-    set(WATCOM16 1)
-  endif()
-  if("${_compiler_version}" EQUAL 12.70)
-    set(WATCOM17 1)
-  endif()
-  if("${_compiler_version}" EQUAL 12.80)
-    set(WATCOM18 1)
-  endif()
-  if("${_compiler_version}" EQUAL 12.90)
-    set(WATCOM19 1)
+  if("${_compiler_id}" STREQUAL "OpenWatcom")
+    if("${_compiler_version}" VERSION_LESS 1.7)
+      set(WATCOM16 1)
+    endif()
+    if("${_compiler_version}" VERSION_EQUAL 1.7)
+      set(WATCOM17 1)
+    endif()
+    if("${_compiler_version}" VERSION_EQUAL 1.8)
+      set(WATCOM18 1)
+    endif()
+    if("${_compiler_version}" VERSION_EQUAL 1.9)
+      set(WATCOM19 1)
+    endif()
   endif()
 endif()
diff --git a/Modules/Platform/WindowsPaths.cmake b/Modules/Platform/WindowsPaths.cmake
index 3240c23..658de3b 100644
--- a/Modules/Platform/WindowsPaths.cmake
+++ b/Modules/Platform/WindowsPaths.cmake
@@ -56,9 +56,10 @@
   if(DEFINED "ENV{ProgramFiles}")
     list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles}")
   endif()
-  if(DEFINED "ENV{ProgramFiles(x86)}")
+  set(programfilesx86 "ProgramFiles(x86)")
+  if(DEFINED "ENV{${programfilesx86}}")
     # 64-bit binary.  32-bit program files are in ProgramFiles(x86).
-    list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles(x86)}")
+    list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{${programfilesx86}}")
   elseif(DEFINED "ENV{SystemDrive}")
     # Guess the 32-bit program files location.
     if(EXISTS "$ENV{SystemDrive}/Program Files (x86)")
diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index 0fe0b32..e034a28 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -104,6 +104,18 @@
       string(REGEX MATCHALL "Number of CPUs = ([0-9]+)" procs "${machinfo_output}")
       set(count "${CMAKE_MATCH_1}")
       #message("ProcessorCount: trying machinfo '${ProcessorCount_cmd_machinfo}'")
+    else()
+      find_program(ProcessorCount_cmd_mpsched mpsched)
+      mark_as_advanced(ProcessorCount_cmd_mpsched)
+      if(ProcessorCount_cmd_mpsched)
+        execute_process(COMMAND ${ProcessorCount_cmd_mpsched} -s
+          OUTPUT_QUIET
+          ERROR_STRIP_TRAILING_WHITESPACE
+          ERROR_VARIABLE mpsched_output)
+        string(REGEX MATCHALL "Processor Count *: *([0-9]+)" procs "${mpsched_output}")
+        set(count "${CMAKE_MATCH_1}")
+        #message("ProcessorCount: trying mpsched -s '${ProcessorCount_cmd_mpsched}'")
+      endif()
     endif()
   endif()
 
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index 5ada030..8c4daac 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -65,8 +65,8 @@
   else()
     file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
   endif()
-  if(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path
-    string(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}")
+  if(WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path
+    set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
   endif()
   set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
   string(REPLACE ".." "__" _outfile ${_outfile})
@@ -135,13 +135,15 @@
     set(targetincludes)
     set(targetdefines)
   else()
-    file(WRITE ${_moc_parameters_file} "${_moc_parameters}\n")
+    set(CMAKE_CONFIGURABLE_FILE_CONTENT "${_moc_parameters}")
+    configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
+                   "${_moc_parameters_file}" @ONLY)
   endif()
 
   set(_moc_extra_parameters_file @${_moc_parameters_file})
   add_custom_command(OUTPUT ${outfile}
                       COMMAND Qt4::moc ${_moc_extra_parameters_file}
-                      DEPENDS ${infile}
+                      DEPENDS ${infile} ${_moc_parameters_file}
                       ${_moc_working_dir}
                       VERBATIM)
 endfunction ()
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 654b4d0..127012f 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -426,6 +426,7 @@
     set(_JAVA_DEPENDS)
     set(_JAVA_COMPILE_DEPENDS)
     set(_JAVA_RESOURCE_FILES)
+    set(_JAVA_RESOURCE_FILES_RELATIVE)
     foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES})
         get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
         get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE)
@@ -462,7 +463,8 @@
             __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE}
                              ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}
                              "Copying ${_JAVA_SOURCE_FILE} to the build directory")
-            list(APPEND _JAVA_RESOURCE_FILES ${_JAVA_SOURCE_FILE})
+            list(APPEND _JAVA_RESOURCE_FILES ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE})
+            list(APPEND _JAVA_RESOURCE_FILES_RELATIVE ${_JAVA_SOURCE_FILE})
         endif ()
     endforeach()
 
@@ -529,7 +531,7 @@
             OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
             COMMAND ${Java_JAR_EXECUTABLE}
                 -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
-                ${_JAVA_RESOURCE_FILES} @java_class_filelist
+                ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist
             COMMAND ${CMAKE_COMMAND}
                 -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
                 -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
@@ -549,7 +551,7 @@
             OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
             COMMAND ${Java_JAR_EXECUTABLE}
                 -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
-                ${_JAVA_RESOURCE_FILES} @java_class_filelist
+                ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist
             COMMAND ${CMAKE_COMMAND}
                 -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
                 -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake
index 7478310..cba22af 100644
--- a/Modules/UseQt4.cmake
+++ b/Modules/UseQt4.cmake
@@ -98,7 +98,9 @@
           include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR})
         endif(QT_INCLUDE_DIRS_NO_SYSTEM)
       endif()
-      set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})
+      if(QT_USE_${module} OR QT_IS_STATIC)
+        set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})
+      endif()
       set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS})
       if(QT_IS_STATIC)
         set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES})
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index 11ca205..918e2ec 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -2,9 +2,7 @@
 # UseSWIG
 # -------
 #
-# SWIG module for CMake
-#
-# Defines the following macros:
+# Defines the following macros for use with SWIG:
 #
 # ::
 #
@@ -13,20 +11,38 @@
 #    SWIG_LINK_LIBRARIES(name [ libraries ])
 #      - Link libraries to swig module
 #
-# All other macros are for internal use only.  To get the actual name of
-# the swig module, use: ${SWIG_MODULE_${name}_REAL_NAME}.  Set Source
-# files properties such as CPLUSPLUS and SWIG_FLAGS to specify special
-# behavior of SWIG.  Also global CMAKE_SWIG_FLAGS can be used to add
-# special flags to all swig calls.  Another special variable is
-# CMAKE_SWIG_OUTDIR, it allows one to specify where to write all the
-# swig generated module (swig -outdir option) The name-specific variable
-# SWIG_MODULE_<name>_EXTRA_DEPS may be used to specify extra
-# dependencies for the generated modules.  If the source file generated
-# by swig need some special flag you can use::
+# Source files properties on module files can be set before the invocation
+# of the SWIG_ADD_MODULE macro to specify special behavior of SWIG.
 #
-#   set_source_files_properties( ${swig_generated_file_fullname}
-#         PROPERTIES COMPILE_FLAGS "-bla")
-
+# The source file property CPLUSPLUS calls SWIG in c++ mode, e.g.::
+#
+#    set_property(SOURCE mymod.i PROPERTY CPLUSPLUS ON)
+#    swig_add_module(mymod python mymod.i)
+#
+# The source file property SWIG_FLAGS adds custom flags to the SWIG executable.
+#
+# The source-file property SWIG_MODULE_NAME have to be provided to specify the actual
+# import name of the module in the target language if it cannot be scanned automatically
+# from source or different from the module file basename.::
+#
+#    set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname)
+#
+# To get the name of the swig module target library, use: ${SWIG_MODULE_${name}_REAL_NAME}.
+#
+# Also some variables can be set to specify special behavior of SWIG.
+#
+# CMAKE_SWIG_FLAGS can be used to add special flags to all swig calls.
+#
+# Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify
+# where to write all the swig generated module (swig -outdir option)
+#
+# The name-specific variable SWIG_MODULE_<name>_EXTRA_DEPS may be used to specify extra
+# dependencies for the generated modules.
+#
+# If the source file generated by swig need some special flag you can use::
+#
+#    set_source_files_properties( ${swig_generated_file_fullname}
+#                                 PROPERTIES COMPILE_FLAGS "-bla")
 
 #=============================================================================
 # Copyright 2004-2009 Kitware, Inc.
@@ -86,7 +102,30 @@
   get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
     ${infile} SWIG_MODULE_NAME)
   if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND")
-    get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE)
+
+    # try to get module name from "%module foo" syntax
+    if ( EXISTS ${infile} )
+      file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*[a-zA-Z0-9_]+.*" )
+    endif ()
+    if ( _MODULE_NAME )
+      string ( REGEX REPLACE "[ ]*%module[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" )
+      set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}")
+
+    else ()
+      # try to get module name from "%module (options=...) foo" syntax
+      if ( EXISTS ${infile} )
+        file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*\\(.*\\)[ ]*[a-zA-Z0-9_]+.*" )
+      endif ()
+      if ( _MODULE_NAME )
+        string ( REGEX REPLACE "[ ]*%module[ ]*\\(.*\\)[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" )
+        set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}")
+
+      else ()
+        # fallback to file basename
+        get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} NAME_WE)
+      endif ()
+    endif ()
+
   endif()
   foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION})
     set(${outfiles} ${${outfiles}}
@@ -181,7 +220,7 @@
   set(swig_dot_i_sources)
   set(swig_other_sources)
   foreach(it ${ARGN})
-    if(${it} MATCHES ".*\\.i$")
+    if(${it} MATCHES "\\.i$")
       set(swig_dot_i_sources ${swig_dot_i_sources} "${it}")
     else()
       set(swig_other_sources ${swig_other_sources} "${it}")
@@ -200,10 +239,13 @@
     MODULE
     ${swig_generated_sources}
     ${swig_other_sources})
+  set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES NO_SONAME ON)
   string(TOLOWER "${language}" swig_lowercase_language)
   if ("${swig_lowercase_language}" STREQUAL "octave")
     set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
     set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".oct")
+  elseif ("${swig_lowercase_language}" STREQUAL "go")
+    set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
   elseif ("${swig_lowercase_language}" STREQUAL "java")
     if (APPLE)
         # In java you want:
@@ -214,6 +256,8 @@
         #   Linux  : libLIBRARY.so
         set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib")
       endif ()
+  elseif ("${swig_lowercase_language}" STREQUAL "lua")
+    set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
   elseif ("${swig_lowercase_language}" STREQUAL "python")
     # this is only needed for the python case where a _modulename.so is generated
     set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
diff --git a/Modules/UseVTKConfig40.cmake b/Modules/UseVTKConfig40.cmake
index 554b8c4..c5022e4 100644
--- a/Modules/UseVTKConfig40.cmake
+++ b/Modules/UseVTKConfig40.cmake
@@ -312,7 +312,7 @@
   if(CMAKE_ANSI_CFLAGS)
     set(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
   endif()
-  if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+  if(CMAKE_SYSTEM MATCHES "OSF1-V")
      set(VTK_REQUIRED_CXX_FLAGS
          "${VTK_REQUIRED_CXX_FLAGS} -timplicit_local -no_implicit_include")
   endif()
diff --git a/Modules/WIX.template.in b/Modules/WIX.template.in
index 59a75c7..bbb7c88 100644
--- a/Modules/WIX.template.in
+++ b/Modules/WIX.template.in
@@ -40,5 +40,7 @@
         <FeatureRef Id="ProductFeature"/>
 
         <UIRef Id="$(var.CPACK_WIX_UI_REF)" />
+
+        <?include "properties.wxi"?>
     </Product>
 </Wix>
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
new file mode 100644
index 0000000..6e64cd2
--- /dev/null
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -0,0 +1,463 @@
+#.rst:
+# WriteCompilerDetectionHeader
+# ----------------------------
+#
+# This module provides the function write_compiler_detection_header().
+#
+# The ``WRITE_COMPILER_DETECTION_HEADER`` function can be used to generate
+# a file suitable for preprocessor inclusion which contains macros to be
+# used in source code::
+#
+#    write_compiler_detection_header(
+#              FILE <file>
+#              PREFIX <prefix>
+#              COMPILERS <compiler> [...]
+#              FEATURES <feature> [...]
+#              [VERSION <version>]
+#              [PROLOG <prolog>]
+#              [EPILOG <epilog>]
+#    )
+#
+# The ``write_compiler_detection_header`` function generates the
+# file ``<file>`` with macros which all have the prefix ``<prefix>``.
+#
+# ``VERSION`` may be used to specify the API version to be generated.
+# Future versions of CMake may introduce alternative APIs.  A given
+# API is selected by any ``<version>`` value greater than or equal
+# to the version of CMake that introduced the given API and less
+# than the version of CMake that introduced its succeeding API.
+# The value of the :variable:`CMAKE_MINIMUM_REQUIRED_VERSION`
+# variable is used if no explicit version is specified.
+# (As of CMake version |release| there is only one API version.)
+#
+# ``PROLOG`` may be specified as text content to write at the start of the
+# header. ``EPILOG`` may be specified as text content to write at the end
+# of the header
+#
+# At least one ``<compiler>`` and one ``<feature>`` must be listed.  Compilers
+# which are known to CMake, but not specified are detected and a preprocessor
+# ``#error`` is generated for them.  A preprocessor macro matching
+# ``<PREFIX>_COMPILER_IS_<compiler>`` is generated for each compiler
+# known to CMake to contain the value ``0`` or ``1``.
+#
+# Possible compiler identifiers are documented with the
+# :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+# Available features in this version of CMake are listed in the
+# :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and
+# :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties.
+#
+# See the :manual:`cmake-compile-features(7)` manual for information on
+# compile features.
+#
+# Feature Test Macros
+# ===================
+#
+# For each compiler, a preprocessor test of the compiler version is generated
+# denoting whether each feature is enabled.  A preprocessor macro
+# matching ``<PREFIX>_COMPILER_<FEATURE>``, where ``<FEATURE>`` is the
+# upper-case ``<feature>`` name, is generated to contain the value
+# ``0`` or ``1`` depending on whether the compiler in use supports the
+# feature:
+#
+# .. code-block:: cmake
+#
+#    write_compiler_detection_header(
+#      FILE climbingstats_compiler_detection.h
+#      PREFIX ClimbingStats
+#      COMPILERS GNU Clang MSVC
+#      FEATURES cxx_variadic_templates
+#    )
+#
+# .. code-block:: c++
+#
+#    #if ClimbingStats_COMPILER_CXX_VARIADIC_TEMPLATES
+#    template<typename... T>
+#    void someInterface(T t...) { /* ... */ }
+#    #else
+#    // Compatibility versions
+#    template<typename T1>
+#    void someInterface(T1 t1) { /* ... */ }
+#    template<typename T1, typename T2>
+#    void someInterface(T1 t1, T2 t2) { /* ... */ }
+#    template<typename T1, typename T2, typename T3>
+#    void someInterface(T1 t1, T2 t2, T3 t3) { /* ... */ }
+#    #endif
+#
+# Symbol Macros
+# =============
+#
+# Some additional symbol-defines are created for particular features for
+# use as symbols which may be conditionally defined empty:
+#
+# .. code-block:: c++
+#
+#    class MyClass ClimbingStats_DECL_CXX_FINAL
+#    {
+#        ClimbingStats_DECL_CXX_CONSTEXPR int someInterface() { return 42; }
+#    };
+#
+# The ``ClimbingStats_DECL_CXX_FINAL`` macro will expand to ``final`` if the
+# compiler (and its flags) support the ``cxx_final`` feature, and the
+# ``ClimbingStats_DECL_CXX_CONSTEXPR`` macro will expand to ``constexpr``
+# if ``cxx_constexpr`` is supported.
+#
+# The following features generate corresponding symbol defines:
+#
+# ========================== =================================== =================
+#         Feature                          Define                      Symbol
+# ========================== =================================== =================
+# ``c_restrict``              ``<PREFIX>_RESTRICT``               ``restrict``
+# ``cxx_constexpr``           ``<PREFIX>_CONSTEXPR``              ``constexpr``
+# ``cxx_deleted_functions``   ``<PREFIX>_DELETED_FUNCTION``       ``= delete``
+# ``cxx_extern_templates``    ``<PREFIX>_EXTERN_TEMPLATE``        ``extern``
+# ``cxx_final``               ``<PREFIX>_FINAL``                  ``final``
+# ``cxx_noexcept``            ``<PREFIX>_NOEXCEPT``               ``noexcept``
+# ``cxx_noexcept``            ``<PREFIX>_NOEXCEPT_EXPR(X)``       ``noexcept(X)``
+# ``cxx_override``            ``<PREFIX>_OVERRIDE``               ``override``
+# ========================== =================================== =================
+#
+# Compatibility Implementation Macros
+# ===================================
+#
+# Some features are suitable for wrapping in a macro with a backward
+# compatibility implementation if the compiler does not support the feature.
+#
+# When the ``cxx_static_assert`` feature is not provided by the compiler,
+# a compatibility implementation is available via the
+# ``<PREFIX>_STATIC_ASSERT(COND)`` and
+# ``<PREFIX>_STATIC_ASSERT_MSG(COND, MSG)`` function-like macros. The macros
+# expand to ``static_assert`` where that compiler feature is available, and
+# to a compatibility implementation otherwise. In the first form, the
+# condition is stringified in the message field of ``static_assert``.  In
+# the second form, the message ``MSG`` is passed to the message field of
+# ``static_assert``, or ignored if using the backward compatibility
+# implementation.
+#
+# The ``cxx_attribute_deprecated`` feature provides a macro definition
+# ``<PREFIX>_DEPRECATED``, which expands to either the standard
+# ``[[deprecated]]`` attribute or a compiler-specific decorator such
+# as ``__attribute__((__deprecated__))`` used by GNU compilers.
+#
+# ============================= ================================ =====================
+#           Feature                          Define                     Symbol
+# ============================= ================================ =====================
+# ``cxx_alignas``                ``<PREFIX>_ALIGNAS``             ``alignas``
+# ``cxx_alignof``                ``<PREFIX>_ALIGNOF``             ``alignof``
+# ``cxx_nullptr``                ``<PREFIX>_NULLPTR``             ``nullptr``
+# ``cxx_static_assert``          ``<PREFIX>_STATIC_ASSERT``       ``static_assert``
+# ``cxx_static_assert``          ``<PREFIX>_STATIC_ASSERT_MSG``   ``static_assert``
+# ``cxx_attribute_deprecated``   ``<PREFIX>_DEPRECATED``          ``[[deprecated]]``
+# ``cxx_attribute_deprecated``   ``<PREFIX>_DEPRECATED_MSG``      ``[[deprecated]]``
+# ============================= ================================ =====================
+#
+# A use-case which arises with such deprecation macros is the deprecation
+# of an entire library.  In that case, all public API in the library may
+# be decorated with the ``<PREFIX>_DEPRECATED`` macro.  This results in
+# very noisy build output when building the library itself, so the macro
+# may be may be defined to empty in that case when building the deprecated
+# library:
+#
+# .. code-block:: cmake
+#
+#   add_library(compat_support ${srcs})
+#   target_compile_definitions(compat_support
+#     PRIVATE
+#       CompatSupport_DEPRECATED=
+#   )
+
+#=============================================================================
+# Copyright 2014 Stephen Kelly <steveire@gmail.com>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeCompilerIdDetection.cmake)
+
+function(_load_compiler_variables CompilerId lang)
+  include("${CMAKE_ROOT}/Modules/Compiler/${CompilerId}-${lang}-FeatureTests.cmake" OPTIONAL)
+  set(_cmake_oldestSupported_${CompilerId} ${_cmake_oldestSupported} PARENT_SCOPE)
+  foreach(feature ${ARGN})
+    set(_cmake_feature_test_${CompilerId}_${feature} ${_cmake_feature_test_${feature}} PARENT_SCOPE)
+  endforeach()
+endfunction()
+
+function(write_compiler_detection_header
+    file_keyword file_arg
+    prefix_keyword prefix_arg
+    )
+  if (NOT file_keyword STREQUAL FILE)
+    message(FATAL_ERROR "write_compiler_detection_header: FILE parameter missing.")
+  endif()
+  if (NOT prefix_keyword STREQUAL PREFIX)
+    message(FATAL_ERROR "write_compiler_detection_header: PREFIX parameter missing.")
+  endif()
+  set(options)
+  set(oneValueArgs VERSION EPILOG PROLOG)
+  set(multiValueArgs COMPILERS FEATURES)
+  cmake_parse_arguments(_WCD "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+  if (NOT _WCD_COMPILERS)
+    message(FATAL_ERROR "Invalid arguments.  write_compiler_detection_header requires at least one compiler.")
+  endif()
+  if (NOT _WCD_FEATURES)
+    message(FATAL_ERROR "Invalid arguments.  write_compiler_detection_header requires at least one feature.")
+  endif()
+
+  if(_WCD_UNPARSED_ARGUMENTS)
+    message(FATAL_ERROR "Unparsed arguments: ${_WCD_UNPARSED_ARGUMENTS}")
+  endif()
+
+  if(NOT _WCD_VERSION)
+    set(_WCD_VERSION ${CMAKE_MINIMUM_REQUIRED_VERSION})
+  endif()
+  if (_WCD_VERSION VERSION_LESS 3.1.0) # Version which introduced this function
+    message(FATAL_ERROR "VERSION parameter too low.")
+  endif()
+
+  set(compilers
+    GNU
+    Clang
+  )
+  foreach(_comp ${_WCD_COMPILERS})
+    list(FIND compilers ${_comp} idx)
+    if (idx EQUAL -1)
+      message(FATAL_ERROR "Unsupported compiler ${_comp}.")
+    endif()
+  endforeach()
+
+  set(file_content "
+// This is a generated file. Do not edit!
+
+#ifndef ${prefix_arg}_COMPILER_DETECTION_H
+#define ${prefix_arg}_COMPILER_DETECTION_H
+")
+
+  if (_WCD_PROLOG)
+    set(file_content "${file_content}\n${_WCD_PROLOG}\n")
+  endif()
+
+  foreach(feature ${_WCD_FEATURES})
+    if (feature MATCHES "^cxx_")
+      list(APPEND _langs CXX)
+      list(APPEND CXX_features ${feature})
+    elseif (feature MATCHES "^c_")
+      list(APPEND _langs C)
+      list(APPEND C_features ${feature})
+    else()
+      message(FATAL_ERROR "Unsupported feature ${feature}.")
+    endif()
+  endforeach()
+  list(REMOVE_DUPLICATES _langs)
+
+  foreach(_lang ${_langs})
+
+    get_property(known_features GLOBAL PROPERTY CMAKE_${_lang}_KNOWN_FEATURES)
+    foreach(feature ${${_lang}_features})
+      list(FIND known_features ${feature} idx)
+      if (idx EQUAL -1)
+        message(FATAL_ERROR "Unsupported feature ${feature}.")
+      endif()
+    endforeach()
+
+    if(_lang STREQUAL CXX)
+      set(file_content "${file_content}\n#ifdef __cplusplus\n")
+    else()
+      set(file_content "${file_content}\n#ifndef __cplusplus\n")
+    endif()
+
+    compiler_id_detection(ID_CONTENT ${_lang} PREFIX ${prefix_arg}_
+      ID_DEFINE
+    )
+
+    set(file_content "${file_content}${ID_CONTENT}\n")
+
+    set(pp_if "if")
+    foreach(compiler ${_WCD_COMPILERS})
+      _load_compiler_variables(${compiler} ${_lang} ${${_lang}_features})
+      set(file_content "${file_content}\n#  ${pp_if} ${prefix_arg}_COMPILER_IS_${compiler}\n")
+      set(file_content "${file_content}
+#    if !(${_cmake_oldestSupported_${compiler}})
+#      error Unsupported compiler version
+#    endif\n")
+      set(pp_if "elif")
+      foreach(feature ${${_lang}_features})
+        string(TOUPPER ${feature} feature_upper)
+        set(feature_PP "COMPILER_${feature_upper}")
+        set(_define_item "\n#    define ${prefix_arg}_${feature_PP} 0\n")
+        if (_cmake_feature_test_${compiler}_${feature} STREQUAL "1")
+          set(_define_item "\n#    define ${prefix_arg}_${feature_PP} 1\n")
+        elseif (_cmake_feature_test_${compiler}_${feature})
+          set(_define_item "\n#      define ${prefix_arg}_${feature_PP} 0\n")
+          set(_define_item "\n#    if ${_cmake_feature_test_${compiler}_${feature}}\n#      define ${prefix_arg}_${feature_PP} 1\n#    else${_define_item}#    endif\n")
+        endif()
+        set(file_content "${file_content}${_define_item}")
+      endforeach()
+    endforeach()
+    if(pp_if STREQUAL "elif")
+      set(file_content "${file_content}
+#  else
+#    error Unsupported compiler
+#  endif\n")
+    endif()
+    foreach(feature ${${_lang}_features})
+      string(TOUPPER ${feature} feature_upper)
+      set(feature_PP "COMPILER_${feature_upper}")
+      set(def_name ${prefix_arg}_${feature_PP})
+      if (feature STREQUAL c_restrict)
+        set(def_value "${prefix_arg}_RESTRICT")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} restrict
+#  else
+#    define ${def_value}
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_constexpr)
+        set(def_value "${prefix_arg}_DECL_${feature_upper}")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} constexpr
+#  else
+#    define ${def_value}
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_final)
+        set(def_value "${prefix_arg}_DECL_${feature_upper}")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} final
+#  else
+#    define ${def_value}
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_override)
+        set(def_value "${prefix_arg}_DECL_${feature_upper}")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} override
+#  else
+#    define ${def_value}
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_static_assert)
+        set(def_value "${prefix_arg}_STATIC_ASSERT(X)")
+        set(def_value_msg "${prefix_arg}_STATIC_ASSERT_MSG(X, MSG)")
+        set(static_assert_struct "template<bool> struct ${prefix_arg}StaticAssert;\ntemplate<> struct ${prefix_arg}StaticAssert<true>{};\n")
+        set(def_standard "#    define ${def_value} static_assert(X, #X)\n#    define ${def_value_msg} static_assert(X, MSG)")
+        set(def_alternative "${static_assert_struct}#    define ${def_value} sizeof(${prefix_arg}StaticAssert<X>)\n#    define ${def_value_msg} sizeof(${prefix_arg}StaticAssert<X>)")
+        set(file_content "${file_content}#  if ${def_name}\n${def_standard}\n#  else\n${def_alternative}\n#  endif\n\n")
+      endif()
+      if (feature STREQUAL cxx_alignas)
+        set(def_value "${prefix_arg}_ALIGNAS(X)")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} alignas(X)
+#  elif ${prefix_arg}_COMPILER_IS_GNU
+#    define ${def_value} __attribute__ ((__aligned__(X)))
+#  else
+#    define ${def_value}
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_alignof)
+        set(def_value "${prefix_arg}_ALIGNOF(X)")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} alignof(X)
+#  elif ${prefix_arg}_COMPILER_IS_GNU
+#    define ${def_value} __alignof__(X)
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_deleted_functions)
+        set(def_value "${prefix_arg}_DELETED_FUNCTION")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} = delete
+#  else
+#    define ${def_value}
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_extern_templates)
+        set(def_value "${prefix_arg}_EXTERN_TEMPLATE")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} extern
+#  else
+#    define ${def_value}
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_noexcept)
+        set(def_value "${prefix_arg}_NOEXCEPT")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} noexcept
+#    define ${def_value}_EXPR(X) noexcept(X)
+#  else
+#    define ${def_value}
+#    define ${def_value}_EXPR(X)
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_nullptr)
+        set(def_value "${prefix_arg}_NULLPTR")
+        set(file_content "${file_content}
+#  if ${def_name}
+#    define ${def_value} nullptr
+#  else
+#    define ${def_value} static_cast<void*>(0)
+#  endif
+\n")
+      endif()
+      if (feature STREQUAL cxx_attribute_deprecated)
+        set(def_name ${prefix_arg}_${feature_PP})
+        set(def_value "${prefix_arg}_DEPRECATED")
+        set(file_content "${file_content}
+#  ifndef ${def_value}
+#    if ${def_name}
+#      define ${def_value} [[deprecated]]
+#      define ${def_value}_MSG(MSG) [[deprecated(MSG)]]
+#    elif defined(__GNUC__) || defined(__clang__)
+#      define ${def_value} __attribute__((__deprecated__))
+#      define ${def_value}_MSG(MSG) __attribute__((__deprecated__(MSG)))
+#    elif defined(_MSC_VER)
+#      define ${def_value} __declspec(deprecated)
+#      define ${def_value}_MSG(MSG) __declspec(deprecated(MSG))
+#    else
+#      define ${def_value}
+#      define ${def_value}_MSG(MSG)
+#    endif
+#  endif
+\n")
+      endif()
+    endforeach()
+
+    set(file_content "${file_content}#endif\n")
+
+  endforeach()
+
+  if (_WCD_EPILOG)
+    set(file_content "${file_content}\n${_WCD_EPILOG}\n")
+  endif()
+  set(file_content "${file_content}\n#endif")
+
+  set(CMAKE_CONFIGURABLE_FILE_CONTENT ${file_content})
+  configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
+    "${file_arg}"
+    @ONLY
+  )
+endfunction()
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 175a034..fe6cc1b 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -18,12 +18,34 @@
 endif()
 if(HAVE_ELF_H)
   set(CMAKE_USE_ELF_PARSER 1)
+elseif(HAIKU)
+  # On Haiku, we need to include elf32.h from the private headers
+  set(CMake_HAIKU_INCLUDE_DIRS
+    /boot/system/develop/headers/private/system
+    /boot/system/develop/headers/private/system/arch/x86
+    )
+
+  set(CMAKE_REQUIRED_INCLUDES ${CMake_HAIKU_INCLUDE_DIRS})
+  CHECK_INCLUDE_FILE("elf32.h" HAVE_ELF32_H)
+  unset(CMAKE_REQUIRED_INCLUDES)
+
+  if(HAVE_ELF32_H)
+    set(CMAKE_USE_ELF_PARSER 1)
+  else()
+    unset(CMake_HAIKU_INCLUDE_DIRS)
+    set(CMAKE_USE_ELF_PARSER)
+  endif()
 else()
   set(CMAKE_USE_ELF_PARSER)
 endif()
 
 set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR})
 
+# ensure Unicode friendly APIs are used on Windows
+if(WIN32)
+  add_definitions(-DUNICODE -D_UNICODE)
+endif()
+
 # configure the .h file
 configure_file(
   "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in"
@@ -52,6 +74,7 @@
   ${CMAKE_EXPAT_INCLUDES}
   ${CMAKE_TAR_INCLUDES}
   ${CMAKE_COMPRESS_INCLUDES}
+  ${CMake_HAIKU_INCLUDE_DIRS}
   )
 
 # let cmake know it is supposed to use it
@@ -140,6 +163,8 @@
   cmComputeLinkInformation.h
   cmComputeTargetDepends.h
   cmComputeTargetDepends.cxx
+  cmCPackPropertiesGenerator.h
+  cmCPackPropertiesGenerator.cxx
   cmCryptoHash.cxx
   cmCryptoHash.h
   cmCustomCommand.cxx
@@ -220,6 +245,8 @@
   cmInstallGenerator.h
   cmInstallGenerator.cxx
   cmInstallExportGenerator.cxx
+  cmInstalledFile.h
+  cmInstalledFile.cxx
   cmInstallFilesGenerator.h
   cmInstallFilesGenerator.cxx
   cmInstallScriptGenerator.h
@@ -323,8 +350,10 @@
     cmSourceGroupCommand
     cmSubdirDependsCommand
     cmTargetCompileDefinitionsCommand
+    cmTargetCompileFeaturesCommand
     cmTargetCompileOptionsCommand
     cmTargetIncludeDirectoriesCommand
+    cmTargetSourcesCommand
     cmUseMangledMesaCommand
     cmUtilitySourceCommand
     cmVariableRequiresCommand
@@ -399,7 +428,6 @@
       cmGlobalVisualStudio12Generator.cxx
       cmGlobalVisualStudioGenerator.cxx
       cmGlobalVisualStudioGenerator.h
-      cmGlobalWatcomWMakeGenerator.cxx
       cmIDEFlagTable.h
       cmIDEOptions.cxx
       cmIDEOptions.h
@@ -419,6 +447,15 @@
   endif()
 endif ()
 
+# Watcom support
+if(WIN32 OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+  set_property(SOURCE cmake.cxx APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_USE_WMAKE)
+  list(APPEND SRCS
+    cmGlobalWatcomWMakeGenerator.cxx
+    cmGlobalWatcomWMakeGenerator.h
+    )
+endif()
+
 # Ninja support
 set(SRCS ${SRCS}
   cmGlobalNinjaGenerator.cxx
@@ -482,7 +519,7 @@
   CTest/cmParseCacheCoverage.cxx
   CTest/cmParseGTMCoverage.cxx
   CTest/cmParsePHPCoverage.cxx
-  CTest/cmParsePythonCoverage.cxx
+  CTest/cmParseCoberturaCoverage.cxx
   CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
   CTest/cmCTestGenericHandler.cxx
   CTest/cmCTestHandlerCommand.cxx
@@ -562,7 +599,11 @@
   set(CPACK_SRCS ${CPACK_SRCS}
     CPack/WiX/cmCPackWIXGenerator.cxx
     CPack/WiX/cmWIXSourceWriter.cxx
+    CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+    CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+    CPack/WiX/cmWIXFilesSourceWriter.cxx
     CPack/WiX/cmWIXRichTextFormatWriter.cxx
+    CPack/WiX/cmWIXPatch.cxx
     CPack/WiX/cmWIXPatchParser.cxx
   )
 endif()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 46909ba..34aefb4 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
 set(CMake_VERSION_MINOR 0)
-set(CMake_VERSION_PATCH 0)
-set(CMake_VERSION_RC 6)
+set(CMake_VERSION_PATCH 20140609)
+#set(CMake_VERSION_RC 1)
diff --git a/Source/CMakeVersionSource.cmake b/Source/CMakeVersionSource.cmake
index 05e265c..888f557 100644
--- a/Source/CMakeVersionSource.cmake
+++ b/Source/CMakeVersionSource.cmake
@@ -30,8 +30,8 @@
 elseif(EXISTS ${CMake_SOURCE_DIR}/CVS/Repository)
   file(READ ${CMake_SOURCE_DIR}/CVS/Repository repo)
   set(branch "")
-  if("${repo}" MATCHES "\\.git/")
-    string(REGEX REPLACE ".*\\.git/([^\r\n]*).*" "-\\1" branch "${repo}")
+  if("${repo}" MATCHES "\\.git/([^\r\n]*)")
+    set(branch "${CMAKE_MATCH_1}")
   endif()
   set(CMake_VERSION_SOURCE "cvs${branch}")
 endif()
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 43119d6..a2995d1 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -1,6 +1,6 @@
 /*============================================================================
   CMake - Cross Platform Makefile Generator
-  Copyright 2000-2013 Kitware, Inc., Insight Software Consortium
+  Copyright 2000-2014 Kitware, Inc., Insight Software Consortium
 
   Distributed under the OSI-approved BSD License (the "License");
   see accompanying file Copyright.txt for details.
@@ -15,10 +15,14 @@
 #include <cmSystemTools.h>
 #include <cmGeneratedFileStream.h>
 #include <cmCryptoHash.h>
+#include <cmInstalledFile.h>
 #include <CPack/cmCPackLog.h>
 #include <CPack/cmCPackComponentGroup.h>
 
 #include "cmWIXSourceWriter.h"
+#include "cmWIXDirectoriesSourceWriter.h"
+#include "cmWIXFeaturesSourceWriter.h"
+#include "cmWIXFilesSourceWriter.h"
 #include "cmWIXRichTextFormatWriter.h"
 
 #include <cmsys/SystemTools.hxx>
@@ -28,31 +32,32 @@
 
 #include <rpc.h> // for GUID generation
 
-#include <sys/types.h>
-#include <sys/stat.h>
-
 cmCPackWIXGenerator::cmCPackWIXGenerator():
-  HasDesktopShortcuts(false)
+  HasDesktopShortcuts(false),
+  Patch(0)
 {
 
 }
 
+cmCPackWIXGenerator::~cmCPackWIXGenerator()
+{
+  if(this->Patch)
+    {
+    delete this->Patch;
+    }
+}
+
 int cmCPackWIXGenerator::InitializeInternal()
 {
   componentPackageMethod = ONE_PACKAGE;
+  this->Patch = new cmWIXPatch(this->Logger);
 
   return this->Superclass::InitializeInternal();
 }
 
-bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command)
+bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
 {
-  std::string cpackTopLevel;
-  if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
-    {
-    return false;
-    }
-
-  std::string logFileName = cpackTopLevel + "/wix.log";
+  std::string logFileName = this->CPackTopLevel + "/wix.log";
 
   cmCPackLogger(cmCPackLog::LOG_DEBUG,
     "Running WiX command: " << command << std::endl);
@@ -81,7 +86,7 @@
 }
 
 bool cmCPackWIXGenerator::RunCandleCommand(
-  const std::string& sourceFile, const std::string& objectFile)
+  std::string const& sourceFile, std::string const& objectFile)
 {
   std::string executable;
   if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable))
@@ -108,7 +113,7 @@
   return RunWiXCommand(command.str());
 }
 
-bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
+bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
 {
   std::string executable;
   if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable))
@@ -121,8 +126,8 @@
   command << " -nologo";
   command << " -out " << QuotePath(packageFileNames.at(0));
 
-  for(extension_set_t::const_iterator i = LightExtensions.begin();
-      i != LightExtensions.end(); ++i)
+  for(extension_set_t::const_iterator i = this->LightExtensions.begin();
+      i != this->LightExtensions.end(); ++i)
     {
     command << " -ext " << QuotePath(*i);
     }
@@ -182,15 +187,14 @@
       "you might want to set this explicitly." << std::endl);
     }
 
-  std::string cpackTopLevel;
-  if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
+  if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel))
     {
     return false;
     }
 
   if(GetOption("CPACK_WIX_LICENSE_RTF") == 0)
     {
-    std::string licenseFilename = cpackTopLevel + "/License.rtf";
+    std::string licenseFilename = this->CPackTopLevel + "/License.rtf";
     SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str());
 
     if(!CreateLicenseFile())
@@ -213,7 +217,7 @@
     {
     std::string defaultRef = "WixUI_InstallDir";
 
-    if(Components.size())
+    if(this->Components.size())
       {
       defaultRef = "WixUI_FeatureTree";
       }
@@ -221,17 +225,24 @@
     SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
     }
 
-  CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions);
-  CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions);
+  const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT");
+  if(packageContact != 0 &&
+     GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0)
+    {
+    SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact);
+    }
 
-  LightExtensions.insert("WixUIExtension");
-  CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions);
-  CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions);
+  CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions);
+  CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions);
+
+  this->LightExtensions.insert("WixUIExtension");
+  CollectExtensions("CPACK_WIX_EXTENSIONS", this->LightExtensions);
+  CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions);
 
   const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
   if(patchFilePath)
     {
-    LoadPatchFragments(patchFilePath);
+    this->Patch->LoadFragments(patchFilePath);
     }
 
   return true;
@@ -244,10 +255,8 @@
     return false;
     }
 
-  if(!CreateWiXVariablesIncludeFile())
-    {
-    return false;
-    }
+  CreateWiXVariablesIncludeFile();
+  CreateWiXPropertiesIncludeFile();
 
   if(!CreateWiXSourceFiles())
     {
@@ -257,9 +266,9 @@
   AppendUserSuppliedExtraSources();
 
   std::stringstream objectFiles;
-  for(size_t i = 0; i < WixSources.size(); ++i)
+  for(size_t i = 0; i < this->WixSources.size(); ++i)
     {
-    const std::string& sourceFilename = WixSources[i];
+    std::string const& sourceFilename = this->WixSources[i];
 
     std::string objectFilename =
       cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj";
@@ -282,7 +291,7 @@
   const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
   if(!cpackWixExtraSources) return;
 
-  cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources);
+  cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources);
 }
 
 void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
@@ -297,22 +306,18 @@
 
   for(size_t i = 0; i < expandedExtraObjects.size(); ++i)
     {
-      stream << " " << QuotePath(expandedExtraObjects[i]);
+    stream << " " << QuotePath(expandedExtraObjects[i]);
     }
 }
 
-bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
+void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
 {
-  std::string cpackTopLevel;
-  if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
-    {
-    return false;
-    }
-
   std::string includeFilename =
-    cpackTopLevel + "/cpack_variables.wxi";
+    this->CPackTopLevel + "/cpack_variables.wxi";
 
-  cmWIXSourceWriter includeFile(Logger, includeFilename, true);
+  cmWIXSourceWriter includeFile(
+    this->Logger, includeFilename, true);
+
   CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID");
   CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID");
   CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR");
@@ -326,12 +331,39 @@
     GetOption("CPACK_PACKAGE_NAME"));
   CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER");
   CopyDefinition(includeFile, "CPACK_WIX_UI_REF");
+}
 
-  return true;
+void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
+{
+  std::string includeFilename =
+    this->CPackTopLevel + "/properties.wxi";
+
+  cmWIXSourceWriter includeFile(
+    this->Logger, includeFilename, true);
+
+  std::string prefix = "CPACK_WIX_PROPERTY_";
+  std::vector<std::string> options = GetOptions();
+
+  for(size_t i = 0; i < options.size(); ++i)
+    {
+    std::string const& name = options[i];
+
+    if(name.length() > prefix.length() &&
+       name.substr(0, prefix.length()) == prefix)
+      {
+      std::string id = name.substr(prefix.length());
+      std::string value = GetOption(name.c_str());
+
+      includeFile.BeginElement("Property");
+      includeFile.AddAttribute("Id", id);
+      includeFile.AddAttribute("Value", value);
+      includeFile.EndElement("Property");
+      }
+    }
 }
 
 void cmCPackWIXGenerator::CopyDefinition(
-  cmWIXSourceWriter &source, const std::string &name)
+  cmWIXSourceWriter &source, std::string const& name)
 {
   const char* value = GetOption(name.c_str());
   if(value)
@@ -341,7 +373,7 @@
 }
 
 void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
-  const std::string& name, const std::string& value)
+  std::string const& name, std::string const& value)
 {
   std::stringstream tmp;
   tmp << name << "=\"" << value << '"';
@@ -352,81 +384,47 @@
 
 bool cmCPackWIXGenerator::CreateWiXSourceFiles()
 {
-  std::string cpackTopLevel;
-  if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
+  std::string directoryDefinitionsFilename =
+    this->CPackTopLevel + "/directories.wxs";
+
+  this->WixSources.push_back(directoryDefinitionsFilename);
+
+  cmWIXDirectoriesSourceWriter directoryDefinitions(
+    this->Logger, directoryDefinitionsFilename);
+  directoryDefinitions.BeginElement("Fragment");
+
+  std::string installRoot;
+  if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot))
     {
     return false;
     }
 
-  std::string directoryDefinitionsFilename =
-    cpackTopLevel + "/directories.wxs";
-
-  WixSources.push_back(directoryDefinitionsFilename);
-
-  cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename);
-  directoryDefinitions.BeginElement("Fragment");
-
   directoryDefinitions.BeginElement("Directory");
   directoryDefinitions.AddAttribute("Id", "TARGETDIR");
   directoryDefinitions.AddAttribute("Name", "SourceDir");
 
-  directoryDefinitions.BeginElement("Directory");
-  if(GetArchitecture() == "x86")
-    {
-    directoryDefinitions.AddAttribute("Id", "ProgramFilesFolder");
-    }
-  else
-    {
-    directoryDefinitions.AddAttribute("Id", "ProgramFiles64Folder");
-    }
-
-  std::vector<std::string> install_root;
-
-  std::string tmp;
-  if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", tmp))
-    {
-    return false;
-    }
-
-  cmSystemTools::SplitPath(tmp.c_str(), install_root);
-
-  if(!install_root.empty() && install_root.back().empty())
-    {
-    install_root.pop_back();
-    }
-
-  for(size_t i = 1; i < install_root.size(); ++i)
-    {
-    directoryDefinitions.BeginElement("Directory");
-
-    if(i == install_root.size() - 1)
-      {
-      directoryDefinitions.AddAttribute("Id", "INSTALL_ROOT");
-      }
-    else
-      {
-      std::stringstream ss;
-      ss << "INSTALL_PREFIX_" << i;
-      directoryDefinitions.AddAttribute("Id", ss.str());
-      }
-
-    directoryDefinitions.AddAttribute("Name", install_root[i]);
-  }
+  size_t installRootSize =
+    directoryDefinitions.BeginInstallationPrefixDirectory(
+      GetProgramFilesFolderId(), installRoot);
 
   std::string fileDefinitionsFilename =
-    cpackTopLevel + "/files.wxs";
+    this->CPackTopLevel + "/files.wxs";
 
-  WixSources.push_back(fileDefinitionsFilename);
+  this->WixSources.push_back(fileDefinitionsFilename);
 
-  cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename);
+  cmWIXFilesSourceWriter fileDefinitions(
+    this->Logger, fileDefinitionsFilename);
+
   fileDefinitions.BeginElement("Fragment");
 
   std::string featureDefinitionsFilename =
-      cpackTopLevel +"/features.wxs";
+      this->CPackTopLevel +"/features.wxs";
 
-  WixSources.push_back(featureDefinitionsFilename);
+  this->WixSources.push_back(featureDefinitionsFilename);
 
-  cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename);
+  cmWIXFeaturesSourceWriter featureDefinitions(
+    this->Logger, featureDefinitionsFilename);
+
   featureDefinitions.BeginElement("Fragment");
 
   featureDefinitions.BeginElement("Feature");
@@ -439,13 +437,15 @@
     {
     return false;
     }
-  featureDefinitions.AddAttribute("Title", cpackPackageName);
 
+  featureDefinitions.AddAttribute("Title", cpackPackageName);
   featureDefinitions.AddAttribute("Level", "1");
 
-  if(!CreateCMakePackageRegistryEntry(featureDefinitions))
+  const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
+  if(package)
     {
-    return false;
+    featureDefinitions.CreateCMakePackageRegistryEntry(
+        package, GetOption("CPACK_WIX_UPGRADE_GUID"));
     }
 
   if(!CreateFeatureHierarchy(featureDefinitions))
@@ -471,7 +471,7 @@
   else
     {
     for(std::map<std::string, cmCPackComponent>::const_iterator
-      i = Components.begin(); i != Components.end(); ++i)
+      i = this->Components.begin(); i != this->Components.end(); ++i)
       {
       cmCPackComponent const& component = i->second;
 
@@ -513,31 +513,51 @@
   featureDefinitions.EndElement("Fragment");
   fileDefinitions.EndElement("Fragment");
 
-  for(size_t i = 1; i < install_root.size(); ++i)
-    {
-    directoryDefinitions.EndElement("Directory");
-    }
-
-  directoryDefinitions.EndElement("Directory");
+  directoryDefinitions.EndInstallationPrefixDirectory(
+    installRootSize);
 
   if(hasShortcuts)
     {
-    CreateStartMenuFolder(directoryDefinitions);
+    directoryDefinitions.EmitStartMenuFolder(
+      GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"));
     }
 
   if(this->HasDesktopShortcuts)
     {
-    CreateDesktopFolder(directoryDefinitions);
+    directoryDefinitions.EmitDesktopFolder();
     }
 
   directoryDefinitions.EndElement("Directory");
   directoryDefinitions.EndElement("Fragment");
 
+  if(!GenerateMainSourceFileFromTemplate())
+    {
+    return false;
+    }
+
+  return this->Patch->CheckForUnappliedFragments();
+}
+
+std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const
+{
+  if(GetArchitecture() == "x86")
+    {
+    return "ProgramFilesFolder";
+    }
+  else
+    {
+    return "ProgramFiles64Folder";
+    }
+}
+
+bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
+{
   std::string wixTemplate = FindTemplate("WIX.template.in");
   if(GetOption("CPACK_WIX_TEMPLATE") != 0)
     {
     wixTemplate = GetOption("CPACK_WIX_TEMPLATE");
     }
+
   if(wixTemplate.empty())
     {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -545,7 +565,7 @@
     return false;
     }
 
-  std::string mainSourceFilePath = cpackTopLevel + "/main.wxs";
+  std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
 
   if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str()))
     {
@@ -556,68 +576,13 @@
     return false;
     }
 
-  WixSources.push_back(mainSourceFilePath);
-
-  std::string fragmentList;
-  for(cmWIXPatchParser::fragment_map_t::const_iterator
-    i = Fragments.begin(); i != Fragments.end(); ++i)
-    {
-    if(!fragmentList.empty())
-      {
-      fragmentList += ", ";
-      }
-
-    fragmentList += "'";
-    fragmentList += i->first;
-    fragmentList += "'";
-    }
-
-  if(fragmentList.size())
-    {
-      cmCPackLogger(cmCPackLog::LOG_ERROR,
-        "Some XML patch fragments did not have matching IDs: " <<
-        fragmentList << std::endl);
-      return false;
-    }
-
-  return true;
-}
-
-bool cmCPackWIXGenerator::CreateCMakePackageRegistryEntry(
-  cmWIXSourceWriter& featureDefinitions)
-{
-  const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
-  if(!package)
-    {
-    return true;
-    }
-
-  featureDefinitions.BeginElement("Component");
-  featureDefinitions.AddAttribute("Id", "CM_PACKAGE_REGISTRY");
-  featureDefinitions.AddAttribute("Directory", "TARGETDIR");
-  featureDefinitions.AddAttribute("Guid", "*");
-
-  std::string registryKey =
-      std::string("Software\\Kitware\\CMake\\Packages\\") + package;
-
-  std::string upgradeGuid = GetOption("CPACK_WIX_UPGRADE_GUID");
-
-  featureDefinitions.BeginElement("RegistryValue");
-  featureDefinitions.AddAttribute("Root", "HKLM");
-  featureDefinitions.AddAttribute("Key", registryKey);
-  featureDefinitions.AddAttribute("Name", upgradeGuid);
-  featureDefinitions.AddAttribute("Type", "string");
-  featureDefinitions.AddAttribute("Value", "[INSTALL_ROOT]");
-  featureDefinitions.AddAttribute("KeyPath", "yes");
-  featureDefinitions.EndElement("RegistryValue");
-
-  featureDefinitions.EndElement("Component");
+  this->WixSources.push_back(mainSourceFilePath);
 
   return true;
 }
 
 bool cmCPackWIXGenerator::CreateFeatureHierarchy(
-  cmWIXSourceWriter& featureDefinitions)
+  cmWIXFeaturesSourceWriter& featureDefinitions)
 {
   for(std::map<std::string, cmCPackComponentGroup>::const_iterator
     i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i)
@@ -625,105 +590,30 @@
     cmCPackComponentGroup const& group = i->second;
     if(group.ParentGroup == 0)
       {
-      if(!EmitFeatureForComponentGroup(featureDefinitions, group))
-        {
-        return false;
-        }
+      featureDefinitions.EmitFeatureForComponentGroup(group);
       }
     }
 
   for(std::map<std::string, cmCPackComponent>::const_iterator
-    i = Components.begin(); i != Components.end(); ++i)
+    i = this->Components.begin(); i != this->Components.end(); ++i)
     {
     cmCPackComponent const& component = i->second;
 
     if(!component.Group)
       {
-      if(!EmitFeatureForComponent(featureDefinitions, component))
-        {
-        return false;
-        }
+      featureDefinitions.EmitFeatureForComponent(component);
       }
     }
 
   return true;
 }
 
-bool cmCPackWIXGenerator::EmitFeatureForComponentGroup(
-  cmWIXSourceWriter& featureDefinitions,
-  cmCPackComponentGroup const& group)
-{
-  featureDefinitions.BeginElement("Feature");
-  featureDefinitions.AddAttribute("Id", "CM_G_" + group.Name);
-
-  if(group.IsExpandedByDefault)
-    {
-    featureDefinitions.AddAttribute("Display", "expand");
-    }
-
-  featureDefinitions.AddAttributeUnlessEmpty(
-    "Title", group.DisplayName);
-
-  featureDefinitions.AddAttributeUnlessEmpty(
-    "Description", group.Description);
-
-  for(std::vector<cmCPackComponentGroup*>::const_iterator
-    i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
-    {
-    if(!EmitFeatureForComponentGroup(featureDefinitions, **i))
-      {
-      return false;
-      }
-    }
-
-  for(std::vector<cmCPackComponent*>::const_iterator
-    i = group.Components.begin(); i != group.Components.end(); ++i)
-    {
-    if(!EmitFeatureForComponent(featureDefinitions, **i))
-      {
-      return false;
-      }
-    }
-
-  featureDefinitions.EndElement("Feature");
-
-  return true;
-}
-
-bool cmCPackWIXGenerator::EmitFeatureForComponent(
-  cmWIXSourceWriter& featureDefinitions,
-  cmCPackComponent const& component)
-{
-  featureDefinitions.BeginElement("Feature");
-  featureDefinitions.AddAttribute("Id", "CM_C_" + component.Name);
-
-  featureDefinitions.AddAttributeUnlessEmpty(
-    "Title", component.DisplayName);
-
-  featureDefinitions.AddAttributeUnlessEmpty(
-    "Description", component.Description);
-
-  if(component.IsRequired)
-    {
-    featureDefinitions.AddAttribute("Absent", "disallow");
-    }
-
-  if(component.IsHidden)
-    {
-    featureDefinitions.AddAttribute("Display", "hidden");
-    }
-
-  featureDefinitions.EndElement("Feature");
-
-  return true;
-}
-
 bool cmCPackWIXGenerator::AddComponentsToFeature(
   std::string const& rootPath,
   std::string const& featureId,
-  cmWIXSourceWriter& directoryDefinitions,
-  cmWIXSourceWriter& fileDefinitions,
-  cmWIXSourceWriter& featureDefinitions,
+  cmWIXDirectoriesSourceWriter& directoryDefinitions,
+  cmWIXFilesSourceWriter& fileDefinitions,
+  cmWIXFeaturesSourceWriter& featureDefinitions,
   shortcut_map_t& shortcutMap)
 {
   featureDefinitions.BeginElement("FeatureRef");
@@ -768,8 +658,8 @@
   std::string const& cpackComponentName,
   std::string const& featureId,
   shortcut_map_t& shortcutMap,
-  cmWIXSourceWriter& fileDefinitions,
-  cmWIXSourceWriter& featureDefinitions)
+  cmWIXFilesSourceWriter& fileDefinitions,
+  cmWIXFeaturesSourceWriter& featureDefinitions)
 {
   bool thisHasDesktopShortcuts = false;
 
@@ -799,6 +689,7 @@
 
   fileDefinitions.BeginElement("DirectoryRef");
   fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER");
+
   fileDefinitions.BeginElement("Component");
   fileDefinitions.AddAttribute("Id", componentId);
   fileDefinitions.AddAttribute("Guid", "*");
@@ -809,63 +700,34 @@
     std::string const& id = i->first;
     cmWIXShortcut const& shortcut = i->second;
 
-    std::string shortcutId = std::string("CM_S") + id;
-    std::string fileId = std::string("CM_F") + id;
+    fileDefinitions.EmitShortcut(id, shortcut, false);
 
-    fileDefinitions.BeginElement("Shortcut");
-    fileDefinitions.AddAttribute("Id", shortcutId);
-    fileDefinitions.AddAttribute("Name", shortcut.textLabel);
-    std::string target = "[#" + fileId + "]";
-    fileDefinitions.AddAttribute("Target", target);
-    fileDefinitions.AddAttribute("WorkingDirectory",
-      shortcut.workingDirectoryId);
-    fileDefinitions.EndElement("Shortcut");
-
-    if (shortcut.desktop)
+    if(shortcut.desktop)
       {
-        thisHasDesktopShortcuts = true;
+      thisHasDesktopShortcuts = true;
       }
     }
 
   if(cpackComponentName.empty())
     {
-    CreateUninstallShortcut(cpackPackageName, fileDefinitions);
+    fileDefinitions.EmitUninstallShortcut(cpackPackageName);
     }
 
-  fileDefinitions.BeginElement("RemoveFolder");
-  fileDefinitions.AddAttribute("Id",
+  fileDefinitions.EmitRemoveFolder(
     "CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix);
-  fileDefinitions.AddAttribute("On", "uninstall");
-  fileDefinitions.EndElement("RemoveFolder");
 
   std::string registryKey =
     std::string("Software\\") + cpackVendor + "\\" + cpackPackageName;
 
-  fileDefinitions.BeginElement("RegistryValue");
-  fileDefinitions.AddAttribute("Root", "HKCU");
-  fileDefinitions.AddAttribute("Key", registryKey);
-
-  std::string valueName;
-  if(!cpackComponentName.empty())
-    {
-      valueName = cpackComponentName + "_";
-    }
-  valueName += "installed";
-
-  fileDefinitions.AddAttribute("Name", valueName);
-  fileDefinitions.AddAttribute("Type", "integer");
-  fileDefinitions.AddAttribute("Value", "1");
-  fileDefinitions.AddAttribute("KeyPath", "yes");
-  fileDefinitions.EndElement("RegistryValue");
+  fileDefinitions.EmitStartMenuShortcutRegistryValue(
+    registryKey, cpackComponentName);
 
   fileDefinitions.EndElement("Component");
   fileDefinitions.EndElement("DirectoryRef");
 
-  featureDefinitions.BeginElement("ComponentRef");
-  featureDefinitions.AddAttribute("Id", componentId);
-  featureDefinitions.EndElement("ComponentRef");
+  featureDefinitions.EmitComponentRef(componentId);
 
-  if (thisHasDesktopShortcuts)
+  if(thisHasDesktopShortcuts)
     {
     this->HasDesktopShortcuts = true;
     componentId = "CM_DESKTOP_SHORTCUT" + idSuffix;
@@ -876,7 +738,7 @@
     fileDefinitions.AddAttribute("Id", componentId);
     fileDefinitions.AddAttribute("Guid", "*");
 
-    for (shortcut_map_t::const_iterator
+    for(shortcut_map_t::const_iterator
       i = shortcutMap.begin(); i != shortcutMap.end(); ++i)
       {
       std::string const& id = i->first;
@@ -885,34 +747,16 @@
       if (!shortcut.desktop)
         continue;
 
-      std::string shortcutId = std::string("CM_DS") + id;
-      std::string fileId = std::string("CM_F") + id;
-
-      fileDefinitions.BeginElement("Shortcut");
-      fileDefinitions.AddAttribute("Id", shortcutId);
-      fileDefinitions.AddAttribute("Name", shortcut.textLabel);
-      std::string target = "[#" + fileId + "]";
-      fileDefinitions.AddAttribute("Target", target);
-      fileDefinitions.AddAttribute("WorkingDirectory",
-        shortcut.workingDirectoryId);
-      fileDefinitions.EndElement("Shortcut");
+      fileDefinitions.EmitShortcut(id, shortcut, true);
       }
 
-    fileDefinitions.BeginElement("RegistryValue");
-    fileDefinitions.AddAttribute("Root", "HKCU");
-    fileDefinitions.AddAttribute("Key", registryKey);
-    fileDefinitions.AddAttribute("Name", valueName + "_desktop");
-    fileDefinitions.AddAttribute("Type", "integer");
-    fileDefinitions.AddAttribute("Value", "1");
-    fileDefinitions.AddAttribute("KeyPath", "yes");
-    fileDefinitions.EndElement("RegistryValue");
+    fileDefinitions.EmitDesktopShortcutRegistryValue(
+      registryKey, cpackComponentName);
 
     fileDefinitions.EndElement("Component");
     fileDefinitions.EndElement("DirectoryRef");
 
-    featureDefinitions.BeginElement("ComponentRef");
-    featureDefinitions.AddAttribute("Id", componentId);
-    featureDefinitions.EndElement("ComponentRef");
+    featureDefinitions.EmitComponentRef(componentId);
     }
 
   featureDefinitions.EndElement("FeatureRef");
@@ -920,19 +764,6 @@
   return true;
 }
 
-void cmCPackWIXGenerator::CreateUninstallShortcut(
-  std::string const& packageName,
-  cmWIXSourceWriter& fileDefinitions)
-{
-  fileDefinitions.BeginElement("Shortcut");
-  fileDefinitions.AddAttribute("Id", "UNINSTALL");
-  fileDefinitions.AddAttribute("Name", "Uninstall " + packageName);
-  fileDefinitions.AddAttribute("Description", "Uninstalls " + packageName);
-  fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe");
-  fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]");
-  fileDefinitions.EndElement("Shortcut");
-}
-
 bool cmCPackWIXGenerator::CreateLicenseFile()
 {
   std::string licenseSourceFilename;
@@ -981,11 +812,11 @@
 }
 
 void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
-  const std::string& topdir,
-  const std::string& directoryId,
-  cmWIXSourceWriter& directoryDefinitions,
-  cmWIXSourceWriter& fileDefinitions,
-  cmWIXSourceWriter& featureDefinitions,
+  std::string const& topdir,
+  std::string const& directoryId,
+  cmWIXDirectoriesSourceWriter& directoryDefinitions,
+  cmWIXFilesSourceWriter& fileDefinitions,
+  cmWIXFeaturesSourceWriter& featureDefinitions,
   const std::vector<std::string>& packageExecutables,
   const std::vector<std::string>& desktopExecutables,
   shortcut_map_t& shortcutMap)
@@ -993,6 +824,16 @@
   cmsys::Directory dir;
   dir.Load(topdir.c_str());
 
+  if(dir.GetNumberOfFiles() == 2)
+    {
+    std::string componentId = fileDefinitions.EmitComponentCreateFolder(
+      directoryId, GenerateGUID());
+
+    featureDefinitions.EmitComponentRef(componentId);
+
+    return;
+    }
+
   for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i)
     {
     std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
@@ -1026,44 +867,18 @@
         desktopExecutables,
         shortcutMap);
 
-      ApplyPatchFragment(subDirectoryId, directoryDefinitions);
+      this->Patch->ApplyFragment(subDirectoryId, directoryDefinitions);
       directoryDefinitions.EndElement("Directory");
       }
     else
       {
-      std::string componentId = std::string("CM_C") + id;
-      std::string fileId = std::string("CM_F") + id;
+      cmInstalledFile const* installedFile =
+        this->GetInstalledFile(relativePath);
 
-      fileDefinitions.BeginElement("DirectoryRef");
-      fileDefinitions.AddAttribute("Id", directoryId);
+      std::string componentId = fileDefinitions.EmitComponentFile(
+        directoryId, id, fullPath, *(this->Patch), installedFile);
 
-      fileDefinitions.BeginElement("Component");
-      fileDefinitions.AddAttribute("Id", componentId);
-      fileDefinitions.AddAttribute("Guid", "*");
-
-      fileDefinitions.BeginElement("File");
-      fileDefinitions.AddAttribute("Id", fileId);
-      fileDefinitions.AddAttribute("Source", fullPath);
-      fileDefinitions.AddAttribute("KeyPath", "yes");
-
-      mode_t fileMode = 0;
-      cmSystemTools::GetPermissions(fullPath.c_str(), fileMode);
-
-      if(!(fileMode & S_IWRITE))
-        {
-        fileDefinitions.AddAttribute("ReadOnly", "yes");
-        }
-
-      ApplyPatchFragment(fileId, fileDefinitions);
-      fileDefinitions.EndElement("File");
-
-      ApplyPatchFragment(componentId, fileDefinitions);
-      fileDefinitions.EndElement("Component");
-      fileDefinitions.EndElement("DirectoryRef");
-
-      featureDefinitions.BeginElement("ComponentRef");
-      featureDefinitions.AddAttribute("Id", componentId);
-      featureDefinitions.EndElement("ComponentRef");
+      featureDefinitions.EmitComponentRef(componentId);
 
       for(size_t j = 0; j < packageExecutables.size(); ++j)
         {
@@ -1092,7 +907,7 @@
 }
 
 bool cmCPackWIXGenerator::RequireOption(
-  const std::string& name, std::string &value) const
+  std::string const& name, std::string &value) const
 {
   const char* tmp = GetOption(name.c_str());
   if(tmp)
@@ -1140,13 +955,13 @@
   return cmSystemTools::UpperCase(result);
 }
 
-std::string cmCPackWIXGenerator::QuotePath(const std::string& path)
+std::string cmCPackWIXGenerator::QuotePath(std::string const& path)
 {
   return std::string("\"") + path + '"';
 }
 
 std::string cmCPackWIXGenerator::GetRightmostExtension(
-  const std::string& filename)
+  std::string const& filename)
 {
   std::string extension;
 
@@ -1159,7 +974,7 @@
   return cmSystemTools::LowerCase(extension);
 }
 
-std::string cmCPackWIXGenerator::PathToId(const std::string& path)
+std::string cmCPackWIXGenerator::PathToId(std::string const& path)
 {
   id_map_t::const_iterator i = PathToIdMap.find(path);
   if(i != PathToIdMap.end()) return i->second;
@@ -1168,7 +983,7 @@
   return id;
 }
 
-std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
+std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
 {
   std::vector<std::string> components;
   cmSystemTools::SplitPath(path.c_str(), components, false);
@@ -1222,7 +1037,7 @@
 }
 
 std::string cmCPackWIXGenerator::CreateHashedId(
-  const std::string& path, const std::string& normalizedFilename)
+  std::string const& path, std::string const& normalizedFilename)
 {
   cmsys::auto_ptr<cmCryptoHash> sha1 = cmCryptoHash::New("SHA1");
   std::string hash = sha1->HashString(path.c_str());
@@ -1245,7 +1060,7 @@
 }
 
 std::string cmCPackWIXGenerator::NormalizeComponentForId(
-  const std::string& component, size_t& replacementCount)
+  std::string const& component, size_t& replacementCount)
 {
   std::string result;
   result.resize(component.size());
@@ -1276,7 +1091,7 @@
 }
 
 void cmCPackWIXGenerator::CollectExtensions(
-     const std::string& variableName, extension_set_t& extensions)
+     std::string const& variableName, extension_set_t& extensions)
 {
   const char *variableContent = GetOption(variableName.c_str());
   if(!variableContent) return;
@@ -1292,7 +1107,7 @@
 }
 
 void cmCPackWIXGenerator::AddCustomFlags(
-  const std::string& variableName, std::ostream& stream)
+  std::string const& variableName, std::ostream& stream)
 {
   const char *variableContent = GetOption(variableName.c_str());
   if(!variableContent) return;
@@ -1306,69 +1121,3 @@
       stream << " " << QuotePath(*i);
     }
 }
-
-void cmCPackWIXGenerator::CreateStartMenuFolder(
-    cmWIXSourceWriter& directoryDefinitions)
-{
-  directoryDefinitions.BeginElement("Directory");
-  directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder");
-
-  directoryDefinitions.BeginElement("Directory");
-  directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER");
-  const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
-  directoryDefinitions.AddAttribute("Name", startMenuFolder);
-  directoryDefinitions.EndElement("Directory");
-
-  directoryDefinitions.EndElement("Directory");
-}
-
-void cmCPackWIXGenerator::CreateDesktopFolder(
-    cmWIXSourceWriter& directoryDefinitions)
-{
-    directoryDefinitions.BeginElement("Directory");
-    directoryDefinitions.AddAttribute("Id", "DesktopFolder");
-    directoryDefinitions.AddAttribute("Name", "Desktop");
-    directoryDefinitions.EndElement("Directory");
-}
-
-void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath)
-{
-  cmWIXPatchParser parser(Fragments, Logger);
-  parser.ParseFile(patchFilePath.c_str());
-}
-
-void cmCPackWIXGenerator::ApplyPatchFragment(
-  const std::string& id, cmWIXSourceWriter& writer)
-{
-  cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
-  if(i == Fragments.end()) return;
-
-  const cmWIXPatchElement& fragment = i->second;
-  for(cmWIXPatchElement::child_list_t::const_iterator
-    j = fragment.children.begin(); j != fragment.children.end(); ++j)
-    {
-    ApplyPatchElement(**j, writer);
-    }
-
-  Fragments.erase(i);
-}
-
-void cmCPackWIXGenerator::ApplyPatchElement(
-  const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
-{
-  writer.BeginElement(element.name);
-
-  for(cmWIXPatchElement::attributes_t::const_iterator
-    i = element.attributes.begin(); i != element.attributes.end(); ++i)
-    {
-    writer.AddAttribute(i->first, i->second);
-    }
-
-  for(cmWIXPatchElement::child_list_t::const_iterator
-    i = element.children.begin(); i != element.children.end(); ++i)
-    {
-    ApplyPatchElement(**i, writer);
-    }
-
-  writer.EndElement(element.name);
-}
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h
index 1de4810..8705d40 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.h
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.h
@@ -13,25 +13,18 @@
 #ifndef cmCPackWIXGenerator_h
 #define cmCPackWIXGenerator_h
 
-#include "cmWIXPatchParser.h"
+#include "cmWIXPatch.h"
+#include "cmWIXShortcut.h"
 
 #include <CPack/cmCPackGenerator.h>
 
 #include <string>
 #include <map>
 
-struct cmWIXShortcut
-{
-  cmWIXShortcut()
-    :desktop(false)
-    {}
-
-  std::string textLabel;
-  std::string workingDirectoryId;
-  bool desktop;
-};
-
 class cmWIXSourceWriter;
+class cmWIXDirectoriesSourceWriter;
+class cmWIXFilesSourceWriter;
+class cmWIXFeaturesSourceWriter;
 
 /** \class cmCPackWIXGenerator
  * \brief A generator for WIX files
@@ -42,6 +35,7 @@
   cmCPackTypeMacro(cmCPackWIXGenerator, cmCPackGenerator);
 
   cmCPackWIXGenerator();
+  ~cmCPackWIXGenerator();
 
 protected:
   virtual int InitializeInternal();
@@ -78,48 +72,39 @@
 
   bool PackageFilesImpl();
 
-  bool CreateWiXVariablesIncludeFile();
+  void CreateWiXVariablesIncludeFile();
+
+  void CreateWiXPropertiesIncludeFile();
 
   void CopyDefinition(
-    cmWIXSourceWriter &source, const std::string &name);
+    cmWIXSourceWriter &source, std::string const& name);
 
   void AddDefinition(cmWIXSourceWriter& source,
-    const std::string& name, const std::string& value);
+    std::string const& name, std::string const& value);
 
   bool CreateWiXSourceFiles();
 
-  bool CreateCMakePackageRegistryEntry(
-    cmWIXSourceWriter& featureDefinitions);
+  std::string GetProgramFilesFolderId() const;
+
+  bool GenerateMainSourceFileFromTemplate();
 
   bool CreateFeatureHierarchy(
-    cmWIXSourceWriter& featureDefinitions);
-
-  bool EmitFeatureForComponentGroup(
-    cmWIXSourceWriter& featureDefinitions,
-    cmCPackComponentGroup const& group);
-
-  bool EmitFeatureForComponent(
-    cmWIXSourceWriter& featureDefinitions,
-    cmCPackComponent const& component);
+    cmWIXFeaturesSourceWriter& featureDefinitions);
 
   bool AddComponentsToFeature(
     std::string const& rootPath,
     std::string const& featureId,
-    cmWIXSourceWriter& directoryDefinitions,
-    cmWIXSourceWriter& fileDefinitions,
-    cmWIXSourceWriter& featureDefinitions,
+    cmWIXDirectoriesSourceWriter& directoryDefinitions,
+    cmWIXFilesSourceWriter& fileDefinitions,
+    cmWIXFeaturesSourceWriter& featureDefinitions,
     shortcut_map_t& shortcutMap);
 
   bool CreateStartMenuShortcuts(
     std::string const& cpackComponentName,
     std::string const& featureId,
     shortcut_map_t& shortcutMap,
-    cmWIXSourceWriter& fileDefinitions,
-    cmWIXSourceWriter& featureDefinitions);
-
-  void CreateUninstallShortcut(
-    std::string const& packageName,
-    cmWIXSourceWriter& fileDefinitions);
+    cmWIXFilesSourceWriter& fileDefinitions,
+    cmWIXFeaturesSourceWriter& featureDefinitions);
 
   void AppendUserSuppliedExtraSources();
 
@@ -127,60 +112,49 @@
 
   bool CreateLicenseFile();
 
-  bool RunWiXCommand(const std::string& command);
+  bool RunWiXCommand(std::string const& command);
 
   bool RunCandleCommand(
-    const std::string& sourceFile, const std::string& objectFile);
+    std::string const& sourceFile, std::string const& objectFile);
 
-  bool RunLightCommand(const std::string& objectFiles);
+  bool RunLightCommand(std::string const& objectFiles);
 
-  void AddDirectoryAndFileDefinitons(const std::string& topdir,
-    const std::string& directoryId,
-    cmWIXSourceWriter& directoryDefinitions,
-    cmWIXSourceWriter& fileDefinitions,
-    cmWIXSourceWriter& featureDefinitions,
+  void AddDirectoryAndFileDefinitons(std::string const& topdir,
+    std::string const& directoryId,
+    cmWIXDirectoriesSourceWriter& directoryDefinitions,
+    cmWIXFilesSourceWriter& fileDefinitions,
+    cmWIXFeaturesSourceWriter& featureDefinitions,
     const std::vector<std::string>& pkgExecutables,
     const std::vector<std::string>& desktopExecutables,
     shortcut_map_t& shortcutMap);
 
-  bool RequireOption(const std::string& name, std::string& value) const;
+  bool RequireOption(std::string const& name, std::string& value) const;
 
   std::string GetArchitecture() const;
 
   static std::string GenerateGUID();
 
-  static std::string QuotePath(const std::string& path);
+  static std::string QuotePath(std::string const& path);
 
-  static std::string GetRightmostExtension(const std::string& filename);
+  static std::string GetRightmostExtension(std::string const& filename);
 
-  std::string PathToId(const std::string& path);
+  std::string PathToId(std::string const& path);
 
-  std::string CreateNewIdForPath(const std::string& path);
+  std::string CreateNewIdForPath(std::string const& path);
 
   static std::string CreateHashedId(
-    const std::string& path, const std::string& normalizedFilename);
+    std::string const& path, std::string const& normalizedFilename);
 
   std::string NormalizeComponentForId(
-    const std::string& component, size_t& replacementCount);
+    std::string const& component, size_t& replacementCount);
 
   static bool IsLegalIdCharacter(char c);
 
   void CollectExtensions(
-       const std::string& variableName, extension_set_t& extensions);
+       std::string const& variableName, extension_set_t& extensions);
 
   void AddCustomFlags(
-    const std::string& variableName, std::ostream& stream);
-
-  void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions);
-
-  void CreateDesktopFolder(cmWIXSourceWriter& directoryDefinitions);
-
-  void LoadPatchFragments(const std::string& patchFilePath);
-
-  void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer);
-
-  void ApplyPatchElement(const cmWIXPatchElement& element,
-    cmWIXSourceWriter& writer);
+    std::string const& variableName, std::ostream& stream);
 
   std::vector<std::string> WixSources;
   id_map_t PathToIdMap;
@@ -189,9 +163,11 @@
   extension_set_t CandleExtensions;
   extension_set_t LightExtensions;
 
-  cmWIXPatchParser::fragment_map_t Fragments;
-
   bool HasDesktopShortcuts;
+
+  std::string CPackTopLevel;
+
+  cmWIXPatch* Patch;
 };
 
 #endif
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
new file mode 100644
index 0000000..a93f89b
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -0,0 +1,87 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#include "cmWIXDirectoriesSourceWriter.h"
+
+cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
+  std::string const& filename):
+    cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
+  std::string const& startMenuFolder)
+{
+  BeginElement("Directory");
+  AddAttribute("Id", "ProgramMenuFolder");
+
+  BeginElement("Directory");
+  AddAttribute("Id", "PROGRAM_MENU_FOLDER");
+  AddAttribute("Name", startMenuFolder);
+  EndElement("Directory");
+
+  EndElement("Directory");
+}
+
+void cmWIXDirectoriesSourceWriter::EmitDesktopFolder()
+{
+  BeginElement("Directory");
+  AddAttribute("Id", "DesktopFolder");
+  AddAttribute("Name", "Desktop");
+  EndElement("Directory");
+}
+
+size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
+  std::string const& programFilesFolderId,
+  std::string const& installRootString)
+{
+  BeginElement("Directory");
+  AddAttribute("Id", programFilesFolderId);
+
+  std::vector<std::string> installRoot;
+
+  cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
+
+  if(!installRoot.empty() && installRoot.back().empty())
+    {
+    installRoot.pop_back();
+    }
+
+  for(size_t i = 1; i < installRoot.size(); ++i)
+    {
+    BeginElement("Directory");
+
+    if(i == installRoot.size() - 1)
+      {
+      AddAttribute("Id", "INSTALL_ROOT");
+      }
+    else
+      {
+      std::stringstream tmp;
+      tmp << "INSTALL_PREFIX_" << i;
+      AddAttribute("Id", tmp.str());
+      }
+
+    AddAttribute("Name", installRoot[i]);
+  }
+
+  return installRoot.size();
+}
+
+void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
+{
+  for(size_t i = 0; i < size; ++i)
+    {
+    EndElement("Directory");
+    }
+}
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
new file mode 100644
index 0000000..f51fdb4
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
@@ -0,0 +1,42 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmWIXDirectoriesSourceWriter_h
+#define cmWIXDirectoriesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+#include <string>
+
+/** \class cmWIXDirectoriesSourceWriter
+ * \brief Helper class to generate directories.wxs
+ */
+class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter
+{
+public:
+  cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
+    std::string const& filename);
+
+  void EmitStartMenuFolder(std::string const& startMenuFolder);
+
+  void EmitDesktopFolder();
+
+  size_t BeginInstallationPrefixDirectory(
+      std::string const& programFilesFolderId,
+      std::string const& installRootString);
+
+  void EndInstallationPrefixDirectory(size_t size);
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
new file mode 100644
index 0000000..0bcfc38
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -0,0 +1,102 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#include "cmWIXFeaturesSourceWriter.h"
+
+cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger,
+  std::string const& filename):
+    cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
+    std::string const& package,
+    std::string const& upgradeGuid)
+{
+  BeginElement("Component");
+  AddAttribute("Id", "CM_PACKAGE_REGISTRY");
+  AddAttribute("Directory", "TARGETDIR");
+  AddAttribute("Guid", "*");
+
+  std::string registryKey =
+      std::string("Software\\Kitware\\CMake\\Packages\\") + package;
+
+  BeginElement("RegistryValue");
+  AddAttribute("Root", "HKLM");
+  AddAttribute("Key", registryKey);
+  AddAttribute("Name", upgradeGuid);
+  AddAttribute("Type", "string");
+  AddAttribute("Value", "[INSTALL_ROOT]");
+  AddAttribute("KeyPath", "yes");
+  EndElement("RegistryValue");
+
+  EndElement("Component");
+}
+
+void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
+  cmCPackComponentGroup const& group)
+{
+  BeginElement("Feature");
+  AddAttribute("Id", "CM_G_" + group.Name);
+
+  if(group.IsExpandedByDefault)
+    {
+    AddAttribute("Display", "expand");
+    }
+
+  AddAttributeUnlessEmpty("Title", group.DisplayName);
+  AddAttributeUnlessEmpty("Description", group.Description);
+
+  for(std::vector<cmCPackComponentGroup*>::const_iterator
+    i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
+    {
+    EmitFeatureForComponentGroup(**i);
+    }
+
+  for(std::vector<cmCPackComponent*>::const_iterator
+    i = group.Components.begin(); i != group.Components.end(); ++i)
+    {
+    EmitFeatureForComponent(**i);
+    }
+
+  EndElement("Feature");
+}
+
+void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
+  cmCPackComponent const& component)
+{
+  BeginElement("Feature");
+  AddAttribute("Id", "CM_C_" + component.Name);
+
+  AddAttributeUnlessEmpty("Title", component.DisplayName);
+  AddAttributeUnlessEmpty("Description", component.Description);
+
+  if(component.IsRequired)
+    {
+    AddAttribute("Absent", "disallow");
+    }
+
+  if(component.IsHidden)
+    {
+    AddAttribute("Display", "hidden");
+    }
+
+  EndElement("Feature");
+}
+
+void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
+{
+  BeginElement("ComponentRef");
+  AddAttribute("Id", id);
+  EndElement("ComponentRef");
+}
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
new file mode 100644
index 0000000..7670417
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
@@ -0,0 +1,39 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmWIXFeaturesSourceWriter_h
+#define cmWIXFeaturesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+#include <CPack/cmCPackGenerator.h>
+
+/** \class cmWIXFeaturesSourceWriter
+ * \brief Helper class to generate features.wxs
+ */
+class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter
+{
+public:
+  cmWIXFeaturesSourceWriter(cmCPackLog* logger,
+    std::string const& filename);
+
+  void CreateCMakePackageRegistryEntry(
+    std::string const& package,
+    std::string const& upgradeGuid);
+
+  void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group);
+
+  void EmitFeatureForComponent(const cmCPackComponent& component);
+
+  void EmitComponentRef(std::string const& id);
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
new file mode 100644
index 0000000..451188e
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
@@ -0,0 +1,186 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#include "cmWIXFilesSourceWriter.h"
+
+#include <cmInstalledFile.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
+  std::string const& filename):
+    cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXFilesSourceWriter::EmitShortcut(
+  std::string const& id,
+  cmWIXShortcut const& shortcut,
+  bool desktop)
+{
+  std::string shortcutId;
+
+  if(desktop)
+    {
+    shortcutId = "CM_DS";
+    }
+  else
+    {
+    shortcutId = "CM_S";
+    }
+
+  shortcutId += id;
+
+  std::string fileId = std::string("CM_F") + id;
+
+  BeginElement("Shortcut");
+  AddAttribute("Id", shortcutId);
+  AddAttribute("Name", shortcut.textLabel);
+  std::string target = "[#" + fileId + "]";
+  AddAttribute("Target", target);
+  AddAttribute("WorkingDirectory", shortcut.workingDirectoryId);
+  EndElement("Shortcut");
+}
+
+void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id)
+{
+  BeginElement("RemoveFolder");
+  AddAttribute("Id", id);
+  AddAttribute("On", "uninstall");
+  EndElement("RemoveFolder");
+}
+
+void cmWIXFilesSourceWriter::EmitStartMenuShortcutRegistryValue(
+  std::string const& registryKey,
+  std::string const& cpackComponentName)
+{
+  EmitInstallRegistryValue(registryKey, cpackComponentName, std::string());
+}
+
+void cmWIXFilesSourceWriter::EmitDesktopShortcutRegistryValue(
+  std::string const& registryKey,
+  std::string const& cpackComponentName)
+{
+  EmitInstallRegistryValue(registryKey, cpackComponentName, "_desktop");
+}
+
+void cmWIXFilesSourceWriter::EmitInstallRegistryValue(
+  std::string const& registryKey,
+  std::string const& cpackComponentName,
+  std::string const& suffix)
+{
+  std::string valueName;
+  if(!cpackComponentName.empty())
+    {
+      valueName = cpackComponentName + "_";
+    }
+
+  valueName += "installed";
+  valueName += suffix;
+
+  BeginElement("RegistryValue");
+  AddAttribute("Root", "HKCU");
+  AddAttribute("Key", registryKey);
+  AddAttribute("Name", valueName);
+  AddAttribute("Type", "integer");
+  AddAttribute("Value", "1");
+  AddAttribute("KeyPath", "yes");
+  EndElement("RegistryValue");
+}
+
+void cmWIXFilesSourceWriter::EmitUninstallShortcut(
+  std::string const& packageName)
+{
+  BeginElement("Shortcut");
+  AddAttribute("Id", "UNINSTALL");
+  AddAttribute("Name", "Uninstall " + packageName);
+  AddAttribute("Description", "Uninstalls " + packageName);
+  AddAttribute("Target", "[SystemFolder]msiexec.exe");
+  AddAttribute("Arguments", "/x [ProductCode]");
+  EndElement("Shortcut");
+}
+
+std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
+  std::string const& directoryId, std::string const& guid)
+{
+  std::string componentId =
+    std::string("CM_C_EMPTY_") + directoryId;
+
+  BeginElement("DirectoryRef");
+  AddAttribute("Id", directoryId);
+
+  BeginElement("Component");
+  AddAttribute("Id", componentId);
+  AddAttribute("Guid", guid);
+
+  BeginElement("CreateFolder");
+
+  EndElement("CreateFolder");
+  EndElement("Component");
+  EndElement("DirectoryRef");
+
+  return componentId;
+}
+
+std::string cmWIXFilesSourceWriter::EmitComponentFile(
+  std::string const& directoryId,
+  std::string const& id,
+  std::string const& filePath,
+  cmWIXPatch &patch,
+  cmInstalledFile const* installedFile)
+{
+  std::string componentId = std::string("CM_C") + id;
+  std::string fileId = std::string("CM_F") + id;
+
+  BeginElement("DirectoryRef");
+  AddAttribute("Id", directoryId);
+
+  BeginElement("Component");
+  AddAttribute("Id", componentId);
+  AddAttribute("Guid", "*");
+
+  if(installedFile)
+    {
+    if(installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE"))
+      {
+      AddAttribute("NeverOverwrite", "yes");
+      }
+    if(installedFile->GetPropertyAsBool("CPACK_PERMANENT"))
+      {
+      AddAttribute("Permanent", "yes");
+      }
+    }
+
+  BeginElement("File");
+  AddAttribute("Id", fileId);
+  AddAttribute("Source", filePath);
+  AddAttribute("KeyPath", "yes");
+
+  mode_t fileMode = 0;
+  cmSystemTools::GetPermissions(filePath.c_str(), fileMode);
+
+  if(!(fileMode & S_IWRITE))
+    {
+    AddAttribute("ReadOnly", "yes");
+    }
+
+  patch.ApplyFragment(fileId, *this);
+  EndElement("File");
+
+  patch.ApplyFragment(componentId, *this);
+  EndElement("Component");
+  EndElement("DirectoryRef");
+
+  return componentId;
+}
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
new file mode 100644
index 0000000..23ef561
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
@@ -0,0 +1,67 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmWIXFilesSourceWriter_h
+#define cmWIXFilesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+#include "cmWIXShortcut.h"
+#include "cmWIXPatch.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+/** \class cmWIXFilesSourceWriter
+ * \brief Helper class to generate files.wxs
+ */
+class cmWIXFilesSourceWriter : public cmWIXSourceWriter
+{
+public:
+  cmWIXFilesSourceWriter(cmCPackLog* logger,
+    std::string const& filename);
+
+  void EmitShortcut(
+      std::string const& id,
+      cmWIXShortcut const& shortcut,
+      bool desktop);
+
+  void EmitRemoveFolder(std::string const& id);
+
+  void EmitStartMenuShortcutRegistryValue(
+    std::string const& registryKey,
+    std::string const& cpackComponentName);
+
+  void EmitDesktopShortcutRegistryValue(
+    std::string const& registryKey,
+    std::string const& cpackComponentName);
+
+  void EmitUninstallShortcut(std::string const& packageName);
+
+  std::string EmitComponentCreateFolder(
+    std::string const& directoryId,
+    std::string const& guid);
+
+  std::string EmitComponentFile(
+    std::string const& directoryId,
+    std::string const& id,
+    std::string const& filePath,
+    cmWIXPatch &patch,
+    cmInstalledFile const* installedFile);
+
+private:
+  void EmitInstallRegistryValue(
+    std::string const& registryKey,
+    std::string const& cpackComponentName,
+    std::string const& suffix);
+};
+
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx
new file mode 100644
index 0000000..b5202e0
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXPatch.cxx
@@ -0,0 +1,91 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 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 "cmWIXPatch.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+cmWIXPatch::cmWIXPatch(cmCPackLog* logger):
+  Logger(logger)
+{
+
+}
+
+void cmWIXPatch::LoadFragments(std::string const& patchFilePath)
+{
+  cmWIXPatchParser parser(Fragments, Logger);
+  parser.ParseFile(patchFilePath.c_str());
+}
+
+void cmWIXPatch::ApplyFragment(
+  std::string const& id, cmWIXSourceWriter& writer)
+{
+  cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
+  if(i == Fragments.end()) return;
+
+  const cmWIXPatchElement& fragment = i->second;
+  for(cmWIXPatchElement::child_list_t::const_iterator
+    j = fragment.children.begin(); j != fragment.children.end(); ++j)
+    {
+    ApplyElement(**j, writer);
+    }
+
+  Fragments.erase(i);
+}
+
+void cmWIXPatch::ApplyElement(
+  const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
+{
+  writer.BeginElement(element.name);
+
+  for(cmWIXPatchElement::attributes_t::const_iterator
+    i = element.attributes.begin(); i != element.attributes.end(); ++i)
+    {
+    writer.AddAttribute(i->first, i->second);
+    }
+
+  for(cmWIXPatchElement::child_list_t::const_iterator
+    i = element.children.begin(); i != element.children.end(); ++i)
+    {
+    ApplyElement(**i, writer);
+    }
+
+  writer.EndElement(element.name);
+}
+
+
+bool cmWIXPatch::CheckForUnappliedFragments()
+{
+  std::string fragmentList;
+  for(cmWIXPatchParser::fragment_map_t::const_iterator
+    i = Fragments.begin(); i != Fragments.end(); ++i)
+    {
+    if(!fragmentList.empty())
+      {
+      fragmentList += ", ";
+      }
+
+    fragmentList += "'";
+    fragmentList += i->first;
+    fragmentList += "'";
+    }
+
+  if(fragmentList.size())
+    {
+      cmCPackLogger(cmCPackLog::LOG_ERROR,
+        "Some XML patch fragments did not have matching IDs: " <<
+        fragmentList << std::endl);
+      return false;
+    }
+
+  return true;
+}
diff --git a/Source/CPack/WiX/cmWIXPatch.h b/Source/CPack/WiX/cmWIXPatch.h
new file mode 100644
index 0000000..7b7b2f1
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXPatch.h
@@ -0,0 +1,45 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmWIXPatch_h
+#define cmWIXPatch_h
+
+#include "cmWIXSourceWriter.h"
+#include "cmWIXPatchParser.h"
+
+#include <string>
+
+/** \class cmWIXPatch
+ * \brief Class that maintains and applies patch fragments
+ */
+class cmWIXPatch
+{
+public:
+  cmWIXPatch(cmCPackLog* logger);
+
+  void LoadFragments(std::string const& patchFilePath);
+
+  void ApplyFragment(std::string const& id, cmWIXSourceWriter& writer);
+
+  bool CheckForUnappliedFragments();
+
+private:
+  void ApplyElement(const cmWIXPatchElement& element,
+    cmWIXSourceWriter& writer);
+
+  cmCPackLog* Logger;
+
+  cmWIXPatchParser::fragment_map_t Fragments;
+};
+
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
index 7ceaf1f..ef67b23 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -34,12 +34,11 @@
 
 }
 
-void cmWIXPatchParser::StartElement(const char *name, const char **atts)
+void cmWIXPatchParser::StartElement(const std::string& name, const char **atts)
 {
-  std::string name_str = name;
   if(State == BEGIN_DOCUMENT)
     {
-    if(name_str == "CPackWiXPatch")
+    if(name == "CPackWiXPatch")
       {
       State = BEGIN_FRAGMENTS;
       }
@@ -50,7 +49,7 @@
     }
   else if(State == BEGIN_FRAGMENTS)
     {
-      if(name_str == "CPackWiXFragment")
+      if(name == "CPackWiXFragment")
         {
         State = INSIDE_FRAGMENT;
         StartFragment(atts);
@@ -107,12 +106,11 @@
     }
 }
 
-void cmWIXPatchParser::EndElement(const char *name)
+void cmWIXPatchParser::EndElement(const std::string& name)
 {
-  std::string name_str = name;
   if(State == INSIDE_FRAGMENT)
     {
-      if(name_str == "CPackWiXFragment")
+      if(name == "CPackWiXFragment")
         {
         State = BEGIN_FRAGMENTS;
         ElementStack.clear();
@@ -132,7 +130,7 @@
   Valid = false;
 }
 
-void cmWIXPatchParser::ReportValidationError(const std::string& message)
+void cmWIXPatchParser::ReportValidationError(std::string const& message)
 {
   ReportError(XML_GetCurrentLineNumber(Parser),
     XML_GetCurrentColumnNumber(Parser),
diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h
index 91b3b66..acfb4c0 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.h
+++ b/Source/CPack/WiX/cmWIXPatchParser.h
@@ -43,14 +43,14 @@
   cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
 
 private:
-  virtual void StartElement(const char *name, const char **atts);
+  virtual void StartElement(const std::string& name, const char **atts);
 
   void StartFragment(const char **attributes);
 
-  virtual void EndElement(const char *name);
+  virtual void EndElement(const std::string& name);
   virtual void ReportError(int line, int column, const char* msg);
 
-  void ReportValidationError(const std::string& message);
+  void ReportValidationError(std::string const& message);
 
   bool IsValid() const;
 
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index ddc1d71..f27caa9 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -15,7 +15,7 @@
 #include <cmVersion.h>
 
 cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
-  const std::string& filename):
+  std::string const& filename):
     File(filename.c_str(), std::ios::binary)
 {
   StartGroup();
@@ -33,7 +33,7 @@
   File.put(0);
 }
 
-void cmWIXRichTextFormatWriter::AddText(const std::string& text)
+void cmWIXRichTextFormatWriter::AddText(std::string const& text)
 {
   typedef unsigned char rtf_byte_t;
 
@@ -167,12 +167,12 @@
   ControlWord("fs20");
 }
 
-void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword)
+void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword)
 {
   File << "\\" << keyword;
 }
 
-void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword)
+void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword)
 {
   File << "\\*\\" << keyword;
 }
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
index 2b665d4..f6327fb 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
@@ -22,10 +22,10 @@
 class cmWIXRichTextFormatWriter
 {
 public:
-  cmWIXRichTextFormatWriter(const std::string& filename);
+  cmWIXRichTextFormatWriter(std::string const& filename);
   ~cmWIXRichTextFormatWriter();
 
-  void AddText(const std::string& text);
+  void AddText(std::string const& text);
 
 private:
   void WriteHeader();
@@ -35,8 +35,8 @@
 
   void WriteDocumentPrefix();
 
-  void ControlWord(const std::string& keyword);
-  void NewControlWord(const std::string& keyword);
+  void ControlWord(std::string const& keyword);
+  void NewControlWord(std::string const& keyword);
 
   void StartGroup();
   void EndGroup();
diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h
new file mode 100644
index 0000000..93095e0
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXShortcut.h
@@ -0,0 +1,29 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmWIXFilesShortcut_h
+#define cmWIXFilesShortcut_h
+
+#include <string>
+
+struct cmWIXShortcut
+{
+  cmWIXShortcut()
+    :desktop(false)
+    {}
+
+  std::string textLabel;
+  std::string workingDirectoryId;
+  bool desktop;
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index e83c226..aad19da 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -17,7 +17,7 @@
 #include <windows.h>
 
 cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
-  const std::string& filename,
+  std::string const& filename,
   bool isIncludeFile):
     Logger(logger),
     File(filename.c_str()),
@@ -51,7 +51,7 @@
   EndElement(Elements.back());
 }
 
-void cmWIXSourceWriter::BeginElement(const std::string& name)
+void cmWIXSourceWriter::BeginElement(std::string const& name)
 {
   if(State == BEGIN)
     {
@@ -101,7 +101,7 @@
 }
 
 void cmWIXSourceWriter::AddProcessingInstruction(
-  const std::string& target, const std::string& content)
+  std::string const& target, std::string const& content)
 {
   if(State == BEGIN)
     {
@@ -116,7 +116,7 @@
 }
 
 void cmWIXSourceWriter::AddAttribute(
-  const std::string& key, const std::string& value)
+  std::string const& key, std::string const& value)
 {
   std::string utf8 = WindowsCodepageToUtf8(value);
 
@@ -124,7 +124,7 @@
 }
 
 void cmWIXSourceWriter::AddAttributeUnlessEmpty(
-    const std::string& key, const std::string& value)
+    std::string const& key, std::string const& value)
 {
   if(value.size())
     {
@@ -132,7 +132,7 @@
     }
 }
 
-std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value)
+std::string cmWIXSourceWriter::WindowsCodepageToUtf8(std::string const& value)
 {
   if(value.empty())
     {
@@ -184,7 +184,7 @@
 }
 
 std::string cmWIXSourceWriter::EscapeAttributeValue(
-  const std::string& value)
+  std::string const& value)
 {
   std::string result;
   result.reserve(value.size());
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h
index 894ad78..65b7240 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXSourceWriter.h
@@ -26,24 +26,24 @@
 {
 public:
   cmWIXSourceWriter(cmCPackLog* logger,
-    const std::string& filename, bool isIncludeFile = false);
+    std::string const& filename, bool isIncludeFile = false);
 
   ~cmWIXSourceWriter();
 
-  void BeginElement(const std::string& name);
+  void BeginElement(std::string const& name);
 
-  void EndElement(const std::string& name);
+  void EndElement(std::string const& name);
 
   void AddProcessingInstruction(
-    const std::string& target, const std::string& content);
+    std::string const& target, std::string const& content);
 
   void AddAttribute(
-    const std::string& key, const std::string& value);
+    std::string const& key, std::string const& value);
 
   void AddAttributeUnlessEmpty(
-    const std::string& key, const std::string& value);
+    std::string const& key, std::string const& value);
 
-  static std::string WindowsCodepageToUtf8(const std::string& value);
+  static std::string WindowsCodepageToUtf8(std::string const& value);
 
 private:
   enum State
@@ -56,7 +56,7 @@
 
   void Indent(size_t count);
 
-  static std::string EscapeAttributeValue(const std::string& value);
+  static std::string EscapeAttributeValue(std::string const& value);
 
   cmCPackLog* Logger;
 
diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx
index f93eca8..77f11cb 100644
--- a/Source/CPack/cmCPackComponentGroup.cxx
+++ b/Source/CPack/cmCPackComponentGroup.cxx
@@ -16,7 +16,8 @@
 #include <string>
 
 //----------------------------------------------------------------------
-unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const
+unsigned long cmCPackComponent::GetInstalledSize(
+    const std::string& installDir) const
 {
   if (this->TotalSize != 0)
     {
@@ -37,7 +38,7 @@
 
 //----------------------------------------------------------------------
 unsigned long
-cmCPackComponent::GetInstalledSizeInKbytes(const char* installDir) const
+cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const
 {
   unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
   return result? result : 1;
diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h
index abae372..0679638 100644
--- a/Source/CPack/cmCPackComponentGroup.h
+++ b/Source/CPack/cmCPackComponentGroup.h
@@ -94,11 +94,11 @@
   /// Get the total installed size of all of the files in this
   /// component, in bytes. installDir is the directory into which the
   /// component was installed.
-  unsigned long GetInstalledSize(const char* installDir) const;
+  unsigned long GetInstalledSize(const std::string& installDir) const;
 
   /// Identical to GetInstalledSize, but returns the result in
   /// kilobytes.
-  unsigned long GetInstalledSizeInKbytes(const char* installDir) const;
+  unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const;
 
  private:
   mutable unsigned long TotalSize;
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 0162d55..936942b 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -403,9 +403,39 @@
   if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) {
       cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE");
   }
-  cmd += " \"";
-  cmd += cmakeExecutable;
-  cmd += "\" -E tar cfz data.tar.gz ";
+
+  const char* debian_compression_type =
+      this->GetOption("CPACK_DEBIAN_COMPRESSION_TYPE");
+  if(!debian_compression_type)
+    {
+    debian_compression_type = "gzip";
+    }
+
+  std::string cmake_tar = " ", compression_modifier = "a", compression_suffix;
+  if(!strcmp(debian_compression_type, "lzma")) {
+      compression_suffix = ".lzma";
+  } else if(!strcmp(debian_compression_type, "xz")) {
+      compression_suffix = ".xz";
+  } else if(!strcmp(debian_compression_type, "bzip2")) {
+      compression_suffix = ".bz2";
+      compression_modifier = "j";
+      cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+  } else if(!strcmp(debian_compression_type, "gzip")) {
+      compression_suffix = ".gz";
+      compression_modifier = "z";
+      cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+  } else if(!strcmp(debian_compression_type, "none")) {
+      compression_suffix = "";
+      compression_modifier = "";
+      cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+  } else {
+      cmCPackLogger(cmCPackLog::LOG_ERROR,
+                    "Error unrecognized compression type: "
+                    << debian_compression_type << std::endl);
+  }
+
+  cmd += cmake_tar + "tar c" + compression_modifier + "f data.tar"
+      + compression_suffix;
 
   // now add all directories which have to be compressed
   // collect all top level install dirs for that
@@ -444,13 +474,13 @@
     std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     tmpFile += "/Deb.log";
     cmGeneratedFileStream ofs(tmpFile.c_str());
-    ofs << "# Run command: " << cmd.c_str() << std::endl
+    ofs << "# Run command: " << cmd << std::endl
       << "# Working directory: " << toplevel << std::endl
       << "# Output:" << std::endl
-      << output.c_str() << std::endl;
+      << output << std::endl;
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
-      << cmd.c_str() << std::endl
-      << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+      << cmd << std::endl
+      << "Please check " << tmpFile << " for errors" << std::endl);
     return 0;
     }
 
@@ -493,9 +523,7 @@
       {
       cmd = this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE");
       }
-    cmd += " \"";
-    cmd += cmakeExecutable;
-    cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums";
+    cmd += cmake_tar + "tar czf control.tar.gz ./control ./md5sums";
     const char* controlExtra =
       this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
   if( controlExtra )
@@ -506,7 +534,7 @@
           controlExtraList.begin(); i != controlExtraList.end(); ++i)
       {
       std::string filenamename =
-        cmsys::SystemTools::GetFilenameName(i->c_str());
+        cmsys::SystemTools::GetFilenameName(*i);
       std::string localcopy = this->GetOption("WDIR");
       localcopy += "/";
       localcopy += filenamename;
@@ -514,7 +542,7 @@
       if( cmsys::SystemTools::CopyFileIfDifferent(
             i->c_str(), localcopy.c_str()) )
         {
-        // debian is picky and need relative to ./ path in the tar.gz
+        // debian is picky and need relative to ./ path in the tar.*
         cmd += " ./";
         cmd += filenamename;
         }
@@ -528,17 +556,17 @@
     std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     tmpFile += "/Deb.log";
     cmGeneratedFileStream ofs(tmpFile.c_str());
-    ofs << "# Run command: " << cmd.c_str() << std::endl
+    ofs << "# Run command: " << cmd << std::endl
       << "# Working directory: " << toplevel << std::endl
       << "# Output:" << std::endl
-      << output.c_str() << std::endl;
+      << output << std::endl;
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
-      << cmd.c_str() << std::endl
-      << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+      << cmd << std::endl
+      << "Please check " << tmpFile << " for errors" << std::endl);
     return 0;
     }
 
-  // ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
+  // ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
   // since debian packages require BSD ar (most Linux distros and even
   // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here.
   std::vector<std::string> arFiles;
@@ -546,7 +574,7 @@
   topLevelString += "/";
   arFiles.push_back(topLevelString + "debian-binary");
   arFiles.push_back(topLevelString + "control.tar.gz");
-  arFiles.push_back(topLevelString + "data.tar.gz");
+  arFiles.push_back(topLevelString + "data.tar" + compression_suffix);
     std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
     outputFileName += "/";
     outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME");
@@ -588,9 +616,9 @@
   // the current COMPONENT belongs to.
   std::string groupVar = "CPACK_COMPONENT_" +
         cmSystemTools::UpperCase(componentName) + "_GROUP";
-    if (NULL != GetOption(groupVar.c_str()))
+    if (NULL != GetOption(groupVar))
       {
-      return std::string(GetOption(groupVar.c_str()));
+      return std::string(GetOption(groupVar));
       }
     else
       {
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 96491aa..91f92c5 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -254,7 +254,7 @@
   // If the project is a CMAKE project then run pre-install
   // and then read the cmake_install script to run it
   if ( !this->InstallProjectViaInstallCMakeProjects(
-         setDestDir, bareTempInstallDirectory.c_str()) )
+         setDestDir, bareTempInstallDirectory) )
     {
     return 0;
     }
@@ -269,7 +269,7 @@
 
 //----------------------------------------------------------------------
 int cmCPackGenerator::InstallProjectViaInstallCommands(
-  bool setDestDir, const char* tempInstallDirectory)
+  bool setDestDir, const std::string& tempInstallDirectory)
 {
   (void) setDestDir;
   const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
@@ -285,7 +285,7 @@
       it != installCommandsVector.end();
       ++it )
       {
-      cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << it->c_str()
+      cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it
         << std::endl);
       std::string output;
       int retVal = 1;
@@ -296,12 +296,12 @@
         std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
         tmpFile += "/InstallOutput.log";
         cmGeneratedFileStream ofs(tmpFile.c_str());
-        ofs << "# Run command: " << it->c_str() << std::endl
+        ofs << "# Run command: " << *it << std::endl
           << "# Output:" << std::endl
-          << output.c_str() << std::endl;
+          << output << std::endl;
         cmCPackLogger(cmCPackLog::LOG_ERROR,
-          "Problem running install command: " << it->c_str() << std::endl
-          << "Please check " << tmpFile.c_str() << " for errors"
+          "Problem running install command: " << *it << std::endl
+          << "Please check " << tmpFile << " for errors"
           << std::endl);
         return 0;
         }
@@ -312,7 +312,7 @@
 
 //----------------------------------------------------------------------
 int cmCPackGenerator::InstallProjectViaInstalledDirectories(
-  bool setDestDir, const char* tempInstallDirectory)
+  bool setDestDir, const std::string& tempInstallDirectory)
 {
   (void)setDestDir;
   (void)tempInstallDirectory;
@@ -329,7 +329,7 @@
       ++it )
       {
       cmCPackLogger(cmCPackLog::LOG_VERBOSE,
-        "Create ignore files regex for: " << it->c_str() << std::endl);
+        "Create ignore files regex for: " << *it << std::endl);
       ignoreFilesRegex.push_back(it->c_str());
       }
     }
@@ -349,7 +349,7 @@
       return 0;
       }
     std::vector<std::string>::iterator it;
-    const char* tempDir = tempInstallDirectory;
+    const std::string& tempDir = tempInstallDirectory;
     for ( it = installDirectoriesVector.begin();
       it != installDirectoriesVector.end();
       ++it )
@@ -357,9 +357,9 @@
       std::list<std::pair<std::string,std::string> > symlinkedFiles;
       cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
       cmsys::Glob gl;
-      std::string top = it->c_str();
+      std::string top = *it;
       it ++;
-      std::string subdir = it->c_str();
+      std::string subdir = *it;
       std::string findExpr = top;
       findExpr += "/*";
       cmCPackLogger(cmCPackLog::LOG_OUTPUT,
@@ -385,7 +385,7 @@
           if ( regIt->find(inFile.c_str()) )
             {
             cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: "
-              << inFile.c_str() << std::endl);
+              << inFile << std::endl);
             skip = true;
             }
           }
@@ -397,7 +397,7 @@
         filePath += "/" + subdir + "/"
           + cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
         cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
-          << inFile.c_str() << " -> " << filePath.c_str() << std::endl);
+          << inFile << " -> " << filePath << std::endl);
         /* If the file is a symlink we will have to re-create it */
         if ( cmSystemTools::FileIsSymlink(inFile.c_str()))
           {
@@ -416,7 +416,7 @@
                 ) )
           {
           cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
-            << inFile.c_str() << " -> " << filePath.c_str() << std::endl);
+            << inFile << " -> " << filePath << std::endl);
           return 0;
           }
         }
@@ -457,7 +457,7 @@
 
 //----------------------------------------------------------------------
 int cmCPackGenerator::InstallProjectViaInstallScript(
-  bool setDestDir, const char* tempInstallDirectory)
+  bool setDestDir, const std::string& tempInstallDirectory)
 {
   const char* cmakeScripts
     = this->GetOption("CPACK_INSTALL_SCRIPT");
@@ -473,7 +473,7 @@
       it != cmakeScriptsVector.end();
       ++it )
       {
-      std::string installScript = it->c_str();
+      std::string installScript = *it;
 
       cmCPackLogger(cmCPackLog::LOG_OUTPUT,
         "- Install script: " << installScript << std::endl);
@@ -499,7 +499,7 @@
         }
       else
         {
-        this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory);
+        this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str());
 
         cmCPackLogger(cmCPackLog::LOG_DEBUG,
           "- Using non-DESTDIR install... (this->SetOption)" << std::endl);
@@ -509,9 +509,9 @@
         }
 
       this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR",
-        tempInstallDirectory);
+        tempInstallDirectory.c_str());
       this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
-        tempInstallDirectory);
+        tempInstallDirectory.c_str());
       int res = this->MakefileMap->ReadListFile(0, installScript.c_str());
       if ( cmSystemTools::GetErrorOccuredFlag() || !res )
         {
@@ -524,7 +524,7 @@
 
 //----------------------------------------------------------------------
 int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
-  bool setDestDir, const char* baseTempInstallDirectory)
+  bool setDestDir, const std::string& baseTempInstallDirectory)
 {
   const char* cmakeProjects
     = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
@@ -562,13 +562,13 @@
           << std::endl);
         return 0;
         }
-      std::string installDirectory = it->c_str();
+      std::string installDirectory = *it;
       ++it;
-      std::string installProjectName = it->c_str();
+      std::string installProjectName = *it;
       ++it;
-      std::string installComponent = it->c_str();
+      std::string installComponent = *it;
       ++it;
-      std::string installSubDirectory = it->c_str();
+      std::string installSubDirectory = *it;
       std::string installFile = installDirectory + "/cmake_install.cmake";
 
       std::vector<std::string> componentsVector;
@@ -586,7 +586,7 @@
         // Determine the installation types for this project (if provided).
         std::string installTypesVar = "CPACK_"
           + cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
-        const char *installTypes = this->GetOption(installTypesVar.c_str());
+        const char *installTypes = this->GetOption(installTypesVar);
         if (installTypes && *installTypes)
           {
           std::vector<std::string> installTypesVector;
@@ -596,15 +596,15 @@
                installTypeIt != installTypesVector.end();
                ++installTypeIt)
             {
-            this->GetInstallationType(installProjectName.c_str(),
-                                      installTypeIt->c_str());
+            this->GetInstallationType(installProjectName,
+                                      *installTypeIt);
             }
           }
 
         // Determine the set of components that will be used in this project
         std::string componentsVar
           = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent);
-        const char *components = this->GetOption(componentsVar.c_str());
+        const char *components = this->GetOption(componentsVar);
         if (components && *components)
           {
           cmSystemTools::ExpandListArgument(components, componentsVector);
@@ -613,7 +613,7 @@
                compIt != componentsVector.end();
                ++compIt)
             {
-            GetComponent(installProjectName.c_str(), compIt->c_str());
+            GetComponent(installProjectName, *compIt);
             }
           componentInstall = true;
           }
@@ -623,7 +623,8 @@
         componentsVector.push_back(installComponent);
         }
 
-      const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
+      const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
+      std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
       cmGlobalGenerator* globalGenerator
         = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
           cmakeGenerator);
@@ -640,7 +641,7 @@
           = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
         std::vector<std::string> buildCommand;
         globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram,
-            installProjectName.c_str(), installDirectory.c_str(),
+            installProjectName, installDirectory,
             globalGenerator->GetPreinstallTargetName(),
             buildConfig, false);
         std::string buildCommandStr =
@@ -662,14 +663,14 @@
           std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
           tmpFile += "/PreinstallOutput.log";
           cmGeneratedFileStream ofs(tmpFile.c_str());
-          ofs << "# Run command: " << buildCommandStr.c_str() << std::endl
-            << "# Directory: " << installDirectory.c_str() << std::endl
+          ofs << "# Run command: " << buildCommandStr << std::endl
+            << "# Directory: " << installDirectory << std::endl
             << "# Output:" << std::endl
-            << output.c_str() << std::endl;
+            << output << std::endl;
           cmCPackLogger(cmCPackLog::LOG_ERROR,
-            "Problem running install command: " << buildCommandStr.c_str()
+            "Problem running install command: " << buildCommandStr
             << std::endl
-            << "Please check " << tmpFile.c_str() << " for errors"
+            << "Please check " << tmpFile << " for errors"
             << std::endl);
           return 0;
           }
@@ -822,9 +823,9 @@
                         << "'" << std::endl);
           }
 
-        if ( buildConfig && *buildConfig )
+        if (!buildConfig.empty())
           {
-          mf->AddDefinition("BUILD_TYPE", buildConfig);
+          mf->AddDefinition("BUILD_TYPE", buildConfig.c_str());
           }
         std::string installComponentLowerCase
           = cmSystemTools::LowerCase(installComponent);
@@ -931,19 +932,19 @@
             std::string absoluteDestFileComponent =
                 std::string("CPACK_ABSOLUTE_DESTINATION_FILES")
                 + "_" + GetComponentInstallDirNameSuffix(installComponent);
-            if (NULL != this->GetOption(absoluteDestFileComponent.c_str()))
+            if (NULL != this->GetOption(absoluteDestFileComponent))
               {
                 std::string absoluteDestFilesListComponent =
-                    this->GetOption(absoluteDestFileComponent.c_str());
+                    this->GetOption(absoluteDestFileComponent);
                 absoluteDestFilesListComponent +=";";
                 absoluteDestFilesListComponent +=
                     mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
-                this->SetOption(absoluteDestFileComponent.c_str(),
+                this->SetOption(absoluteDestFileComponent,
                     absoluteDestFilesListComponent.c_str());
               }
             else
               {
-              this->SetOption(absoluteDestFileComponent.c_str(),
+              this->SetOption(absoluteDestFileComponent,
                   mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
               }
             }
@@ -972,7 +973,7 @@
 }
 
 //----------------------------------------------------------------------
-void cmCPackGenerator::SetOptionIfNotSet(const char* op,
+void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
   const char* value)
 {
   const char* def = this->MakefileMap->GetDefinition(op);
@@ -984,12 +985,8 @@
 }
 
 //----------------------------------------------------------------------
-void cmCPackGenerator::SetOption(const char* op, const char* value)
+void cmCPackGenerator::SetOption(const std::string& op, const char* value)
 {
-  if ( !op )
-    {
-    return;
-    }
   if ( !value )
     {
     this->MakefileMap->RemoveDefinition(op);
@@ -1004,7 +1001,7 @@
 int cmCPackGenerator::DoPackage()
 {
   cmCPackLogger(cmCPackLog::LOG_OUTPUT,
-    "Create package using " << this->Name.c_str() << std::endl);
+    "Create package using " << this->Name << std::endl);
 
   // Prepare CPack internal name and check
   // values for many CPACK_xxx vars
@@ -1092,7 +1089,7 @@
    * may update this during PackageFiles.
    * (either putting several names or updating the provided one)
    */
-  packageFileNames.push_back(tempPackageFileName);
+  packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : "");
   toplevel = tempDirectory;
   if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag())
     {
@@ -1142,7 +1139,7 @@
 }
 
 //----------------------------------------------------------------------
-int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf)
+int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
 {
   this->MakefileMap = mf;
   this->Name = name;
@@ -1176,19 +1173,19 @@
 }
 
 //----------------------------------------------------------------------
-bool cmCPackGenerator::IsSet(const char* name) const
+bool cmCPackGenerator::IsSet(const std::string& name) const
 {
   return this->MakefileMap->IsSet(name);
 }
 
 //----------------------------------------------------------------------
-bool cmCPackGenerator::IsOn(const char* name) const
+bool cmCPackGenerator::IsOn(const std::string& name) const
 {
   return cmSystemTools::IsOn(GetOption(name));
 }
 
 //----------------------------------------------------------------------
-const char* cmCPackGenerator::GetOption(const char* op) const
+const char* cmCPackGenerator::GetOption(const std::string& op) const
 {
   const char* ret = this->MakefileMap->GetDefinition(op);
   if(!ret)
@@ -1202,6 +1199,12 @@
 }
 
 //----------------------------------------------------------------------
+std::vector<std::string> cmCPackGenerator::GetOptions() const
+{
+  return this->MakefileMap->GetDefinitions();
+}
+
+//----------------------------------------------------------------------
 int cmCPackGenerator::PackageFiles()
 {
   return 0;
@@ -1266,7 +1269,7 @@
     << (name ? name : "(NULL)") << std::endl);
   std::string ffile = this->MakefileMap->GetModulesFile(name);
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
-    << ffile.c_str() << std::endl);
+    << ffile << std::endl);
   return ffile;
 }
 
@@ -1311,6 +1314,14 @@
 }
 
 //----------------------------------------------------------------------
+cmInstalledFile const* cmCPackGenerator::GetInstalledFile(
+  std::string const& name) const
+{
+  cmake const* cm = this->MakefileMap->GetCMakeInstance();
+  return cm->GetInstalledFile(name);
+}
+
+//----------------------------------------------------------------------
 int cmCPackGenerator::PrepareGroupingKind()
 {
   // find a component package method specified by the user
@@ -1425,14 +1436,14 @@
   std::string suffix="-"+groupOrComponentName;
   /* check if we should use DISPLAY name */
   std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME";
-  if (IsOn(dispNameVar.c_str()))
+  if (IsOn(dispNameVar))
     {
     /* the component Group case */
     if (isGroupName)
       {
       std::string groupDispVar = "CPACK_COMPONENT_GROUP_"
           + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
-      const char* groupDispName = GetOption(groupDispVar.c_str());
+      const char* groupDispName = GetOption(groupDispVar);
       if (groupDispName)
         {
         suffix = "-"+std::string(groupDispName);
@@ -1443,7 +1454,7 @@
       {
       std::string dispVar = "CPACK_COMPONENT_"
            + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
-            const char* dispName = GetOption(dispVar.c_str());
+            const char* dispName = GetOption(dispVar);
             if(dispName)
               {
               suffix = "-"+std::string(dispName);
@@ -1480,8 +1491,8 @@
 
 //----------------------------------------------------------------------
 cmCPackInstallationType*
-cmCPackGenerator::GetInstallationType(const char *projectName,
-                                      const char *name)
+cmCPackGenerator::GetInstallationType(const std::string& projectName,
+                                      const std::string& name)
 {
   (void) projectName;
   bool hasInstallationType = this->InstallationTypes.count(name) != 0;
@@ -1494,7 +1505,7 @@
     installType->Name = name;
 
     const char* displayName
-      = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
+      = this->GetOption(macroPrefix + "_DISPLAY_NAME");
     if (displayName && *displayName)
       {
       installType->DisplayName = displayName;
@@ -1512,7 +1523,8 @@
 
 //----------------------------------------------------------------------
 cmCPackComponent*
-cmCPackGenerator::GetComponent(const char *projectName, const char *name)
+cmCPackGenerator::GetComponent(const std::string& projectName,
+                               const std::string& name)
 {
   bool hasComponent = this->Components.count(name) != 0;
   cmCPackComponent *component = &this->Components[name];
@@ -1523,7 +1535,7 @@
       + cmsys::SystemTools::UpperCase(name);
     component->Name = name;
     const char* displayName
-      = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
+      = this->GetOption(macroPrefix + "_DISPLAY_NAME");
     if (displayName && *displayName)
       {
       component->DisplayName = displayName;
@@ -1533,23 +1545,23 @@
       component->DisplayName = component->Name;
       }
     component->IsHidden
-      = this->IsOn((macroPrefix + "_HIDDEN").c_str());
+      = this->IsOn(macroPrefix + "_HIDDEN");
     component->IsRequired
-      = this->IsOn((macroPrefix + "_REQUIRED").c_str());
+      = this->IsOn(macroPrefix + "_REQUIRED");
     component->IsDisabledByDefault
-      = this->IsOn((macroPrefix + "_DISABLED").c_str());
+      = this->IsOn(macroPrefix + "_DISABLED");
     component->IsDownloaded
-      = this->IsOn((macroPrefix + "_DOWNLOADED").c_str())
+      = this->IsOn(macroPrefix + "_DOWNLOADED")
         || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
 
-    const char* archiveFile = this->GetOption((macroPrefix +
-                                               "_ARCHIVE_FILE").c_str());
+    const char* archiveFile = this->GetOption(macroPrefix +
+                                               "_ARCHIVE_FILE");
     if (archiveFile && *archiveFile)
       {
       component->ArchiveFile = archiveFile;
       }
 
-    const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str());
+    const char* groupName = this->GetOption(macroPrefix + "_GROUP");
     if (groupName && *groupName)
       {
       component->Group = GetComponentGroup(projectName, groupName);
@@ -1561,7 +1573,7 @@
       }
 
     const char* description
-      = this->GetOption((macroPrefix + "_DESCRIPTION").c_str());
+      = this->GetOption(macroPrefix + "_DESCRIPTION");
     if (description && *description)
       {
       component->Description = description;
@@ -1569,7 +1581,7 @@
 
     // Determine the installation types.
     const char *installTypes
-      = this->GetOption((macroPrefix + "_INSTALL_TYPES").c_str());
+      = this->GetOption(macroPrefix + "_INSTALL_TYPES");
     if (installTypes && *installTypes)
       {
       std::vector<std::string> installTypesVector;
@@ -1580,12 +1592,12 @@
            ++installTypesIt)
         {
         component->InstallationTypes.push_back(
-          this->GetInstallationType(projectName, installTypesIt->c_str()));
+          this->GetInstallationType(projectName, *installTypesIt));
         }
       }
 
     // Determine the component dependencies.
-    const char *depends = this->GetOption((macroPrefix + "_DEPENDS").c_str());
+    const char *depends = this->GetOption(macroPrefix + "_DEPENDS");
     if (depends && *depends)
       {
       std::vector<std::string> dependsVector;
@@ -1596,7 +1608,7 @@
            ++dependIt)
         {
         cmCPackComponent *child = GetComponent(projectName,
-                                               dependIt->c_str());
+                                               *dependIt);
         component->Dependencies.push_back(child);
         child->ReverseDependencies.push_back(component);
         }
@@ -1607,7 +1619,8 @@
 
 //----------------------------------------------------------------------
 cmCPackComponentGroup*
-cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name)
+cmCPackGenerator::GetComponentGroup(const std::string& projectName,
+                                    const std::string& name)
 {
   (void) projectName;
   std::string macroPrefix = "CPACK_COMPONENT_GROUP_"
@@ -1619,7 +1632,7 @@
     // Define the group
     group->Name = name;
     const char* displayName
-      = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
+      = this->GetOption(macroPrefix + "_DISPLAY_NAME");
     if (displayName && *displayName)
       {
       group->DisplayName = displayName;
@@ -1630,17 +1643,17 @@
       }
 
     const char* description
-      = this->GetOption((macroPrefix + "_DESCRIPTION").c_str());
+      = this->GetOption(macroPrefix + "_DESCRIPTION");
     if (description && *description)
       {
       group->Description = description;
       }
     group->IsBold
-      = this->IsOn((macroPrefix + "_BOLD_TITLE").c_str());
+      = this->IsOn(macroPrefix + "_BOLD_TITLE");
     group->IsExpandedByDefault
-      = this->IsOn((macroPrefix + "_EXPANDED").c_str());
+      = this->IsOn(macroPrefix + "_EXPANDED");
     const char* parentGroupName
-      = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str());
+      = this->GetOption(macroPrefix + "_PARENT_GROUP");
     if (parentGroupName && *parentGroupName)
       {
       group->ParentGroup = GetComponentGroup(projectName, parentGroupName);
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index bb33aa0..ed89b53 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -22,9 +22,10 @@
   // Forward declarations are insufficient since we use them in
   // std::map data members below...
 
-#define cmCPackTypeMacro(class, superclass) \
-  cmTypeMacro(class, superclass); \
-  static cmCPackGenerator* CreateGenerator() { return new class; }
+#define cmCPackTypeMacro(klass, superclass) \
+  cmTypeMacro(klass, superclass); \
+  static cmCPackGenerator* CreateGenerator() { return new klass; } \
+  class cmCPackTypeMacro_UseTrailingSemicolon
 
 #define cmCPackLogger(logType, msg) \
   do { \
@@ -46,6 +47,7 @@
 
 class cmMakefile;
 class cmCPackLog;
+class cmInstalledFile;
 
 /** \class cmCPackGenerator
  * \brief A superclass of all CPack Generators
@@ -90,7 +92,7 @@
   /**
    * Initialize generator
    */
-  int Initialize(const char* name, cmMakefile* mf);
+  int Initialize(const std::string& name, cmMakefile* mf);
 
   /**
    * Construct generator
@@ -99,11 +101,12 @@
   virtual ~cmCPackGenerator();
 
   //! Set and get the options
-  void SetOption(const char* op, const char* value);
-  void SetOptionIfNotSet(const char* op, const char* value);
-  const char* GetOption(const char* op) const;
-  bool IsSet(const char* name) const;
-  bool IsOn(const char* name) const;
+  void SetOption(const std::string& op, const char* value);
+  void SetOptionIfNotSet(const std::string& op, const char* value);
+  const char* GetOption(const std::string& op) const;
+  std::vector<std::string> GetOptions() const;
+  bool IsSet(const std::string& name) const;
+  bool IsOn(const std::string& name) const;
 
   //! Set the logger
   void SetLogger(cmCPackLog* log) { this->Logger = log; }
@@ -127,6 +130,8 @@
 
   int CleanTemporaryDirectory();
 
+  cmInstalledFile const* GetInstalledFile(std::string const& name) const;
+
   virtual const char* GetOutputExtension() { return ".cpack"; }
   virtual const char* GetOutputPostfix() { return 0; }
 
@@ -189,13 +194,13 @@
 
   //! Run install commands if specified
   virtual int InstallProjectViaInstallCommands(
-    bool setDestDir, const char* tempInstallDirectory);
+    bool setDestDir, const std::string& tempInstallDirectory);
   virtual int InstallProjectViaInstallScript(
-    bool setDestDir, const char* tempInstallDirectory);
+    bool setDestDir, const std::string& tempInstallDirectory);
   virtual int InstallProjectViaInstalledDirectories(
-    bool setDestDir, const char* tempInstallDirectory);
+    bool setDestDir, const std::string& tempInstallDirectory);
   virtual int InstallProjectViaInstallCMakeProjects(
-    bool setDestDir, const char* tempInstallDirectory);
+    bool setDestDir, const std::string& tempInstallDirectory);
 
   /**
    * The various level of support of
@@ -244,12 +249,14 @@
    * @return true if component installation is supported and wanted.
    */
   virtual bool WantsComponentInstallation() const;
-  virtual cmCPackInstallationType* GetInstallationType(const char *projectName,
-                                                       const char* name);
-  virtual cmCPackComponent* GetComponent(const char *projectName,
-                                         const char* name);
-  virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName,
-                                                   const char* name);
+  virtual cmCPackInstallationType* GetInstallationType(
+                                                const std::string& projectName,
+                                                const std::string& name);
+  virtual cmCPackComponent* GetComponent(const std::string& projectName,
+                                         const std::string& name);
+  virtual cmCPackComponentGroup* GetComponentGroup(
+                                                const std::string& projectName,
+                                                const std::string& name);
 
   cmSystemTools::OutputOption GeneratorVerbose;
   std::string Name;
diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index b36c2a2..9faf2b0 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -151,7 +151,8 @@
 }
 
 //----------------------------------------------------------------------
-cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name)
+cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
+                                                const std::string& name)
 {
   cmCPackGenerator* gen = this->NewGeneratorInternal(name);
   if ( !gen )
@@ -165,12 +166,8 @@
 
 //----------------------------------------------------------------------
 cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
-  const char* name)
+  const std::string& name)
 {
-  if ( !name )
-    {
-    return 0;
-    }
   cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it
     = this->GeneratorCreators.find(name);
   if ( it == this->GeneratorCreators.end() )
@@ -181,11 +178,11 @@
 }
 
 //----------------------------------------------------------------------
-void cmCPackGeneratorFactory::RegisterGenerator(const char* name,
+void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name,
   const char* generatorDescription,
   CreateGeneratorCall* createGenerator)
 {
-  if ( !name || !createGenerator )
+  if ( !createGenerator )
     {
     cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR,
       "Cannot register generator" << std::endl);
diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h
index dff2e49..010777f 100644
--- a/Source/CPack/cmCPackGeneratorFactory.h
+++ b/Source/CPack/cmCPackGeneratorFactory.h
@@ -31,26 +31,26 @@
   ~cmCPackGeneratorFactory();
 
   //! Get the generator
-  cmCPackGenerator* NewGenerator(const char* name);
+  cmCPackGenerator* NewGenerator(const std::string& name);
   void DeleteGenerator(cmCPackGenerator* gen);
 
   typedef cmCPackGenerator* CreateGeneratorCall();
 
-  void RegisterGenerator(const char* name,
+  void RegisterGenerator(const std::string& name,
     const char* generatorDescription,
     CreateGeneratorCall* createGenerator);
 
   void SetLogger(cmCPackLog* logger) { this->Logger = logger; }
 
-  typedef std::map<cmStdString, cmStdString> DescriptionsMap;
+  typedef std::map<std::string, std::string> DescriptionsMap;
   const DescriptionsMap& GetGeneratorsList() const
     { return this->GeneratorDescriptions; }
 
 private:
-  cmCPackGenerator* NewGeneratorInternal(const char* name);
+  cmCPackGenerator* NewGeneratorInternal(const std::string& name);
   std::vector<cmCPackGenerator*> Generators;
 
-  typedef std::map<cmStdString, CreateGeneratorCall*> t_GeneratorCreatorsMap;
+  typedef std::map<std::string, CreateGeneratorCall*> t_GeneratorCreatorsMap;
   t_GeneratorCreatorsMap GeneratorCreators;
   DescriptionsMap GeneratorDescriptions;
   cmCPackLog* Logger;
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx
index 4e8bf0f..7befca0 100644
--- a/Source/CPack/cmCPackLog.cxx
+++ b/Source/CPack/cmCPackLog.cxx
@@ -169,27 +169,27 @@
     {
     if ( error && !this->ErrorPrefix.empty() )
       {
-      *this->DefaultError << this->ErrorPrefix.c_str();
+      *this->DefaultError << this->ErrorPrefix;
       }
     else if ( warning && !this->WarningPrefix.empty() )
       {
-      *this->DefaultError << this->WarningPrefix.c_str();
+      *this->DefaultError << this->WarningPrefix;
       }
     else if ( output && !this->OutputPrefix.empty() )
       {
-      *this->DefaultOutput << this->OutputPrefix.c_str();
+      *this->DefaultOutput << this->OutputPrefix;
       }
     else if ( verbose && !this->VerbosePrefix.empty() )
       {
-      *this->DefaultOutput << this->VerbosePrefix.c_str();
+      *this->DefaultOutput << this->VerbosePrefix;
       }
     else if ( debug && !this->DebugPrefix.empty() )
       {
-      *this->DefaultOutput << this->DebugPrefix.c_str();
+      *this->DefaultOutput << this->DebugPrefix;
       }
     else if ( !this->Prefix.empty() )
       {
-      *this->DefaultOutput << this->Prefix.c_str();
+      *this->DefaultOutput << this->Prefix;
       }
     if ( useFileAndLine )
       {
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 62bfa91..0113698 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -83,10 +83,10 @@
       fileN = fileN.substr(fileN.find('/')+1, std::string::npos);
       }
     cmSystemTools::ReplaceString(fileN, "/", "\\");
-    str << "  Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
+    str << "  Delete \"$INSTDIR\\" << fileN << "\"" << std::endl;
     }
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: "
-    << str.str().c_str() << std::endl);
+    << str.str() << std::endl);
   this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str());
   std::vector<std::string> dirs;
   this->GetListOfSubdirectories(toplevel.c_str(), dirs);
@@ -117,14 +117,14 @@
         }
       }
     cmSystemTools::ReplaceString(fileN, "/", "\\");
-    dstr << "  RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
+    dstr << "  RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl;
     if (!componentName.empty())
       {
       this->Components[componentName].Directories.push_back(fileN);
       }
     }
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: "
-    << dstr.str().c_str() << std::endl);
+    << dstr.str() << std::endl);
   this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES",
                           dstr.str().c_str());
 
@@ -320,7 +320,7 @@
   std::string nsisCmd = "\"";
   nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM");
   nsisCmd += "\" \"" + nsisFileName + "\"";
-  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd.c_str()
+  cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd
     << std::endl);
   std::string output;
   int retVal = 1;
@@ -329,12 +329,12 @@
   if ( !res || retVal )
     {
     cmGeneratedFileStream ofs(tmpFile.c_str());
-    ofs << "# Run command: " << nsisCmd.c_str() << std::endl
+    ofs << "# Run command: " << nsisCmd << std::endl
       << "# Output:" << std::endl
-      << output.c_str() << std::endl;
+      << output << std::endl;
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: "
-      << nsisCmd.c_str() << std::endl
-      << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+      << nsisCmd << std::endl
+      << "Please check " << tmpFile << " for errors" << std::endl);
     return 0;
     }
   return 1;
@@ -427,7 +427,7 @@
 
   std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION";
   cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: "
-    << nsisCmd.c_str() << std::endl);
+    << nsisCmd << std::endl);
   std::string output;
   int retVal = 1;
   bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(),
@@ -442,13 +442,13 @@
     std::string tmpFile = topDir ? topDir : ".";
     tmpFile += "/NSISOutput.log";
     cmGeneratedFileStream ofs(tmpFile.c_str());
-    ofs << "# Run command: " << nsisCmd.c_str() << std::endl
+    ofs << "# Run command: " << nsisCmd << std::endl
       << "# Output:" << std::endl
-      << output.c_str() << std::endl;
+      << output << std::endl;
     cmCPackLogger(cmCPackLog::LOG_ERROR,
       "Problem checking NSIS version with command: "
-      << nsisCmd.c_str() << std::endl
-      << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+      << nsisCmd << std::endl
+      << "Please check " << tmpFile << " for errors" << std::endl);
     return 0;
     }
   if ( versionRex.find(output))
@@ -470,7 +470,7 @@
     {
     // No version check for NSIS cvs build
     cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS "
-      << versionRexCVS.match(1).c_str() << std::endl);
+      << versionRexCVS.match(1) << std::endl);
     }
   this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
   this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin");
@@ -629,7 +629,7 @@
     // if so add a desktop link
     std::string desktop = "CPACK_CREATE_DESKTOP_LINK_";
     desktop += linkName;
-    if(this->IsSet(desktop.c_str()))
+    if(this->IsSet(desktop))
       {
       str << "  StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
       str << "    CreateShortCut \"$DESKTOP\\"
@@ -844,12 +844,12 @@
       std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
       tmpFile += "/CompressZip.log";
       cmGeneratedFileStream ofs(tmpFile.c_str());
-      ofs << "# Run command: " << cmd.c_str() << std::endl
+      ofs << "# Run command: " << cmd << std::endl
         << "# Output:" << std::endl
-        << output.c_str() << std::endl;
+        << output << std::endl;
       cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: "
-        << cmd.c_str() << std::endl
-        << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+        << cmd << std::endl
+        << "Please check " << tmpFile << " for errors" << std::endl);
       return "";
     }
 
@@ -891,7 +891,7 @@
     path = *pathIt;
     cmSystemTools::ReplaceString(path, "/", "\\");
     macrosOut << "  Delete \"$INSTDIR\\"
-              << path.c_str()
+              << path
               << "\"\n";
     }
   for (pathIt = component->Directories.begin();
@@ -901,7 +901,7 @@
     path = *pathIt;
     cmSystemTools::ReplaceString(path, "/", "\\");
     macrosOut << "  RMDir \"$INSTDIR\\"
-              << path.c_str()
+              << path
               << "\"\n";
     }
   macrosOut << "  noremove_" << component->Name << ":\n";
diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx
index 76e15fb..28c7f1d 100644
--- a/Source/CPack/cmCPackOSXX11Generator.cxx
+++ b/Source/CPack/cmCPackOSXX11Generator.cxx
@@ -227,7 +227,7 @@
 
 //----------------------------------------------------------------------
 /*
-bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name)
+bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
 {
   std::string uname = cmSystemTools::UpperCase(name);
   std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
@@ -271,8 +271,8 @@
 */
 
 //----------------------------------------------------------------------
-bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name,
-  const char* dir, const char* outputFileName /* = 0 */,
+bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name,
+  const std::string& dir, const char* outputFileName /* = 0 */,
   bool copyOnly /* = false */)
 {
   std::string inFName = "CPack.";
@@ -288,7 +288,7 @@
 
   if ( !outputFileName )
     {
-    outputFileName = name;
+    outputFileName = name.c_str();
     }
 
   std::string destFileName = dir;
diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h
index b7bd243..9d0a6d1 100644
--- a/Source/CPack/cmCPackOSXX11Generator.h
+++ b/Source/CPack/cmCPackOSXX11Generator.h
@@ -37,8 +37,9 @@
   virtual const char* GetPackagingInstallPrefix();
   virtual const char* GetOutputExtension() { return ".dmg"; }
 
-  //bool CopyCreateResourceFile(const char* name, const char* dir);
-  bool CopyResourcePlistFile(const char* name, const char* dir,
+  //bool CopyCreateResourceFile(const std::string& name,
+  //                            const std::string& dir);
+  bool CopyResourcePlistFile(const std::string& name, const std::string& dir,
     const char* outputFileName = 0, bool copyOnly = false);
   std::string InstallPrefix;
 };
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index c5b9c6f..d736948 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -43,14 +43,14 @@
 }
 
 //----------------------------------------------------------------------
-int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir,
-                                                    const char* script,
-                                                    const char* name)
+int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir,
+                                                    const std::string& script,
+                                                    const std::string& name)
 {
   std::string dst = resdir;
   dst += "/";
   dst += name;
-  cmSystemTools::CopyFileAlways(script, dst.c_str());
+  cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str());
   cmSystemTools::SetPermissions(dst.c_str(),0777);
   cmCPackLogger(cmCPackLog::LOG_VERBOSE,
                 "copy script : " << script << "\ninto " << dst.c_str() <<
@@ -553,8 +553,9 @@
 }
 
 //----------------------------------------------------------------------
-bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
-                                                          const char* dirName)
+bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
+                                            const std::string& name,
+                                            const std::string& dirName)
 {
   std::string uname = cmSystemTools::UpperCase(name);
   std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
@@ -563,7 +564,7 @@
     {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str()
                   << " not specified. It should point to "
-                  << (name ? name : "(NULL)")
+                  << (!name.empty() ? name : "<empty>")
                   << ".rtf, " << name
                   << ".html, or " << name << ".txt file" << std::endl);
     return false;
@@ -571,7 +572,7 @@
   if ( !cmSystemTools::FileExists(inFileName) )
     {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
-                  << (name ? name : "(NULL)")
+                  << (!name.empty() ? name : "<empty>")
                   << " resource file: " << inFileName << std::endl);
     return false;
     }
@@ -600,12 +601,13 @@
   return true;
 }
 
-bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name,
-                                                         const char* outName)
+bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
+                                                const std::string& name,
+                                                const char* outName)
 {
   if (!outName)
     {
-    outName = name;
+    outName = name.c_str();
     }
 
   std::string inFName = "CPack.";
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h
index ba3d968..e350a60 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.h
+++ b/Source/CPack/cmCPackPackageMakerGenerator.h
@@ -38,9 +38,9 @@
   virtual bool SupportsComponentInstallation() const;
 
 protected:
-  int CopyInstallScript(const char* resdir,
-                        const char* script,
-                        const char* name);
+  int CopyInstallScript(const std::string& resdir,
+                        const std::string& script,
+                        const std::string& name);
   virtual int InitializeInternal();
   int PackageFiles();
   virtual const char* GetOutputExtension() { return ".dmg"; }
@@ -51,8 +51,9 @@
   // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
   // version of name) specifies the input file to use for this file,
   // which will be configured via ConfigureFile.
-  bool CopyCreateResourceFile(const char* name, const char *dirName);
-  bool CopyResourcePlistFile(const char* name, const char* outName = 0);
+  bool CopyCreateResourceFile(const std::string& name,
+                              const std::string& dirName);
+  bool CopyResourcePlistFile(const std::string& name, const char* outName = 0);
 
   // Run PackageMaker with the given command line, which will (if
   // successful) produce the given package file. Returns true if
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 66a4194..c6171dc 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -272,9 +272,9 @@
   // the current COMPONENT belongs to.
   std::string groupVar = "CPACK_COMPONENT_" +
         cmSystemTools::UpperCase(componentName) + "_GROUP";
-    if (NULL != GetOption(groupVar.c_str()))
+    if (NULL != GetOption(groupVar))
       {
-      return std::string(GetOption(groupVar.c_str()));
+      return std::string(GetOption(groupVar));
       }
     else
       {
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index 8342fee..6c1d201 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -43,7 +43,7 @@
   if ( inFile.empty() )
     {
     cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find template file: "
-      << inFile.c_str() << std::endl);
+      << inFile << std::endl);
     return 0;
     }
   this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str());
@@ -134,6 +134,6 @@
   cmSystemTools::ReplaceString(res, headerLengthTag, buffer);
 
   // Write in file
-  *os << res.c_str();
+  *os << res;
   return this->Superclass::GenerateHeader(os);
 }
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index a19b778..ad37c42 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -26,6 +26,7 @@
 #include <cmsys/CommandLineArguments.hxx>
 #include <cmsys/SystemTools.hxx>
 #include <cmsys/Encoding.hxx>
+#include <locale.h>
 
 //----------------------------------------------------------------------------
 static const char * cmDocumentationName[][2] =
@@ -68,7 +69,7 @@
 //----------------------------------------------------------------------------
 struct cpackDefinitions
 {
-  typedef std::map<cmStdString, cmStdString> MapType;
+  typedef std::map<std::string, std::string> MapType;
   MapType Map;
   cmCPackLog *Log;
 };
@@ -91,7 +92,7 @@
   value = value.c_str() + pos + 1;
   def->Map[key] = value;
   cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
-    << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl);
+    << key << " to \"" << value << "\"" << std::endl);
   return 1;
 }
 
@@ -100,6 +101,7 @@
 // this is CPack.
 int main (int argc, char const* const* argv)
 {
+  setlocale(LC_ALL, "");
   cmsys::Encoding::CommandLineArguments args =
     cmsys::Encoding::CommandLineArguments::Main(argc, argv);
   argc = args.argc();
@@ -195,7 +197,7 @@
     }
 
   cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
-    "Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
+    "Read CPack config file: " << cpackConfigFile << std::endl);
 
   cmake cminst;
   cminst.RemoveUnscriptableCommands();
@@ -257,26 +259,31 @@
       return 1;
       }
 
+    if ( !cpackBuildConfig.empty() )
+      {
+      globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
+      }
+
     if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
       {
       cpackConfigFile =
         cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
       cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
-        "Read CPack configuration file: " << cpackConfigFile.c_str()
+        "Read CPack configuration file: " << cpackConfigFile
         << std::endl);
       if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) )
         {
         cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
           "Problem reading CPack config file: \""
-          << cpackConfigFile.c_str() << "\"" << std::endl);
+          << cpackConfigFile << "\"" << std::endl);
         return 1;
         }
       }
     else if ( cpackConfigFileSpecified )
       {
       cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-        "Cannot find CPack config file: \"" << cpackConfigFile.c_str()
-        << "\"" << std::endl);
+        "Cannot find CPack config file: \"" <<
+         cpackConfigFile << "\"" << std::endl);
       return 1;
       }
 
@@ -317,16 +324,12 @@
                                 cpackProjectDirectory.c_str());
         }
       }
-    if ( !cpackBuildConfig.empty() )
-      {
-      globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
-      }
     cpackDefinitions::MapType::iterator cdit;
     for ( cdit = definitions.Map.begin();
       cdit != definitions.Map.end();
       ++cdit )
       {
-      globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
+      globalMF->AddDefinition(cdit->first, cdit->second.c_str());
       }
 
     const char* cpackModulesPath =
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 381c70c..3014a93 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -225,35 +225,35 @@
     return true;
     }
 
-  virtual void StartElement(const char* name, const char**)
+  virtual void StartElement(const std::string& name, const char**)
     {
     this->CData.clear();
-    if(strcmp(name, "log") == 0)
+    if(name == "log")
       {
       this->Rev = Revision();
       this->Changes.clear();
       }
     // affected-files can contain blocks of
     // modified, unknown, renamed, kind-changed, removed, conflicts, added
-    else if(strcmp(name, "modified") == 0
-            || strcmp(name, "renamed") == 0
-            || strcmp(name, "kind-changed") == 0)
+    else if(name == "modified"
+            || name == "renamed"
+            || name == "kind-changed")
       {
       this->CurChange = Change();
       this->CurChange.Action = 'M';
       }
-    else if(strcmp(name, "added") == 0)
+    else if(name == "added")
       {
       this->CurChange = Change();
       this->CurChange = 'A';
       }
-    else if(strcmp(name, "removed") == 0)
+    else if(name == "removed")
       {
       this->CurChange = Change();
       this->CurChange = 'D';
       }
-    else if(strcmp(name, "unknown") == 0
-            || strcmp(name, "conflicts") == 0)
+    else if(name == "unknown"
+            || name == "conflicts")
       {
       // Should not happen here
       this->CurChange = Change();
@@ -265,27 +265,27 @@
     this->CData.insert(this->CData.end(), data, data+length);
     }
 
-  virtual void EndElement(const char* name)
+  virtual void EndElement(const std::string& name)
     {
-    if(strcmp(name, "log") == 0)
+    if(name == "log")
       {
       this->BZR->DoRevision(this->Rev, this->Changes);
       }
-    else if((strcmp(name, "file") == 0 || strcmp(name, "directory") == 0)
-            && !this->CData.empty())
+    else if(!this->CData.empty() &&
+            (name == "file" || name == "directory"))
       {
       this->CurChange.Path.assign(&this->CData[0], this->CData.size());
       cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
       this->Changes.push_back(this->CurChange);
       }
-    else if(strcmp(name, "symlink") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "symlink")
       {
       // symlinks have an arobase at the end in the log
       this->CurChange.Path.assign(&this->CData[0], this->CData.size()-1);
       cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
       this->Changes.push_back(this->CurChange);
       }
-    else if(strcmp(name, "committer") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "committer")
       {
       this->Rev.Author.assign(&this->CData[0], this->CData.size());
       if(this->EmailRegex.find(this->Rev.Author))
@@ -294,15 +294,15 @@
         this->Rev.EMail = this->EmailRegex.match(2);
         }
       }
-    else if(strcmp(name, "timestamp") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "timestamp")
       {
       this->Rev.Date.assign(&this->CData[0], this->CData.size());
       }
-    else if(strcmp(name, "message") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "message")
       {
       this->Rev.Log.assign(&this->CData[0], this->CData.size());
       }
-    else if(strcmp(name, "revno") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "revno")
       {
       this->Rev.Rev.assign(&this->CData[0], this->CData.size());
       }
@@ -409,7 +409,7 @@
     {
     opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions");
     }
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
+  std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
 
   // TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
 
@@ -418,7 +418,7 @@
   bzr_update.push_back(this->CommandLineTool.c_str());
   bzr_update.push_back("pull");
 
-  for(std::vector<cmStdString>::const_iterator ai = args.begin();
+  for(std::vector<std::string>::const_iterator ai = args.begin();
       ai != args.end(); ++ai)
     {
     bzr_update.push_back(ai->c_str());
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 0fac136..b4818be 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -156,34 +156,36 @@
 }
 
 //----------------------------------------------------------------------
-void CMakeStdoutCallback(const char* m, int len, void* s)
+void CMakeOutputCallback(const char* m, size_t len, void* s)
 {
   std::string* out = (std::string*)s;
   out->append(m, len);
 }
-struct cmSetupOutputCaptureCleanup
+
+//----------------------------------------------------------------------
+class cmCTestBuildAndTestCaptureRAII
 {
-  ~cmSetupOutputCaptureCleanup()
-  {
-    cmSystemTools::SetErrorCallback(0, 0);
+  cmake& CM;
+public:
+  cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s): CM(cm)
+    {
+    cmSystemTools::SetMessageCallback(CMakeMessageCallback, &s);
+    cmSystemTools::SetStdoutCallback(CMakeOutputCallback, &s);
+    cmSystemTools::SetStderrCallback(CMakeOutputCallback, &s);
+    this->CM.SetProgressCallback(CMakeProgressCallback, &s);
+    }
+  ~cmCTestBuildAndTestCaptureRAII()
+    {
+    this->CM.SetProgressCallback(0, 0);
+    cmSystemTools::SetStderrCallback(0, 0);
     cmSystemTools::SetStdoutCallback(0, 0);
-  }
+    cmSystemTools::SetMessageCallback(0, 0);
+    }
 };
 
 //----------------------------------------------------------------------
 int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
 {
-  unsigned int k;
-  std::string cmakeOutString;
-  cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString);
-  cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &cmakeOutString);
-  // make sure SetStdoutCallback and SetErrorCallback are set to null
-  // after this function exits so that they do not point at a destroyed
-  // string cmakeOutString
-  cmSetupOutputCaptureCleanup cleanup;
-  static_cast<void>(cleanup);
-  cmOStringStream out;
-
   // if the generator and make program are not specified then it is an error
   if (!this->BuildGenerator.size())
     {
@@ -197,6 +199,12 @@
     return 1;
     }
 
+  cmake cm;
+  std::string cmakeOutString;
+  cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString);
+  static_cast<void>(captureRAII);
+  cmOStringStream out;
+
   if ( this->CTest->GetConfigType().size() == 0 &&
        this->ConfigSample.size())
     {
@@ -233,19 +241,15 @@
     }
   cmSystemTools::ChangeDirectory(this->BinaryDir.c_str());
 
-  // should we cmake?
-  cmake cm;
-  cm.SetProgressCallback(CMakeProgressCallback, &cmakeOutString);
-
   if(this->BuildNoCMake)
     {
     // Make the generator available for the Build call below.
     cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
-                            this->BuildGenerator.c_str()));
+                            this->BuildGenerator));
     cm.SetGeneratorToolset(this->BuildGeneratorToolset);
 
     // Load the cache to make CMAKE_MAKE_PROGRAM available.
-    cm.GetCacheManager()->LoadCache(this->BinaryDir.c_str());
+    cm.GetCacheManager()->LoadCache(this->BinaryDir);
     }
   else
     {
@@ -295,9 +299,9 @@
       config = "Debug";
       }
     int retVal = cm.GetGlobalGenerator()->Build(
-      this->SourceDir.c_str(), this->BinaryDir.c_str(),
-      this->BuildProject.c_str(), tarIt->c_str(),
-      &output, this->BuildMakeProgram.c_str(),
+      this->SourceDir, this->BinaryDir,
+      this->BuildProject, *tarIt,
+      &output, this->BuildMakeProgram,
       config,
       !this->BuildNoClean,
       false, remainingTime);
@@ -369,7 +373,7 @@
 
   std::vector<const char*> testCommand;
   testCommand.push_back(fullPath.c_str());
-  for(k=0; k < this->TestCommandArgs.size(); ++k)
+  for(size_t k=0; k < this->TestCommandArgs.size(); ++k)
     {
     testCommand.push_back(this->TestCommandArgs[k].c_str());
     }
@@ -383,7 +387,7 @@
     cmSystemTools::ChangeDirectory(this->BuildRunDir.c_str());
     }
   out << "Running test command: \"" << fullPath << "\"";
-  for(k=0; k < this->TestCommandArgs.size(); ++k)
+  for(size_t k=0; k < this->TestCommandArgs.size(); ++k)
     {
     out << " \"" << this->TestCommandArgs[k] << "\"";
     }
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index ca50c64..d1e9a4d 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -54,7 +54,7 @@
                std::string &cmakeOutString,
                std::string &cwd, cmake *cm);
 
-  cmStdString  Output;
+  std::string  Output;
 
   std::string              BuildGenerator;
   std::string              BuildGeneratorToolset;
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index b250fc3..a5a593a 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -101,8 +101,7 @@
         }
       if ( this->GlobalGenerator )
         {
-        if ( strcmp(this->GlobalGenerator->GetName(),
-            cmakeGeneratorName) != 0 )
+        if ( this->GlobalGenerator->GetName() != cmakeGeneratorName )
           {
           delete this->GlobalGenerator;
           this->GlobalGenerator = 0;
@@ -139,11 +138,12 @@
       std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
       std::string buildCommand
         = this->GlobalGenerator->
-        GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration,
-                                  cmakeBuildAdditionalFlags, true);
+        GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "",
+          cmakeBuildConfiguration,
+          cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", true);
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                  "SetMakeCommand:"
-                 << buildCommand.c_str() << "\n");
+                 << buildCommand << "\n");
       this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str());
       }
     else
@@ -160,7 +160,7 @@
         "\n"
         "Alternatively, set CTEST_BUILD_COMMAND to build the project "
         "with a custom command line.";
-      this->SetError(ostr.str().c_str());
+      this->SetError(ostr.str());
       return 0;
       }
     }
diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h
index 08887fe..2632ebc 100644
--- a/Source/CTest/cmCTestBuildCommand.h
+++ b/Source/CTest/cmCTestBuildCommand.h
@@ -43,7 +43,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_build";}
+  virtual std::string GetName() const { return "ctest_build";}
 
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index c5deb96..7922c9a 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -380,7 +380,7 @@
 
   // Create lists of regular expression strings for errors, error exceptions,
   // warnings and warning exceptions.
-  std::vector<cmStdString>::size_type cc;
+  std::vector<std::string>::size_type cc;
   for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ )
     {
     this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
@@ -400,7 +400,7 @@
     }
 
   // Pre-compile regular expressions objects for all regular expressions
-  std::vector<cmStdString>::iterator it;
+  std::vector<std::string>::iterator it;
 
 #define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
   regexes.clear(); \
@@ -409,7 +409,7 @@
   for ( it = strings.begin(); it != strings.end(); ++it ) \
     { \
     cmCTestLog(this->CTest, DEBUG, "Add " #strings ": " \
-    << it->c_str() << std::endl); \
+    << *it << std::endl); \
     regexes.push_back(it->c_str()); \
     }
   cmCTestBuildHandlerPopulateRegexVector(
@@ -602,7 +602,7 @@
   // Sort XML fragments in chronological order.
   cmFileTimeComparison ftc;
   FragmentCompare fragmentCompare(&ftc);
-  typedef std::set<cmStdString, FragmentCompare> Fragments;
+  typedef std::set<std::string, FragmentCompare> Fragments;
   Fragments fragments(fragmentCompare);
 
   // Identify fragments on disk.
@@ -889,7 +889,7 @@
   int* retVal, const char* dir, int timeout, std::ostream& ofs)
 {
   // First generate the command and arguments
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+  std::vector<std::string> args = cmSystemTools::ParseArguments(command);
 
   if(args.size() < 1)
     {
@@ -897,7 +897,7 @@
     }
 
   std::vector<const char*> argv;
-  for(std::vector<cmStdString>::const_iterator a = args.begin();
+  for(std::vector<std::string>::const_iterator a = args.begin();
     a != args.end(); ++a)
     {
     argv.push_back(a->c_str());
@@ -1133,7 +1133,7 @@
         errorwarning.PostContext = "";
 
         // Copy pre-context to report
-        std::deque<cmStdString>::iterator pcit;
+        std::deque<std::string>::iterator pcit;
         for ( pcit = this->PreContext.begin();
           pcit != this->PreContext.end();
           ++pcit )
diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h
index ff7cfd6..09346f9 100644
--- a/Source/CTest/cmCTestBuildHandler.h
+++ b/Source/CTest/cmCTestBuildHandler.h
@@ -97,10 +97,10 @@
   double                  StartBuildTime;
   double                  EndBuildTime;
 
-  std::vector<cmStdString> CustomErrorMatches;
-  std::vector<cmStdString> CustomErrorExceptions;
-  std::vector<cmStdString> CustomWarningMatches;
-  std::vector<cmStdString> CustomWarningExceptions;
+  std::vector<std::string> CustomErrorMatches;
+  std::vector<std::string> CustomErrorExceptions;
+  std::vector<std::string> CustomWarningMatches;
+  std::vector<std::string> CustomWarningExceptions;
   std::vector<std::string> ReallyCustomWarningMatches;
   std::vector<std::string> ReallyCustomWarningExceptions;
   std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
@@ -121,8 +121,8 @@
   size_t                                BuildOutputLogSize;
   std::vector<char>                     CurrentProcessingLine;
 
-  cmStdString                           SimplifySourceDir;
-  cmStdString                           SimplifyBuildDir;
+  std::string                           SimplifySourceDir;
+  std::string                           SimplifyBuildDir;
   size_t                                OutputLineCounter;
   typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
   t_ErrorsAndWarningsVector             ErrorsAndWarnings;
@@ -130,7 +130,7 @@
   size_t                                PostContextCount;
   size_t                                MaxPreContext;
   size_t                                MaxPostContext;
-  std::deque<cmStdString>               PreContext;
+  std::deque<std::string>               PreContext;
 
   int                                   TotalErrors;
   int                                   TotalWarnings;
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index 17dbb55..ab363d0 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -99,7 +99,7 @@
       opts = "-dP";
       }
     }
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
+  std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
 
   // Specify the start time for nightly testing.
   if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -112,7 +112,7 @@
   cvs_update.push_back(this->CommandLineTool.c_str());
   cvs_update.push_back("-z3");
   cvs_update.push_back("update");
-  for(std::vector<cmStdString>::const_iterator ai = args.begin();
+  for(std::vector<std::string>::const_iterator ai = args.begin();
       ai != args.end(); ++ai)
     {
     cvs_update.push_back(ai->c_str());
@@ -308,7 +308,7 @@
              "   Gathering version information (one . per updated file):\n"
              "    " << std::flush);
 
-  for(std::map<cmStdString, Directory>::const_iterator
+  for(std::map<std::string, Directory>::const_iterator
         di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
     {
     this->WriteXMLDirectory(xml, di->first, di->second);
diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h
index b7fe567..64e1747 100644
--- a/Source/CTest/cmCTestCVS.h
+++ b/Source/CTest/cmCTestCVS.h
@@ -32,8 +32,8 @@
   virtual bool WriteXMLUpdates(std::ostream& xml);
 
   // Update status for files in each directory.
-  class Directory: public std::map<cmStdString, PathStatus> {};
-  std::map<cmStdString, Directory> Dirs;
+  class Directory: public std::map<std::string, PathStatus> {};
+  std::map<std::string, Directory> Dirs;
 
   std::string ComputeBranchFlag(std::string const& dir);
   void LoadRevisions(std::string const& file, const char* branchFlag,
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index 5eed409..1aa8768 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -69,7 +69,7 @@
         cmOStringStream e;
         e << "CMakeLists.txt file does not exist ["
           << cmakelists_file << "]";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return 0;
         }
 
diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h
index b592c5a..7941d4e 100644
--- a/Source/CTest/cmCTestConfigureCommand.h
+++ b/Source/CTest/cmCTestConfigureCommand.h
@@ -38,7 +38,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_configure";}
+  virtual std::string GetName() const { return "ctest_configure";}
 
   cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand);
 
diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx
index 7c41298..a6e39a4 100644
--- a/Source/CTest/cmCTestConfigureHandler.cxx
+++ b/Source/CTest/cmCTestConfigureHandler.cxx
@@ -76,7 +76,7 @@
     cmGeneratedFileStream ofs;
     this->StartLogFile("Configure", ofs);
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: "
-      << cCommand.c_str() << std::endl);
+      << cCommand << std::endl);
     res = this->CTest->RunMakeCommand(cCommand.c_str(), &output,
       &retVal, buildDirectory.c_str(),
       0, ofs);
@@ -99,7 +99,7 @@
         {
         os << retVal;
         }
-      os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>"
+      os << "<ConfigureCommand>" << cCommand << "</ConfigureCommand>"
         << std::endl;
       cmCTestLog(this->CTest, DEBUG, "End" << std::endl);
       os << "<Log>" << cmXMLSafe(output) << "</Log>" << std::endl;
diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx
index 72ff720..41f016b 100644
--- a/Source/CTest/cmCTestCoverageCommand.cxx
+++ b/Source/CTest/cmCTestCoverageCommand.cxx
@@ -25,7 +25,8 @@
 {
   this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
     "CoverageCommand", "CTEST_COVERAGE_COMMAND");
-
+  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
+    "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS");
   cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
     this->CTest->GetInitializedHandler("coverage"));
   if ( !handler )
diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h
index 11bb411..5762e07 100644
--- a/Source/CTest/cmCTestCoverageCommand.h
+++ b/Source/CTest/cmCTestCoverageCommand.h
@@ -39,7 +39,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_coverage";}
+  virtual std::string GetName() const { return "ctest_coverage";}
 
   cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand);
 
@@ -56,7 +56,7 @@
   };
 
   bool LabelsMentioned;
-  std::set<cmStdString> Labels;
+  std::set<std::string> Labels;
 };
 
 
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 3c65c55..da27c8c 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -11,7 +11,7 @@
 ============================================================================*/
 #include "cmCTestCoverageHandler.h"
 #include "cmParsePHPCoverage.h"
-#include "cmParsePythonCoverage.h"
+#include "cmParseCoberturaCoverage.h"
 #include "cmParseGTMCoverage.h"
 #include "cmParseCacheCoverage.h"
 #include "cmCTest.h"
@@ -157,7 +157,7 @@
   logGlob += this->CTest->GetCurrentTag();
   logGlob += "/CoverageLog*";
   cmsys::Glob gl;
-  gl.FindFiles(logGlob.c_str());
+  gl.FindFiles(logGlob);
   std::vector<std::string> const& files = gl.GetFiles();
   for(std::vector<std::string>::const_iterator fi = files.begin();
       fi != files.end(); ++fi)
@@ -241,7 +241,7 @@
   bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(),
     fBinDir.c_str());
   // Always check parent directory of the file.
-  std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str());
+  std::string fileDir = cmSystemTools::GetFilenamePath(fFile);
   std::string checkDir;
 
   // We also need to check the binary/source directory pair.
@@ -269,7 +269,7 @@
       fFile.c_str(), checkDir.c_str());
   if ( ndc.size() )
     {
-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str()
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
       << " so skip coverage of " << file << std::endl);
     return false;
     }
@@ -296,7 +296,7 @@
     checkDir = fSrcDir;
     }
   fFile = checkDir + "/" + relPath;
-  fFile = cmSystemTools::GetFilenamePath(fFile.c_str());
+  fFile = cmSystemTools::GetFilenamePath(fFile);
 
   if ( fileDir == fFile )
     {
@@ -308,7 +308,7 @@
     fFile.c_str(), checkDir.c_str());
   if ( ndc.size() )
     {
-    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str()
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
       << " so skip coverage of: " << file << std::endl);
     return false;
     }
@@ -363,7 +363,7 @@
 
   // setup the regex exclude stuff
   this->CustomCoverageExcludeRegex.clear();
-  std::vector<cmStdString>::iterator rexIt;
+  std::vector<std::string>::iterator rexIt;
   for ( rexIt = this->CustomCoverageExclude.begin();
     rexIt != this->CustomCoverageExclude.end();
     ++ rexIt )
@@ -383,6 +383,12 @@
     {
     return error;
     }
+  file_count += this->HandleLCovCoverage(&cont);
+  error = cont.Error;
+  if ( file_count < 0 )
+    {
+    return error;
+    }
   file_count += this->HandleTracePyCoverage(&cont);
   error = cont.Error;
   if ( file_count < 0 )
@@ -395,7 +401,7 @@
     {
     return error;
     }
-  file_count += this->HandlePythonCoverage(&cont);
+  file_count += this->HandleCoberturaCoverage(&cont);
   error = cont.Error;
   if ( file_count < 0 )
     {
@@ -477,7 +483,7 @@
       {
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
         ".NoDartCoverage found, so skip coverage check for: "
-        << fullFileName.c_str()
+        << fullFileName
         << std::endl);
       continue;
       }
@@ -488,7 +494,7 @@
     if ( !cmSystemTools::FileExists(fullFileName.c_str()) )
       {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
-        << fullFileName.c_str() << std::endl);
+        << fullFileName << std::endl);
       continue;
       }
 
@@ -503,7 +509,7 @@
       }
 
     const std::string fileName
-      = cmSystemTools::GetFilenameName(fullFileName.c_str());
+      = cmSystemTools::GetFilenameName(fullFileName);
     std::string shortFileName =
       this->CTest->GetShortPathToFile(fullFileName.c_str());
     const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov
@@ -516,7 +522,7 @@
     if ( !ifs)
       {
       cmOStringStream ostr;
-      ostr <<  "Cannot open source file: " << fullFileName.c_str();
+      ostr <<  "Cannot open source file: " << fullFileName;
       errorsWhileAccumulating.push_back(ostr.str());
       error ++;
       continue;
@@ -535,7 +541,7 @@
         cc != fcov.size() -1 )
         {
         cmOStringStream ostr;
-        ostr << "Problem reading source file: " << fullFileName.c_str()
+        ostr << "Problem reading source file: " << fullFileName
              << " line:" << cc << "  out total: " << fcov.size()-1;
         errorsWhileAccumulating.push_back(ostr.str());
         error ++;
@@ -605,7 +611,7 @@
     if (!ifs)
       {
       cmOStringStream ostr;
-      ostr <<  "Cannot open source file: " << fullPath.c_str();
+      ostr <<  "Cannot open source file: " << fullPath;
       errorsWhileAccumulating.push_back(ostr.str());
       error ++;
       continue;
@@ -613,7 +619,7 @@
     int untested = 0;
     std::string line;
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "Actually performing coverage for: " << i->c_str() << std::endl);
+      "Actually performing coverage for: " << *i << std::endl);
     while (cmSystemTools::GetLineFromStream(ifs, line))
       {
       covLogFile << "\t\t<Line Number=\"" << untested << "\" Count=\"0\">"
@@ -647,7 +653,7 @@
       ++ erIt )
       {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "  " << erIt->c_str() << std::endl);
+        "  " << *erIt << std::endl);
       }
     }
 
@@ -713,19 +719,19 @@
                                 this->CustomCoverageExclude);
   this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB",
                                 this->ExtraCoverageGlobs);
-  std::vector<cmStdString>::iterator it;
+  std::vector<std::string>::iterator it;
   for ( it = this->CustomCoverageExclude.begin();
     it != this->CustomCoverageExclude.end();
     ++ it )
     {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: "
-      << it->c_str() << std::endl);
+      << *it << std::endl);
     }
   for ( it = this->ExtraCoverageGlobs.begin();
     it != this->ExtraCoverageGlobs.end(); ++it)
     {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage glob: "
-      << it->c_str() << std::endl);
+      << *it << std::endl);
     }
 }
 
@@ -773,10 +779,10 @@
 }
 
 //----------------------------------------------------------------------
-int cmCTestCoverageHandler::HandlePythonCoverage(
+int cmCTestCoverageHandler::HandleCoberturaCoverage(
   cmCTestCoverageHandlerContainer* cont)
 {
-  cmParsePythonCoverage cov(*cont, this->CTest);
+  cmParseCoberturaCoverage cov(*cont, this->CTest);
 
   // Assume the coverage.xml is in the source directory
   std::string coverageXMLFile = this->CTest->GetBinaryDir() + "/coverage.xml";
@@ -784,14 +790,14 @@
   if(cmSystemTools::FileExists(coverageXMLFile.c_str()))
     {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               "Parsing coverage.py XML file: " << coverageXMLFile
+               "Parsing Cobertura XML file: " << coverageXMLFile
                << std::endl);
     cov.ReadCoverageXML(coverageXMLFile.c_str());
     }
   else
     {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               "Cannot find coverage.py XML file: " << coverageXMLFile
+               "Cannot find Cobertura XML file: " << coverageXMLFile
                << std::endl);
     }
   return static_cast<int>(cont->TotalCoverage.size());
@@ -871,9 +877,22 @@
 {
   std::string gcovCommand
     = this->CTest->GetCTestConfiguration("CoverageCommand");
+  if (gcovCommand.empty())
+    {
+    cmCTestLog(this->CTest, ERROR_MESSAGE,
+      "Could not find gcov." << std::endl);
+    return 0;
+    }
   std::string gcovExtraFlags
     = this->CTest->GetCTestConfiguration("CoverageExtraFlags");
 
+  // Immediately skip to next coverage option since codecov is only for Intel
+  // compiler
+  if ( gcovCommand == "codecov" )
+    {
+    return 0;
+    }
+
   // Style 1
   std::string st1gcovOutputRex1
     = "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$";
@@ -941,7 +960,7 @@
 
     // Call gcov to get coverage data for this *.gcda file:
     //
-    std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str());
+    std::string fileDir = cmSystemTools::GetFilenamePath(*it);
     std::string command = "\"" + gcovCommand + "\" " +
       gcovExtraFlags + " " +
       "-o \"" + fileDir + "\" " +
@@ -953,17 +972,17 @@
     std::string output = "";
     std::string errors = "";
     int retVal = 0;
-    *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl;
-    *cont->OFS << "  Command: " << command.c_str() << std::endl;
+    *cont->OFS << "* Run coverage for: " << fileDir << std::endl;
+    *cont->OFS << "  Command: " << command << std::endl;
     int res = this->CTest->RunCommand(command.c_str(), &output, &errors,
       &retVal, tempDir.c_str(), 0 /*this->TimeOut*/);
 
-    *cont->OFS << "  Output: " << output.c_str() << std::endl;
-    *cont->OFS << "  Errors: " << errors.c_str() << std::endl;
+    *cont->OFS << "  Output: " << output << std::endl;
+    *cont->OFS << "  Errors: " << errors << std::endl;
     if ( ! res )
       {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Problem running coverage on file: " << it->c_str() << std::endl);
+        "Problem running coverage on file: " << *it << std::endl);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
         "Command produced error: " << errors << std::endl);
       cont->Error ++;
@@ -972,7 +991,7 @@
     if ( retVal != 0 )
       {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
-        << retVal << " while processing: " << it->c_str() << std::endl);
+        << retVal << " while processing: " << *it << std::endl);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
         "Command produced error: " << cont->Error << std::endl);
       }
@@ -983,8 +1002,8 @@
       << "--------------------------------------------------------------"
       << std::endl);
 
-    std::vector<cmStdString> lines;
-    std::vector<cmStdString>::iterator line;
+    std::vector<std::string> lines;
+    std::vector<std::string>::iterator line;
 
     cmSystemTools::Split(output.c_str(), lines);
 
@@ -993,7 +1012,7 @@
       std::string sourceFile;
       std::string gcovFile;
 
-      cmCTestLog(this->CTest, DEBUG, "Line: [" << line->c_str() << "]"
+      cmCTestLog(this->CTest, DEBUG, "Line: [" << *line << "]"
         << std::endl);
 
       if ( line->size() == 0 )
@@ -1139,7 +1158,7 @@
            !cmSystemTools::StringStartsWith(line->c_str(), "Removing "))
           {
           cmCTestLog(this->CTest, ERROR_MESSAGE,
-            "Unknown gcov output line: [" << line->c_str() << "]"
+            "Unknown gcov output line: [" << *line << "]"
             << std::endl);
           cont->Error ++;
           //abort();
@@ -1232,8 +1251,8 @@
         if ( IsFileInDir(sourceFile, cont->SourceDir) )
           {
           cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   produced s: "
-            << sourceFile.c_str() << std::endl);
-          *cont->OFS << "  produced in source dir: " << sourceFile.c_str()
+            << sourceFile << std::endl);
+          *cont->OFS << "  produced in source dir: " << sourceFile
             << std::endl;
           actualSourceFile
             = cmSystemTools::CollapseFullPath(sourceFile.c_str());
@@ -1241,8 +1260,8 @@
         else if ( IsFileInDir(sourceFile, cont->BinaryDir) )
           {
           cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   produced b: "
-            << sourceFile.c_str() << std::endl);
-          *cont->OFS << "  produced in binary dir: " << sourceFile.c_str()
+            << sourceFile << std::endl);
+          *cont->OFS << "  produced in binary dir: " << sourceFile
             << std::endl;
           actualSourceFile
             = cmSystemTools::CollapseFullPath(sourceFile.c_str());
@@ -1256,19 +1275,19 @@
               "Something went wrong" << std::endl);
             cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
               "Cannot find file: ["
-              << sourceFile.c_str() << "]" << std::endl);
+              << sourceFile << "]" << std::endl);
             cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
               " in source dir: ["
-              << cont->SourceDir.c_str() << "]"
+              << cont->SourceDir << "]"
               << std::endl);
             cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
               " or binary dir: ["
               << cont->BinaryDir.size() << "]"
               << std::endl);
             *cont->OFS << "  Something went wrong. Cannot find file: "
-              << sourceFile.c_str()
-              << " in source dir: " << cont->SourceDir.c_str()
-              << " or binary dir: " << cont->BinaryDir.c_str() << std::endl;
+              << sourceFile
+              << " in source dir: " << cont->SourceDir
+              << " or binary dir: " << cont->BinaryDir << std::endl;
 
             missingFiles.insert(sourceFile);
             }
@@ -1290,6 +1309,270 @@
   return file_count;
 }
 
+//----------------------------------------------------------------------
+int cmCTestCoverageHandler::HandleLCovCoverage(
+  cmCTestCoverageHandlerContainer* cont)
+{
+  std::string lcovCommand
+    = this->CTest->GetCTestConfiguration("CoverageCommand");
+  std::string lcovExtraFlags
+    = this->CTest->GetCTestConfiguration("CoverageExtraFlags");
+  if ( lcovCommand != "codecov" )
+    {
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+               " Not a valid Intel Coverage command."
+               << std::endl);
+    return 0;
+    }
+  // There is only percentage completed output from LCOV
+  std::string st2lcovOutputRex3 = "[0-9]+%";
+  cmsys::RegularExpression st2re3(st2lcovOutputRex3.c_str());
+
+  cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+    " This is coverage command: " << lcovCommand
+    << std::endl);
+
+  cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+    " These are coverage command flags: " << lcovExtraFlags
+    << std::endl);
+
+  std::vector<std::string> files;
+  this->FindLCovFiles(files);
+  std::vector<std::string>::iterator it;
+
+  if ( files.size() == 0 )
+    {
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+      " Cannot find any LCov coverage files."
+      << std::endl);
+    // No coverage files is a valid thing, so the exit code is 0
+    return 0;
+    }
+  std::string testingDir = this->CTest->GetBinaryDir();
+  std::string tempDir = testingDir;
+  std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
+
+  std::set<std::string> missingFiles;
+
+  std::string actualSourceFile = "";
+  cmCTestLog(this->CTest, HANDLER_OUTPUT,
+    "   Processing coverage (each . represents one file):" << std::endl);
+  cmCTestLog(this->CTest, HANDLER_OUTPUT, "    ");
+  int file_count = 0;
+
+  // make sure output from lcov is in English!
+  cmCTestCoverageHandlerLocale locale_C;
+  static_cast<void>(locale_C);
+
+  // In intel compiler we have to call codecov only once in each executable
+  // directory. It collects all *.dyn files to generate .dpi file.
+  for ( it = files.begin(); it != files.end(); ++ it )
+    {
+    cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
+    std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str());
+    cmSystemTools::ChangeDirectory(fileDir.c_str());
+    std::string command = "\"" + lcovCommand + "\" " +
+      lcovExtraFlags + " ";
+
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Current coverage dir: "
+               << fileDir.c_str() << std::endl);
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str()
+               << std::endl);
+
+    std::string output = "";
+    std::string errors = "";
+    int retVal = 0;
+    *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl;
+    *cont->OFS << "  Command: " << command.c_str() << std::endl;
+    int res = this->CTest->RunCommand(command.c_str(), &output, &errors,
+                &retVal, fileDir.c_str(), 0 /*this->TimeOut*/);
+
+    *cont->OFS << "  Output: " << output.c_str() << std::endl;
+    *cont->OFS << "  Errors: " << errors.c_str() << std::endl;
+    if ( ! res )
+      {
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+        "Problem running coverage on file: " << it->c_str() << std::endl);
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+        "Command produced error: " << errors << std::endl);
+      cont->Error ++;
+      continue;
+      }
+    if ( retVal != 0 )
+      {
+      cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
+        << retVal << " while processing: " << it->c_str() << std::endl);
+      cmCTestLog(this->CTest, ERROR_MESSAGE,
+        "Command produced error: " << cont->Error << std::endl);
+      }
+    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+      "--------------------------------------------------------------"
+      << std::endl
+      << output << std::endl
+      << "--------------------------------------------------------------"
+      << std::endl);
+
+    std::vector<std::string> lines;
+    std::vector<std::string>::iterator line;
+
+    cmSystemTools::Split(output.c_str(), lines);
+
+    for ( line = lines.begin(); line != lines.end(); ++line)
+      {
+      std::string sourceFile;
+      std::string lcovFile;
+
+      if ( line->size() == 0 )
+        {
+        // Ignore empty line
+        }
+      // Look for LCOV files in binary directory
+      // Intel Compiler creates a CodeCoverage dir for each subfolder and
+      // each subfolder has LCOV files
+      cmsys::Glob gl;
+      gl.RecurseOn();
+      gl.RecurseThroughSymlinksOff();
+      std::string dir;
+      std::vector<std::string> lcovFiles;
+      dir = this->CTest->GetBinaryDir();
+      std::string daGlob;
+      daGlob = dir;
+      daGlob += "/*.LCOV";
+      cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                 "   looking for LCOV files in: " << daGlob << std::endl);
+      gl.FindFiles(daGlob);
+      // Keep a list of all LCOV files
+      lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(),
+                       gl.GetFiles().end());
+
+      for(std::vector<std::string>::iterator a = lcovFiles.begin();
+          a != lcovFiles.end(); ++a)
+        {
+        lcovFile = *a;
+        cmsys::ifstream srcead(lcovFile.c_str());
+        if ( ! srcead )
+          {
+          cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
+                     << lcovFile << std::endl);
+          }
+        std::string srcname;
+
+        int success = cmSystemTools::GetLineFromStream(srcead, srcname);
+        if ( !success )
+          {
+          cmCTestLog(this->CTest, ERROR_MESSAGE,
+                     "Error while parsing lcov file '" << lcovFile << "':"
+                     << " No source file name found!" << std::endl);
+          return 0;
+          }
+        srcname = srcname.substr(18);
+        // We can directly read found LCOV files to determine the source
+        // files
+        sourceFile = srcname;
+        actualSourceFile = srcname;
+
+        for(std::vector<std::string>::iterator t = lcovFiles.begin();
+            t != lcovFiles.end(); ++t)
+          {
+          cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found LCOV File: "
+                     << *t << std::endl);
+          }
+        cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SourceFile: "
+                   << sourceFile << std::endl);
+        cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "lCovFile: "
+                   << lcovFile << std::endl);
+
+        // If we have some LCOV files to process
+        if ( !lcovFile.empty() && !actualSourceFile.empty() )
+          {
+          cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec
+            = cont->TotalCoverage[actualSourceFile];
+
+          cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   in lcovFile: "
+                     << lcovFile << std::endl);
+
+          cmsys::ifstream ifile(lcovFile.c_str());
+          if ( ! ifile )
+            {
+            cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
+                       << lcovFile << std::endl);
+            }
+          else
+            {
+            long cnt = -1;
+            std::string nl;
+
+            // Skip the first line
+            cmSystemTools::GetLineFromStream(ifile, nl);
+            cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+                       "File is ready, start reading." << std::endl);
+            while ( cmSystemTools::GetLineFromStream(ifile, nl) )
+              {
+              cnt ++;
+
+              // Skip empty lines
+              if ( !nl.size() )
+                {
+                continue;
+                }
+
+              // Skip unused lines
+              if ( nl.size() < 12 )
+                {
+                continue;
+                }
+
+              // Read the coverage count from the beginning of the lcov
+              // output line
+              std::string prefix = nl.substr(0, 17);
+              int cov = atoi(prefix.c_str());
+
+              // Read the line number starting at the 17th character of the
+              // lcov output line
+              std::string lineNumber = nl.substr(17, 7);
+
+              int lineIdx = atoi(lineNumber.c_str())-1;
+              if ( lineIdx >= 0 )
+                {
+                while ( vec.size() <= static_cast<size_t>(lineIdx) )
+                  {
+                  vec.push_back(-1);
+                  }
+
+                // Initially all entries are -1 (not used). If we get coverage
+                // information, increment it to 0 first.
+                if ( vec[lineIdx] < 0 )
+                  {
+                  if ( cov > 0 || prefix.find("#") != prefix.npos )
+                    {
+                    vec[lineIdx] = 0;
+                    }
+                  }
+
+                vec[lineIdx] += cov;
+                }
+              }
+            }
+
+          actualSourceFile = "";
+          }
+        }
+      }
+
+    file_count++;
+
+    if ( file_count % 50 == 0 )
+      {
+      cmCTestLog(this->CTest, HANDLER_OUTPUT, " processed: " << file_count
+                 << " out of " << files.size() << std::endl);
+      cmCTestLog(this->CTest, HANDLER_OUTPUT, "    ");
+      }
+    }
+
+  cmSystemTools::ChangeDirectory(currentDirectory.c_str());
+  return file_count;
+}
+
 //----------------------------------------------------------------------------
 void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
 {
@@ -1321,6 +1604,34 @@
     }
 }
 
+//----------------------------------------------------------------------------
+void cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
+{
+  cmsys::Glob gl;
+  gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is
+                   // used while compiling.
+  gl.RecurseThroughSymlinksOff();
+  std::string prevBinaryDir;
+  cmSystemTools::ChangeDirectory(
+    this->CTest->GetCTestConfiguration("BuildDirectory").c_str());
+
+  // Run profmerge to merge all *.dyn files into dpi files
+  cmSystemTools::RunSingleCommand("profmerge");
+
+  prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str();
+
+  // DPI file should appear in build directory
+  std::string daGlob;
+  daGlob = prevBinaryDir;
+  daGlob += "/*.dpi";
+  cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+             "   looking for dpi files in: " << daGlob << std::endl);
+  gl.FindFiles(daGlob);
+  files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
+  cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+             "Now searching in: " << daGlob << std::endl);
+}
+
 //----------------------------------------------------------------------
 int cmCTestCoverageHandler::HandleTracePyCoverage(
   cmCTestCoverageHandlerContainer* cont)
@@ -1358,24 +1669,24 @@
       {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
         "Cannot find source Python file corresponding to: "
-        << fileIt->c_str() << std::endl);
+        << *fileIt << std::endl);
       continue;
       }
 
     std::string actualSourceFile
       = cmSystemTools::CollapseFullPath(fileName.c_str());
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "   Check coverage for file: " << actualSourceFile.c_str()
+      "   Check coverage for file: " << actualSourceFile
       << std::endl);
     cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec
       = &cont->TotalCoverage[actualSourceFile];
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-      "   in file: " << fileIt->c_str() << std::endl);
+      "   in file: " << *fileIt << std::endl);
     cmsys::ifstream ifile(fileIt->c_str());
     if ( ! ifile )
       {
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
-        << fileIt->c_str() << std::endl);
+        << *fileIt << std::endl);
       }
     else
       {
@@ -1423,7 +1734,7 @@
           // So, this will be set to 0.
           cov = 0;
           }
-        cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix.c_str()
+        cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix
           << " cov: " << cov
           << std::endl);
         // Read the line number starting at the 10th character of the gcov
@@ -1498,7 +1809,7 @@
 //----------------------------------------------------------------------
 int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
   cmCTestCoverageHandlerContainer* cont,
-  std::set<cmStdString>& coveredFileNames,
+  std::set<std::string>& coveredFileNames,
   std::vector<std::string>& files,
   std::vector<std::string>& filesFullPath)
 {
@@ -1536,10 +1847,10 @@
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Cannot open coverage file: " <<
-               outputFile.c_str() << std::endl);
+               outputFile << std::endl);
     return 0;
     }
-  std::map<cmStdString, cmStdString> fileMap;
+  std::map<std::string, std::string> fileMap;
   std::vector<std::string>::iterator fp = filesFullPath.begin();
   for(std::vector<std::string>::iterator f =  files.begin();
       f != files.end(); ++f, ++fp)
@@ -1552,7 +1863,7 @@
   std::string lineIn;
   bool valid = false; // are we in a valid output file
   int line = 0; // line of the current file
-  cmStdString file;
+  std::string file;
   while(cmSystemTools::GetLineFromStream(fin, lineIn))
     {
     bool startFile = false;
@@ -1587,7 +1898,7 @@
           }
         count++; // move on one
         }
-      std::map<cmStdString, cmStdString>::iterator
+      std::map<std::string, std::string>::iterator
         i = fileMap.find(file);
       // if the file should be covered write out the header for that file
       if(i != fileMap.end())
@@ -1596,7 +1907,7 @@
         count++;
         cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                    "Produce coverage for file: "
-                   << file.c_str() << " " << count
+                   << file << " " << count
                    << std::endl);
         // start the file output
         covLogFile << "\t<File Name=\""
@@ -1657,12 +1968,12 @@
   if(arg)
     {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               "Run : " << program.c_str() << " " << arg << "\n");
+               "Run : " << program << " " << arg << "\n");
     }
   else
     {
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-               "Run : " << program.c_str() << "\n");
+               "Run : " << program << "\n");
     }
   // create a process object and start it
   cmCTestRunProcess runCoverageSrc;
@@ -1680,7 +1991,7 @@
   if(!runCoverageSrc.StartProcess())
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not run : "
-               << program.c_str() << " " << arg << "\n"
+               << program << " " << arg << "\n"
                << "kwsys process state : "
                << runCoverageSrc.GetProcessState());
     return 0;
@@ -1749,10 +2060,10 @@
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Cannot open coverage summary file: " <<
-               outputFile.c_str() << std::endl);
+               outputFile << std::endl);
     return 0;
     }
-  std::set<cmStdString> coveredFileNames;
+  std::set<std::string> coveredFileNames;
   while(cmSystemTools::GetLineFromStream(fin, stdline))
     {
     // if we have a line of output from stdout
@@ -1790,14 +2101,14 @@
         {
         cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                    ".NoDartCoverage found, so skip coverage check for: "
-                   << file.c_str()
+                   << file
                    << std::endl);
         continue;
         }
 
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                  "Doing coverage for: "
-                 << file.c_str()
+                 << file
                  << std::endl);
 
       coveredFiles.push_back(sourceFile);
@@ -1808,7 +2119,7 @@
       total_tested += functionsCalled;
       total_untested += (totalFunctions - functionsCalled);
 
-      std::string fileName = cmSystemTools::GetFilenameName(file.c_str());
+      std::string fileName = cmSystemTools::GetFilenameName(file);
       std::string shortFileName =
         this->CTest->GetShortPathToFile(file.c_str());
 
@@ -1824,7 +2135,7 @@
         cmet /= 2.0f;
         }
       cmet /= 100.0f;
-      tmpLog << stdline.c_str() << "\n";
+      tmpLog << stdline << "\n";
       tmpLog << fileName << "\n";
       tmpLog << "functionsCalled: " << functionsCalled/100 << "\n";
       tmpLog << "totalFunctions: " << totalFunctions/100 << "\n";
@@ -1951,7 +2262,7 @@
   if(pos == inputLine.npos)
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing string : "
-               << inputLine.c_str() << "\n");
+               << inputLine << "\n");
     return false;
     }
   // the source file has "" around it so extract out the file name
@@ -1985,7 +2296,7 @@
   if(pos != inputLine.npos)
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing input : "
-               << inputLine.c_str() << " last pos not npos =  " << pos <<
+               << inputLine << " last pos not npos =  " << pos <<
                "\n");
     }
   return true;
@@ -2099,10 +2410,10 @@
 
 //----------------------------------------------------------------------------
 void
-cmCTestCoverageHandler::SetLabelFilter(std::set<cmStdString> const& labels)
+cmCTestCoverageHandler::SetLabelFilter(std::set<std::string> const& labels)
 {
   this->LabelFilter.clear();
-  for(std::set<cmStdString>::const_iterator li = labels.begin();
+  for(std::set<std::string>::const_iterator li = labels.begin();
       li != labels.end(); ++li)
     {
     this->LabelFilter.insert(this->GetLabelId(*li));
@@ -2152,7 +2463,7 @@
 {
   std::set<std::string> extraMatches;
 
-  for(std::vector<cmStdString>::iterator i = this->ExtraCoverageGlobs.begin();
+  for(std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin();
       i != this->ExtraCoverageGlobs.end(); ++i)
     {
     cmsys::Glob gl;
diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h
index 660f501..38a3353 100644
--- a/Source/CTest/cmCTestCoverageHandler.h
+++ b/Source/CTest/cmCTestCoverageHandler.h
@@ -55,7 +55,7 @@
   void PopulateCustomVectors(cmMakefile *mf);
 
   /** Report coverage only for sources with these labels.  */
-  void SetLabelFilter(std::set<cmStdString> const& labels);
+  void SetLabelFilter(std::set<std::string> const& labels);
 
 private:
   bool ShouldIDoCoverage(const char* file, const char* srcDir,
@@ -68,11 +68,15 @@
   int HandleGCovCoverage(cmCTestCoverageHandlerContainer* cont);
   void FindGCovFiles(std::vector<std::string>& files);
 
+  //! Handle coverage using Intel's LCov
+  int HandleLCovCoverage(cmCTestCoverageHandlerContainer* cont);
+  void FindLCovFiles(std::vector<std::string>& files);
+
   //! Handle coverage using xdebug php coverage
   int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont);
 
   //! Handle coverage for Python with coverage.py
-  int HandlePythonCoverage(cmCTestCoverageHandlerContainer* cont);
+  int HandleCoberturaCoverage(cmCTestCoverageHandlerContainer* cont);
 
   //! Handle coverage for mumps
   int HandleMumpsCoverage(cmCTestCoverageHandlerContainer* cont);
@@ -81,7 +85,7 @@
   int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont);
   int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont);
   int RunBullseyeCoverageBranch(cmCTestCoverageHandlerContainer* cont,
-                                std::set<cmStdString>& coveredFileNames,
+                                std::set<std::string>& coveredFileNames,
                                 std::vector<std::string>& files,
                                 std::vector<std::string>& filesFullPath);
 
@@ -112,19 +116,19 @@
 
   std::set<std::string> FindUncoveredFiles(
     cmCTestCoverageHandlerContainer* cont);
-  std::vector<cmStdString> CustomCoverageExclude;
+  std::vector<std::string> CustomCoverageExclude;
   std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex;
-  std::vector<cmStdString> ExtraCoverageGlobs;
+  std::vector<std::string> ExtraCoverageGlobs;
 
 
   // Map from source file to label ids.
   class LabelSet: public std::set<int> {};
-  typedef std::map<cmStdString, LabelSet> LabelMapType;
+  typedef std::map<std::string, LabelSet> LabelMapType;
   LabelMapType SourceLabels;
   LabelMapType TargetDirs;
 
   // Map from label name to label id.
-  typedef std::map<cmStdString, int> LabelIdMapType;
+  typedef std::map<std::string, int> LabelIdMapType;
   LabelIdMapType LabelIdMap;
   std::vector<std::string> Labels;
   int GetLabelId(std::string const& label);
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
index abc33de..5ddef01 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
@@ -25,8 +25,8 @@
   if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) )
     {
     cmOStringStream ostr;
-    ostr << "problem removing the binary directory: " << args[0].c_str();
-    this->SetError(ostr.str().c_str());
+    ostr << "problem removing the binary directory: " << args[0];
+    this->SetError(ostr.str());
     return false;
     }
 
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
index 07e59a4..d182d17 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
@@ -48,7 +48,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_empty_binary_directory";}
+  virtual std::string GetName() const { return "ctest_empty_binary_directory";}
 
   cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand);
 
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index 0e0e797..aaa01b2 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -179,8 +179,8 @@
     {
     opts = this->CTest->GetCTestConfiguration("GITUpdateOptions");
     }
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
-  for(std::vector<cmStdString>::const_iterator ai = args.begin();
+  std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+  for(std::vector<std::string>::const_iterator ai = args.begin();
       ai != args.end(); ++ai)
     {
     git_fetch.push_back(ai->c_str());
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index 5338f30..2df2229 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -30,12 +30,8 @@
 }
 
 //----------------------------------------------------------------------
-void cmCTestGenericHandler::SetOption(const char* op, const char* value)
+void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
 {
-  if ( !op )
-    {
-    return;
-    }
   if ( !value )
     {
     cmCTestGenericHandler::t_StringToString::iterator remit
@@ -51,14 +47,10 @@
 }
 
 //----------------------------------------------------------------------
-void cmCTestGenericHandler::SetPersistentOption(const char* op,
+void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
                                                 const char* value)
 {
   this->SetOption(op, value);
-  if ( !op )
-    {
-    return;
-    }
   if ( !value )
     {
     cmCTestGenericHandler::t_StringToString::iterator remit
@@ -83,12 +75,12 @@
     it != this->PersistentOptions.end();
     ++ it )
     {
-    this->Options[it->first.c_str()] = it->second.c_str();
+    this->Options[it->first] = it->second.c_str();
     }
 }
 
 //----------------------------------------------------------------------
-const char* cmCTestGenericHandler::GetOption(const char* op)
+const char* cmCTestGenericHandler::GetOption(const std::string& op)
 {
   cmCTestGenericHandler::t_StringToString::iterator remit
     = this->Options.find(op);
@@ -129,10 +121,10 @@
     return false;
     }
   if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(),
-      ostr.str().c_str(), xofs, true) )
+      ostr.str(), xofs, true) )
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
-      "Cannot create resulting XML file: " << ostr.str().c_str()
+      "Cannot create resulting XML file: " << ostr.str()
       << std::endl);
     return false;
     }
@@ -161,10 +153,10 @@
     ostr << "_" << this->CTest->GetCurrentTag();
     }
   ostr << ".log";
-  if( !this->CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) )
+  if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) )
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: "
-      << ostr.str().c_str() << std::endl);
+      << ostr.str() << std::endl);
     return false;
     }
   return true;
diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h
index ba8febb..2788cba 100644
--- a/Source/CTest/cmCTestGenericHandler.h
+++ b/Source/CTest/cmCTestGenericHandler.h
@@ -71,12 +71,12 @@
   cmCTestGenericHandler();
   virtual ~cmCTestGenericHandler();
 
-  typedef std::map<cmStdString,cmStdString> t_StringToString;
+  typedef std::map<std::string,std::string> t_StringToString;
 
 
-  void SetPersistentOption(const char* op, const char* value);
-  void SetOption(const char* op, const char* value);
-  const char* GetOption(const char* op);
+  void SetPersistentOption(const std::string& op, const char* value);
+  void SetOption(const std::string& op, const char* value);
+  const char* GetOption(const std::string& op);
 
   void SetCommand(cmCTestCommand* command)
     {
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index 8c51102..5f570b5 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -132,7 +132,7 @@
 
   this->WriteXMLGlobal(xml);
 
-  for(std::map<cmStdString, Directory>::const_iterator
+  for(std::map<std::string, Directory>::const_iterator
         di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
     {
     this->WriteXMLDirectory(xml, di->first, di->second);
diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h
index a648a59..cb0d165 100644
--- a/Source/CTest/cmCTestGlobalVC.h
+++ b/Source/CTest/cmCTestGlobalVC.h
@@ -39,8 +39,8 @@
   };
 
   // Update status for files in each directory.
-  class Directory: public std::map<cmStdString, File> {};
-  std::map<cmStdString, Directory> Dirs;
+  class Directory: public std::map<std::string, File> {};
+  std::map<std::string, Directory> Dirs;
 
   // Old and new repository revisions.
   std::string OldRevision;
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 86a7617..0f79d68 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -149,8 +149,8 @@
     {
     opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
     }
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
-  for(std::vector<cmStdString>::const_iterator ai = args.begin();
+  std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+  for(std::vector<std::string>::const_iterator ai = args.begin();
       ai != args.end(); ++ai)
     {
     hg_update.push_back(ai->c_str());
@@ -189,10 +189,10 @@
     return true;
     }
 
-  virtual void StartElement(const char* name, const char** atts)
+  virtual void StartElement(const std::string& name, const char** atts)
     {
     this->CData.clear();
-    if(strcmp(name, "logentry") == 0)
+    if(name == "logentry")
       {
       this->Rev = Revision();
       if(const char* rev = this->FindAttribute(atts, "revision"))
@@ -208,29 +208,29 @@
     this->CData.insert(this->CData.end(), data, data+length);
     }
 
-  virtual void EndElement(const char* name)
+  virtual void EndElement(const std::string& name)
     {
-    if(strcmp(name, "logentry") == 0)
+    if(name == "logentry")
       {
       this->HG->DoRevision(this->Rev, this->Changes);
       }
-    else if(strcmp(name, "author") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "author")
       {
       this->Rev.Author.assign(&this->CData[0], this->CData.size());
       }
-    else if ( strcmp(name, "email") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "email")
       {
       this->Rev.EMail.assign(&this->CData[0], this->CData.size());
       }
-    else if(strcmp(name, "date") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "date")
       {
       this->Rev.Date.assign(&this->CData[0], this->CData.size());
       }
-    else if(strcmp(name, "msg") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "msg")
       {
       this->Rev.Log.assign(&this->CData[0], this->CData.size());
       }
-    else if(strcmp(name, "files") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "files")
       {
       std::vector<std::string> paths = this->SplitCData();
       for(unsigned int i = 0; i < paths.size(); ++i)
@@ -242,7 +242,7 @@
         this->Changes.push_back(this->CurChange);
         }
       }
-    else if(strcmp(name, "file_adds") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "file_adds")
       {
       std::string added_paths(this->CData.begin(), this->CData.end());
       for(unsigned int i = 0; i < this->Changes.size(); ++i)
@@ -253,7 +253,7 @@
           }
         }
       }
-     else if(strcmp(name, "file_dels") == 0 && !this->CData.empty())
+     else if(!this->CData.empty() && name == "file_dels")
       {
       std::string added_paths(this->CData.begin(), this->CData.end());
       for(unsigned int i = 0; i < this->Changes.size(); ++i)
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 2e2feb0..0e29160 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -48,7 +48,7 @@
       {
       cmOStringStream e;
       e << "called with unknown argument \"" << args[i] << "\".";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index cd3bd57..10a5199 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -567,7 +567,7 @@
     fxml << "\n";
     fxml << "\t\t<!-- Interested parties -->\n";
     fxml << "\t\t<Labels>\n";
-    for(std::set<cmStdString>::const_iterator li = this->Labels.begin();
+    for(std::set<std::string>::const_iterator li = this->Labels.begin();
         li != this->Labels.end(); ++li)
       {
       fxml << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n";
@@ -680,8 +680,8 @@
       continue;
       }
 
-    if(this->Match(line.c_str(), this->RegexWarning) &&
-       !this->Match(line.c_str(), this->RegexWarningSuppress))
+    if(this->Match(line, this->RegexWarning) &&
+       !this->Match(line, this->RegexWarningSuppress))
       {
       return true;
       }
diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h
index f680d19..bc90d28 100644
--- a/Source/CTest/cmCTestLaunch.h
+++ b/Source/CTest/cmCTestLaunch.h
@@ -73,7 +73,7 @@
   bool HaveErr;
 
   // Labels associated with the build rule.
-  std::set<cmStdString> Labels;
+  std::set<std::string> Labels;
   void LoadLabels();
   bool SourceMatches(std::string const& lhs,
                      std::string const& rhs);
diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h
index b50170d..e239d46 100644
--- a/Source/CTest/cmCTestMemCheckCommand.h
+++ b/Source/CTest/cmCTestMemCheckCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_memcheck";}
+  virtual std::string GetName() const { return "ctest_memcheck";}
 
   cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand);
 
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index fdce04d..ecaa474 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -49,21 +49,15 @@
 {
 public:
   cmBoundsCheckerParser(cmCTest* c) { this->CTest = c;}
-  void StartElement(const char* name, const char** atts)
+  void StartElement(const std::string& name, const char** atts)
     {
-      if(strcmp(name, "MemoryLeak") == 0)
+      if(name == "MemoryLeak" ||
+         name == "ResourceLeak")
         {
         this->Errors.push_back(cmCTestMemCheckHandler::MLK);
         }
-      if(strcmp(name, "ResourceLeak") == 0)
-        {
-        this->Errors.push_back(cmCTestMemCheckHandler::MLK);
-        }
-      if(strcmp(name, "Error") == 0)
-        {
-        this->ParseError(atts);
-        }
-      if(strcmp(name, "Dangling Pointer") == 0)
+      else if(name == "Error" ||
+              name == "Dangling Pointer")
         {
         this->ParseError(atts);
         }
@@ -79,7 +73,7 @@
       ostr << "\n";
       this->Log += ostr.str();
     }
-  void EndElement(const char* )
+  void EndElement(const std::string& )
     {
     }
 
@@ -246,8 +240,8 @@
 void cmCTestMemCheckHandler::GenerateTestCommand(
   std::vector<std::string>& args, int test)
 {
-  std::vector<cmStdString>::size_type pp;
-  cmStdString index;
+  std::vector<std::string>::size_type pp;
+  std::string index;
   cmOStringStream stream;
   std::string memcheckcommand
     = cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
@@ -255,9 +249,9 @@
   index = stream.str();
   for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ )
     {
-    cmStdString arg = this->MemoryTesterDynamicOptions[pp];
-    cmStdString::size_type pos = arg.find("??");
-    if (pos != cmStdString::npos)
+      std::string arg = this->MemoryTesterDynamicOptions[pp];
+      std::string::size_type pos = arg.find("??");
+    if (pos != std::string::npos)
       {
       arg.replace(pos, 2, index);
       }
@@ -520,7 +514,7 @@
           cmCTestLog(this->CTest, ERROR_MESSAGE,
             "Cannot find memory checker suppression file: "
             << this->CTest->GetCTestConfiguration(
-              "MemoryCheckSuppressionFile").c_str() << std::endl);
+              "MemoryCheckSuppressionFile") << std::endl);
           return false;
           }
         std::string suppressions = "--suppressions="
@@ -575,12 +569,12 @@
       }
     default:
       cmCTestLog(this->CTest, ERROR_MESSAGE,
-        "Do not understand memory checker: " << this->MemoryTester.c_str()
+        "Do not understand memory checker: " << this->MemoryTester
         << std::endl);
       return false;
     }
 
-  std::vector<cmStdString>::size_type cc;
+  std::vector<std::string>::size_type cc;
   for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ )
     {
     this->MemoryTesterGlobalResults[cc] = 0;
@@ -627,7 +621,7 @@
   const std::string& str, std::string& log,
   int* results)
 {
-  std::vector<cmStdString> lines;
+  std::vector<std::string> lines;
   cmSystemTools::Split(str.c_str(), lines);
   cmOStringStream ostr;
   log = "";
@@ -636,7 +630,7 @@
 
   int defects = 0;
 
-  for( std::vector<cmStdString>::iterator i = lines.begin();
+  for( std::vector<std::string>::iterator i = lines.begin();
        i != lines.end(); ++i)
     {
     int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
@@ -681,7 +675,7 @@
   const std::string& str, std::string& log,
   int* results)
 {
-  std::vector<cmStdString> lines;
+  std::vector<std::string> lines;
   cmSystemTools::Split(str.c_str(), lines);
   bool unlimitedOutput = false;
   if(str.find("CTEST_FULL_OUTPUT") != str.npos ||
@@ -864,10 +858,10 @@
 {
   log = "";
   double sttime = cmSystemTools::GetTime();
-  std::vector<cmStdString> lines;
+  std::vector<std::string> lines;
   cmSystemTools::Split(str.c_str(), lines);
   cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl);
-  std::vector<cmStdString>::size_type cc;
+  std::vector<std::string>::size_type cc;
   for ( cc = 0; cc < lines.size(); cc ++ )
     {
     if(lines[cc] == BOUNDS_CHECKER_MARKER)
@@ -891,7 +885,7 @@
       else if(!parser.ParseChunk(theLine.c_str(), theLine.size()))
         {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
-                   "Error in ParseChunk: " << theLine.c_str()
+                   "Error in ParseChunk: " << theLine
                    << std::endl);
         }
       }
@@ -922,8 +916,8 @@
 {
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
              "PostProcessBoundsCheckerTest for : "
-             << res.Name.c_str() << std::endl);
-  cmStdString ofile = testOutputFileName(test);
+             << res.Name << std::endl);
+  std::string ofile = testOutputFileName(test);
   if ( ofile.empty() )
     {
     return;
@@ -949,10 +943,10 @@
   cmSystemTools::Delay(1000);
   cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str());
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
-    << this->BoundsCheckerDPBDFile.c_str() << std::endl);
+    << this->BoundsCheckerDPBDFile << std::endl);
   cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str());
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
-    << this->BoundsCheckerXMLFile.c_str() << std::endl);
+    << this->BoundsCheckerXMLFile << std::endl);
 }
 
 void
@@ -961,7 +955,7 @@
 {
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
              "PostProcessPurifyTest for : "
-             << res.Name.c_str() << std::endl);
+             << res.Name << std::endl);
   appendMemTesterOutput(res, test);
 }
 
@@ -971,7 +965,7 @@
 {
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
              "PostProcessValgrindTest for : "
-             << res.Name.c_str() << std::endl);
+             << res.Name << std::endl);
   appendMemTesterOutput(res, test);
 }
 
@@ -979,7 +973,7 @@
 cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res,
                                               int test)
 {
-  cmStdString ofile = testOutputFileName(test);
+  std::string ofile = testOutputFileName(test);
 
   if ( ofile.empty() )
     {
@@ -1000,15 +994,15 @@
     }
 }
 
-cmStdString
+std::string
 cmCTestMemCheckHandler::testOutputFileName(int test)
 {
-  cmStdString index;
+  std::string index;
   cmOStringStream stream;
   stream << test;
   index = stream.str();
-  cmStdString ofile = this->MemoryTesterOutputFile;
-  cmStdString::size_type pos = ofile.find("??");
+  std::string ofile = this->MemoryTesterOutputFile;
+  std::string::size_type pos = ofile.find("??");
   ofile.replace(pos, 2, index);
 
   if ( !cmSystemTools::FileExists(ofile.c_str()) )
diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h
index 040d2e0..0521a48 100644
--- a/Source/CTest/cmCTestMemCheckHandler.h
+++ b/Source/CTest/cmCTestMemCheckHandler.h
@@ -89,8 +89,8 @@
   std::string              BoundsCheckerDPBDFile;
   std::string              BoundsCheckerXMLFile;
   std::string              MemoryTester;
-  std::vector<cmStdString> MemoryTesterDynamicOptions;
-  std::vector<cmStdString> MemoryTesterOptions;
+  std::vector<std::string> MemoryTesterDynamicOptions;
+  std::vector<std::string> MemoryTesterOptions;
   int                      MemoryTesterStyle;
   std::string              MemoryTesterOutputFile;
   int                      MemoryTesterGlobalResults[NO_MEMORY_FAULT];
@@ -103,8 +103,8 @@
    */
   void GenerateDartOutput(std::ostream& os);
 
-  std::vector<cmStdString> CustomPreMemCheck;
-  std::vector<cmStdString> CustomPostMemCheck;
+  std::vector<std::string> CustomPreMemCheck;
+  std::vector<std::string> CustomPostMemCheck;
 
   //! Parse Valgrind/Purify/Bounds Checker result out of the output
   //string. After running, log holds the output and results hold the
@@ -127,7 +127,7 @@
                              int test);
 
   ///! generate the output filename for the given test index
-  cmStdString testOutputFileName(int test);
+  std::string testOutputFileName(int test);
 };
 
 #endif
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index ddd1707..b9e6721 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -369,7 +369,7 @@
 
   // Write list of failed tests
   fout << "---\n";
-  for(std::vector<cmStdString>::iterator i = this->Failed->begin();
+  for(std::vector<std::string>::iterator i = this->Failed->begin();
       i != this->Failed->end(); ++i)
     {
     fout << i->c_str() << "\n";
@@ -672,7 +672,7 @@
     indexStr << " #" << p.Index << ":";
     cmCTestLog(this->CTest, HANDLER_OUTPUT,
       std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
-      << indexStr.str().c_str());
+      << indexStr.str());
     cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
     cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl);
     //pop working dir
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index 1b53ec7..605de31 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -41,8 +41,8 @@
   void PrintTestList();
   void PrintLabels();
 
-  void SetPassFailVectors(std::vector<cmStdString>* passed,
-                          std::vector<cmStdString>* failed)
+  void SetPassFailVectors(std::vector<std::string>* passed,
+                          std::vector<std::string>* failed)
     {
     this->Passed = passed;
     this->Failed = failed;
@@ -107,9 +107,9 @@
   PropertiesMap Properties;
   std::map<int, bool> TestRunningMap;
   std::map<int, bool> TestFinishMap;
-  std::map<int, cmStdString> TestOutput;
-  std::vector<cmStdString>* Passed;
-  std::vector<cmStdString>* Failed;
+  std::map<int, std::string> TestOutput;
+  std::vector<std::string>* Passed;
+  std::vector<std::string>* Failed;
   std::vector<std::string> LastTestsFailed;
   std::set<std::string> LockedResources;
   std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index b09d6f5..0bb1a99 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -346,13 +346,13 @@
     //The CTEST_P4_OPTIONS variable adds additional Perforce command line
     //options before the main command
     std::string opts = this->CTest->GetCTestConfiguration("P4Options");
-    std::vector<cmStdString> args =
+    std::vector<std::string> args =
             cmSystemTools::ParseArguments(opts.c_str());
 
-    for(std::vector<cmStdString>::const_iterator ai = args.begin();
+    for(std::vector<std::string>::const_iterator ai = args.begin();
         ai != args.end(); ++ai)
       {
-      P4Options.push_back(ai->c_str());
+      P4Options.push_back(*ai);
       }
     }
 
@@ -538,8 +538,8 @@
     {
     opts = this->CTest->GetCTestConfiguration("P4UpdateOptions");
     }
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
-  for(std::vector<cmStdString>::const_iterator ai = args.begin();
+  std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+  for(std::vector<std::string>::const_iterator ai = args.begin();
       ai != args.end(); ++ai)
     {
     p4_sync.push_back(ai->c_str());
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h
index 9c0af81..c95694a 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.h
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.h
@@ -46,7 +46,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_read_custom_files";}
+  virtual std::string GetName() const { return "ctest_read_custom_files";}
 
   cmTypeMacro(cmCTestReadCustomFilesCommand, cmCTestCommand);
 
diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx
index fe429bd..bdf9b9c 100644
--- a/Source/CTest/cmCTestRunScriptCommand.cxx
+++ b/Source/CTest/cmCTestRunScriptCommand.cxx
@@ -56,7 +56,7 @@
         &ret);
       cmOStringStream str;
       str << ret;
-      this->Makefile->AddDefinition(returnVariable.c_str(), str.str().c_str());
+      this->Makefile->AddDefinition(returnVariable, str.str().c_str());
       }
     }
   return true;
diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h
index f34bd13..0998e5c 100644
--- a/Source/CTest/cmCTestRunScriptCommand.h
+++ b/Source/CTest/cmCTestRunScriptCommand.h
@@ -47,7 +47,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_run_script";}
+  virtual std::string GetName() const { return "ctest_run_script";}
 
   cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand);
 };
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index cdf90b9..385388d 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -334,9 +334,9 @@
         *this->TestHandler->LogFile << "Test Failed.\n";
         }
       }
-    *this->TestHandler->LogFile << "\"" << this->TestProperties->Name.c_str()
+    *this->TestHandler->LogFile << "\"" << this->TestProperties->Name
       << "\" end time: " << this->CTest->CurrentTime() << std::endl
-      << "\"" << this->TestProperties->Name.c_str() << "\" time elapsed: "
+      << "\"" << this->TestProperties->Name << "\" time elapsed: "
       << buffer << std::endl
       << "----------------------------------------------------------"
       << std::endl << std::endl;
@@ -388,8 +388,8 @@
     }
   cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
              << ": process test output now: "
-             << this->TestProperties->Name.c_str() << " "
-             << this->TestResult.Name.c_str() << std::endl);
+             << this->TestProperties->Name << " "
+             << this->TestResult.Name << std::endl);
   cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
     (this->TestHandler);
   switch ( handler->MemoryTesterStyle )
@@ -465,9 +465,9 @@
       //Required file was not found
       this->TestProcess = new cmProcess;
       *this->TestHandler->LogFile << "Unable to find required file: "
-               << file.c_str() << std::endl;
+               << file << std::endl;
       cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: "
-               << file.c_str() << std::endl);
+               << file << std::endl);
       this->TestResult.Output = "Unable to find required file: " + file;
       this->TestResult.FullCommandLine = "";
       this->TestResult.CompletionStatus = "Not Run";
@@ -482,9 +482,9 @@
     // that has that information
     this->TestProcess = new cmProcess;
     *this->TestHandler->LogFile << "Unable to find executable: "
-                   << args[1].c_str() << std::endl;
+                   << args[1] << std::endl;
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: "
-               << args[1].c_str() << std::endl);
+               << args[1] << std::endl);
     this->TestResult.Output = "Unable to find executable: " + args[1];
     this->TestResult.FullCommandLine = "";
     this->TestResult.CompletionStatus = "Not Run";
@@ -711,7 +711,7 @@
   indexStr << " #" << this->Index << ":";
   cmCTestLog(this->CTest, HANDLER_OUTPUT,
              std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
-             << indexStr.str().c_str());
+             << indexStr.str());
   cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
   const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
   std::string outname = this->TestProperties->Name + " ";
@@ -722,18 +722,18 @@
     << this->TestProperties->Name << std::endl;
   *this->TestHandler->LogFile << this->TestProperties->Index << "/"
     << this->TestHandler->TotalNumberOfTests
-    << " Test: " << this->TestProperties->Name.c_str() << std::endl;
+    << " Test: " << this->TestProperties->Name << std::endl;
   *this->TestHandler->LogFile << "Command: \"" << this->ActualCommand << "\"";
 
   for (std::vector<std::string>::iterator i = this->Arguments.begin();
        i != this->Arguments.end(); ++i)
     {
     *this->TestHandler->LogFile
-      << " \"" << i->c_str() << "\"";
+      << " \"" << *i << "\"";
     }
   *this->TestHandler->LogFile << std::endl
     << "Directory: " << this->TestProperties->Directory << std::endl
-    << "\"" << this->TestProperties->Name.c_str() << "\" start time: "
+    << "\"" << this->TestProperties->Name << "\" start time: "
     << this->StartTime << std::endl;
 
   *this->TestHandler->LogFile
@@ -741,9 +741,9 @@
     << "----------------------------------------------------------"
     << std::endl;
   *this->TestHandler->LogFile
-    << this->ProcessOutput.c_str() << "<end of output>" << std::endl;
+    << this->ProcessOutput << "<end of output>" << std::endl;
 
   cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str());
   cmCTestLog(this->CTest, DEBUG, "Testing "
-             << this->TestProperties->Name.c_str() << " ... ");
+             << this->TestProperties->Name << " ... ");
 }
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 2668c8e..86dc2f2 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -277,7 +277,7 @@
     {
     opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions");
     }
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
+  std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
 
   // Specify the start time for nightly testing.
   if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -287,7 +287,7 @@
 
   std::vector<char const*> svn_update;
   svn_update.push_back("update");
-  for(std::vector<cmStdString>::const_iterator ai = args.begin();
+  for(std::vector<std::string>::const_iterator ai = args.begin();
       ai != args.end(); ++ai)
     {
     svn_update.push_back(ai->c_str());
@@ -314,9 +314,9 @@
   std::string userOptions =
     this->CTest->GetCTestConfiguration("SVNOptions");
 
-  std::vector<cmStdString> parsedUserOptions =
+  std::vector<std::string> parsedUserOptions =
     cmSystemTools::ParseArguments(userOptions.c_str());
-  for(std::vector<cmStdString>::iterator i = parsedUserOptions.begin();
+  for(std::vector<std::string>::iterator i = parsedUserOptions.begin();
       i != parsedUserOptions.end(); ++i)
     {
     args.push_back(i->c_str());
@@ -361,10 +361,10 @@
     return true;
     }
 
-  virtual void StartElement(const char* name, const char** atts)
+  virtual void StartElement(const std::string& name, const char** atts)
     {
     this->CData.clear();
-    if(strcmp(name, "logentry") == 0)
+    if(name == "logentry")
       {
       this->Rev = Revision();
       this->Rev.SVNInfo = &SVNRepo;
@@ -374,7 +374,7 @@
         }
       this->Changes.clear();
       }
-    else if(strcmp(name, "path") == 0)
+    else if(name == "path")
       {
       this->CurChange = Change();
       if(const char* action = this->FindAttribute(atts, "action"))
@@ -389,28 +389,28 @@
     this->CData.insert(this->CData.end(), data, data+length);
     }
 
-  virtual void EndElement(const char* name)
+  virtual void EndElement(const std::string& name)
     {
-    if(strcmp(name, "logentry") == 0)
+    if(name == "logentry")
       {
       this->SVN->DoRevisionSVN(this->Rev, this->Changes);
       }
-    else if(strcmp(name, "path") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "path")
       {
       std::string orig_path(&this->CData[0], this->CData.size());
       std::string new_path = SVNRepo.BuildLocalPath( orig_path );
       this->CurChange.Path.assign(new_path);
       this->Changes.push_back(this->CurChange);
       }
-    else if(strcmp(name, "author") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "author")
       {
       this->Rev.Author.assign(&this->CData[0], this->CData.size());
       }
-    else if(strcmp(name, "date") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "date")
       {
       this->Rev.Date.assign(&this->CData[0], this->CData.size());
       }
-    else if(strcmp(name, "msg") == 0 && !this->CData.empty())
+    else if(!this->CData.empty() && name == "msg")
       {
       this->Rev.Log.assign(&this->CData[0], this->CData.size());
       }
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 00a0a09..567acfc 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -231,7 +231,7 @@
              cmSystemTools::GetCTestCommand() << "\n");
 
   // now pass through all the other arguments
-  std::vector<cmStdString> &initArgs =
+  std::vector<std::string> &initArgs =
     this->CTest->GetInitialCommandLineArguments();
   //*** need to make sure this does not have the current script ***
   for(size_t i=1; i < initArgs.size(); ++i)
@@ -337,8 +337,8 @@
   // Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR.
   // Also, some commands need Makefile->GetCurrentDirectory().
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  this->Makefile->SetStartDirectory(cwd.c_str());
-  this->Makefile->SetStartOutputDirectory(cwd.c_str());
+  this->Makefile->SetStartDirectory(cwd);
+  this->Makefile->SetStartOutputDirectory(cwd);
 
   // remove all cmake commands which are not scriptable, since they can't be
   // used in ctest scripts
@@ -426,7 +426,7 @@
       cmSystemTools::GetErrorOccuredFlag())
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:"
-               << systemFile.c_str() << "\n");
+               << systemFile << "\n");
     return 2;
     }
 
@@ -436,7 +436,7 @@
   for (std::map<std::string, std::string>::const_iterator it = defs.begin();
        it != defs.end(); ++it)
     {
-    this->Makefile->AddDefinition(it->first.c_str(), it->second.c_str());
+    this->Makefile->AddDefinition(it->first, it->second.c_str());
     }
 
   // finally read in the script
@@ -444,7 +444,7 @@
     cmSystemTools::GetErrorOccuredFlag())
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: "
-               << script.c_str()
+               << script
                << std::endl);
     // Reset the error flag so that it can run more than
     // one script with an error when you
@@ -646,7 +646,7 @@
   if (!this->CTestEnv.empty())
     {
     std::vector<std::string> envArgs;
-    cmSystemTools::ExpandListArgument(this->CTestEnv.c_str(),envArgs);
+    cmSystemTools::ExpandListArgument(this->CTestEnv,envArgs);
     cmSystemTools::AppendEnv(envArgs);
     }
 
@@ -766,13 +766,13 @@
 
   // do an initial cvs update as required
   command = this->UpdateCmd;
-  std::vector<cmStdString>::iterator it;
+  std::vector<std::string>::iterator it;
   for (it = this->ExtraUpdates.begin();
     it != this->ExtraUpdates.end();
     ++ it )
     {
     std::vector<std::string> cvsArgs;
-    cmSystemTools::ExpandListArgument(it->c_str(),cvsArgs);
+    cmSystemTools::ExpandListArgument(*it,cvsArgs);
     if (cvsArgs.size() == 2)
       {
       std::string fullCommand = command;
@@ -781,7 +781,7 @@
       output = "";
       retVal = 0;
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: "
-        << fullCommand.c_str() << std::endl);
+        << fullCommand << std::endl);
       res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output,
         &retVal, cvsArgs[0].c_str(),
         this->HandlerVerbose, 0 /*this->TimeOut*/);
@@ -902,7 +902,7 @@
     command += "\"";
     retVal = 0;
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: "
-      << command.c_str() << std::endl);
+      << command << std::endl);
     res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
       &retVal, this->BinaryDir.c_str(),
       this->HandlerVerbose, 0 /*this->TimeOut*/);
@@ -916,7 +916,7 @@
         }
 
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
-        "Write CMake output to file: " << cmakeOutputFile.c_str()
+        "Write CMake output to file: " << cmakeOutputFile
         << std::endl);
       cmGeneratedFileStream fout(cmakeOutputFile.c_str());
       if ( fout )
@@ -927,7 +927,7 @@
         {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
           "Cannot open CMake output file: "
-          << cmakeOutputFile.c_str() << " for writing" << std::endl);
+          << cmakeOutputFile << " for writing" << std::endl);
         }
       }
     if (!res || retVal != 0)
@@ -948,7 +948,7 @@
     output = "";
     retVal = 0;
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: "
-      << command.c_str() << std::endl);
+      << command << std::endl);
     res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
       &retVal, this->BinaryDir.c_str(), this->HandlerVerbose,
       0 /*this->TimeOut*/);
@@ -962,13 +962,13 @@
         {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
           "Unable to run cmake:" << std::endl
-          << cmakeFailedOuput.c_str() << std::endl);
+          << cmakeFailedOuput << std::endl);
         return 10;
         }
       cmCTestLog(this->CTest, ERROR_MESSAGE,
         "Unable to run ctest:" << std::endl
-        << "command: " << command.c_str() << std::endl
-        << "output: " << output.c_str() << std::endl);
+        << "command: " << command << std::endl
+        << "output: " << output << std::endl);
       if (!res)
         {
         return 11;
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index 44e9dd0..42c2f20 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -138,26 +138,26 @@
   // Try to remove the binary directory once
   static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath);
 
-  std::vector<cmStdString> ConfigurationScripts;
+  std::vector<std::string> ConfigurationScripts;
   std::vector<bool> ScriptProcessScope;
 
   bool Backup;
   bool EmptyBinDir;
   bool EmptyBinDirOnce;
 
-  cmStdString SourceDir;
-  cmStdString BinaryDir;
-  cmStdString BackupSourceDir;
-  cmStdString BackupBinaryDir;
-  cmStdString CTestRoot;
-  cmStdString CVSCheckOut;
-  cmStdString CTestCmd;
-  cmStdString UpdateCmd;
-  cmStdString CTestEnv;
-  cmStdString InitialCache;
-  cmStdString CMakeCmd;
-  cmStdString CMOutFile;
-  std::vector<cmStdString> ExtraUpdates;
+  std::string SourceDir;
+  std::string BinaryDir;
+  std::string BackupSourceDir;
+  std::string BackupBinaryDir;
+  std::string CTestRoot;
+  std::string CVSCheckOut;
+  std::string CTestCmd;
+  std::string UpdateCmd;
+  std::string CTestEnv;
+  std::string InitialCache;
+  std::string CMakeCmd;
+  std::string CMOutFile;
+  std::vector<std::string> ExtraUpdates;
 
   double MinimumInterval;
   double ContinuousDuration;
diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h
index c6baf1c..740a7e1 100644
--- a/Source/CTest/cmCTestSleepCommand.h
+++ b/Source/CTest/cmCTestSleepCommand.h
@@ -47,7 +47,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_sleep";}
+  virtual std::string GetName() const { return "ctest_sleep";}
 
   cmTypeMacro(cmCTestSleepCommand, cmCTestCommand);
 
diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx
index 228a173..da46f4a 100644
--- a/Source/CTest/cmCTestStartCommand.cxx
+++ b/Source/CTest/cmCTestStartCommand.cxx
@@ -131,7 +131,7 @@
       << "  " << sourceDir << "\n"
       << "which is not an existing directory.  "
       << "Set CTEST_CHECKOUT_COMMAND to a command line to create it.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -160,7 +160,7 @@
     {
     // Use a generic VC object to run and log the command.
     cmCTestVC vc(this->CTest, ofs);
-    vc.SetSourceDirectory(sourceDir.c_str());
+    vc.SetSourceDirectory(sourceDir);
     if(!vc.InitialCheckout(initialCheckoutCommand))
       {
       return false;
diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h
index e5535c1..3b8843f 100644
--- a/Source/CTest/cmCTestStartCommand.h
+++ b/Source/CTest/cmCTestStartCommand.h
@@ -55,7 +55,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_start";}
+  virtual std::string GetName() const { return "ctest_start";}
 
   cmTypeMacro(cmCTestStartCommand, cmCTestCommand);
 
diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx
index 24974e3..07a994d 100644
--- a/Source/CTest/cmCTestSubmitCommand.cxx
+++ b/Source/CTest/cmCTestSubmitCommand.cxx
@@ -72,7 +72,7 @@
   if (notesFilesVariable)
     {
     std::vector<std::string> notesFiles;
-    std::vector<cmStdString> newNotesFiles;
+    cmCTest::VectorOfStrings newNotesFiles;
     cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
     std::vector<std::string>::iterator it;
     for ( it = notesFiles.begin();
@@ -89,7 +89,7 @@
   if (extraFilesVariable)
     {
     std::vector<std::string> extraFiles;
-    std::vector<cmStdString> newExtraFiles;
+    cmCTest::VectorOfStrings newExtraFiles;
     cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
     std::vector<std::string>::iterator it;
     for ( it = extraFiles.begin();
@@ -222,7 +222,7 @@
 
   if(this->ArgumentDoing == ArgumentDoingFiles)
     {
-    cmStdString filename(arg);
+    std::string filename(arg);
     if(cmSystemTools::FileExists(filename.c_str()))
       {
       this->Files.insert(filename);
diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h
index 64c6cae..3673fbd 100644
--- a/Source/CTest/cmCTestSubmitCommand.h
+++ b/Source/CTest/cmCTestSubmitCommand.h
@@ -48,7 +48,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_submit";}
+  virtual std::string GetName() const { return "ctest_submit";}
 
   cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand);
 
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 139f515..7c72cba 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -68,10 +68,10 @@
     return val;
     }
 
-  virtual void StartElement(const char* name, const char** atts)
+  virtual void StartElement(const std::string& name, const char** atts)
     {
     this->CurrentValue.clear();
-    if(strcmp(name, "cdash") == 0)
+    if(name == "cdash")
       {
       this->CDashVersion = this->FindAttribute(atts, "version");
       }
@@ -82,9 +82,9 @@
     this->CurrentValue.insert(this->CurrentValue.end(), data, data+length);
     }
 
-  virtual void EndElement(const char* name)
+  virtual void EndElement(const std::string& name)
     {
-    if(strcmp(name, "status") == 0)
+    if(name == "status")
       {
       std::string status = cmSystemTools::UpperCase(this->GetCurrentValue());
       if(status == "OK" || status == "SUCCESS")
@@ -100,15 +100,15 @@
         this->Status = STATUS_ERROR;
         }
       }
-    else if(strcmp(name, "filename") == 0)
+    else if(name == "filename")
       {
       this->Filename = this->GetCurrentValue();
       }
-    else if(strcmp(name, "md5") == 0)
+    else if(name == "md5")
       {
       this->MD5 = this->GetCurrentValue();
       }
-    else if(strcmp(name, "message") == 0)
+    else if(name == "message")
       {
       this->Message = this->GetCurrentValue();
       }
@@ -170,10 +170,10 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
-  const std::set<cmStdString>& files,
-  const cmStdString& remoteprefix,
-  const cmStdString& url)
+bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
+  const std::set<std::string>& files,
+  const std::string& remoteprefix,
+  const std::string& url)
 {
   CURL *curl;
   CURLcode res;
@@ -217,30 +217,30 @@
 
       ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
 
-      cmStdString local_file = *file;
+      std::string local_file = *file;
       if ( !cmSystemTools::FileExists(local_file.c_str()) )
         {
         local_file = localprefix + "/" + *file;
         }
-      cmStdString upload_as
+      std::string upload_as
         = url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
 
       struct stat st;
       if ( ::stat(local_file.c_str(), &st) )
         {
         cmCTestLog(this->CTest, ERROR_MESSAGE, "   Cannot find file: "
-          << local_file.c_str() << std::endl);
+          << local_file << std::endl);
         ::curl_easy_cleanup(curl);
         ::curl_global_cleanup();
         return false;
         }
 
       ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
-      *this->LogFile << "\tUpload file: " << local_file.c_str() << " to "
-          << upload_as.c_str() << std::endl;
+      *this->LogFile << "\tUpload file: " << local_file << " to "
+          << upload_as << std::endl;
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   Upload file: "
-        << local_file.c_str() << " to "
-        << upload_as.c_str() << std::endl);
+        << local_file << " to "
+        << upload_as << std::endl);
 
       ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
 
@@ -290,11 +290,11 @@
         {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
           "   Error when uploading file: "
-          << local_file.c_str() << std::endl);
+          << local_file << std::endl);
         cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error message was: "
           << error_buffer << std::endl);
         *this->LogFile << "   Error when uploading file: "
-                       << local_file.c_str()
+                       << local_file
                        << std::endl
                        << "   Error message was: "
                        << error_buffer << std::endl
@@ -324,10 +324,10 @@
 
 //----------------------------------------------------------------------------
 // Uploading files is simpler
-bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
-  const std::set<cmStdString>& files,
-  const cmStdString& remoteprefix,
-  const cmStdString& url)
+bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
+  const std::set<std::string>& files,
+  const std::string& remoteprefix,
+  const std::string& url)
 {
   CURL *curl;
   CURLcode res;
@@ -336,10 +336,10 @@
 
   /* In windows, this will init the winsock stuff */
   ::curl_global_init(CURL_GLOBAL_ALL);
-  cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
-  cmStdString curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
+  std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
+  std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
   std::vector<std::string> args;
-  cmSystemTools::ExpandListArgument(curlopt.c_str(), args);
+  cmSystemTools::ExpandListArgument(curlopt, args);
   bool verifyPeerOff = false;
   bool verifyHostOff = false;
   for( std::vector<std::string>::iterator i = args.begin();
@@ -354,7 +354,7 @@
       verifyHostOff = true;
       }
     }
-  cmStdString::size_type kk;
+  std::string::size_type kk;
   cmCTest::SetOfStrings::const_iterator file;
   for ( file = files.begin(); file != files.end(); ++file )
     {
@@ -414,18 +414,18 @@
       ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
       ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
 
-      cmStdString local_file = *file;
+      std::string local_file = *file;
       if ( !cmSystemTools::FileExists(local_file.c_str()) )
         {
         local_file = localprefix + "/" + *file;
         }
-      cmStdString remote_file
+      std::string remote_file
         = remoteprefix + cmSystemTools::GetFilenameName(*file);
 
-      *this->LogFile << "\tUpload file: " << local_file.c_str() << " to "
-          << remote_file.c_str() << std::endl;
+      *this->LogFile << "\tUpload file: " << local_file << " to "
+          << remote_file << std::endl;
 
-      cmStdString ofile = "";
+      std::string ofile = "";
       for ( kk = 0; kk < remote_file.size(); kk ++ )
         {
         char c = remote_file[kk];
@@ -448,8 +448,8 @@
           ofile.append(hexCh);
           }
         }
-      cmStdString upload_as
-        = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&")
+      std::string upload_as
+        = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
         + "FileName=" + ofile;
 
       upload_as += "&MD5=";
@@ -461,7 +461,7 @@
       else
         {
         char md5[33];
-        cmSystemTools::ComputeFileMD5(local_file.c_str(), md5);
+        cmSystemTools::ComputeFileMD5(local_file, md5);
         md5[32] = 0;
         upload_as += md5;
         }
@@ -470,7 +470,7 @@
       if ( ::stat(local_file.c_str(), &st) )
         {
         cmCTestLog(this->CTest, ERROR_MESSAGE, "   Cannot find file: "
-          << local_file.c_str() << std::endl);
+          << local_file << std::endl);
         ::curl_easy_cleanup(curl);
         ::curl_global_cleanup();
         return false;
@@ -478,8 +478,8 @@
 
       ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   Upload file: "
-        << local_file.c_str() << " to "
-        << upload_as.c_str() << " Size: " << st.st_size << std::endl);
+        << local_file << " to "
+        << upload_as << " Size: " << st.st_size << std::endl);
 
       // specify target
       ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
@@ -595,11 +595,11 @@
         {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
           "   Error when uploading file: "
-          << local_file.c_str() << std::endl);
+          << local_file << std::endl);
         cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error message was: "
           << error_buffer << std::endl);
         *this->LogFile << "   Error when uploading file: "
-                       << local_file.c_str()
+                       << local_file
                        << std::endl
                        << "   Error message was: " << error_buffer
                        << std::endl;
@@ -666,9 +666,9 @@
 
 //----------------------------------------------------------------------------
 bool cmCTestSubmitHandler::TriggerUsingHTTP(
-  const std::set<cmStdString>& files,
-  const cmStdString& remoteprefix,
-  const cmStdString& url)
+  const std::set<std::string>& files,
+  const std::string& remoteprefix,
+  const std::string& url)
 {
   CURL *curl;
   char error_buffer[1024];
@@ -721,10 +721,10 @@
       ::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
       ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
 
-      cmStdString rfile
+      std::string rfile
         = remoteprefix + cmSystemTools::GetFilenameName(*file);
-      cmStdString ofile = "";
-      cmStdString::iterator kk;
+      std::string ofile = "";
+      std::string::iterator kk;
       for ( kk = rfile.begin(); kk < rfile.end(); ++ kk)
         {
         char c = *kk;
@@ -747,18 +747,18 @@
           ofile.append(hexCh);
           }
         }
-      cmStdString turl
-        = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&")
+      std::string turl
+        = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
         + "xmlfile=" + ofile;
-      *this->LogFile << "Trigger url: " << turl.c_str() << std::endl;
+      *this->LogFile << "Trigger url: " << turl << std::endl;
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   Trigger url: "
-        << turl.c_str() << std::endl);
+        << turl << std::endl);
       curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
       curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
       if ( curl_easy_perform(curl) )
         {
         cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error when triggering: "
-          << turl.c_str() << std::endl);
+          << turl << std::endl);
         cmCTestLog(this->CTest, ERROR_MESSAGE, "   Error message was: "
           << error_buffer << std::endl);
         *this->LogFile << "\tTriggering failed with error: " << error_buffer
@@ -805,11 +805,11 @@
 
 //----------------------------------------------------------------------------
 bool cmCTestSubmitHandler::SubmitUsingSCP(
-  const cmStdString& scp_command,
-  const cmStdString& localprefix,
-  const std::set<cmStdString>& files,
-  const cmStdString& remoteprefix,
-  const cmStdString& url)
+  const std::string& scp_command,
+  const std::string& localprefix,
+  const std::set<std::string>& files,
+  const std::string& remoteprefix,
+  const std::string& url)
 {
   if ( !scp_command.size() || !localprefix.size() ||
     !files.size() || !remoteprefix.size() || !url.size() )
@@ -906,10 +906,10 @@
 
 //----------------------------------------------------------------------------
 bool cmCTestSubmitHandler::SubmitUsingCP(
-  const cmStdString& localprefix,
-  const std::set<cmStdString>& files,
-  const cmStdString& remoteprefix,
-  const cmStdString& destination)
+  const std::string& localprefix,
+  const std::set<std::string>& files,
+  const std::string& remoteprefix,
+  const std::string& destination)
 {
   if ( !localprefix.size() ||
     !files.size() || !remoteprefix.size() || !destination.size() )
@@ -932,8 +932,8 @@
     std::string rfname = destination + "/" + remoteprefix + *file;
     cmSystemTools::CopyFileAlways(lfname.c_str(), rfname.c_str());
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   Copy file: "
-        << lfname.c_str() << " to "
-        << rfname.c_str() << std::endl);
+        << lfname << " to "
+        << rfname << std::endl);
     }
   std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
   cmSystemTools::Touch(tagDoneFile.c_str(), true);
@@ -947,17 +947,17 @@
 
 //----------------------------------------------------------------------------
 #if defined(CTEST_USE_XMLRPC)
-bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
-  const std::set<cmStdString>& files,
-  const cmStdString& remoteprefix,
-  const cmStdString& url)
+bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix,
+  const std::set<std::string>& files,
+  const std::string& remoteprefix,
+  const std::string& url)
 {
   xmlrpc_env env;
   char ctestString[] = "CTest";
   std::string ctestVersionString = cmVersion::GetCMakeVersion();
   char* ctestVersion = const_cast<char*>(ctestVersionString.c_str());
 
-  cmStdString realURL = url + "/" + remoteprefix + "/Command/";
+  std::string realURL = url + "/" + remoteprefix + "/Command/";
 
   /* Start up our XML-RPC client library. */
   xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion);
@@ -973,7 +973,7 @@
     {
     xmlrpc_value *result;
 
-    cmStdString local_file = *file;
+    std::string local_file = *file;
     if ( !cmSystemTools::FileExists(local_file.c_str()) )
       {
       local_file = localprefix + "/" + *file;
@@ -1045,10 +1045,10 @@
   return true;
 }
 #else
-bool cmCTestSubmitHandler::SubmitUsingXMLRPC(cmStdString const&,
-                                             std::set<cmStdString> const&,
-                                             cmStdString const&,
-                                             cmStdString const&)
+bool cmCTestSubmitHandler::SubmitUsingXMLRPC(std::string const&,
+                                             std::set<std::string> const&,
+                                             std::string const&,
+                                             std::string const&)
 {
   return false;
 }
@@ -1085,7 +1085,7 @@
       }
     if ( getenv("HTTP_PROXY_TYPE") )
       {
-      cmStdString type = getenv("HTTP_PROXY_TYPE");
+      std::string type = getenv("HTTP_PROXY_TYPE");
       // HTTP/SOCKS4/SOCKS5
       if ( type == "HTTP" )
         {
@@ -1122,7 +1122,7 @@
       }
     if ( getenv("FTP_PROXY_TYPE") )
       {
-      cmStdString type = getenv("FTP_PROXY_TYPE");
+      std::string type = getenv("FTP_PROXY_TYPE");
       // HTTP/SOCKS4/SOCKS5
       if ( type == "HTTP" )
         {
@@ -1178,12 +1178,12 @@
   this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml");
   if(this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml"))
     {
-    cmCTest::VectorOfStrings gfiles;
+    std::vector<std::string> gfiles;
     std::string gpath
       = buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
     std::string::size_type glen = gpath.size() + 1;
     gpath = gpath + "/CoverageLog*";
-    cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath.c_str()
+    cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath
       << std::endl);
     if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) )
       {
@@ -1191,7 +1191,7 @@
       for ( cc = 0; cc < gfiles.size(); cc ++ )
         {
         gfiles[cc] = gfiles[cc].substr(glen);
-        cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc].c_str()
+        cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc]
           << std::endl);
         this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str());
         }
@@ -1232,7 +1232,7 @@
     cmCTest::SetOfStrings::iterator it;
     for ( it = files.begin(); it != files.end(); ++ it )
       {
-      ofs << cnt << "\t" << it->c_str() << std::endl;
+      ofs << cnt << "\t" << *it << std::endl;
       cnt ++;
       }
     }
@@ -1247,7 +1247,7 @@
     }
   this->SetLogFile(&ofs);
 
-  cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
+  std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
 
   if ( dropMethod == "" || dropMethod == "ftp" )
     {
@@ -1448,7 +1448,7 @@
       oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
     cmSystemTools::ChangeDirectory(buildDirectory.c_str());
     cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "   Change directory: "
-               << buildDirectory.c_str() << std::endl);
+               << buildDirectory << std::endl);
 
     if ( !this->SubmitUsingCP(
            "Testing/"+this->CTest->GetCurrentTag(),
diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h
index 14eac80..accabd1 100644
--- a/Source/CTest/cmCTestSubmitHandler.h
+++ b/Source/CTest/cmCTestSubmitHandler.h
@@ -47,33 +47,33 @@
   /**
    * Submit file using various ways
    */
-  bool SubmitUsingFTP(const cmStdString& localprefix,
-                      const std::set<cmStdString>& files,
-                      const cmStdString& remoteprefix,
-                      const cmStdString& url);
-  bool SubmitUsingHTTP(const cmStdString& localprefix,
-                       const std::set<cmStdString>& files,
-                       const cmStdString& remoteprefix,
-                       const cmStdString& url);
-  bool SubmitUsingSCP(const cmStdString& scp_command,
-                      const cmStdString& localprefix,
-                      const std::set<cmStdString>& files,
-                      const cmStdString& remoteprefix,
-                      const cmStdString& url);
+  bool SubmitUsingFTP(const std::string& localprefix,
+                      const std::set<std::string>& files,
+                      const std::string& remoteprefix,
+                      const std::string& url);
+  bool SubmitUsingHTTP(const std::string& localprefix,
+                       const std::set<std::string>& files,
+                       const std::string& remoteprefix,
+                       const std::string& url);
+  bool SubmitUsingSCP(const std::string& scp_command,
+                      const std::string& localprefix,
+                      const std::set<std::string>& files,
+                      const std::string& remoteprefix,
+                      const std::string& url);
 
-  bool SubmitUsingCP( const cmStdString& localprefix,
-                      const std::set<cmStdString>& files,
-                      const cmStdString& remoteprefix,
-                      const cmStdString& url);
+  bool SubmitUsingCP( const std::string& localprefix,
+                      const std::set<std::string>& files,
+                      const std::string& remoteprefix,
+                      const std::string& url);
 
-  bool TriggerUsingHTTP(const std::set<cmStdString>& files,
-                        const cmStdString& remoteprefix,
-                        const cmStdString& url);
+  bool TriggerUsingHTTP(const std::set<std::string>& files,
+                        const std::string& remoteprefix,
+                        const std::string& url);
 
-  bool SubmitUsingXMLRPC(const cmStdString& localprefix,
-                       const std::set<cmStdString>& files,
-                       const cmStdString& remoteprefix,
-                       const cmStdString& url);
+  bool SubmitUsingXMLRPC(const std::string& localprefix,
+                       const std::set<std::string>& files,
+                       const std::string& remoteprefix,
+                       const std::string& url);
 
   typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
 
@@ -82,10 +82,10 @@
   std::string GetSubmitResultsPrefix();
 
   class         ResponseParser;
-  cmStdString   HTTPProxy;
+  std::string   HTTPProxy;
   int           HTTPProxyType;
-  cmStdString   HTTPProxyAuth;
-  cmStdString   FTPProxy;
+  std::string   HTTPProxyAuth;
+  std::string   FTPProxy;
   int           FTPProxyType;
   std::ostream* LogFile;
   bool SubmitPart[cmCTest::PartCount];
diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h
index 451ac99..a1e5f36 100644
--- a/Source/CTest/cmCTestTestCommand.h
+++ b/Source/CTest/cmCTestTestCommand.h
@@ -39,7 +39,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_test";}
+  virtual std::string GetName() const { return "ctest_test";}
 
   cmTypeMacro(cmCTestTestCommand, cmCTestHandlerCommand);
 
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 3a04b33..f21d166 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -60,7 +60,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "subdirs";}
+  virtual std::string GetName() const { return "subdirs";}
 
   cmTypeMacro(cmCTestSubdirCommand, cmCommand);
 
@@ -125,7 +125,7 @@
       {
       std::string m = "Could not find include file: ";
       m += fname;
-      this->SetError(m.c_str());
+      this->SetError(m);
       return false;
       }
     }
@@ -157,7 +157,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "add_subdirectory";}
+  virtual std::string GetName() const { return "add_subdirectory";}
 
   cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand);
 
@@ -213,7 +213,7 @@
     {
     std::string m = "Could not find include file: ";
     m += fname;
-    this->SetError(m.c_str());
+    this->SetError(m);
     return false;
     }
   return true;
@@ -243,7 +243,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "add_test";}
+  virtual std::string GetName() const { return "add_test";}
 
   cmTypeMacro(cmCTestAddTestCommand, cmCommand);
 
@@ -287,7 +287,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "set_tests_properties";}
+  virtual std::string GetName() const { return "set_tests_properties";}
 
   cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand);
 
@@ -509,7 +509,7 @@
   if ( val )
     {
     this->UseExcludeLabelRegExpFlag = true;
-    this->ExcludeLabelRegularExpression = val;
+    this->ExcludeLabelRegExp = val;
     }
   val = this->GetOption("IncludeRegularExpression");
   if ( val )
@@ -540,8 +540,8 @@
   this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile);
   this->LogFile = &mLogFile;
 
-  std::vector<cmStdString> passed;
-  std::vector<cmStdString> failed;
+  std::vector<std::string> passed;
+  std::vector<std::string> failed;
   int total;
 
   //start the real time clock
@@ -569,7 +569,7 @@
       {
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
         << "The following tests passed:" << std::endl);
-      for(std::vector<cmStdString>::iterator j = passed.begin();
+      for(std::vector<std::string>::iterator j = passed.begin();
           j != passed.end(); ++j)
         {
         cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j
@@ -616,7 +616,7 @@
           ofs << ftit->TestCount << ":" << ftit->Name << std::endl;
           cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3)
                      << ftit->TestCount << " - "
-                     << ftit->Name.c_str() << " ("
+                     << ftit->Name << " ("
                      << this->GetTestStatus(ftit->Status) << ")"
                      << std::endl);
           }
@@ -661,8 +661,8 @@
   cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
   cmCTestTestHandler::TestResultsVector::iterator ri =
     this->TestResults.begin();
-  std::map<cmStdString, double> labelTimes;
-  std::set<cmStdString> labels;
+  std::map<std::string, double> labelTimes;
+  std::set<std::string> labels;
   // initialize maps
   std::string::size_type maxlen = 0;
   for(; it != this->TestList.end(); ++it)
@@ -702,7 +702,7 @@
     {
     cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:");
     }
-  for(std::set<cmStdString>::const_iterator i = labels.begin();
+  for(std::set<std::string>::const_iterator i = labels.begin();
       i != labels.end(); ++i)
     {
     std::string label = *i;
@@ -1022,7 +1022,7 @@
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "parse error: missing tag: "
-               << tag << " found [" << line.c_str() << "]" << std::endl);
+               << tag << " found [" << line << "]" << std::endl);
     ret = false;
     }
   return ret;
@@ -1050,8 +1050,8 @@
 }
 
 //---------------------------------------------------------------------
-void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
-                                         std::vector<cmStdString> &failed)
+void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed,
+                                         std::vector<std::string> &failed)
 {
   this->ComputeTestList();
   this->StartTest = this->CTest->CurrentTime();
@@ -1216,14 +1216,14 @@
       << "name=\"Command Line\"><Value>"
       << cmXMLSafe(result->FullCommandLine)
       << "</Value></NamedMeasurement>\n";
-    std::map<cmStdString,cmStdString>::iterator measureIt;
+    std::map<std::string,std::string>::iterator measureIt;
     for ( measureIt = result->Properties->Measurements.begin();
       measureIt != result->Properties->Measurements.end();
       ++ measureIt )
       {
       os
         << "\t\t\t<NamedMeasurement type=\"text/string\" "
-        << "name=\"" << measureIt->first.c_str() << "\"><Value>"
+        << "name=\"" << measureIt->first << "\"><Value>"
         << cmXMLSafe(measureIt->second)
         << "</Value></NamedMeasurement>\n";
       }
@@ -1328,9 +1328,9 @@
 }
 
 //----------------------------------------------------------------------
-int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec)
+int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
 {
-  std::vector<cmStdString>::iterator it;
+  std::vector<std::string>::iterator it;
   for ( it = vec.begin(); it != vec.end(); ++it )
     {
     int retVal = 0;
@@ -1506,7 +1506,7 @@
     // then try with the exe extension
     else
       {
-      failed.push_back(attempted[ai].c_str());
+      failed.push_back(attempted[ai]);
       tempPath = attempted[ai];
       tempPath += cmSystemTools::GetExecutableExtension();
       if(cmSystemTools::FileExists(tempPath.c_str())
@@ -1517,7 +1517,7 @@
         }
       else
         {
-        failed.push_back(tempPath.c_str());
+        failed.push_back(tempPath);
         }
       }
     }
@@ -1558,7 +1558,7 @@
     this->IncludeLabelRegularExpression.
       compile(this->IncludeLabelRegExp.c_str());
     }
-  if ( !this->IncludeLabelRegExp.empty() )
+  if ( !this->ExcludeLabelRegExp.empty() )
     {
     this->ExcludeLabelRegularExpression.
       compile(this->ExcludeLabelRegExp.c_str());
@@ -1820,7 +1820,7 @@
   else if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
     {
     cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: "
-      << lastTestsFailedLog.c_str() <<
+      << lastTestsFailedLog <<
       " while generating list of previously failed tests." << std::endl);
     }
 }
@@ -1960,7 +1960,7 @@
             << " " << k1 << "=\"" << v1 << "\""
             << " " << k2 << "=\"" << v2 << "\""
             << " encoding=\"none\""
-            << "><Value>Image " << filename.c_str()
+            << "><Value>Image " << filename
             << " is empty</Value></NamedMeasurement>";
           }
         else
@@ -2014,10 +2014,10 @@
           << "\t\t\t<NamedMeasurement"
           << " name=\"" << measurementfile.match(idx) << "\""
           << " text=\"text/string\""
-          << "><Value>File " << filename.c_str()
+          << "><Value>File " << filename
           << " not found</Value></NamedMeasurement>"
           << std::endl;
-        cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename.c_str()
+        cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename
           << "\" not found." << std::endl);
         }
       cxml.erase(measurementfile.start(),
@@ -2112,7 +2112,7 @@
   const std::vector<std::string>& args)
 {
   std::vector<std::string>::const_iterator it;
-  std::vector<cmStdString> tests;
+  std::vector<std::string> tests;
   bool found = false;
   for ( it = args.begin(); it != args.end(); ++ it )
     {
@@ -2137,7 +2137,7 @@
       break;
       }
     std::string val = *it;
-    std::vector<cmStdString>::const_iterator tit;
+    std::vector<std::string>::const_iterator tit;
     for ( tit = tests.begin(); tit != tests.end(); ++ tit )
       {
       cmCTestTestHandler::ListOfTests::iterator rtit;
@@ -2154,7 +2154,7 @@
           if ( key == "ATTACHED_FILES" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
 
             for(std::vector<std::string>::iterator f = lval.begin();
                 f != lval.end(); ++f)
@@ -2165,7 +2165,7 @@
           if ( key == "ATTACHED_FILES_ON_FAIL" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
 
             for(std::vector<std::string>::iterator f = lval.begin();
                 f != lval.end(); ++f)
@@ -2176,7 +2176,7 @@
           if ( key == "RESOURCE_LOCK" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
 
             for(std::vector<std::string>::iterator f = lval.begin();
                 f != lval.end(); ++f)
@@ -2196,7 +2196,7 @@
           if ( key == "REQUIRED_FILES" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
 
             for(std::vector<std::string>::iterator f = lval.begin();
                 f != lval.end(); ++f)
@@ -2211,14 +2211,14 @@
           if ( key == "FAIL_REGULAR_EXPRESSION" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
             std::vector<std::string>::iterator crit;
             for ( crit = lval.begin(); crit != lval.end(); ++ crit )
               {
               rtit->ErrorRegularExpressions.push_back(
                 std::pair<cmsys::RegularExpression, std::string>(
                   cmsys::RegularExpression(crit->c_str()),
-                  std::string(crit->c_str())));
+                  std::string(*crit)));
               }
             }
           if ( key == "PROCESSORS" )
@@ -2240,7 +2240,7 @@
           if ( key == "DEPENDS" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
             std::vector<std::string>::iterator crit;
             for ( crit = lval.begin(); crit != lval.end(); ++ crit )
               {
@@ -2250,7 +2250,7 @@
           if ( key == "ENVIRONMENT" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
             std::vector<std::string>::iterator crit;
             for ( crit = lval.begin(); crit != lval.end(); ++ crit )
               {
@@ -2260,7 +2260,7 @@
           if ( key == "LABELS" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
             std::vector<std::string>::iterator crit;
             for ( crit = lval.begin(); crit != lval.end(); ++ crit )
               {
@@ -2284,14 +2284,14 @@
           if ( key == "PASS_REGULAR_EXPRESSION" )
             {
             std::vector<std::string> lval;
-            cmSystemTools::ExpandListArgument(val.c_str(), lval);
+            cmSystemTools::ExpandListArgument(val, lval);
             std::vector<std::string>::iterator crit;
             for ( crit = lval.begin(); crit != lval.end(); ++ crit )
               {
               rtit->RequiredRegularExpressions.push_back(
                 std::pair<cmsys::RegularExpression, std::string>(
                   cmsys::RegularExpression(crit->c_str()),
-                  std::string(crit->c_str())));
+                  std::string(*crit)));
               }
             }
           if ( key == "WORKING_DIRECTORY" )
@@ -2319,7 +2319,7 @@
     }
   if ( this->MemCheck )
     {
-    std::vector<cmStdString>::iterator it;
+    std::vector<std::string>::iterator it;
     bool found = false;
     for ( it = this->CustomTestsIgnore.begin();
       it != this->CustomTestsIgnore.end(); ++ it )
@@ -2339,7 +2339,7 @@
     }
   else
     {
-    std::vector<cmStdString>::iterator it;
+    std::vector<std::string>::iterator it;
     bool found = false;
     for ( it = this->CustomTestsIgnore.begin();
       it != this->CustomTestsIgnore.end(); ++ it )
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 63f9c93..fe43bb8 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -87,8 +87,8 @@
   // ctest -j N will break for that feature
   struct cmCTestTestProperties
   {
-    cmStdString Name;
-    cmStdString Directory;
+    std::string Name;
+    std::string Directory;
     std::vector<std::string> Args;
     std::vector<std::string> RequiredFiles;
     std::vector<std::string> Depends;
@@ -98,7 +98,7 @@
                           std::string> > ErrorRegularExpressions;
     std::vector<std::pair<cmsys::RegularExpression,
                           std::string> > RequiredRegularExpressions;
-    std::map<cmStdString, cmStdString> Measurements;
+    std::map<std::string, std::string> Measurements;
     bool IsInBasedOnREOptions;
     bool WillFail;
     float Cost;
@@ -162,7 +162,7 @@
   virtual int PreProcessHandler();
   virtual int PostProcessHandler();
   virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
-  int ExecuteCommands(std::vector<cmStdString>& vec);
+  int ExecuteCommands(std::vector<std::string>& vec);
 
   void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result);
   void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result);
@@ -177,7 +177,7 @@
   typedef std::vector<cmCTestTestResult> TestResultsVector;
   TestResultsVector    TestResults;
 
-  std::vector<cmStdString> CustomTestsIgnore;
+  std::vector<std::string> CustomTestsIgnore;
   std::string             StartTest;
   std::string             EndTest;
   unsigned int            StartTestTime;
@@ -210,8 +210,8 @@
   /**
    * Run the tests for a directory and any subdirectories
    */
-  void ProcessDirectory(std::vector<cmStdString> &passed,
-                        std::vector<cmStdString> &failed);
+  void ProcessDirectory(std::vector<std::string> &passed,
+                        std::vector<std::string> &failed);
 
   /**
    * Get the list of tests in directory and subdirectories.
@@ -251,8 +251,8 @@
   void ExpandTestsToRunInformation(size_t numPossibleTests);
   void ExpandTestsToRunInformationForRerunFailed();
 
-  std::vector<cmStdString> CustomPreTest;
-  std::vector<cmStdString> CustomPostTest;
+  std::vector<std::string> CustomPreTest;
+  std::vector<std::string> CustomPostTest;
 
   std::vector<int>        TestsToRun;
 
diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h
index a785bd8..fb80333 100644
--- a/Source/CTest/cmCTestUpdateCommand.h
+++ b/Source/CTest/cmCTestUpdateCommand.h
@@ -39,7 +39,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_update";}
+  virtual std::string GetName() const { return "ctest_update";}
 
   cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand);
 
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index 11474ec..fda61ea 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -331,7 +331,7 @@
 {
   std::string sourceDirectory = dir;
   cmCTestLog(this->CTest, DEBUG, "Check directory: "
-    << sourceDirectory.c_str() << std::endl);
+    << sourceDirectory << std::endl);
   sourceDirectory += "/.svn";
   if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
     {
diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx
index 731c1c7..f7de294 100644
--- a/Source/CTest/cmCTestUploadCommand.cxx
+++ b/Source/CTest/cmCTestUploadCommand.cxx
@@ -47,7 +47,7 @@
 {
   if(this->ArgumentDoing == ArgumentDoingFiles)
     {
-    cmStdString filename(arg);
+    std::string filename(arg);
     if(cmSystemTools::FileExists(filename.c_str()))
       {
       this->Files.insert(filename);
diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h
index e867fb6..4a07608 100644
--- a/Source/CTest/cmCTestUploadCommand.h
+++ b/Source/CTest/cmCTestUploadCommand.h
@@ -43,7 +43,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "ctest_upload";}
+  virtual std::string GetName() const { return "ctest_upload";}
 
   cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand);
 
diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx
index caf2e53..4c3f81b 100644
--- a/Source/CTest/cmCTestUploadHandler.cxx
+++ b/Source/CTest/cmCTestUploadHandler.cxx
@@ -64,7 +64,7 @@
   for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
     {
     cmCTestLog(this->CTest, OUTPUT,
-               "\tUpload file: " << it->c_str() << std::endl);
+               "\tUpload file: " << *it << std::endl);
     ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n"
        << "<Content encoding=\"base64\">\n";
     ofs << this->CTest->Base64EncodeFile(*it);
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index fbee227..f89fa2b 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -63,9 +63,9 @@
     }
 
   // Construct the initial checkout command line.
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+  std::vector<std::string> args = cmSystemTools::ParseArguments(command);
   std::vector<char const*> vc_co;
-  for(std::vector<cmStdString>::const_iterator ai = args.begin();
+  for(std::vector<std::string>::const_iterator ai = args.begin();
       ai != args.end(); ++ai)
     {
     vc_co.push_back(ai->c_str());
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index 85e07ae..d17f169 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -215,7 +215,19 @@
       {
       coverageVector.push_back(-1);
       }
-    coverageVector[linenumber] += count;
+    // Accounts for lines that were previously marked
+    // as non-executable code (-1). if the parser comes back with
+    // a non-zero count, increase the count by 1 to push the line
+    // into the executable code set in addition to the count found.
+    if(coverageVector[linenumber] == -1 &&
+        count > 0)
+      {
+        coverageVector[linenumber] += count+1;
+      }
+    else
+      {
+        coverageVector[linenumber] += count;
+      }
     }
   return true;
 }
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
new file mode 100644
index 0000000..6b98056
--- /dev/null
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -0,0 +1,168 @@
+#include "cmStandardIncludes.h"
+#include "cmSystemTools.h"
+#include "cmXMLParser.h"
+#include "cmParseCoberturaCoverage.h"
+#include <cmsys/Directory.hxx>
+#include <cmsys/FStream.hxx>
+
+//----------------------------------------------------------------------------
+class cmParseCoberturaCoverage::XMLParser: public cmXMLParser
+{
+public:
+  XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
+    : CTest(ctest), Coverage(cont)
+  {
+   this->InSources = false;
+   this->InSource  = false;
+   this->FilePaths.push_back(this->Coverage.SourceDir);
+   this->CurFileName = "";
+  }
+
+  virtual ~XMLParser()
+  {
+  }
+
+protected:
+
+
+  virtual void EndElement(const std::string& name)
+  {
+   if(name == "source")
+     {
+     this->InSource=false;
+     }
+   else if (name == "sources")
+     {
+     this->InSources=false;
+     }
+  }
+
+  virtual void CharacterDataHandler(const char* data, int length)
+  {
+     std::string tmp;
+     tmp.insert(0,data,length);
+     if (this->InSources && this->InSource)
+       {
+       this->FilePaths.push_back(tmp);
+       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Adding Source: "
+                   << tmp << std::endl);
+       }
+  }
+
+  virtual void StartElement(const std::string& name, const char** atts)
+  {
+    std::string FoundSource;
+    std::string finalpath = "";
+    if(name == "source")
+    {
+      this->InSource = true;
+    }
+    else if(name == "sources")
+      {
+      this->InSources = true;
+      }
+    else if(name == "class")
+    {
+      int tagCount = 0;
+      while(true)
+      {
+        if(strcmp(atts[tagCount], "filename") == 0)
+        {
+          cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Reading file: "
+                     << atts[tagCount+1]<< std::endl);
+          std::string filename = atts[tagCount+1];
+          for(size_t i=0;i < FilePaths.size();i++)
+            {
+            finalpath = FilePaths[i] + "/" + filename;
+            if(cmSystemTools::FileExists(finalpath.c_str()))
+              {
+              this->CurFileName = finalpath;
+              break;
+              }
+            }
+          cmsys::ifstream fin(this->CurFileName.c_str());
+          if(this->CurFileName == "" || !fin )
+          {
+            this->CurFileName = this->Coverage.BinaryDir + "/" +
+                                   atts[tagCount+1];
+            fin.open(this->CurFileName.c_str());
+            if (!fin)
+            {
+              cmCTestLog(this->CTest, ERROR_MESSAGE,
+                         "Python Coverage: Error opening " << this->CurFileName
+                         << std::endl);
+              this->Coverage.Error++;
+              break;
+            }
+          }
+          std::string line;
+          FileLinesType& curFileLines =
+            this->Coverage.TotalCoverage[this->CurFileName];
+          curFileLines.push_back(-1);
+          while(cmSystemTools::GetLineFromStream(fin, line))
+          {
+            curFileLines.push_back(-1);
+          }
+
+          break;
+        }
+        ++tagCount;
+      }
+    }
+    else if(name == "line")
+    {
+      int tagCount = 0;
+      int curNumber = -1;
+      int curHits = -1;
+      while(true)
+      {
+        if(strcmp(atts[tagCount], "hits") == 0)
+        {
+          curHits = atoi(atts[tagCount+1]);
+        }
+        else if(strcmp(atts[tagCount], "number") == 0)
+        {
+          curNumber = atoi(atts[tagCount+1]);
+        }
+
+        if(curHits > -1 && curNumber > 0)
+        {
+          FileLinesType& curFileLines =
+            this->Coverage.TotalCoverage[this->CurFileName];
+            {
+            curFileLines[curNumber-1] = curHits;
+            }
+          break;
+        }
+        ++tagCount;
+      }
+    }
+  }
+
+private:
+
+  bool InSources;
+  bool InSource;
+  std::vector<std::string> FilePaths;
+  typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
+     FileLinesType;
+  cmCTest* CTest;
+  cmCTestCoverageHandlerContainer& Coverage;
+  std::string CurFileName;
+
+};
+
+
+cmParseCoberturaCoverage::cmParseCoberturaCoverage(
+    cmCTestCoverageHandlerContainer& cont,
+    cmCTest* ctest)
+    :Coverage(cont), CTest(ctest)
+{
+}
+
+bool cmParseCoberturaCoverage::ReadCoverageXML(const char* xmlFile)
+{
+  cmParseCoberturaCoverage::XMLParser parser(this->CTest, this->Coverage);
+  parser.ParseFile(xmlFile);
+  return true;
+}
diff --git a/Source/CTest/cmParseCoberturaCoverage.h b/Source/CTest/cmParseCoberturaCoverage.h
new file mode 100644
index 0000000..ff5954d
--- /dev/null
+++ b/Source/CTest/cmParseCoberturaCoverage.h
@@ -0,0 +1,51 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2000-2009 Kitware, Inc.
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef cmParseCoberturaCoverage_h
+#define cmParseCoberturaCoverage_h
+
+#include "cmStandardIncludes.h"
+#include "cmCTestCoverageHandler.h"
+
+/** \class cmParsePythonCoverage
+ * \brief Parse coverage.py Python coverage information
+ *
+ * This class is used to parse the output of the coverage.py tool that
+ * is currently maintained by Ned Batchelder. That tool has a command
+ * that produces xml output in the format typically output by the common
+ * Java-based Cobertura coverage application. This helper class parses
+ * that XML file to fill the coverage-handler container.
+ */
+class cmParseCoberturaCoverage
+{
+public:
+
+  //! Create the coverage parser by passing in the coverage handler
+  //! container and the cmCTest object
+  cmParseCoberturaCoverage(cmCTestCoverageHandlerContainer& cont,
+    cmCTest* ctest);
+
+  bool inSources;
+  bool inSource;
+  std::vector<std::string> filepaths;
+  //! Read the XML produced by running `coverage xml`
+  bool ReadCoverageXML(const char* xmlFile);
+
+private:
+
+  class XMLParser;
+  cmCTestCoverageHandlerContainer& Coverage;
+  cmCTest* CTest;
+  std::string CurFileName;
+};
+
+#endif
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx
index 528d0db..be10c2e 100644
--- a/Source/CTest/cmParseGTMCoverage.cxx
+++ b/Source/CTest/cmParseGTMCoverage.cxx
@@ -106,7 +106,19 @@
         {
         cmCTestCoverageHandlerContainer::SingleFileCoverageVector&
           coverageVector = this->Coverage.TotalCoverage[filepath];
-        coverageVector[lineoffset + linenumber] += count;
+        // This section accounts for lines that were previously marked
+        // as non-executable code (-1), if the parser comes back with
+        // a non-zero count, increase the count by 1 to push the line
+        // into the executable code set in addtion to the count found.
+        if(coverageVector[lineoffset + linenumber] == -1 &&
+           count > 0)
+          {
+          coverageVector[lineoffset + linenumber] += count+1;
+          }
+        else
+          {
+          coverageVector[lineoffset + linenumber] += count;
+          }
         lastoffset = lineoffset;
         }
       }
@@ -141,7 +153,7 @@
     if(pos == 0)
       {
       char nextchar = line[function.size()];
-      if(nextchar == ' ' || nextchar == '(')
+      if(nextchar == ' ' || nextchar == '('|| nextchar == '\t')
         {
         lineoffset = linenum;
         return true;
@@ -182,7 +194,7 @@
   //          ( file  , entry ) = "number_executed:timing_info"
   // ^COVERAGE("%RSEL","init",8,"FOR_LOOP",1)=1
   //          ( file  , entry, line, IGNORE ) =number_executed
-  std::vector<cmStdString> args;
+  std::vector<std::string> args;
   std::string::size_type pos = line.find('(', 0);
   // if no ( is found, then return line has no coverage
   if(pos == std::string::npos)
@@ -261,7 +273,11 @@
   // ^COVERAGE("%RSEL","SRC"), the line offset is 0
   if(args.size() == 2)
     {
-    linenumber = 0;
+    // To avoid double counting of line 0 of each entry point,
+    // Don't count the lines that do not give an explicit line
+    // number.
+    routine="";
+    function="";
     }
   else
     {
diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx
index 6226feb..6236211 100644
--- a/Source/CTest/cmParseMumpsCoverage.cxx
+++ b/Source/CTest/cmParseMumpsCoverage.cxx
@@ -122,7 +122,7 @@
   glob.RecurseOn();
   std::string pat = d;
   pat += "/*.m";
-  glob.FindFiles(pat.c_str());
+  glob.FindFiles(pat);
   std::vector<std::string>& files = glob.GetFiles();
   std::vector<std::string>::iterator fileIt;
   for ( fileIt = files.begin(); fileIt != files.end();
@@ -140,7 +140,7 @@
 bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
                                          std::string& filepath)
 {
-  std::map<cmStdString, cmStdString>::iterator i =
+  std::map<std::string, std::string>::iterator i =
     this->RoutineToDirectory.find(routine);
   if(i != this->RoutineToDirectory.end())
     {
diff --git a/Source/CTest/cmParseMumpsCoverage.h b/Source/CTest/cmParseMumpsCoverage.h
index c1effa7..bc71891 100644
--- a/Source/CTest/cmParseMumpsCoverage.h
+++ b/Source/CTest/cmParseMumpsCoverage.h
@@ -44,7 +44,7 @@
   bool FindMumpsFile(std::string const& routine,
                      std::string& filepath);
 protected:
-  std::map<cmStdString, cmStdString> RoutineToDirectory;
+  std::map<std::string, std::string> RoutineToDirectory;
   cmCTestCoverageHandlerContainer& Coverage;
   cmCTest* CTest;
 };
diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx
index 1c26c1c..3b7f968 100644
--- a/Source/CTest/cmParsePHPCoverage.cxx
+++ b/Source/CTest/cmParsePHPCoverage.cxx
@@ -34,7 +34,7 @@
   return true;
 }
 bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
-                                           cmStdString const& fileName)
+                                           std::string const& fileName)
 {
   cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector
     = this->Coverage.TotalCoverage[fileName];
@@ -166,7 +166,7 @@
     // read the string data
     in.read(s, size-1);
     s[size-1] = 0;
-    cmStdString fileName = s;
+    std::string fileName = s;
     delete [] s;
     // read close quote
     if(in.get(c) && c != '"')
diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h
index 035a093..92a7634 100644
--- a/Source/CTest/cmParsePHPCoverage.h
+++ b/Source/CTest/cmParsePHPCoverage.h
@@ -35,7 +35,7 @@
   bool ReadArraySize(std::istream& in, int& size);
   bool ReadFileInformation(std::istream& in);
   bool ReadInt(std::istream& in, int& v);
-  bool ReadCoverageArray(std::istream& in, cmStdString const&);
+  bool ReadCoverageArray(std::istream& in, std::string const&);
   bool ReadUntil(std::istream& in, char until);
   cmCTestCoverageHandlerContainer& Coverage;
   cmCTest* CTest;
diff --git a/Source/CTest/cmParsePythonCoverage.cxx b/Source/CTest/cmParsePythonCoverage.cxx
deleted file mode 100644
index 38a770a..0000000
--- a/Source/CTest/cmParsePythonCoverage.cxx
+++ /dev/null
@@ -1,113 +0,0 @@
-#include "cmStandardIncludes.h"
-#include "cmSystemTools.h"
-#include "cmXMLParser.h"
-#include "cmParsePythonCoverage.h"
-#include <cmsys/Directory.hxx>
-#include <cmsys/FStream.hxx>
-
-//----------------------------------------------------------------------------
-class cmParsePythonCoverage::XMLParser: public cmXMLParser
-{
-public:
-  XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
-    : CTest(ctest), Coverage(cont)
-  {
-  }
-
-  virtual ~XMLParser()
-  {
-  }
-
-protected:
-
-  virtual void StartElement(const char* name, const char** atts)
-  {
-    if(strcmp(name, "class") == 0)
-    {
-      int tagCount = 0;
-      while(true)
-      {
-        if(strcmp(atts[tagCount], "filename") == 0)
-        {
-          cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Reading file: "
-                     << atts[tagCount+1] << std::endl);
-          this->CurFileName = this->Coverage.SourceDir + "/" +
-                                 atts[tagCount+1];
-          FileLinesType& curFileLines =
-            this->Coverage.TotalCoverage[this->CurFileName];
-          cmsys::ifstream fin(this->CurFileName.c_str());
-          if(!fin)
-          {
-            cmCTestLog(this->CTest, ERROR_MESSAGE,
-                       "Python Coverage: Error opening " << this->CurFileName
-                       << std::endl);
-            this->Coverage.Error++;
-            break;
-          }
-
-          std::string line;
-          curFileLines.push_back(-1);
-          while(cmSystemTools::GetLineFromStream(fin, line))
-          {
-            curFileLines.push_back(-1);
-          }
-
-          break;
-        }
-        ++tagCount;
-      }
-    }
-    else if(strcmp(name, "line") == 0)
-    {
-      int tagCount = 0;
-      int curNumber = -1;
-      int curHits = -1;
-      while(true)
-      {
-        if(strcmp(atts[tagCount], "hits") == 0)
-        {
-          curHits = atoi(atts[tagCount+1]);
-        }
-        else if(strcmp(atts[tagCount], "number") == 0)
-        {
-          curNumber = atoi(atts[tagCount+1]);
-        }
-
-        if(curHits > -1 && curNumber > -1)
-        {
-          FileLinesType& curFileLines =
-            this->Coverage.TotalCoverage[this->CurFileName];
-          curFileLines[curNumber] = curHits;
-          break;
-        }
-        ++tagCount;
-      }
-    }
-  }
-
-  virtual void EndElement(const char*) {}
-
-private:
-
-  typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
-     FileLinesType;
-  cmCTest* CTest;
-  cmCTestCoverageHandlerContainer& Coverage;
-  std::string CurFileName;
-
-};
-
-
-cmParsePythonCoverage::cmParsePythonCoverage(
-    cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest)
-    :Coverage(cont), CTest(ctest)
-{
-}
-
-bool cmParsePythonCoverage::ReadCoverageXML(const char* xmlFile)
-{
-  cmParsePythonCoverage::XMLParser parser(this->CTest, this->Coverage);
-  parser.ParseFile(xmlFile);
-  return true;
-}
diff --git a/Source/CTest/cmParsePythonCoverage.h b/Source/CTest/cmParsePythonCoverage.h
deleted file mode 100644
index 668c7f9..0000000
--- a/Source/CTest/cmParsePythonCoverage.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*============================================================================
-  CMake - Cross Platform Makefile Generator
-  Copyright 2000-2009 Kitware, Inc.
-
-  Distributed under the OSI-approved BSD License (the "License");
-  see accompanying file Copyright.txt for details.
-
-  This software is distributed WITHOUT ANY WARRANTY; without even the
-  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-  See the License for more information.
-============================================================================*/
-
-#ifndef cmParsePythonCoverage_h
-#define cmParsePythonCoverage_h
-
-#include "cmStandardIncludes.h"
-#include "cmCTestCoverageHandler.h"
-
-/** \class cmParsePythonCoverage
- * \brief Parse coverage.py Python coverage information
- *
- * This class is used to parse the output of the coverage.py tool that
- * is currently maintained by Ned Batchelder. That tool has a command
- * that produces xml output in the format typically output by the common
- * Java-based Cobertura coverage application. This helper class parses
- * that XML file to fill the coverage-handler container.
- */
-class cmParsePythonCoverage
-{
-public:
-
-  //! Create the coverage parser by passing in the coverage handler
-  //! container and the cmCTest object
-  cmParsePythonCoverage(cmCTestCoverageHandlerContainer& cont,
-    cmCTest* ctest);
-
-  //! Read the XML produced by running `coverage xml`
-  bool ReadCoverageXML(const char* xmlFile);
-
-private:
-
-  class XMLParser;
-  cmCTestCoverageHandlerContainer& Coverage;
-  cmCTest* CTest;
-  std::string CurFileName;
-};
-
-#endif
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 2d1ef5c..a9d4d98 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -16,6 +16,7 @@
 
 #include <signal.h>
 #include <sys/ioctl.h>
+#include <locale.h>
 
 #include "cmCursesMainForm.h"
 #include "cmCursesStandardIncludes.h"
@@ -73,7 +74,8 @@
 
 }
 
-void CMakeErrorHandler(const char* message, const char* title, bool&, void* clientData)
+void CMakeMessageHandler(const char* message, const char* title, bool&,
+                         void* clientData)
 {
   cmCursesForm* self = static_cast<cmCursesForm*>( clientData );
   self->AddError(message, title);
@@ -81,6 +83,8 @@
 
 int main(int argc, char const* const* argv)
 {
+  setlocale(LC_ALL, "");
+
   cmsys::Encoding::CommandLineArguments encoding_args =
     cmsys::Encoding::CommandLineArguments::Main(argc, argv);
   argc = encoding_args.argc();
@@ -171,7 +175,7 @@
     return 1;
     }
 
-  cmSystemTools::SetErrorCallback(CMakeErrorHandler, myform);
+  cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform);
 
   cmCursesForm::CurrentForm = myform;
 
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
index 249137f..682f95f 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
@@ -19,9 +19,10 @@
 #include "cmCursesDummyWidget.h"
 #include "../cmSystemTools.h"
 
-cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key,
-                                                         int labelwidth,
-                                                         int entrywidth) :
+cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
+                                                        const std::string& key,
+                                                        int labelwidth,
+                                                        int entrywidth) :
   Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
 {
   this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
@@ -31,7 +32,7 @@
 }
 
 cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
-  const char* key, const cmCacheManager::CacheIterator& it, bool isNew,
+  const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew,
   int labelwidth, int entrywidth)
   : Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
 {
@@ -50,7 +51,7 @@
     {
     case  cmCacheManager::BOOL:
       this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
-      if (cmSystemTools::IsOn(it.GetValue()))
+      if (cmSystemTools::IsOn(it.GetValue().c_str()))
         {
         static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true);
         }
@@ -93,7 +94,8 @@
         }
       break;
     case cmCacheManager::UNINITIALIZED:
-      cmSystemTools::Error("Found an undefined variable: ", it.GetName());
+      cmSystemTools::Error("Found an undefined variable: ",
+                           it.GetName().c_str());
       break;
     default:
       // TODO : put warning message here
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h
index 1357a02..98107cc 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.h
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h
@@ -18,8 +18,9 @@
 class cmCursesCacheEntryComposite
 {
 public:
-  cmCursesCacheEntryComposite(const char* key, int labelwidth, int entrywidth);
-  cmCursesCacheEntryComposite(const char* key,
+  cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
+                              int entrywidth);
+  cmCursesCacheEntryComposite(const std::string& key,
                               const cmCacheManager::CacheIterator& it,
                               bool isNew, int labelwidth, int entrywidth);
   ~cmCursesCacheEntryComposite();
diff --git a/Source/CursesDialog/cmCursesLabelWidget.cxx b/Source/CursesDialog/cmCursesLabelWidget.cxx
index b5ed312..b50eb64 100644
--- a/Source/CursesDialog/cmCursesLabelWidget.cxx
+++ b/Source/CursesDialog/cmCursesLabelWidget.cxx
@@ -19,7 +19,7 @@
   field_opts_off(this->Field,  O_EDIT);
   field_opts_off(this->Field,  O_ACTIVE);
   field_opts_off(this->Field,  O_STATIC);
-  this->SetValue(name.c_str());
+  this->SetValue(name);
 }
 
 cmCursesLabelWidget::~cmCursesLabelWidget()
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index d94cd37..0734927 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -84,9 +84,9 @@
 }
 
 // See if a cache entry is in the list of entries in the ui.
-bool cmCursesMainForm::LookForCacheEntry(const char* key)
+bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
 {
-  if (!key || !this->Entries)
+  if (!this->Entries)
     {
     return false;
     }
@@ -94,7 +94,7 @@
   std::vector<cmCursesCacheEntryComposite*>::iterator it;
   for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
     {
-    if (!strcmp(key, (*it)->Key.c_str()))
+    if (key == (*it)->Key)
       {
       return true;
       }
@@ -146,7 +146,7 @@
           this->CMakeInstance->GetCacheManager()->NewIterator();
         !i.IsAtEnd(); i.Next())
       {
-      const char* key = i.GetName();
+      std::string key = i.GetName();
       if ( i.GetType() == cmCacheManager::INTERNAL ||
            i.GetType() == cmCacheManager::STATIC ||
            i.GetType() == cmCacheManager::UNINITIALIZED )
@@ -168,7 +168,7 @@
           this->CMakeInstance->GetCacheManager()->NewIterator();
         !i.IsAtEnd(); i.Next())
       {
-      const char* key = i.GetName();
+      std::string key = i.GetName();
       if ( i.GetType() == cmCacheManager::INTERNAL ||
            i.GetType() == cmCacheManager::STATIC ||
            i.GetType() == cmCacheManager::UNINITIALIZED )
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index 883a2b3..fba9bc5 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -51,7 +51,7 @@
    * Returns true if an entry with the given key is in the
    * list of current composites.
    */
-  bool LookForCacheEntry(const char* key);
+  bool LookForCacheEntry(const std::string& key);
 
   enum {
     MIN_WIDTH = 65,
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx
index 652b2df..2f4b59e 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.cxx
+++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx
@@ -59,7 +59,6 @@
     {
     return false;
     }
-  return false;
 }
 
 void cmCursesOptionsWidget::AddOption(std::string const & option )
@@ -74,7 +73,7 @@
     {
     this->CurrentOption = 0;
     }
-  this->SetValue(this->Options[this->CurrentOption].c_str());
+  this->SetValue(this->Options[this->CurrentOption]);
 }
 void cmCursesOptionsWidget::PreviousOption()
 {
@@ -86,10 +85,10 @@
     {
     this->CurrentOption--;
     }
-  this->SetValue(this->Options[this->CurrentOption].c_str());
+  this->SetValue(this->Options[this->CurrentOption]);
 }
 
-void cmCursesOptionsWidget::SetOption(const char* value)
+void cmCursesOptionsWidget::SetOption(const std::string& value)
 {
   this->CurrentOption = 0; // default to 0 index
   this->SetValue(value);
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h
index b52ac9d..5cee489 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.h
+++ b/Source/CursesDialog/cmCursesOptionsWidget.h
@@ -25,7 +25,7 @@
   // when this widget has focus. Returns true if the input was
   // handled.
   virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w);
-  void SetOption(const char*);
+  void SetOption(const std::string&);
   void AddOption(std::string const &);
   void NextOption();
   void PreviousOption();
diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx
index 14c325b..cd93bc3 100644
--- a/Source/CursesDialog/cmCursesPathWidget.cxx
+++ b/Source/CursesDialog/cmCursesPathWidget.cxx
@@ -57,9 +57,9 @@
     {
     glob = cstr + "*";
     }
-  std::vector<cmStdString> dirs;
+  std::vector<std::string> dirs;
 
-  cmSystemTools::SimpleGlob(glob.c_str(), dirs, (this->Type == cmCacheManager::PATH?-1:0));
+  cmSystemTools::SimpleGlob(glob, dirs, (this->Type == cmCacheManager::PATH?-1:0));
   if ( this->CurrentIndex < dirs.size() )
     {
     cstr = dirs[this->CurrentIndex];
@@ -74,7 +74,7 @@
     cstr += "/";
     }
 
-  this->SetString(cstr.c_str());
+  this->SetString(cstr);
   touchwin(w);
   wrefresh(w);
   form_driver(form, REQ_END_FIELD);
diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index bd1ff71..d25022d 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -195,7 +195,7 @@
   return true;
 }
 
-void cmCursesStringWidget::SetString(const char* value)
+void cmCursesStringWidget::SetString(const std::string& value)
 {
   this->SetValue(value);
 }
diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h
index e939049..dd8c02a 100644
--- a/Source/CursesDialog/cmCursesStringWidget.h
+++ b/Source/CursesDialog/cmCursesStringWidget.h
@@ -37,7 +37,7 @@
   /**
    * Set/Get the string.
    */
-  void SetString(const char* value);
+  void SetString(const std::string& value);
   const char* GetString();
   virtual const char* GetValue();
 
diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx
index 5dffcaa..e5363f4 100644
--- a/Source/CursesDialog/cmCursesWidget.cxx
+++ b/Source/CursesDialog/cmCursesWidget.cxx
@@ -46,10 +46,10 @@
     }
 }
 
-void cmCursesWidget::SetValue(const char* value)
+void cmCursesWidget::SetValue(const std::string& value)
 {
   this->Value = value;
-  set_field_buffer(this->Field, 0, value);
+  set_field_buffer(this->Field, 0, value.c_str());
 }
 
 const char* cmCursesWidget::GetValue()
diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h
index 952c67a..d91a0cb 100644
--- a/Source/CursesDialog/cmCursesWidget.h
+++ b/Source/CursesDialog/cmCursesWidget.h
@@ -40,7 +40,7 @@
    * Set/Get the value (setting the value also changes the contents
    * of the field buffer).
    */
-  virtual void SetValue(const char* value);
+  virtual void SetValue(const std::string& value);
   virtual const char* GetValue();
 
   /**
diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt
index 7885a0c..8da88c1 100644
--- a/Source/QtDialog/CMakeLists.txt
+++ b/Source/QtDialog/CMakeLists.txt
@@ -154,14 +154,6 @@
 endif()
 
 if(APPLE)
-  set(CMAKE_POSTFLIGHT_SCRIPT
-    "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
-  set(CMAKE_POSTUPGRADE_SCRIPT
-    "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
-  configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postflight.sh.in"
-    "${CMake_BINARY_DIR}/Source/QtDialog/postflight.sh")
-  configure_file("${CMake_SOURCE_DIR}/Source/QtDialog/postupgrade.sh.in"
-    "${CMake_BINARY_DIR}/Source/QtDialog/postupgrade.sh")
   install(CODE "execute_process(COMMAND ln -s \"../MacOS/CMake\" cmake-gui
                 WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin)")
 endif()
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 821121e..82fa3a3 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -14,6 +14,7 @@
 #include <QDir>
 #include <QTranslator>
 #include <QLocale>
+#include <QTextCodec>
 #include "QMacInstallDialog.h"
 #include "CMakeSetupDialog.h"
 #include "cmDocumentation.h"
@@ -78,6 +79,11 @@
 
   QApplication app(argc, argv);
 
+#if defined(CMAKE_ENCODING_UTF8)
+  QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
+  QTextCodec::setCodecForLocale(utf8_codec);
+#endif
+
   // clean out standard Qt paths for plugins, which we don't use anyway
   // when creating Mac bundles, it potentially causes problems
   foreach(QString p, QApplication::libraryPaths())
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 10879c0..8a37797 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -578,7 +578,8 @@
 void CMakeSetupDialog::doSourceBrowse()
 {
   QString dir = QFileDialog::getExistingDirectory(this,
-    tr("Enter Path to Source"), this->SourceDirectory->text());
+    tr("Enter Path to Source"), this->SourceDirectory->text(),
+    QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
   if(!dir.isEmpty())
     {
     this->setSourceDirectory(dir);
@@ -608,7 +609,8 @@
 void CMakeSetupDialog::doBinaryBrowse()
 {
   QString dir = QFileDialog::getExistingDirectory(this,
-    tr("Enter Path to Build"), this->BinaryDirectory->currentText());
+    tr("Enter Path to Build"), this->BinaryDirectory->currentText(),
+    QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
   if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText())
     {
     this->setBinaryDirectory(dir);
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 0fe5f8c..b833648 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -35,7 +35,9 @@
 
   cmSystemTools::DisableRunCommandOutput();
   cmSystemTools::SetRunCommandHideConsole(true);
-  cmSystemTools::SetErrorCallback(QCMake::errorCallback, this);
+  cmSystemTools::SetMessageCallback(QCMake::messageCallback, this);
+  cmSystemTools::SetStdoutCallback(QCMake::stdoutCallback, this);
+  cmSystemTools::SetStderrCallback(QCMake::stderrCallback, this);
 
   this->CMakeInstance = new cmake;
   this->CMakeInstance->SetCMakeEditCommand(
@@ -111,13 +113,13 @@
     cmCacheManager::CacheIterator itm = cachem->NewIterator();
     if ( itm.Find("CMAKE_HOME_DIRECTORY"))
       {
-      setSourceDirectory(QString::fromLocal8Bit(itm.GetValue()));
+      setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str()));
       }
     if ( itm.Find("CMAKE_GENERATOR"))
       {
       const char* extraGen = cachem->GetCacheValue("CMAKE_EXTRA_GENERATOR");
       std::string curGen = cmExternalMakefileProjectGenerator::
-                              CreateFullGeneratorName(itm.GetValue(), extraGen);
+        CreateFullGeneratorName(itm.GetValue(), extraGen? extraGen : "");
       this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
       }
     }
@@ -201,11 +203,11 @@
       }
 
     QCMakeProperty prop;
-    prop.Key = QString::fromLocal8Bit(i.GetName());
+    prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
     int idx = props.indexOf(prop);
     if(idx == -1)
       {
-      toremove.append(QString::fromLocal8Bit(i.GetName()));
+      toremove.append(QString::fromLocal8Bit(i.GetName().c_str()));
       }
     else
       {
@@ -286,15 +288,15 @@
       }
 
     QCMakeProperty prop;
-    prop.Key = QString::fromLocal8Bit(i.GetName());
+    prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
     prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING"));
-    prop.Value = QString::fromLocal8Bit(i.GetValue());
+    prop.Value = QString::fromLocal8Bit(i.GetValue().c_str());
     prop.Advanced = i.GetPropertyAsBool("ADVANCED");
 
     if(i.GetType() == cmCacheManager::BOOL)
       {
       prop.Type = QCMakeProperty::BOOL;
-      prop.Value = cmSystemTools::IsOn(i.GetValue());
+      prop.Value = cmSystemTools::IsOn(i.GetValue().c_str());
       }
     else if(i.GetType() == cmCacheManager::PATH)
       {
@@ -348,14 +350,28 @@
   QCoreApplication::processEvents();
 }
 
-void QCMake::errorCallback(const char* msg, const char* /*title*/,
-                           bool& /*stop*/, void* cd)
+void QCMake::messageCallback(const char* msg, const char* /*title*/,
+                             bool& /*stop*/, void* cd)
 {
   QCMake* self = reinterpret_cast<QCMake*>(cd);
   emit self->errorMessage(QString::fromLocal8Bit(msg));
   QCoreApplication::processEvents();
 }
 
+void QCMake::stdoutCallback(const char* msg, size_t len, void* cd)
+{
+  QCMake* self = reinterpret_cast<QCMake*>(cd);
+  emit self->outputMessage(QString::fromLocal8Bit(msg,int(len)));
+  QCoreApplication::processEvents();
+}
+
+void QCMake::stderrCallback(const char* msg, size_t len, void* cd)
+{
+  QCMake* self = reinterpret_cast<QCMake*>(cd);
+  emit self->outputMessage(QString::fromLocal8Bit(msg,int(len)));
+  QCoreApplication::processEvents();
+}
+
 QString QCMake::binaryDirectory() const
 {
   return this->BinaryDirectory;
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 93ac8ab..bd82f0d 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -136,8 +136,10 @@
 
   static bool interruptCallback(void*);
   static void progressCallback(const char* msg, float percent, void* cd);
-  static void errorCallback(const char* msg, const char* title,
-                            bool&, void* cd);
+  static void messageCallback(const char* msg, const char* title,
+                              bool&, void* cd);
+  static void stdoutCallback(const char* msg, size_t len, void* cd);
+  static void stderrCallback(const char* msg, size_t len, void* cd);
   bool SuppressDevWarnings;
   bool WarnUninitializedMode;
   bool WarnUnusedMode;
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index a0c5e17..41f98b5 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -67,7 +67,8 @@
     title = title.arg(this->Variable);
     }
   this->fileDialogExists(true);
-  path = QFileDialog::getOpenFileName(this, title, info.absolutePath());
+  path = QFileDialog::getOpenFileName(this, title, info.absolutePath(),
+    QString(), NULL, QFileDialog::DontResolveSymlinks);
   this->fileDialogExists(false);
 
   if(!path.isEmpty())
@@ -91,7 +92,8 @@
     title = title.arg(this->Variable);
     }
   this->fileDialogExists(true);
-  path = QFileDialog::getExistingDirectory(this, title, this->text());
+  path = QFileDialog::getExistingDirectory(this, title, this->text(),
+    QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
   this->fileDialogExists(false);
   if(!path.isEmpty())
     {
diff --git a/Source/QtDialog/QtDialogCPack.cmake.in b/Source/QtDialog/QtDialogCPack.cmake.in
index 3196471..7ae8605 100644
--- a/Source/QtDialog/QtDialogCPack.cmake.in
+++ b/Source/QtDialog/QtDialogCPack.cmake.in
@@ -9,9 +9,6 @@
     # / and then install
     # cmake into the bundle for cmake-gui and must use DESTDIR
     set(CPACK_SET_DESTDIR TRUE)
-    # we also want to run post install stuff to setup command line
-    set(CPACK_POSTFLIGHT_SCRIPT "@CMAKE_POSTFLIGHT_SCRIPT@")
-    set(CPACK_POSTUPGRADE_SCRIPT "@CMAKE_POSTUPGRADE_SCRIPT@")
   endif()
 endif()
 
diff --git a/Source/QtDialog/postflight.sh.in b/Source/QtDialog/postflight.sh.in
deleted file mode 100755
index 0b96889..0000000
--- a/Source/QtDialog/postflight.sh.in
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-"$2@CMAKE_INSTALL_SUBDIR@/CMake.app/Contents/MacOS/CMake" --mac-install
-exit 0
diff --git a/Source/QtDialog/postupgrade.sh.in b/Source/QtDialog/postupgrade.sh.in
deleted file mode 100755
index 06bd986..0000000
--- a/Source/QtDialog/postupgrade.sh.in
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/bash
-exit 0
diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h
index 38ed208..f147ec0 100644
--- a/Source/cmAddCompileOptionsCommand.h
+++ b/Source/cmAddCompileOptionsCommand.h
@@ -35,7 +35,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "add_compile_options";}
+  virtual std::string GetName() const {return "add_compile_options";}
 
   cmTypeMacro(cmAddCompileOptionsCommand, cmCommand);
 };
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 3de04f5..6a95550 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -173,6 +173,10 @@
           break;
         }
 
+      if (cmSystemTools::FileIsFullPath(filename.c_str()))
+        {
+        filename = cmSystemTools::CollapseFullPath(filename);
+        }
        switch (doing)
          {
          case doing_working_directory:
@@ -273,7 +277,7 @@
     {
     // Lookup an existing command.
     if(cmSourceFile* sf =
-       this->Makefile->GetSourceFileWithOutput(output[0].c_str()))
+       this->Makefile->GetSourceFileWithOutput(output[0]))
       {
       if(cmCustomCommand* cc = sf->GetCustomCommand())
         {
@@ -286,9 +290,9 @@
 
     // No command for this output exists.
     cmOStringStream e;
-    e << "given APPEND option with output \"" << output[0].c_str()
+    e << "given APPEND option with output \"" << output[0]
       << "\" which is not already a custom command output.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -305,7 +309,7 @@
     {
     // Source is empty, use the target.
     std::vector<std::string> no_depends;
-    this->Makefile->AddCustomCommandToTarget(target.c_str(), no_depends,
+    this->Makefile->AddCustomCommandToTarget(target, no_depends,
                                              commandLines, cctype,
                                              comment, working.c_str(),
                                              escapeOldStyle);
@@ -314,7 +318,7 @@
     {
     // Target is empty, use the output.
     this->Makefile->AddCustomCommandToOutput(output, depends,
-                                             main_dependency.c_str(),
+                                             main_dependency,
                                              commandLines, comment,
                                              working.c_str(), false,
                                              escapeOldStyle);
@@ -324,7 +328,7 @@
       {
       bool okay = false;
       if(cmSourceFile* sf =
-         this->Makefile->GetSourceFileWithOutput(output[0].c_str()))
+         this->Makefile->GetSourceFileWithOutput(output[0]))
         {
         if(cmCustomCommand* cc = sf->GetCustomCommand())
           {
@@ -337,7 +341,7 @@
         cmOStringStream e;
         e << "could not locate source file with a custom command producing \""
           << output[0] << "\" even though this command tried to create it!";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       }
@@ -367,7 +371,7 @@
       {
       e << "The SOURCE signatures of add_custom_command are no longer "
            "supported.";
-      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      this->Makefile->IssueMessage(messageType, e.str());
       if (messageType == cmake::FATAL_ERROR)
         {
         return false;
@@ -375,8 +379,8 @@
       }
 
     // Use the old-style mode for backward compatibility.
-    this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends,
-                                             source.c_str(), commandLines,
+    this->Makefile->AddCustomCommandOldStyle(target, outputs, depends,
+                                             source, commandLines,
                                              comment);
     }
 
@@ -397,7 +401,7 @@
       {
       std::string e = "attempted to have a file \"" + *o +
         "\" in a source directory as an output of custom command.";
-      this->SetError(e.c_str());
+      this->SetError(e);
       cmSystemTools::SetFatalErrorOccured();
       return false;
       }
@@ -409,7 +413,7 @@
       cmOStringStream msg;
       msg << "called with OUTPUT containing a \"" << (*o)[pos]
           << "\".  This character is not allowed.";
-      this->SetError(msg.str().c_str());
+      this->SetError(msg.str());
       return false;
       }
     }
diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h
index 114957f..1d6ddb2 100644
--- a/Source/cmAddCustomCommandCommand.h
+++ b/Source/cmAddCustomCommandCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "add_custom_command";}
+  virtual std::string GetName() const {return "add_custom_command";}
 
   cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
 protected:
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index e27d830..2fb0eb3 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -34,7 +34,7 @@
     e << "called with invalid target name \"" << targetName
       << "\".  Target names may not contain a slash.  "
       << "Use ADD_CUSTOM_COMMAND to generate files.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -149,7 +149,7 @@
     cmOStringStream msg;
     msg << "called with target name containing a \"" << targetName[pos]
         << "\".  This character is not allowed.";
-    this->SetError(msg.str().c_str());
+    this->SetError(msg.str());
     return false;
     }
 
@@ -187,7 +187,7 @@
           "\" is reserved or not valid for certain "
           "CMake features, such as generator expressions, and may result "
           "in undefined behavior.";
-      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      this->Makefile->IssueMessage(messageType, e.str());
 
       if (messageType == cmake::FATAL_ERROR)
         {
@@ -208,7 +208,7 @@
   std::string msg;
   if(!this->Makefile->EnforceUniqueName(targetName, msg, true))
     {
-    this->SetError(msg.c_str());
+    this->SetError(msg);
     return false;
     }
   }
@@ -224,7 +224,7 @@
   // Add the utility target to the makefile.
   bool escapeOldStyle = !verbatim;
   cmTarget* target =
-    this->Makefile->AddUtilityCommand(targetName.c_str(), excludeFromAll,
+    this->Makefile->AddUtilityCommand(targetName, excludeFromAll,
                                       working_directory.c_str(), depends,
                                       commandLines, escapeOldStyle, comment);
 
diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h
index d0fcdad..d2b00ad 100644
--- a/Source/cmAddCustomTargetCommand.h
+++ b/Source/cmAddCustomTargetCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const
+  virtual std::string GetName() const
     {return "add_custom_target";}
 
   cmTypeMacro(cmAddCustomTargetCommand, cmCommand);
diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h
index d05f187..9800fd2 100644
--- a/Source/cmAddDefinitionsCommand.h
+++ b/Source/cmAddDefinitionsCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "add_definitions";}
+  virtual std::string GetName() const {return "add_definitions";}
 
   cmTypeMacro(cmAddDefinitionsCommand, cmCommand);
 };
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index b55334f..e897d81 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -38,7 +38,7 @@
       cmOStringStream e;
       e << "Cannot add target-level dependencies to INTERFACE library "
         "target \"" << target_name << "\".\n";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
@@ -46,7 +46,7 @@
     ++s; // skip over target_name
     for (; s != args.end(); ++s)
       {
-      target->AddUtility(s->c_str(), this->Makefile);
+      target->AddUtility(*s, this->Makefile);
       }
     }
   else
diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h
index 247cc54..db3712a 100644
--- a/Source/cmAddDependenciesCommand.h
+++ b/Source/cmAddDependenciesCommand.h
@@ -40,7 +40,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "add_dependencies";}
+  virtual std::string GetName() const { return "add_dependencies";}
 
   cmTypeMacro(cmAddDependenciesCommand, cmCommand);
 };
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 3f9400e..c30e764 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -101,7 +101,7 @@
           "\" is reserved or not valid for certain "
           "CMake features, such as generator expressions, and may result "
           "in undefined behavior.";
-      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      this->Makefile->IssueMessage(messageType, e.str());
 
       if (messageType == cmake::FATAL_ERROR)
         {
@@ -132,9 +132,9 @@
     }
   if (isAlias)
     {
-    if(!cmGeneratorExpression::IsValidTargetName(exename.c_str()))
+    if(!cmGeneratorExpression::IsValidTargetName(exename))
       {
-      this->SetError(("Invalid name for ALIAS: " + exename).c_str());
+      this->SetError("Invalid name for ALIAS: " + exename);
       return false;
       }
     if(excludeFromAll)
@@ -151,7 +151,7 @@
       {
       cmOStringStream e;
       e << "ALIAS requires exactly one target argument.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
@@ -161,7 +161,7 @@
       cmOStringStream e;
       e << "cannot create ALIAS target \"" << exename
         << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     cmTarget *aliasedTarget =
@@ -172,7 +172,7 @@
       e << "cannot create ALIAS target \"" << exename
         << "\" because target \"" << aliasedName << "\" does not already "
         "exist.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     cmTarget::TargetType type = aliasedTarget->GetType();
@@ -182,7 +182,7 @@
       e << "cannot create ALIAS target \"" << exename
         << "\" because target \"" << aliasedName << "\" is not an "
         "executable.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     if(aliasedTarget->IsImported())
@@ -190,10 +190,10 @@
       cmOStringStream e;
       e << "cannot create ALIAS target \"" << exename
         << "\" because target \"" << aliasedName << "\" is IMPORTED.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
-    this->Makefile->AddAlias(exename.c_str(), aliasedTarget);
+    this->Makefile->AddAlias(exename, aliasedTarget);
     return true;
     }
 
@@ -206,12 +206,12 @@
       cmOStringStream e;
       e << "cannot create imported target \"" << exename
         << "\" because another target with the same name already exists.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
     // Create the imported target.
-    this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE,
+    this->Makefile->AddImportedTarget(exename, cmTarget::EXECUTABLE,
                                       importGlobal);
     return true;
     }
@@ -221,7 +221,7 @@
   std::string msg;
   if(!this->Makefile->EnforceUniqueName(exename, msg))
     {
-    this->SetError(msg.c_str());
+    this->SetError(msg);
     return false;
     }
   }
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index 30ecce3..e134077 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "add_executable";}
+  virtual std::string GetName() const { return "add_executable";}
 
   cmTypeMacro(cmAddExecutableCommand, cmCommand);
 };
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index e62a40e..cdc9f2a 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -53,7 +53,7 @@
         {
         cmOStringStream e;
         e << "INTERFACE library specified with conflicting STATIC type.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       ++s;
@@ -66,7 +66,7 @@
         {
         cmOStringStream e;
         e << "INTERFACE library specified with conflicting SHARED type.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       ++s;
@@ -79,7 +79,7 @@
         {
         cmOStringStream e;
         e << "INTERFACE library specified with conflicting MODULE type.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       ++s;
@@ -92,7 +92,7 @@
         {
         cmOStringStream e;
         e << "INTERFACE library specified with conflicting OBJECT type.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       ++s;
@@ -105,7 +105,7 @@
         {
         cmOStringStream e;
         e << "INTERFACE library specified with conflicting UNKNOWN type.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       ++s;
@@ -118,7 +118,7 @@
         {
         cmOStringStream e;
         e << "INTERFACE library specified with conflicting ALIAS type.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       ++s;
@@ -130,21 +130,21 @@
         {
         cmOStringStream e;
         e << "INTERFACE library specified with conflicting/multiple types.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       if (isAlias)
         {
         cmOStringStream e;
         e << "INTERFACE library specified with conflicting ALIAS type.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       if (excludeFromAll)
         {
         cmOStringStream e;
         e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       ++s;
@@ -157,7 +157,7 @@
         {
         cmOStringStream e;
         e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       ++s;
@@ -177,7 +177,7 @@
       {
       cmOStringStream e;
       e << "GLOBAL option may only be used with IMPORTED libraries.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     else
@@ -192,14 +192,14 @@
       {
       cmOStringStream e;
       e << "INTERFACE library requires no source arguments.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     if (importGlobal && !importTarget)
       {
       cmOStringStream e;
       e << "INTERFACE library specified as GLOBAL, but not as IMPORTED.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -239,7 +239,7 @@
           "\" is reserved or not valid for certain "
           "CMake features, such as generator expressions, and may result "
           "in undefined behavior.";
-      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      this->Makefile->IssueMessage(messageType, e.str());
 
       if (messageType == cmake::FATAL_ERROR)
         {
@@ -250,9 +250,9 @@
 
   if (isAlias)
     {
-    if(!cmGeneratorExpression::IsValidTargetName(libName.c_str()))
+    if(!cmGeneratorExpression::IsValidTargetName(libName))
       {
-      this->SetError(("Invalid name for ALIAS: " + libName).c_str());
+      this->SetError("Invalid name for ALIAS: " + libName);
       return false;
       }
     if(excludeFromAll)
@@ -269,7 +269,7 @@
       {
       cmOStringStream e;
       e << "ALIAS requires exactly one target argument.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
@@ -279,7 +279,7 @@
       cmOStringStream e;
       e << "cannot create ALIAS target \"" << libName
         << "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     cmTarget *aliasedTarget =
@@ -290,7 +290,7 @@
       e << "cannot create ALIAS target \"" << libName
         << "\" because target \"" << aliasedName << "\" does not already "
         "exist.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     cmTarget::TargetType aliasedType = aliasedTarget->GetType();
@@ -303,7 +303,7 @@
       cmOStringStream e;
       e << "cannot create ALIAS target \"" << libName
         << "\" because target \"" << aliasedName << "\" is not a library.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     if(aliasedTarget->IsImported())
@@ -311,10 +311,10 @@
       cmOStringStream e;
       e << "cannot create ALIAS target \"" << libName
         << "\" because target \"" << aliasedName << "\" is IMPORTED.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
-    this->Makefile->AddAlias(libName.c_str(), aliasedTarget);
+    this->Makefile->AddAlias(libName, aliasedTarget);
     return true;
     }
 
@@ -367,7 +367,7 @@
         {
         cmOStringStream e;
         e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       }
@@ -378,12 +378,12 @@
       cmOStringStream e;
       e << "cannot create imported target \"" << libName
         << "\" because another target with the same name already exists.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
     // Create the imported target.
-    this->Makefile->AddImportedTarget(libName.c_str(), type, importGlobal);
+    this->Makefile->AddImportedTarget(libName, type, importGlobal);
     return true;
     }
 
@@ -402,7 +402,7 @@
   std::string msg;
   if(!this->Makefile->EnforceUniqueName(libName, msg))
     {
-    this->SetError(msg.c_str());
+    this->SetError(msg);
     return false;
     }
   }
@@ -416,11 +416,11 @@
       {
       cmOStringStream e;
       e << "Invalid name for INTERFACE library target: " << libName;
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
-    this->Makefile->AddLibrary(libName.c_str(),
+    this->Makefile->AddLibrary(libName,
                                type,
                                srclists,
                                excludeFromAll);
@@ -442,7 +442,7 @@
     ++s;
     }
 
-  this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll);
+  this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll);
 
   return true;
 }
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index 1001043..350708b 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "add_library";}
+  virtual std::string GetName() const { return "add_library";}
 
   cmTypeMacro(cmAddLibraryCommand, cmCommand);
 };
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 5b1c9c6..4ea2524 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -66,7 +66,7 @@
     std::string error = "given source \"";
     error += srcArg;
     error += "\" which is not an existing directory.";
-    this->SetError(error.c_str());
+    this->SetError(error);
     return false;
     }
   srcPath = cmSystemTools::CollapseFullPath(srcPath.c_str());
@@ -87,7 +87,7 @@
         << this->Makefile->GetCurrentDirectory() << "\".  "
         << "When specifying an out-of-tree source a binary directory "
         << "must be explicitly specified.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
@@ -121,7 +121,7 @@
   binPath = cmSystemTools::CollapseFullPath(binPath.c_str());
 
   // Add the subdirectory using the computed full paths.
-  this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
+  this->Makefile->AddSubDirectory(srcPath, binPath,
                                   excludeFromAll, false, true);
 
   return true;
diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h
index 1e5b1ab..abf3efc 100644
--- a/Source/cmAddSubDirectoryCommand.h
+++ b/Source/cmAddSubDirectoryCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "add_subdirectory";}
+  virtual std::string GetName() const { return "add_subdirectory";}
 
   cmTypeMacro(cmAddSubDirectoryCommand, cmCommand);
 };
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index a9165f5..2531a1a 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -44,7 +44,7 @@
 
   // Create the test but add a generator only the first time it is
   // seen.  This preserves behavior from before test generators.
-  cmTest* test = this->Makefile->GetTest(args[0].c_str());
+  cmTest* test = this->Makefile->GetTest(args[0]);
   if(test)
     {
     // If the test was already added by a new-style signature do not
@@ -54,13 +54,13 @@
       cmOStringStream e;
       e << " given test name \"" << args[0]
         << "\" which already exists in this directory.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
   else
     {
-    test = this->Makefile->CreateTest(args[0].c_str());
+    test = this->Makefile->CreateTest(args[0]);
     test->SetOldStyle(true);
     this->Makefile->AddTestGenerator(new cmTestGenerator(test));
     }
@@ -137,7 +137,7 @@
       {
       cmOStringStream e;
       e << " given unknown argument:\n  " << args[i] << "\n";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -157,17 +157,17 @@
     }
 
   // Require a unique test name within the directory.
-  if(this->Makefile->GetTest(name.c_str()))
+  if(this->Makefile->GetTest(name))
     {
     cmOStringStream e;
     e << " given test NAME \"" << name
       << "\" which already exists in this directory.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
   // Add the test.
-  cmTest* test = this->Makefile->CreateTest(name.c_str());
+  cmTest* test = this->Makefile->CreateTest(name);
   test->SetOldStyle(false);
   test->SetCommand(command);
   if(!working_directory.empty())
diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h
index 9173454..624288f 100644
--- a/Source/cmAddTestCommand.h
+++ b/Source/cmAddTestCommand.h
@@ -40,7 +40,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "add_test";}
+  virtual std::string GetName() const { return "add_test";}
 
   cmTypeMacro(cmAddTestCommand, cmCommand);
 private:
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 01f64b7..d8c3c43 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -40,7 +40,7 @@
     }
 
   // was the list already populated
-  const char *def = this->Makefile->GetDefinition(args[1].c_str());
+  const char *def = this->Makefile->GetDefinition(args[1]);
   if (def)
     {
     sourceListValue = def;
@@ -72,7 +72,7 @@
           // add the file as a class file so
           // depends can be done
           cmSourceFile* sf =
-            this->Makefile->GetOrCreateSource(fullname.c_str());
+            this->Makefile->GetOrCreateSource(fullname);
           sf->SetProperty("ABSTRACT","0");
           if(!sourceListValue.empty())
             {
@@ -83,7 +83,7 @@
         }
       }
     }
-  this->Makefile->AddDefinition(args[1].c_str(), sourceListValue.c_str());
+  this->Makefile->AddDefinition(args[1], sourceListValue.c_str());
   return true;
 }
 
diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h
index 8b5fa8a..6615273 100644
--- a/Source/cmAuxSourceDirectoryCommand.h
+++ b/Source/cmAuxSourceDirectoryCommand.h
@@ -44,7 +44,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "aux_source_directory";}
+  virtual std::string GetName() const { return "aux_source_directory";}
 
   cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand);
 };
diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h
index 52f0e9c..1fcae50 100644
--- a/Source/cmBreakCommand.h
+++ b/Source/cmBreakCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "break";}
+  virtual std::string GetName() const {return "break";}
 
   cmTypeMacro(cmBreakCommand, cmCommand);
 };
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index c06b8ad..93f7801 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -44,7 +44,7 @@
   // Parse remaining arguments.
   const char* configuration = 0;
   const char* project_name = 0;
-  const char* target = 0;
+  std::string target;
   enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget };
   Doing doing = DoingNone;
   for(unsigned int i=1; i < args.size(); ++i)
@@ -74,13 +74,13 @@
     else if(doing == DoingTarget)
       {
       doing = DoingNone;
-      target = args[i].c_str();
+      target = args[i];
       }
     else
       {
       cmOStringStream e;
       e << "unknown argument \"" << args[i] << "\"";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -107,7 +107,7 @@
 
   std::string makecommand = this->Makefile->GetLocalGenerator()
     ->GetGlobalGenerator()->GenerateCMakeBuildCommand(target, configuration,
-                                                      0, true);
+                                                      "", true);
 
   this->Makefile->AddDefinition(variable, makecommand.c_str());
 
@@ -136,8 +136,8 @@
     }
 
   std::string makecommand = this->Makefile->GetLocalGenerator()
-    ->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(),
-                                                      0, true);
+    ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType,
+                                                      "", true);
 
   if(cacheValue)
     {
diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h
index 2160655..3fb618f 100644
--- a/Source/cmBuildCommand.h
+++ b/Source/cmBuildCommand.h
@@ -50,7 +50,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "build_command";}
+  virtual std::string GetName() const {return "build_command";}
 
   cmTypeMacro(cmBuildCommand, cmCommand);
 };
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index e3528e1..c64209f 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -25,7 +25,7 @@
     this->SetError("called with incorrect number of arguments");
     return false;
     }
-  const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str());
+  const char* cacheValue = this->Makefile->GetDefinition(args[0]);
   if(cacheValue)
     {
     // do we need to correct the value?
@@ -36,7 +36,7 @@
       cmSystemTools::ReplaceString(cv,"/", "_");
       cmSystemTools::ReplaceString(cv,"(", "_");
       cmSystemTools::ReplaceString(cv,")", "_");
-      this->Makefile->AddCacheDefinition(args[0].c_str(),
+      this->Makefile->AddCacheDefinition(args[0],
                                      cv.c_str(),
                                      "Name of build.",
                                      cmCacheManager::STRING);
@@ -71,7 +71,7 @@
   cmSystemTools::ReplaceString(buildname,
                                ")", "_");
 
-  this->Makefile->AddCacheDefinition(args[0].c_str(),
+  this->Makefile->AddCacheDefinition(args[0],
                                  buildname.c_str(),
                                  "Name of build.",
                                  cmCacheManager::STRING);
diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h
index 2f7acde..8f8038f 100644
--- a/Source/cmBuildNameCommand.h
+++ b/Source/cmBuildNameCommand.h
@@ -21,7 +21,7 @@
   virtual cmCommand* Clone() { return new cmBuildNameCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
-  virtual const char* GetName() const {return "build_name";}
+  virtual std::string GetName() const {return "build_name";}
   virtual bool IsScriptable() const { return true; }
   virtual bool IsDiscouraged() const { return true; }
 };
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 62f2383..5234538 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -53,7 +53,7 @@
     result_list += value;
     }
 
-  this->Makefile->AddDefinition(variable.c_str(), result_list.c_str());
+  this->Makefile->AddDefinition(variable, result_list.c_str());
 
   return true;
 }
@@ -97,7 +97,7 @@
   else
     {
     std::string e = "does not recognize <key> " + key;
-    this->SetError(e.c_str());
+    this->SetError(e);
     return false;
     }
 
diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h
index 27ba638..463b180 100644
--- a/Source/cmCMakeHostSystemInformationCommand.h
+++ b/Source/cmCMakeHostSystemInformationCommand.h
@@ -48,7 +48,7 @@
    /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const
+  virtual std::string GetName() const
     {
     return "cmake_host_system_information";
     }
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index 6e2ca64..58b61de 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -79,8 +79,8 @@
             &required_patch, &required_tweak) < 2)
     {
     cmOStringStream e;
-    e << "could not parse VERSION \"" << version_string.c_str() << "\".";
-    this->SetError(e.str().c_str());
+    e << "could not parse VERSION \"" << version_string << "\".";
+    this->SetError(e.str());
     return false;
     }
 
@@ -98,7 +98,7 @@
     {
     // The current version is too low.
     cmOStringStream e;
-    e << "CMake " << version_string.c_str()
+    e << "CMake " << version_string
       << " or higher is required.  You are running version "
       << cmVersion::GetCMakeVersion();
     this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -135,7 +135,7 @@
     cmOStringStream e;
     e << "called with unknown argument \""
       << this->UnknownArguments[0] << "\".";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
   return true;
diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h
index 0cdd4c5..31b7271 100644
--- a/Source/cmCMakeMinimumRequired.h
+++ b/Source/cmCMakeMinimumRequired.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "cmake_minimum_required";}
+  virtual std::string GetName() const {return "cmake_minimum_required";}
 
   cmTypeMacro(cmCMakeMinimumRequired, cmCommand);
 
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index f4be559..ddd5d6a 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -58,7 +58,7 @@
 
   cmOStringStream e;
   e << "given unknown first argument \"" << args[0] << "\"";
-  this->SetError(e.str().c_str());
+  this->SetError(e.str());
   return false;
 }
 
@@ -84,7 +84,7 @@
     {
     cmOStringStream e;
     e << "SET given unrecognized policy status \"" << args[2] << "\"";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -116,7 +116,7 @@
     cmOStringStream e;
     e << "GET given policy \"" << id << "\" which is not known to this "
       << "version of CMake.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -126,15 +126,15 @@
     {
     case cmPolicies::OLD:
       // Report that the policy is set to OLD.
-      this->Makefile->AddDefinition(var.c_str(), "OLD");
+      this->Makefile->AddDefinition(var, "OLD");
       break;
     case cmPolicies::WARN:
       // Report that the policy is not set.
-      this->Makefile->AddDefinition(var.c_str(), "");
+      this->Makefile->AddDefinition(var, "");
       break;
     case cmPolicies::NEW:
       // Report that the policy is set to NEW.
-      this->Makefile->AddDefinition(var.c_str(), "NEW");
+      this->Makefile->AddDefinition(var, "NEW");
       break;
     case cmPolicies::REQUIRED_IF_USED:
     case cmPolicies::REQUIRED_ALWAYS:
diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h
index 7e3f4e6..8dc8fbe 100644
--- a/Source/cmCMakePolicyCommand.h
+++ b/Source/cmCMakePolicyCommand.h
@@ -46,7 +46,7 @@
  /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "cmake_policy";}
+  virtual std::string GetName() const {return "cmake_policy";}
 
   cmTypeMacro(cmCMakePolicyCommand, cmCommand);
 private:
diff --git a/Source/cmCPackPropertiesGenerator.cxx b/Source/cmCPackPropertiesGenerator.cxx
new file mode 100644
index 0000000..cf24c13
--- /dev/null
+++ b/Source/cmCPackPropertiesGenerator.cxx
@@ -0,0 +1,45 @@
+#include "cmCPackPropertiesGenerator.h"
+
+#include "cmLocalGenerator.h"
+
+cmCPackPropertiesGenerator::cmCPackPropertiesGenerator(
+  cmMakefile* mf,
+  cmInstalledFile const& installedFile,
+  std::vector<std::string> const& configurations):
+    cmScriptGenerator("CPACK_BUILD_CONFIG", configurations),
+    Makefile(mf),
+    InstalledFile(installedFile)
+{
+  this->ActionsPerConfig = true;
+}
+
+void cmCPackPropertiesGenerator::GenerateScriptForConfig(std::ostream& os,
+  const std::string& config, Indent const& indent)
+{
+  std::string const& expandedFileName =
+      this->InstalledFile.GetNameExpression().Evaluate(this->Makefile, config);
+
+  cmInstalledFile::PropertyMapType const& properties =
+    this->InstalledFile.GetProperties();
+
+  for(cmInstalledFile::PropertyMapType::const_iterator i = properties.begin();
+    i != properties.end(); ++i)
+    {
+    std::string const& name = i->first;
+    cmInstalledFile::Property const& property = i->second;
+
+    os << indent << "set_property(INSTALL " <<
+      cmLocalGenerator::EscapeForCMake(expandedFileName) << " PROPERTY " <<
+      cmLocalGenerator::EscapeForCMake(name);
+
+    for(cmInstalledFile::ExpressionVectorType::const_iterator
+      j = property.ValueExpressions.begin();
+      j != property.ValueExpressions.end(); ++j)
+      {
+      std::string value = (*j)->Evaluate(this->Makefile, config);
+      os << " " << cmLocalGenerator::EscapeForCMake(value);
+      }
+
+    os << ")\n";
+    }
+}
diff --git a/Source/cmCPackPropertiesGenerator.h b/Source/cmCPackPropertiesGenerator.h
new file mode 100644
index 0000000..71e2eaa
--- /dev/null
+++ b/Source/cmCPackPropertiesGenerator.h
@@ -0,0 +1,38 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 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 cmCPackPropertiesGenerator_h
+#define cmCPackPropertiesGenerator_h
+
+#include "cmScriptGenerator.h"
+#include "cmInstalledFile.h"
+
+/** \class cmCPackPropertiesGenerator
+ * \brief Support class for generating CPackProperties.cmake.
+ *
+ */
+class cmCPackPropertiesGenerator: public cmScriptGenerator
+{
+public:
+  cmCPackPropertiesGenerator(
+     cmMakefile* mf,
+     cmInstalledFile const& installedFile,
+     std::vector<std::string> const& configurations);
+
+protected:
+  virtual void GenerateScriptForConfig(std::ostream& os,
+    const std::string& config, Indent const& indent);
+
+  cmMakefile* Makefile;
+  cmInstalledFile const& InstalledFile;
+};
+
+#endif
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index cb62f21..dd2a1b8 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -557,9 +557,9 @@
       sf->RealSourceFile = rsf;
       sf->FullPath = rsf->GetFullPath();
       sf->SourceName =
-        cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath.c_str());
+        cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath);
       sf->SourceExtension =
-        cmSystemTools::GetFilenameLastExtension(sf->FullPath.c_str());
+        cmSystemTools::GetFilenameLastExtension(sf->FullPath);
 
       // Store the proxy in the map so it can be re-used and deleted later.
       cmCPluginAPISourceFileMap::value_type entry(rsf, sf);
@@ -583,7 +583,7 @@
     }
 
   // Create the real cmSourceFile instance and copy over saved information.
-  cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath.c_str());
+  cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath);
   rsf->GetProperties() = osf->Properties;
   for(std::vector<std::string>::iterator i = osf->Depends.begin();
       i != osf->Depends.end(); ++i)
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index acedc1a..d797d3b 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -78,7 +78,7 @@
           lctime->tm_mday,
           str.c_str());
   cmCTestLog(this, OUTPUT, "Determine Nightly Start Time" << std::endl
-    << "   Specified time: " << str.c_str() << std::endl);
+    << "   Specified time: " << str << std::endl);
   //Convert the nightly start time to seconds. Since we are
   //providing only a time and a timezone, the current date of
   //the local machine is assumed. Consequently, nightlySeconds
@@ -217,8 +217,6 @@
         url += "?" + fields;
         }
       break;
-    default:
-      break;
     }
 
   ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
@@ -649,8 +647,8 @@
 bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
 {
   std::string src_dir
-    = this->GetCTestConfiguration("SourceDirectory").c_str();
-  std::string bld_dir = this->GetCTestConfiguration("BuildDirectory").c_str();
+    = this->GetCTestConfiguration("SourceDirectory");
+  std::string bld_dir = this->GetCTestConfiguration("BuildDirectory");
   this->DartVersion = 1;
   this->DropSiteCDash = false;
   for(Part p = PartStart; p != PartCount; p = Part(p+1))
@@ -681,14 +679,14 @@
   if ( !fname.empty() )
     {
     cmCTestLog(this, OUTPUT, "   Reading ctest configuration file: "
-      << fname.c_str() << std::endl);
+      << fname << std::endl);
     bool readit = mf->ReadListFile(mf->GetCurrentListFile(),
       fname.c_str() );
     if(!readit)
       {
       std::string m = "Could not find include file: ";
       m += fname;
-      command->SetError(m.c_str());
+      command->SetError(m);
       return false;
       }
     }
@@ -696,10 +694,10 @@
     {
     cmCTestLog(this, WARNING,
       "Cannot locate CTest configuration: in BuildDirectory: "
-      << bld_dir_fname.c_str() << std::endl);
+      << bld_dir_fname << std::endl);
     cmCTestLog(this, WARNING,
       "Cannot locate CTest configuration: in SourceDirectory: "
-      << src_dir_fname.c_str() << std::endl);
+      << src_dir_fname << std::endl);
     }
 
   this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime",
@@ -748,13 +746,13 @@
       }
     }
   cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "UpdateCTestConfiguration  from :"
-             << fileName.c_str() << "\n");
+             << fileName << "\n");
   if ( !cmSystemTools::FileExists(fileName.c_str()) )
     {
     // No need to exit if we are not producing XML
     if ( this->ProduceXML )
       {
-      cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName.c_str()
+      cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName
         << std::endl);
       return false;
       }
@@ -762,7 +760,7 @@
   else
     {
     cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:"
-               << fileName.c_str() << "\n");
+               << fileName << "\n");
     // parse the dart test file
     cmsys::ifstream fin(fileName.c_str());
 
@@ -930,7 +928,7 @@
     {
     std::string name = file;
     name += ".gz";
-    if ( this->CTestFileExists(name.c_str()) )
+    if ( this->CTestFileExists(name) )
       {
       this->AddSubmitFile(part, file);
       }
@@ -1153,7 +1151,7 @@
   int* retVal, const char* dir, int timeout, std::ostream& ofs)
 {
   // First generate the command and arguments
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+  std::vector<std::string> args = cmSystemTools::ParseArguments(command);
 
   if(args.size() < 1)
     {
@@ -1161,7 +1159,7 @@
     }
 
   std::vector<const char*> argv;
-  for(std::vector<cmStdString>::const_iterator a = args.begin();
+  for(std::vector<std::string>::const_iterator a = args.begin();
     a != args.end(); ++a)
     {
     argv.push_back(a->c_str());
@@ -1346,7 +1344,7 @@
     *output += oss.str();
     if ( log )
       {
-      *log << output->c_str();
+      *log << *output;
       }
     cmSystemTools::ChangeDirectory(oldpath.c_str());
 
@@ -1562,7 +1560,7 @@
       for(std::vector<std::string>::iterator i = args.begin();
           i != args.end(); ++i)
         {
-        ostr << "    <Label>" << i->c_str() << "</Label>\n";
+        ostr << "    <Label>" << *i << "</Label>\n";
         }
       ostr << "  </Labels>\n";
       }
@@ -1606,7 +1604,7 @@
 
   for ( it = files.begin(); it != files.end(); it ++ )
     {
-    cmCTestLog(this, OUTPUT, "\tAdd file: " << it->c_str() << std::endl);
+    cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl);
     std::string note_time = this->CurrentTime();
     os << "<Note Name=\"" << cmXMLSafe(*it) << "\">\n"
       << "<Time>" << cmSystemTools::GetTime() << "</Time>\n"
@@ -1624,8 +1622,8 @@
       }
     else
       {
-      os << "Problem reading file: " << it->c_str() << std::endl;
-      cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << it->c_str()
+      os << "Problem reading file: " << *it << std::endl;
+      cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << *it
         << " while creating notes" << std::endl);
       }
     os << "</Text>\n"
@@ -1637,7 +1635,7 @@
 }
 
 //----------------------------------------------------------------------
-int cmCTest::GenerateNotesFile(const std::vector<cmStdString> &files)
+int cmCTest::GenerateNotesFile(const VectorOfStrings &files)
 {
   cmGeneratedFileStream ofs;
   if ( !this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs) )
@@ -1658,7 +1656,7 @@
     return 1;
     }
 
-  std::vector<cmStdString> files;
+  VectorOfStrings files;
 
   cmCTestLog(this, OUTPUT, "Create notes file" << std::endl);
 
@@ -1675,7 +1673,7 @@
 std::string cmCTest::Base64GzipEncodeFile(std::string file)
 {
   std::string tarFile = file + "_temp.tar.gz";
-  std::vector<cmStdString> files;
+  std::vector<std::string> files;
   files.push_back(file);
 
   if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false))
@@ -1722,9 +1720,9 @@
 
 
 //----------------------------------------------------------------------
-bool cmCTest::SubmitExtraFiles(const std::vector<cmStdString> &files)
+bool cmCTest::SubmitExtraFiles(const VectorOfStrings &files)
 {
-  std::vector<cmStdString>::const_iterator it;
+  VectorOfStrings::const_iterator it;
   for ( it = files.begin();
     it != files.end();
     ++ it )
@@ -1732,7 +1730,7 @@
     if ( !cmSystemTools::FileExists(it->c_str()) )
       {
       cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: "
-        << it->c_str() << " to submit."
+        << *it << " to submit."
         << std::endl;);
       return false;
       }
@@ -1749,7 +1747,7 @@
     return 1;
     }
 
-  std::vector<cmStdString> files;
+  VectorOfStrings files;
 
   cmCTestLog(this, OUTPUT, "Submit extra files" << std::endl);
 
@@ -2126,7 +2124,7 @@
   if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1)
     {
     i++;
-    this->AddCTestConfigurationOverwrite(args[i].c_str());
+    this->AddCTestConfigurationOverwrite(args[i]);
     }
   if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1)
     {
@@ -2246,7 +2244,7 @@
   std::string value;
   cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
 
-  if (cmCacheManager::ParseEntry(arg.c_str(), name, value, type))
+  if (cmCacheManager::ParseEntry(arg, name, value, type))
     {
     this->Definitions[name] = value;
     return true;
@@ -2319,7 +2317,7 @@
         executeTests = false;
         cmCTestLog(this, ERROR_MESSAGE,
           "CTest -T called with incorrect option: "
-          << args[i].c_str() << std::endl);
+          << args[i] << std::endl);
         cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
           << "  " << ctestExec << " -T all" << std::endl
           << "  " << ctestExec << " -T start" << std::endl
@@ -2356,7 +2354,7 @@
         {
         executeTests = false;
         cmCTestLog(this, ERROR_MESSAGE,
-          "CTest -M called with incorrect option: " << str.c_str()
+          "CTest -M called with incorrect option: " << str
           << std::endl);
         cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
           << "  " << ctestExec << " -M Continuous" << std::endl
@@ -2527,11 +2525,11 @@
   std::string fname = dir;
   fname += "/CTestCustom.cmake";
   cmCTestLog(this, DEBUG, "* Check for file: "
-    << fname.c_str() << std::endl);
+    << fname << std::endl);
   if ( cmSystemTools::FileExists(fname.c_str()) )
     {
     cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
-      << fname.c_str() << std::endl);
+      << fname << std::endl);
     bool erroroc = cmSystemTools::GetErrorOccuredFlag();
     cmSystemTools::ResetErrorOccuredFlag();
 
@@ -2540,7 +2538,7 @@
       {
       cmCTestLog(this, ERROR_MESSAGE,
         "Problem reading custom configuration: "
-        << fname.c_str() << std::endl);
+        << fname << std::endl);
       }
     found = true;
     if ( erroroc )
@@ -2552,7 +2550,7 @@
   std::string rexpr = dir;
   rexpr += "/CTestCustom.ctest";
   cmCTestLog(this, DEBUG, "* Check for file: "
-    << rexpr.c_str() << std::endl);
+    << rexpr << std::endl);
   if ( !found && cmSystemTools::FileExists(rexpr.c_str()) )
     {
     cmsys::Glob gl;
@@ -2564,13 +2562,13 @@
       ++ fileIt )
       {
       cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
-        << fileIt->c_str() << std::endl);
+        << *fileIt << std::endl);
       if ( !mf->ReadListFile(0, fileIt->c_str()) ||
         cmSystemTools::GetErrorOccuredFlag() )
         {
         cmCTestLog(this, ERROR_MESSAGE,
           "Problem reading custom configuration: "
-          << fileIt->c_str() << std::endl);
+          << *fileIt << std::endl);
         }
       }
     found = true;
@@ -2584,7 +2582,7 @@
       {
       cmCTestLog(this, DEBUG,
         "* Read custom CTest configuration vectors for handler: "
-        << it->first.c_str() << " (" << it->second << ")" << std::endl);
+        << it->first << " (" << it->second << ")" << std::endl);
       it->second->PopulateCustomVectors(mf);
       }
     }
@@ -2593,13 +2591,9 @@
 }
 
 //----------------------------------------------------------------------
-void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def,
-  VectorOfStrings& vec)
+void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
+  std::vector<std::string>& vec)
 {
-  if ( !def)
-    {
-    return;
-    }
   const char* dval = mf->GetDefinition(def);
   if ( !dval )
     {
@@ -2614,18 +2608,15 @@
 
   for ( it = slist.begin(); it != slist.end(); ++it )
     {
-    cmCTestLog(this, DEBUG, "  -- " << it->c_str() << std::endl);
-    vec.push_back(it->c_str());
+    cmCTestLog(this, DEBUG, "  -- " << *it << std::endl);
+    vec.push_back(*it);
     }
 }
 
 //----------------------------------------------------------------------
-void cmCTest::PopulateCustomInteger(cmMakefile* mf, const char* def, int& val)
+void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def,
+  int& val)
 {
-  if ( !def)
-    {
-    return;
-    }
   const char* dval = mf->GetDefinition(def);
   if ( !dval )
     {
@@ -2702,7 +2693,7 @@
 }
 
 //----------------------------------------------------------------------
-std::string cmCTest::GetCTestConfiguration(const char *name)
+std::string cmCTest::GetCTestConfiguration(const std::string& name)
 {
   if ( this->CTestConfigurationOverwrites.find(name) !=
     this->CTestConfigurationOverwrites.end() )
@@ -2847,9 +2838,8 @@
 }
 
 //----------------------------------------------------------------------
-void cmCTest::AddCTestConfigurationOverwrite(const char* encstr)
+void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr)
 {
-  std::string overStr = encstr;
   size_t epos = overStr.find("=");
   if ( epos == overStr.npos )
     {
@@ -2857,7 +2847,7 @@
       "CTest configuration overwrite specified in the wrong format."
       << std::endl
       << "Valid format is: --overwrite key=value" << std::endl
-      << "The specified was: --overwrite " << overStr.c_str() << std::endl);
+      << "The specified was: --overwrite " << overStr << std::endl);
     return;
     }
   std::string key = overStr.substr(0, epos);
@@ -2877,7 +2867,7 @@
 
 //----------------------------------------------------------------------
 bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
-  const char* dconfig, const char* cmake_var)
+  const char* dconfig, const std::string& cmake_var)
 {
   const char* ctvar;
   ctvar = mf->GetDefinition(cmake_var);
@@ -2900,7 +2890,7 @@
   const char* dir,
   double timeout)
 {
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+  std::vector<std::string> args = cmSystemTools::ParseArguments(command);
 
   if(args.size() < 1)
     {
@@ -2908,7 +2898,7 @@
     }
 
   std::vector<const char*> argv;
-  for(std::vector<cmStdString>::const_iterator a = args.begin();
+  for(std::vector<std::string>::const_iterator a = args.begin();
       a != args.end(); ++a)
     {
     argv.push_back(a->c_str());
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index becb0f5..246294f 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -70,8 +70,8 @@
   {
     PartInfo(): Enabled(false) {}
 
-    void SetName(const char* name) { this->Name = name; }
-    const char* GetName() const { return this->Name.c_str(); }
+    void SetName(const std::string& name) { this->Name = name; }
+    const std::string& GetName() const { return this->Name; }
 
     void Enable() { this->Enabled = true; }
     operator bool() const { return this->Enabled; }
@@ -101,8 +101,8 @@
       if the string does not name a valid part.  */
   Part GetPartFromName(const char* name);
 
-  typedef std::vector<cmStdString> VectorOfStrings;
-  typedef std::set<cmStdString> SetOfStrings;
+  typedef std::vector<cmsys::String> VectorOfStrings;
+  typedef std::set<std::string> SetOfStrings;
 
   ///! Process Command line arguments
   int Run(std::vector<std::string> &, std::string* output = 0);
@@ -134,7 +134,7 @@
   /*
    * Is the tomorrow tag set?
    */
-  bool GetTomorrowTag() { return this->TomorrowTag; };
+  bool GetTomorrowTag() { return this->TomorrowTag; }
 
   /**
    * Try to run tests of the project
@@ -167,12 +167,12 @@
    * Set the cmake test mode (experimental, nightly, continuous).
    */
   void SetTestModel(int mode);
-  int GetTestModel() { return this->TestModel; };
+  int GetTestModel() { return this->TestModel; }
 
   std::string GetTestModelString();
   static int GetTestModelFromString(const char* str);
   static std::string CleanString(const std::string& str);
-  std::string GetCTestConfiguration(const char *name);
+  std::string GetCTestConfiguration(const std::string& name);
   void SetCTestConfiguration(const char *name, const char* value);
   void EmptyCTestConfiguration();
 
@@ -185,9 +185,9 @@
   //! Set the notes files to be created.
   void SetNotesFiles(const char* notes);
 
-  void PopulateCustomVector(cmMakefile* mf, const char* definition,
-    VectorOfStrings& vec);
-  void PopulateCustomInteger(cmMakefile* mf, const char* def,
+  void PopulateCustomVector(cmMakefile* mf, const std::string& definition,
+    std::vector<std::string>& vec);
+  void PopulateCustomInteger(cmMakefile* mf, const std::string& def,
     int& val);
 
   ///! Get the current time as string
@@ -332,7 +332,7 @@
    * Set the CTest variable from CMake variable
    */
   bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
-    const char* dconfig, const char* cmake_var);
+    const char* dconfig, const std::string& cmake_var);
 
   //! Make string safe to be send as an URL
   static std::string MakeURLSafe(const std::string&);
@@ -349,14 +349,14 @@
 
   //! Add overwrite to ctest configuration.
   // The format is key=value
-  void AddCTestConfigurationOverwrite(const char* encstr);
+  void AddCTestConfigurationOverwrite(const std::string& encstr);
 
   //! Create XML file that contains all the notes specified
-  int GenerateNotesFile(const std::vector<cmStdString> &files);
+  int GenerateNotesFile(const VectorOfStrings &files);
 
   //! Submit extra files to the server
   bool SubmitExtraFiles(const char* files);
-  bool SubmitExtraFiles(const std::vector<cmStdString> &files);
+  bool SubmitExtraFiles(const VectorOfStrings &files);
 
   //! Set the output log file name
   void SetOutputLogFileName(const char* name);
@@ -391,8 +391,8 @@
   //! Read the custom configuration files and apply them to the current ctest
   int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf);
 
-  std::vector<cmStdString> &GetInitialCommandLineArguments()
-  { return this->InitialCommandLineArguments; };
+  std::vector<std::string> &GetInitialCommandLineArguments()
+  { return this->InitialCommandLineArguments; }
 
   //! Set the track to submit to
   void SetSpecificTrack(const char* track);
@@ -447,13 +447,13 @@
   void DetermineNextDayStop();
 
   // these are helper classes
-  typedef std::map<cmStdString,cmCTestGenericHandler*> t_TestingHandlers;
+  typedef std::map<std::string,cmCTestGenericHandler*> t_TestingHandlers;
   t_TestingHandlers TestingHandlers;
 
   bool ShowOnly;
 
   //! Map of configuration properties
-  typedef std::map<cmStdString, cmStdString> CTestConfigurationMap;
+  typedef std::map<std::string, std::string> CTestConfigurationMap;
 
   std::string             CTestConfigFile;
   // TODO: The ctest configuration should be a hierarchy of
@@ -463,7 +463,7 @@
   CTestConfigurationMap CTestConfiguration;
   CTestConfigurationMap CTestConfigurationOverwrites;
   PartInfo                Parts[PartCount];
-  typedef std::map<cmStdString, Part> PartMapType;
+  typedef std::map<std::string, Part> PartMapType;
   PartMapType             PartMap;
 
   std::string             CurrentTag;
@@ -556,7 +556,7 @@
   int  DartVersion;
   bool DropSiteCDash;
 
-  std::vector<cmStdString> InitialCommandLineArguments;
+  std::vector<std::string> InitialCommandLineArguments;
 
   int SubmitIndex;
 
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index cc9fa57..d6b84a0 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -82,19 +82,19 @@
 }
 
 
-bool cmCacheManager::LoadCache(const char* path)
+bool cmCacheManager::LoadCache(const std::string& path)
 {
   return this->LoadCache(path,true);
 }
 
-bool cmCacheManager::LoadCache(const char* path,
+bool cmCacheManager::LoadCache(const std::string& path,
                                bool internal)
 {
-  std::set<cmStdString> emptySet;
+  std::set<std::string> emptySet;
   return this->LoadCache(path, internal, emptySet, emptySet);
 }
 
-static bool ParseEntryWithoutType(const char* entry,
+static bool ParseEntryWithoutType(const std::string& entry,
                                   std::string& var,
                                   std::string& value)
 {
@@ -132,7 +132,7 @@
   return flag;
 }
 
-bool cmCacheManager::ParseEntry(const char* entry,
+bool cmCacheManager::ParseEntry(const std::string& entry,
                                 std::string& var,
                                 std::string& value,
                                 CacheEntryType& type)
@@ -178,7 +178,7 @@
   return flag;
 }
 
-void cmCacheManager::CleanCMakeFiles(const char* path)
+void cmCacheManager::CleanCMakeFiles(const std::string& path)
 {
   std::string glob = path;
   glob += cmake::GetCMakeFilesDirectory();
@@ -193,10 +193,10 @@
     }
 }
 
-bool cmCacheManager::LoadCache(const char* path,
+bool cmCacheManager::LoadCache(const std::string& path,
                                bool internal,
-                               std::set<cmStdString>& excludes,
-                               std::set<cmStdString>& includes)
+                               std::set<std::string>& excludes,
+                               std::set<std::string>& includes)
 {
   std::string cacheFile = path;
   cacheFile += "/CMakeCache.txt";
@@ -428,7 +428,7 @@
 }
 
 
-bool cmCacheManager::SaveCache(const char* path)
+bool cmCacheManager::SaveCache(const std::string& path)
 {
   std::string cacheFile = path;
   cacheFile += "/CMakeCache.txt";
@@ -500,7 +500,7 @@
   fout << "########################\n";
   fout << "\n";
 
-  for( std::map<cmStdString, CacheEntry>::const_iterator i =
+  for( std::map<std::string, CacheEntry>::const_iterator i =
          this->Cache.begin(); i != this->Cache.end(); ++i)
     {
     const CacheEntry& ce = (*i).second;
@@ -578,7 +578,7 @@
   return true;
 }
 
-bool cmCacheManager::DeleteCache(const char* path)
+bool cmCacheManager::DeleteCache(const std::string& path)
 {
   std::string cacheFile = path;
   cmSystemTools::ConvertToUnixSlashes(cacheFile);
@@ -644,13 +644,13 @@
         fout << "\\n";
         }
       oneLine = helpString.substr(pos, i - pos);
-      fout << oneLine.c_str() << "\n";
+      fout << oneLine << "\n";
       pos = i;
       }
     }
 }
 
-void cmCacheManager::RemoveCacheEntry(const char* key)
+void cmCacheManager::RemoveCacheEntry(const std::string& key)
 {
   CacheEntryMap::iterator i = this->Cache.find(key);
   if(i != this->Cache.end())
@@ -660,7 +660,8 @@
 }
 
 
-cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key)
+cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(
+    const std::string& key)
 {
   CacheEntryMap::iterator i = this->Cache.find(key);
   if(i != this->Cache.end())
@@ -676,7 +677,7 @@
   return CacheIterator(*this, key);
 }
 
-const char* cmCacheManager::GetCacheValue(const char* key) const
+const char* cmCacheManager::GetCacheValue(const std::string& key) const
 {
   CacheEntryMap::const_iterator i = this->Cache.find(key);
   if(i != this->Cache.end() &&
@@ -692,12 +693,12 @@
 {
   out << "=================================================" << std::endl;
   out << "CMakeCache Contents:" << std::endl;
-  for(std::map<cmStdString, CacheEntry>::const_iterator i =
+  for(std::map<std::string, CacheEntry>::const_iterator i =
         this->Cache.begin(); i != this->Cache.end(); ++i)
     {
     if((*i).second.Type != INTERNAL)
       {
-      out << (*i).first.c_str() << " = " << (*i).second.Value.c_str()
+      out << (*i).first << " = " << (*i).second.Value
           << std::endl;
       }
     }
@@ -708,7 +709,7 @@
 }
 
 
-void cmCacheManager::AddCacheEntry(const char* key,
+void cmCacheManager::AddCacheEntry(const std::string& key,
                                    const char* value,
                                    const char* helpString,
                                    CacheEntryType type)
@@ -763,7 +764,7 @@
   this->Position = this->Container.Cache.begin();
 }
 
-bool cmCacheManager::CacheIterator::Find(const char* key)
+bool cmCacheManager::CacheIterator::Find(const std::string& key)
 {
   this->Position = this->Container.Cache.find(key);
   return !this->IsAtEnd();
@@ -803,13 +804,13 @@
 
 //----------------------------------------------------------------------------
 const char*
-cmCacheManager::CacheEntry::GetProperty(const char* prop) const
+cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
 {
-  if(strcmp(prop, "TYPE") == 0)
+  if(prop == "TYPE")
     {
     return cmCacheManagerTypes[this->Type];
     }
-  else if(strcmp(prop, "VALUE") == 0)
+  else if(prop == "VALUE")
     {
     return this->Value.c_str();
     }
@@ -819,14 +820,14 @@
 }
 
 //----------------------------------------------------------------------------
-void cmCacheManager::CacheEntry::SetProperty(const char* prop,
+void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
                                              const char* value)
 {
-  if(strcmp(prop, "TYPE") == 0)
+  if(prop == "TYPE")
     {
     this->Type = cmCacheManager::StringToType(value? value : "STRING");
     }
-  else if(strcmp(prop, "VALUE") == 0)
+  else if(prop == "VALUE")
     {
     this->Value = value? value : "";
     }
@@ -837,15 +838,15 @@
 }
 
 //----------------------------------------------------------------------------
-void cmCacheManager::CacheEntry::AppendProperty(const char* prop,
+void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
                                                 const char* value,
                                                 bool asString)
 {
-  if(strcmp(prop, "TYPE") == 0)
+  if(prop == "TYPE")
     {
     this->Type = cmCacheManager::StringToType(value? value : "STRING");
     }
-  else if(strcmp(prop, "VALUE") == 0)
+  else if(prop == "VALUE")
     {
     if(value)
       {
@@ -863,7 +864,8 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const
+const char* cmCacheManager::CacheIterator::GetProperty(
+    const std::string& prop) const
 {
   if(!this->IsAtEnd())
     {
@@ -873,7 +875,8 @@
 }
 
 //----------------------------------------------------------------------------
-void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
+void cmCacheManager::CacheIterator::SetProperty(const std::string& p,
+                                                const char* v)
 {
   if(!this->IsAtEnd())
     {
@@ -882,7 +885,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmCacheManager::CacheIterator::AppendProperty(const char* p,
+void cmCacheManager::CacheIterator::AppendProperty(const std::string& p,
                                                    const char* v,
                                                    bool asString)
 {
@@ -893,7 +896,8 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const
+bool cmCacheManager::CacheIterator::GetPropertyAsBool(
+    const std::string& prop) const
 {
   if(const char* value = this->GetProperty(prop))
     {
@@ -903,13 +907,14 @@
 }
 
 //----------------------------------------------------------------------------
-void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v)
+void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v)
 {
   this->SetProperty(p, v ? "ON" : "OFF");
 }
 
 //----------------------------------------------------------------------------
-bool cmCacheManager::CacheIterator::PropertyExists(const char* prop) const
+bool cmCacheManager::CacheIterator::PropertyExists(
+    const std::string& prop) const
 {
   return this->GetProperty(prop)? true:false;
 }
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index f487e8e..d9a9112 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -39,9 +39,9 @@
     std::string Value;
     CacheEntryType Type;
     cmPropertyMap Properties;
-    const char* GetProperty(const char*) const;
-    void SetProperty(const char* property, const char* value);
-    void AppendProperty(const char* property, const char* value,
+    const char* GetProperty(const std::string&) const;
+    void SetProperty(const std::string& property, const char* value);
+    void AppendProperty(const std::string& property, const char* value,
                         bool asString=false);
     bool Initialized;
     CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false)
@@ -53,26 +53,26 @@
   {
   public:
     void Begin();
-    bool Find(const char*);
+    bool Find(const std::string&);
     bool IsAtEnd() const;
     void Next();
-    const char *GetName() const {
-      return this->Position->first.c_str(); }
-    const char* GetProperty(const char*) const ;
-    bool GetPropertyAsBool(const char*) const ;
-    bool PropertyExists(const char*) const;
-    void SetProperty(const char* property, const char* value);
-    void AppendProperty(const char* property, const char* value,
+    std::string GetName() const {
+      return this->Position->first; }
+    const char* GetProperty(const std::string&) const ;
+    bool GetPropertyAsBool(const std::string&) const ;
+    bool PropertyExists(const std::string&) const;
+    void SetProperty(const std::string& property, const char* value);
+    void AppendProperty(const std::string& property, const char* value,
                         bool asString=false);
-    void SetProperty(const char* property, bool value);
-    const char* GetValue() const { return this->GetEntry().Value.c_str(); }
+    void SetProperty(const std::string& property, bool value);
+    std::string GetValue() const { return this->GetEntry().Value; }
     bool GetValueAsBool() const;
     void SetValue(const char*);
     CacheEntryType GetType() const { return this->GetEntry().Type; }
     void SetType(CacheEntryType ty) { this->GetEntry().Type = ty; }
     bool Initialized() { return this->GetEntry().Initialized; }
     cmCacheManager &Container;
-    std::map<cmStdString, CacheEntry>::iterator Position;
+    std::map<std::string, CacheEntry>::iterator Position;
     CacheIterator(cmCacheManager &cm) : Container(cm) {
       this->Begin();
     }
@@ -108,19 +108,19 @@
   ///! Load a cache for given makefile.  Loads from ouput home.
   bool LoadCache(cmMakefile*);
   ///! Load a cache for given makefile.  Loads from path/CMakeCache.txt.
-  bool LoadCache(const char* path);
-  bool LoadCache(const char* path, bool internal);
-  bool LoadCache(const char* path, bool internal,
-                 std::set<cmStdString>& excludes,
-                 std::set<cmStdString>& includes);
+  bool LoadCache(const std::string& path);
+  bool LoadCache(const std::string& path, bool internal);
+  bool LoadCache(const std::string& path, bool internal,
+                 std::set<std::string>& excludes,
+                 std::set<std::string>& includes);
 
   ///! Save cache for given makefile.  Saves to ouput home CMakeCache.txt.
   bool SaveCache(cmMakefile*) ;
   ///! Save cache for given makefile.  Saves to ouput path/CMakeCache.txt
-  bool SaveCache(const char* path) ;
+  bool SaveCache(const std::string& path) ;
 
   ///! Delete the cache given
-  bool DeleteCache(const char* path);
+  bool DeleteCache(const std::string& path);
 
   ///! Print the cache to a stream
   void PrintCache(std::ostream&) const;
@@ -129,20 +129,20 @@
   cmCacheManager::CacheIterator GetCacheIterator(const char *key=0);
 
   ///! Remove an entry from the cache
-  void RemoveCacheEntry(const char* key);
+  void RemoveCacheEntry(const std::string& key);
 
   ///! Get the number of entries in the cache
   int GetSize() {
     return static_cast<int>(this->Cache.size()); }
 
   ///! Break up a line like VAR:type="value" into var, type and value
-  static bool ParseEntry(const char* entry,
+  static bool ParseEntry(const std::string& entry,
                          std::string& var,
                          std::string& value,
                          CacheEntryType& type);
 
   ///! Get a value from the cache given a key
-  const char* GetCacheValue(const char* key) const;
+  const char* GetCacheValue(const std::string& key) const;
 
   /** Get the version of CMake that wrote the cache.  */
   unsigned int GetCacheMajorVersion() const
@@ -153,20 +153,20 @@
 
 protected:
   ///! Add an entry into the cache
-  void AddCacheEntry(const char* key, const char* value,
+  void AddCacheEntry(const std::string& key, const char* value,
                      const char* helpString, CacheEntryType type);
 
   ///! Get a cache entry object for a key
-  CacheEntry *GetCacheEntry(const char *key);
+  CacheEntry *GetCacheEntry(const std::string& key);
   ///! Clean out the CMakeFiles directory if no CMakeCache.txt
-  void CleanCMakeFiles(const char* path);
+  void CleanCMakeFiles(const std::string& path);
 
   // Cache version info
   unsigned int CacheMajorVersion;
   unsigned int CacheMinorVersion;
 private:
   cmake* CMakeInstance;
-  typedef  std::map<cmStdString, CacheEntry> CacheEntryMap;
+  typedef  std::map<std::string, CacheEntry> CacheEntryMap;
   static void OutputHelpString(std::ostream& fout,
                                const std::string& helpString);
   static void OutputKey(std::ostream& fout, std::string const& key);
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index e148857..a34ea71 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -81,7 +81,7 @@
    * not implement this method.  At this point, reading and
    * writing to the cache can be done.
    */
-  virtual void FinalPass() {};
+  virtual void FinalPass() {}
 
   /**
    * Does this command have a final pass?  Query after InitialPass.
@@ -124,7 +124,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const = 0;
+  virtual std::string GetName() const = 0;
 
   /**
    * Enable the command.
@@ -166,7 +166,7 @@
   /**
    * Set the error message
    */
-  void SetError(const char* e)
+  void SetError(const std::string& e)
     {
     this->Error = this->GetName();
     this->Error += " ";
diff --git a/Source/cmCommandArgumentLexer.cxx b/Source/cmCommandArgumentLexer.cxx
index e62e53e..e23ef8a 100644
--- a/Source/cmCommandArgumentLexer.cxx
+++ b/Source/cmCommandArgumentLexer.cxx
@@ -1069,7 +1069,7 @@
                         "fatal flex scanner internal error--no action found" );
         } /* end of action switch */
                 } /* end of scanning one token */
-return 0; /* this should not happend but it should silence a warning */
+return 0; /* this should not happen but it quiets some compilers */
 } /* end of cmCommandArgument_yylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index dbeeb07..64b67c9 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -49,14 +49,14 @@
   this->FileName = file;
 }
 
-char* cmCommandArgumentParserHelper::AddString(const char* str)
+char* cmCommandArgumentParserHelper::AddString(const std::string& str)
 {
-  if ( !str || !*str )
+  if ( str.empty() )
     {
     return this->EmptyVariable;
     }
-  char* stVal = new char[strlen(str)+1];
-  strcpy(stVal, str);
+  char* stVal = new char[str.size()+1];
+  strcpy(stVal, str.c_str());
   this->Variables.push_back(stVal);
   return stVal;
 }
@@ -79,7 +79,7 @@
       {
       if (this->EscapeQuotes)
         {
-        return this->AddString(cmSystemTools::EscapeQuotes(ptr).c_str());
+        return this->AddString(cmSystemTools::EscapeQuotes(ptr));
         }
       else
         {
@@ -94,7 +94,7 @@
       {
       if(this->EscapeQuotes)
         {
-        return this->AddString(cmSystemTools::EscapeQuotes(c).c_str());
+        return this->AddString(cmSystemTools::EscapeQuotes(c));
         }
       else
         {
@@ -120,7 +120,7 @@
     {
     cmOStringStream ostr;
     ostr << this->FileLine;
-    return this->AddString(ostr.str().c_str());
+    return this->AddString(ostr.str());
     }
   const char* value = this->Makefile->GetDefinition(var);
   if(!value && !this->RemoveEmpty)
@@ -137,23 +137,23 @@
                                      this->Makefile->GetHomeOutputDirectory()))
         {
         cmOStringStream msg;
-        cmListFileBacktrace bt;
+        cmListFileBacktrace bt(this->Makefile->GetLocalGenerator());
         cmListFileContext lfc;
         lfc.FilePath = this->FileName;
         lfc.Line = this->FileLine;
         bt.push_back(lfc);
         msg << "uninitialized variable \'" << var << "\'";
         this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
-                                                        msg.str().c_str(), bt);
+                                                        msg.str(), bt);
         }
       }
     return 0;
     }
   if (this->EscapeQuotes && value)
     {
-    return this->AddString(cmSystemTools::EscapeQuotes(value).c_str());
+    return this->AddString(cmSystemTools::EscapeQuotes(value));
     }
-  return this->AddString(value);
+  return this->AddString(value ? value : "");
 }
 
 char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
@@ -166,7 +166,7 @@
     // then return an empty string
     if(!ret && this->RemoveEmpty)
       {
-      return this->AddString(ret);
+      return this->AddString("");
       }
     // if the ret was not 0, then return it
     if(ret)
@@ -181,7 +181,7 @@
   std::string ref = "@";
   ref += var;
   ref += "@";
-  return this->AddString(ref.c_str());
+  return this->AddString(ref);
 }
 
 char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
@@ -293,7 +293,7 @@
   if ( Verbose )
     {
     std::cerr << "Expanding [" << str << "] produced: ["
-              << this->Result.c_str() << "]" << std::endl;
+              << this->Result << "]" << std::endl;
     }
   return 1;
 }
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index f8c672f..d375ae6 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -77,8 +77,8 @@
   char BSLASHVariable[3];
 
 private:
-  cmStdString::size_type InputBufferPos;
-  cmStdString InputBuffer;
+  std::string::size_type InputBufferPos;
+  std::string InputBuffer;
   std::vector<char> OutputBuffer;
   int CurrentLine;
   int Verbose;
@@ -86,7 +86,7 @@
   void Print(const char* place, const char* str);
   void SafePrintMissing(const char* str, int line, int cnt);
 
-  char* AddString(const char* str);
+  char* AddString(const std::string& str);
 
   void CleanupParser();
   void SetError(std::string const& msg);
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 1be5980..995f191 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -172,7 +172,7 @@
 
 //----------------------------------------------------------------------------
 cmComputeLinkDepends
-::cmComputeLinkDepends(cmTarget const* target, const char* config,
+::cmComputeLinkDepends(cmTarget const* target, const std::string& config,
                        cmTarget const* head)
 {
   // Store context information.
@@ -184,7 +184,8 @@
   this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
 
   // The configuration being linked.
-  this->Config = (config && *config)? config : 0;
+  this->HasConfig = !config.empty();
+  this->Config = (this->HasConfig)? config : std::string();
   this->LinkType = this->Target->ComputeLinkType(this->Config);
 
   // Enable debug mode if requested.
@@ -254,7 +255,8 @@
             "---------------------------------------"
             "---------------------------------------\n");
     fprintf(stderr, "Link dependency analysis for target %s, config %s\n",
-            this->Target->GetName(), this->Config?this->Config:"noconfig");
+            this->Target->GetName().c_str(),
+            this->HasConfig?this->Config.c_str():"noconfig");
     this->DisplayConstraintGraph();
     }
 
@@ -278,12 +280,12 @@
 }
 
 //----------------------------------------------------------------------------
-std::map<cmStdString, int>::iterator
+std::map<std::string, int>::iterator
 cmComputeLinkDepends::AllocateLinkEntry(std::string const& item)
 {
-  std::map<cmStdString, int>::value_type
+  std::map<std::string, int>::value_type
     index_entry(item, static_cast<int>(this->EntryList.size()));
-  std::map<cmStdString, int>::iterator
+  std::map<std::string, int>::iterator
     lei = this->LinkEntryIndex.insert(index_entry).first;
   this->EntryList.push_back(LinkEntry());
   this->InferredDependSets.push_back(0);
@@ -296,7 +298,7 @@
                                        std::string const& item)
 {
   // Check if the item entry has already been added.
-  std::map<cmStdString, int>::iterator lei = this->LinkEntryIndex.find(item);
+  std::map<std::string, int>::iterator lei = this->LinkEntryIndex.find(item);
   if(lei != this->LinkEntryIndex.end())
     {
     // Yes.  We do not need to follow the item's dependencies again.
@@ -310,7 +312,7 @@
   int index = lei->second;
   LinkEntry& entry = this->EntryList[index];
   entry.Item = item;
-  entry.Target = this->FindTargetToLink(depender_index, entry.Item.c_str());
+  entry.Target = this->FindTargetToLink(depender_index, entry.Item);
   entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' &&
                   item.substr(0, 10) != "-framework");
 
@@ -326,7 +328,7 @@
     // Look for an old-style <item>_LIB_DEPENDS variable.
     std::string var = entry.Item;
     var += "_LIB_DEPENDS";
-    if(const char* val = this->Makefile->GetDefinition(var.c_str()))
+    if(const char* val = this->Makefile->GetDefinition(var))
       {
       // The item dependencies are known.  Follow them.
       BFSEntry qe = {index, val};
@@ -422,7 +424,7 @@
 void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
 {
   // Check if the target already has an entry.
-  std::map<cmStdString, int>::iterator lei =
+  std::map<std::string, int>::iterator lei =
     this->LinkEntryIndex.find(dep.Item);
   if(lei == this->LinkEntryIndex.end())
     {
@@ -433,7 +435,7 @@
     LinkEntry& entry = this->EntryList[lei->second];
     entry.Item = dep.Item;
     entry.Target = this->FindTargetToLink(dep.DependerIndex,
-                                          dep.Item.c_str());
+                                          dep.Item);
 
     // This item was added specifically because it is a dependent
     // shared library.  It may get special treatment
@@ -504,7 +506,7 @@
         {
         std::string var = *di;
         var += "_LINK_TYPE";
-        if(const char* val = this->Makefile->GetDefinition(var.c_str()))
+        if(const char* val = this->Makefile->GetDefinition(var))
           {
           if(strcmp(val, "debug") == 0)
             {
@@ -620,7 +622,7 @@
 
 //----------------------------------------------------------------------------
 cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
-                                                 const char* name)
+                                                 const std::string& name)
 {
   // Look for a target in the scope of the depender.
   cmMakefile* mf = this->Makefile;
@@ -968,14 +970,14 @@
 //----------------------------------------------------------------------------
 void cmComputeLinkDepends::DisplayFinalEntries()
 {
-  fprintf(stderr, "target [%s] links to:\n", this->Target->GetName());
+  fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str());
   for(std::vector<LinkEntry>::const_iterator lei =
         this->FinalLinkEntries.begin();
       lei != this->FinalLinkEntries.end(); ++lei)
     {
     if(lei->Target)
       {
-      fprintf(stderr, "  target [%s]\n", lei->Target->GetName());
+      fprintf(stderr, "  target [%s]\n", lei->Target->GetName().c_str());
       }
     else
       {
@@ -998,7 +1000,7 @@
   // directories of targets linked in another configuration as link
   // directories.
   if(cmTarget const* tgt
-                      = this->FindTargetToLink(depender_index, item.c_str()))
+                      = this->FindTargetToLink(depender_index, item))
     {
     if(!tgt->IsImported())
       {
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index 9776f55..13fc993 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -32,7 +32,7 @@
 class cmComputeLinkDepends
 {
 public:
-  cmComputeLinkDepends(cmTarget const* target, const char* config,
+  cmComputeLinkDepends(cmTarget const* target, const std::string& config,
                        cmTarget const* head);
   ~cmComputeLinkDepends();
 
@@ -68,7 +68,8 @@
   bool DebugMode;
 
   // Configuration information.
-  const char* Config;
+  bool HasConfig;
+  std::string Config;
   cmTarget::LinkLibraryType LinkType;
 
   // Output information.
@@ -76,18 +77,19 @@
 
   typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType;
 
-  std::map<cmStdString, int>::iterator
+  std::map<std::string, int>::iterator
   AllocateLinkEntry(std::string const& item);
   int AddLinkEntry(int depender_index, std::string const& item);
   void AddVarLinkEntries(int depender_index, const char* value);
   void AddDirectLinkEntries();
   void AddLinkEntries(int depender_index,
                       std::vector<std::string> const& libs);
-  cmTarget const* FindTargetToLink(int depender_index, const char* name);
+  cmTarget const* FindTargetToLink(int depender_index,
+                                   const std::string& name);
 
   // One entry for each unique item.
   std::vector<LinkEntry> EntryList;
-  std::map<cmStdString, int> LinkEntryIndex;
+  std::map<std::string, int> LinkEntryIndex;
 
   // BFS of initial dependencies.
   struct BFSEntry
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 6986965..ea8536f 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -239,7 +239,7 @@
 
 //----------------------------------------------------------------------------
 cmComputeLinkInformation
-::cmComputeLinkInformation(cmTarget const* target, const char* config,
+::cmComputeLinkInformation(cmTarget const* target, const std::string& config,
                            cmTarget const* headTarget)
 {
   // Store context information.
@@ -268,7 +268,7 @@
 
   // Get the language used for linking this target.
   this->LinkLanguage = this->Target->GetLinkerLanguage(config, headTarget);
-  if(!this->LinkLanguage)
+  if(this->LinkLanguage.empty())
     {
     // The Compute method will do nothing, so skip the rest of the
     // initialization.
@@ -293,7 +293,7 @@
     std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_";
     loader_flag_var += this->LinkLanguage;
     loader_flag_var += "_FLAG";
-    this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var.c_str());
+    this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var);
     }
 
   // Get options needed to link libraries.
@@ -317,8 +317,8 @@
     rtVar += this->LinkLanguage;
     rtVar += "_FLAG";
     std::string rtSepVar = rtVar + "_SEP";
-    this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar.c_str());
-    this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar.c_str());
+    this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar);
+    this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar);
     this->RuntimeAlways =
       (this->Makefile->
        GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
@@ -330,7 +330,7 @@
     rlVar += "_RPATH_LINK_";
     rlVar += this->LinkLanguage;
     rlVar += "_FLAG";
-    this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar.c_str());
+    this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar);
     }
 
   // Check if we need to include the runtime search path at link time.
@@ -338,7 +338,7 @@
   std::string var = "CMAKE_SHARED_LIBRARY_LINK_";
   var += this->LinkLanguage;
   var += "_WITH_RUNTIME_PATH";
-  this->LinkWithRuntimePath = this->Makefile->IsOn(var.c_str());
+  this->LinkWithRuntimePath = this->Makefile->IsOn(var);
   }
 
   // Check the platform policy for missing soname case.
@@ -496,16 +496,17 @@
     }
 
   // We require a link language for the target.
-  if(!this->LinkLanguage)
+  if(this->LinkLanguage.empty())
     {
     cmSystemTools::
       Error("CMake can not determine linker language for target: ",
-            this->Target->GetName());
+            this->Target->GetName().c_str());
     return false;
     }
 
   // Compute the ordered link line items.
-  cmComputeLinkDepends cld(this->Target, this->Config, this->HeadTarget);
+  cmComputeLinkDepends cld(this->Target, this->Config,
+                           this->HeadTarget);
   cld.SetOldLinkDirMode(this->OldLinkDirMode);
   cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
 
@@ -592,7 +593,7 @@
   std::string libVar = "CMAKE_";
   libVar += lang;
   libVar += "_IMPLICIT_LINK_LIBRARIES";
-  if(const char* libs = this->Makefile->GetDefinition(libVar.c_str()))
+  if(const char* libs = this->Makefile->GetDefinition(libVar))
     {
     std::vector<std::string> libsVec;
     cmSystemTools::ExpandListArgument(libs, libsVec);
@@ -601,7 +602,7 @@
       {
       if(this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end())
         {
-        this->AddItem(i->c_str(), 0);
+        this->AddItem(*i, 0);
         }
       }
     }
@@ -611,7 +612,7 @@
   std::string dirVar = "CMAKE_";
   dirVar += lang;
   dirVar += "_IMPLICIT_LINK_DIRECTORIES";
-  if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str()))
+  if(const char* dirs = this->Makefile->GetDefinition(dirVar))
     {
     std::vector<std::string> dirsVec;
     cmSystemTools::ExpandListArgument(dirs, dirsVec);
@@ -624,7 +625,7 @@
                                        cmTarget const* tgt)
 {
   // Compute the proper name to use to link this library.
-  const char* config = this->Config;
+  const std::string& config = this->Config;
   bool impexe = (tgt && tgt->IsExecutableWithExports());
   if(impexe && !this->UseImportLibrary && !this->LoaderFlag)
     {
@@ -819,7 +820,7 @@
     static_link_type_flag_var += this->LinkLanguage;
     static_link_type_flag_var += "_FLAGS";
     static_link_type_flag =
-      this->Makefile->GetDefinition(static_link_type_flag_var.c_str());
+      this->Makefile->GetDefinition(static_link_type_flag_var);
 
     std::string shared_link_type_flag_var = "CMAKE_";
     shared_link_type_flag_var += target_type_str;
@@ -827,7 +828,7 @@
     shared_link_type_flag_var += this->LinkLanguage;
     shared_link_type_flag_var += "_FLAGS";
     shared_link_type_flag =
-      this->Makefile->GetDefinition(shared_link_type_flag_var.c_str());
+      this->Makefile->GetDefinition(shared_link_type_flag_var);
     }
 
   // We can support link type switching only if all needed flags are
@@ -902,7 +903,7 @@
   // be the library name.  Match index 3 will be the library
   // extension.
   reg = "^(";
-  for(std::set<cmStdString>::iterator p = this->LinkPrefixes.begin();
+  for(std::set<std::string>::iterator p = this->LinkPrefixes.begin();
       p != this->LinkPrefixes.end(); ++p)
     {
     reg += *p;
@@ -1126,9 +1127,10 @@
 
   // Full path libraries should specify a valid library file name.
   // See documentation of CMP0008.
+  std::string generator = this->GlobalGenerator->GetName();
   if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
-     (strstr(this->GlobalGenerator->GetName(), "Visual Studio") ||
-      strstr(this->GlobalGenerator->GetName(), "Xcode")))
+     (generator.find("Visual Studio") != generator.npos ||
+      generator.find("Xcode") != generator.npos))
     {
     std::string file = cmSystemTools::GetFilenameName(item);
     if(!this->ExtractAnyLibraryName.find(file.c_str()))
@@ -1368,7 +1370,7 @@
 
   // Add the item using the -framework option.
   this->Items.push_back(Item("-framework", false));
-  fw = this->LocalGenerator->EscapeForShell(fw.c_str());
+  fw = this->LocalGenerator->EscapeForShell(fw);
   this->Items.push_back(Item(fw, false));
 }
 
@@ -1417,7 +1419,7 @@
   implicitDirVar += this->LinkLanguage;
   implicitDirVar += "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES";
   if(const char* implicitDirs =
-     this->Makefile->GetDefinition(implicitDirVar.c_str()))
+     this->Makefile->GetDefinition(implicitDirVar))
     {
     cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
     }
@@ -1504,9 +1506,9 @@
       // Print the warning at most once for this item.
       std::string wid = "CMP0008-WARNING-GIVEN-";
       wid += item;
-      if(!this->CMakeInstance->GetPropertyAsBool(wid.c_str()))
+      if(!this->CMakeInstance->GetPropertyAsBool(wid))
         {
-        this->CMakeInstance->SetProperty(wid.c_str(), "1");
+        this->CMakeInstance->SetProperty(wid, "1");
         cmOStringStream w;
         w << (this->Makefile->GetPolicies()
               ->GetPolicyWarning(cmPolicies::CMP0008)) << "\n"
@@ -1640,7 +1642,7 @@
 
   // List the paths old behavior is adding.
   os << "and other libraries with known full path:\n";
-  std::set<cmStdString> emitted;
+  std::set<std::string> emitted;
   for(std::vector<std::string>::const_iterator
         i = this->OldLinkDirItems.begin();
       i != this->OldLinkDirItems.end(); ++i)
@@ -1690,7 +1692,7 @@
   implicitDirVar += this->LinkLanguage;
   implicitDirVar += "_IMPLICIT_LINK_DIRECTORIES";
   if(const char* implicitDirs =
-     this->Makefile->GetDefinition(implicitDirVar.c_str()))
+     this->Makefile->GetDefinition(implicitDirVar))
     {
     cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
     }
@@ -1708,7 +1710,7 @@
   implicitLibVar += this->LinkLanguage;
   implicitLibVar += "_IMPLICIT_LINK_LIBRARIES";
   if(const char* implicitLibs =
-     this->Makefile->GetDefinition(implicitLibVar.c_str()))
+     this->Makefile->GetDefinition(implicitLibVar))
     {
     cmSystemTools::ExpandListArgument(implicitLibs, implicitLibVec);
     }
@@ -1856,7 +1858,7 @@
 //----------------------------------------------------------------------------
 static void cmCLI_ExpandListUnique(const char* str,
                                    std::vector<std::string>& out,
-                                   std::set<cmStdString>& emitted)
+                                   std::set<std::string>& emitted)
 {
   std::vector<std::string> tmp;
   cmSystemTools::ExpandListArgument(str, tmp);
@@ -1894,7 +1896,7 @@
     this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
 
   // Construct the RPATH.
-  std::set<cmStdString> emitted;
+  std::set<std::string> emitted;
   if(use_install_rpath)
     {
     const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH");
@@ -1976,11 +1978,11 @@
     {
     std::string useVar = "CMAKE_" + *li +
       "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
-    if(this->Makefile->IsOn(useVar.c_str()))
+    if(this->Makefile->IsOn(useVar))
       {
       std::string dirVar = "CMAKE_" + *li +
         "_IMPLICIT_LINK_DIRECTORIES";
-      if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str()))
+      if(const char* dirs = this->Makefile->GetDefinition(dirVar))
         {
         cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted);
         }
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 356e6ed..e345fe2 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -29,7 +29,7 @@
 class cmComputeLinkInformation
 {
 public:
-  cmComputeLinkInformation(cmTarget const* target, const char* config,
+  cmComputeLinkInformation(cmTarget const* target, const std::string& config,
                            cmTarget const* headTarget);
   ~cmComputeLinkInformation();
   bool Compute();
@@ -50,7 +50,7 @@
   std::vector<std::string> const& GetDirectories();
   std::vector<std::string> const& GetDepends();
   std::vector<std::string> const& GetFrameworkPaths();
-  const char* GetLinkLanguage() const { return this->LinkLanguage; }
+  std::string GetLinkLanguage() const { return this->LinkLanguage; }
   std::vector<std::string> const& GetRuntimeSearchPath();
   std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
   std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
@@ -82,8 +82,8 @@
   cmake* CMakeInstance;
 
   // Configuration information.
-  const char* Config;
-  const char* LinkLanguage;
+  std::string Config;
+  std::string LinkLanguage;
   bool LinkDependsNoShared;
 
   // Modes for dealing with dependent shared libraries.
@@ -126,7 +126,7 @@
   std::vector<std::string> StaticLinkExtensions;
   std::vector<std::string> SharedLinkExtensions;
   std::vector<std::string> LinkExtensions;
-  std::set<cmStdString> LinkPrefixes;
+  std::set<std::string> LinkPrefixes;
   cmsys::RegularExpression ExtractStaticLibraryName;
   cmsys::RegularExpression ExtractSharedLibraryName;
   cmsys::RegularExpression ExtractAnyLibraryName;
@@ -153,7 +153,7 @@
   // Framework info.
   void ComputeFrameworkInfo();
   void AddFrameworkPath(std::string const& p);
-  std::set<cmStdString> FrameworkPathsEmmitted;
+  std::set<std::string> FrameworkPathsEmmitted;
   cmsys::RegularExpression SplitFramework;
 
   // Linker search path computation.
@@ -165,14 +165,14 @@
   void LoadImplicitLinkInfo();
   void AddImplicitLinkInfo();
   void AddImplicitLinkInfo(std::string const& lang);
-  std::set<cmStdString> ImplicitLinkDirs;
-  std::set<cmStdString> ImplicitLinkLibs;
+  std::set<std::string> ImplicitLinkDirs;
+  std::set<std::string> ImplicitLinkLibs;
 
   // Additional paths configured by the runtime linker
   std::vector<std::string> RuntimeLinkDirs;
 
   // Linker search path compatibility mode.
-  std::set<cmStdString> OldLinkDirMask;
+  std::set<std::string> OldLinkDirMask;
   std::vector<std::string> OldLinkDirItems;
   std::vector<std::string> OldUserFlagItems;
   bool OldLinkDirMode;
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 9136869..f28217f 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -16,6 +16,7 @@
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
+#include "cmSourceFile.h"
 #include "cmTarget.h"
 #include "cmake.h"
 
@@ -211,31 +212,45 @@
   // dependencies in all targets, because the generated build-systems can't
   // deal with config-specific dependencies.
   {
-  std::set<cmStdString> emitted;
-  {
-  std::vector<std::string> tlibs;
-  depender->GetDirectLinkLibraries(0, tlibs, depender);
-  // A target should not depend on itself.
-  emitted.insert(depender->GetName());
-  for(std::vector<std::string>::const_iterator lib = tlibs.begin();
-      lib != tlibs.end(); ++lib)
-    {
-    // Don't emit the same library twice for this target.
-    if(emitted.insert(*lib).second)
-      {
-      this->AddTargetDepend(depender_index, lib->c_str(), true);
-      this->AddInterfaceDepends(depender_index, lib->c_str(),
-                                true, emitted);
-      }
-    }
-  }
+  std::set<std::string> emitted;
+  cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator()
+                                  ->GetGlobalGenerator()
+                                  ->GetGeneratorTarget(depender);
+
   std::vector<std::string> configs;
   depender->GetMakefile()->GetConfigurations(configs);
+  if (configs.empty())
+    {
+    configs.push_back("");
+    }
   for (std::vector<std::string>::const_iterator it = configs.begin();
     it != configs.end(); ++it)
     {
+    std::vector<cmSourceFile const*> objectFiles;
+    gt->GetExternalObjects(objectFiles, *it);
+    for(std::vector<cmSourceFile const*>::const_iterator
+        oi = objectFiles.begin(); oi != objectFiles.end(); ++oi)
+      {
+      std::string objLib = (*oi)->GetObjectLibrary();
+      if (!objLib.empty() && emitted.insert(objLib).second)
+        {
+        if(depender->GetType() != cmTarget::EXECUTABLE &&
+            depender->GetType() != cmTarget::STATIC_LIBRARY &&
+            depender->GetType() != cmTarget::SHARED_LIBRARY &&
+            depender->GetType() != cmTarget::MODULE_LIBRARY)
+          {
+          this->GlobalGenerator->GetCMakeInstance()
+            ->IssueMessage(cmake::FATAL_ERROR,
+                            "Only executables and non-OBJECT libraries may "
+                            "reference target objects.",
+                            depender->GetBacktrace());
+          return;
+          }
+        const_cast<cmTarget*>(depender)->AddUtility(objLib);
+        }
+      }
     std::vector<std::string> tlibs;
-    depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender);
+    depender->GetDirectLinkLibraries(*it, tlibs, depender);
 
     // A target should not depend on itself.
     emitted.insert(depender->GetName());
@@ -245,8 +260,8 @@
       // Don't emit the same library twice for this target.
       if(emitted.insert(*lib).second)
         {
-        this->AddTargetDepend(depender_index, lib->c_str(), true);
-        this->AddInterfaceDepends(depender_index, lib->c_str(),
+        this->AddTargetDepend(depender_index, *lib, true);
+        this->AddInterfaceDepends(depender_index, *lib,
                                   true, emitted);
         }
       }
@@ -255,17 +270,17 @@
 
   // Loop over all utility dependencies.
   {
-  std::set<cmStdString> const& tutils = depender->GetUtilities();
-  std::set<cmStdString> emitted;
+  std::set<std::string> const& tutils = depender->GetUtilities();
+  std::set<std::string> emitted;
   // A target should not depend on itself.
   emitted.insert(depender->GetName());
-  for(std::set<cmStdString>::const_iterator util = tutils.begin();
+  for(std::set<std::string>::const_iterator util = tutils.begin();
       util != tutils.end(); ++util)
     {
     // Don't emit the same utility twice for this target.
     if(emitted.insert(*util).second)
       {
-      this->AddTargetDepend(depender_index, util->c_str(), false);
+      this->AddTargetDepend(depender_index, *util, false);
       }
     }
   }
@@ -274,8 +289,8 @@
 //----------------------------------------------------------------------------
 void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
                                                  cmTarget const* dependee,
-                                                 const char *config,
-                                               std::set<cmStdString> &emitted)
+                                                 const std::string& config,
+                                               std::set<std::string> &emitted)
 {
   cmTarget const* depender = this->Targets[depender_index];
   if(cmTarget::LinkInterface const* iface =
@@ -288,8 +303,8 @@
       // Don't emit the same library twice for this target.
       if(emitted.insert(*lib).second)
         {
-        this->AddTargetDepend(depender_index, lib->c_str(), true);
-        this->AddInterfaceDepends(depender_index, lib->c_str(),
+        this->AddTargetDepend(depender_index, *lib, true);
+        this->AddInterfaceDepends(depender_index, *lib,
                                   true, emitted);
         }
       }
@@ -298,9 +313,9 @@
 
 //----------------------------------------------------------------------------
 void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
-                                             const char* dependee_name,
+                                             const std::string& dependee_name,
                                              bool linking,
-                                             std::set<cmStdString> &emitted)
+                                             std::set<std::string> &emitted)
 {
   cmTarget const* depender = this->Targets[depender_index];
   cmTarget const* dependee =
@@ -317,7 +332,7 @@
 
   if(dependee)
     {
-    this->AddInterfaceDepends(depender_index, dependee, 0, emitted);
+    this->AddInterfaceDepends(depender_index, dependee, "", emitted);
     std::vector<std::string> configs;
     depender->GetMakefile()->GetConfigurations(configs);
     for (std::vector<std::string>::const_iterator it = configs.begin();
@@ -326,14 +341,14 @@
       // A target should not depend on itself.
       emitted.insert(depender->GetName());
       this->AddInterfaceDepends(depender_index, dependee,
-                                it->c_str(), emitted);
+                                *it, emitted);
       }
     }
 }
 
 //----------------------------------------------------------------------------
 void cmComputeTargetDepends::AddTargetDepend(int depender_index,
-                                             const char* dependee_name,
+                                             const std::string& dependee_name,
                                              bool linking)
 {
   // Get the depender.
@@ -371,15 +386,17 @@
       e << "The dependency target \"" <<  dependee_name
         << "\" of target \"" << depender->GetName() << "\" does not exist.";
 
-      cmListFileBacktrace nullBacktrace;
       cmListFileBacktrace const* backtrace =
         depender->GetUtilityBacktrace(dependee_name);
-      if(!backtrace)
+      if(backtrace)
         {
-        backtrace = &nullBacktrace;
+        cm->IssueMessage(messageType, e.str(), *backtrace);
+        }
+      else
+        {
+        cm->IssueMessage(messageType, e.str());
         }
 
-      cm->IssueMessage(messageType, e.str(), *backtrace);
       }
     }
 
@@ -407,8 +424,8 @@
   if(dependee->IsImported())
     {
     // Skip imported targets but follow their utility dependencies.
-    std::set<cmStdString> const& utils = dependee->GetUtilities();
-    for(std::set<cmStdString>::const_iterator i = utils.begin();
+    std::set<std::string> const& utils = dependee->GetUtilities();
+    for(std::set<std::string>::const_iterator i = utils.begin();
         i != utils.end(); ++i)
       {
       if(cmTarget const* transitive_dependee =
@@ -435,22 +452,23 @@
 
 //----------------------------------------------------------------------------
 void
-cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name)
+cmComputeTargetDepends::DisplayGraph(Graph const& graph,
+                                     const std::string& name)
 {
-  fprintf(stderr, "The %s target dependency graph is:\n", name);
+  fprintf(stderr, "The %s target dependency graph is:\n", name.c_str());
   int n = static_cast<int>(graph.size());
   for(int depender_index = 0; depender_index < n; ++depender_index)
     {
     EdgeList const& nl = graph[depender_index];
     cmTarget const* depender = this->Targets[depender_index];
     fprintf(stderr, "target %d is [%s]\n",
-            depender_index, depender->GetName());
+            depender_index, depender->GetName().c_str());
     for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
       {
       int dependee_index = *ni;
       cmTarget const* dependee = this->Targets[dependee_index];
       fprintf(stderr, "  depends on target %d [%s] (%s)\n", dependee_index,
-              dependee->GetName(), ni->IsStrong()? "strong" : "weak");
+              dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak");
       }
     }
   fprintf(stderr, "\n");
@@ -472,7 +490,7 @@
       {
       int i = *ni;
       fprintf(stderr, "  contains target %d [%s]\n",
-              i, this->Targets[i]->GetName());
+              i, this->Targets[i]->GetName().c_str());
       }
     }
   fprintf(stderr, "\n");
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index 6cd6da0..7553816 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -45,16 +45,18 @@
   void CollectTargets();
   void CollectDepends();
   void CollectTargetDepends(int depender_index);
-  void AddTargetDepend(int depender_index, const char* dependee_name,
+  void AddTargetDepend(int depender_index,
+                       const std::string& dependee_name,
                        bool linking);
   void AddTargetDepend(int depender_index, cmTarget const* dependee,
                        bool linking);
   bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
-  void AddInterfaceDepends(int depender_index, const char* dependee_name,
-                           bool linking, std::set<cmStdString> &emitted);
+  void AddInterfaceDepends(int depender_index,
+                           const std::string& dependee_name,
+                           bool linking, std::set<std::string> &emitted);
   void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
-                           const char *config,
-                           std::set<cmStdString> &emitted);
+                           const std::string& config,
+                           std::set<std::string> &emitted);
   cmGlobalGenerator* GlobalGenerator;
   bool DebugMode;
   bool NoCycles;
@@ -71,7 +73,7 @@
   typedef cmGraphAdjacencyList Graph;
   Graph InitialGraph;
   Graph FinalGraph;
-  void DisplayGraph(Graph const& graph, const char* name);
+  void DisplayGraph(Graph const& graph, const std::string& name);
 
   // Deal with connected components.
   void DisplayComponents(cmComputeComponentGraph const& ccg);
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index c5e95d0..2b0280d 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -16,4 +16,5 @@
 #cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE
 #cmakedefine HAVE_UNSETENV
 #cmakedefine CMAKE_USE_ELF_PARSER
+#cmakedefine CMAKE_ENCODING_UTF8
 #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index f8ec642..395e6c8 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -38,7 +38,7 @@
     e << "input location\n"
       << "  " << this->InputFile << "\n"
       << "is a directory but a file was expected.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -61,14 +61,14 @@
     {
     std::string e = "attempted to configure a file: " + this->OutputFile
       + " into a source directory.";
-    this->SetError(e.c_str());
+    this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
     }
   std::string errorMessage;
   if (!this->NewLineStyle.ReadFromArguments(args, errorMessage))
     {
-    this->SetError(errorMessage.c_str());
+    this->SetError(errorMessage);
     return false;
     }
   this->CopyOnly = false;
diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h
index 86de92c..8155ef7 100644
--- a/Source/cmConfigureFileCommand.h
+++ b/Source/cmConfigureFileCommand.h
@@ -34,7 +34,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "configure_file";}
+  virtual std::string GetName() const { return "configure_file";}
 
   /**
    * This determines if the command is invoked when in script mode.
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 7b52069..a3f3277 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -28,7 +28,7 @@
 
   const char* sourceDirectory = argv[2].c_str();
   const char* projectName = 0;
-  const char* targetName = 0;
+  std::string targetName;
   std::vector<std::string> cmakeFlags;
   std::vector<std::string> compileDefs;
   std::string outputVariable;
@@ -249,7 +249,8 @@
         si != sources.end(); ++si)
       {
       std::string ext = cmSystemTools::GetFilenameLastExtension(*si);
-      if(const char* lang = gg->GetLanguageFromExtension(ext.c_str()))
+      std::string lang = gg->GetLanguageFromExtension(ext.c_str());
+      if(!lang.empty())
         {
         testLangs.insert(lang);
         }
@@ -283,7 +284,7 @@
       {
       cmOStringStream e;
       e << "Failed to open\n"
-        << "  " << outFileName.c_str() << "\n"
+        << "  " << outFileName << "\n"
         << cmSystemTools::GetLastSystemError();
       this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return -1;
@@ -306,13 +307,13 @@
       std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE";
       std::string rulesOverrideLang = rulesOverrideBase + "_" + *li;
       if(const char* rulesOverridePath =
-         this->Makefile->GetDefinition(rulesOverrideLang.c_str()))
+         this->Makefile->GetDefinition(rulesOverrideLang))
         {
         fprintf(fout, "set(%s \"%s\")\n",
                 rulesOverrideLang.c_str(), rulesOverridePath);
         }
       else if(const char* rulesOverridePath2 =
-              this->Makefile->GetDefinition(rulesOverrideBase.c_str()))
+              this->Makefile->GetDefinition(rulesOverrideBase))
         {
         fprintf(fout, "set(%s \"%s\")\n",
                 rulesOverrideBase.c_str(), rulesOverridePath2);
@@ -324,7 +325,7 @@
         li != testLangs.end(); ++li)
       {
       std::string langFlags = "CMAKE_" + *li + "_FLAGS";
-      const char* flags = this->Makefile->GetDefinition(langFlags.c_str());
+      const char* flags = this->Makefile->GetDefinition(langFlags);
       fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(),
               lg->EscapeForCMake(flags?flags:"").c_str());
       fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
@@ -356,7 +357,7 @@
       cmExportTryCompileFileGenerator tcfg;
       tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
       tcfg.SetExports(targets);
-      tcfg.SetConfig(this->Makefile->GetDefinition(
+      tcfg.SetConfig(this->Makefile->GetSafeDefinition(
                                           "CMAKE_TRY_COMPILE_CONFIGURATION"));
 
       if(!tcfg.GenerateImportFile())
@@ -449,7 +450,7 @@
     fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
             this->BinaryDirectory.c_str());
     /* Create the actual executable.  */
-    fprintf(fout, "add_executable(%s", targetName);
+    fprintf(fout, "add_executable(%s", targetName.c_str());
     for(std::vector<std::string>::iterator si = sources.begin();
         si != sources.end(); ++si)
       {
@@ -465,12 +466,13 @@
     if (useOldLinkLibs)
       {
       fprintf(fout,
-              "target_link_libraries(%s ${LINK_LIBRARIES})\n",targetName);
+              "target_link_libraries(%s ${LINK_LIBRARIES})\n",
+              targetName.c_str());
       }
     else
       {
       fprintf(fout, "target_link_libraries(%s %s)\n",
-              targetName,
+              targetName.c_str(),
               libsToLink.c_str());
       }
     fclose(fout);
@@ -482,7 +484,7 @@
   std::string output;
   // actually do the try compile now that everything is setup
   int res = this->Makefile->TryCompile(sourceDirectory,
-                                       this->BinaryDirectory.c_str(),
+                                       this->BinaryDirectory,
                                        projectName,
                                        targetName,
                                        this->SrcFileSignature,
@@ -494,14 +496,14 @@
     }
 
   // set the result var to the return value to indicate success or failure
-  this->Makefile->AddCacheDefinition(argv[0].c_str(),
+  this->Makefile->AddCacheDefinition(argv[0],
                                      (res == 0 ? "TRUE" : "FALSE"),
                                      "Result of TRY_COMPILE",
                                      cmCacheManager::INTERNAL);
 
   if ( outputVariable.size() > 0 )
     {
-    this->Makefile->AddDefinition(outputVariable.c_str(), output.c_str());
+    this->Makefile->AddDefinition(outputVariable, output.c_str());
     }
 
   if (this->SrcFileSignature)
@@ -517,9 +519,9 @@
         {
         cmOStringStream emsg;
         emsg << "Cannot copy output executable\n"
-             << "  '" << this->OutputFile.c_str() << "'\n"
+             << "  '" << this->OutputFile << "'\n"
              << "to destination specified by COPY_FILE:\n"
-             << "  '" << copyFile.c_str() << "'\n";
+             << "  '" << copyFile << "'\n";
         if(!this->FindErrorMessage.empty())
           {
           emsg << this->FindErrorMessage.c_str();
@@ -538,7 +540,7 @@
 
     if(!copyFileError.empty())
       {
-      this->Makefile->AddDefinition(copyFileError.c_str(),
+      this->Makefile->AddDefinition(copyFileError,
                                     copyFileErrorMessage.c_str());
       }
     }
@@ -564,7 +566,7 @@
   cmsys::Directory dir;
   dir.Load(binDir);
   size_t fileNum;
-  std::set<cmStdString> deletedFiles;
+  std::set<std::string> deletedFiles;
   for (fileNum = 0; fileNum <  dir.GetNumberOfFiles(); ++fileNum)
     {
     if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
@@ -609,7 +611,7 @@
     }
 }
 
-void cmCoreTryCompile::FindOutputFile(const char* targetName)
+void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
 {
   this->FindErrorMessage = "";
   this->OutputFile = "";
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index 5c67f13..3272462 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -44,7 +44,7 @@
   TryCompileCode. The result is stored in OutputFile. If nothing is found,
   the error message is stored in FindErrorMessage.
    */
-  void FindOutputFile(const char* targetName);
+  void FindOutputFile(const std::string& targetName);
 
 
   cmTypeMacro(cmCoreTryCompile, cmCommand);
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index de20cb7..02fb8cb 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -169,13 +169,13 @@
   // Construct the source list.
   std::string sourceListValue;
   {
-  cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver.c_str());
+  cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
   sf->SetProperty("ABSTRACT","0");
   sourceListValue = args[1];
   }
   for(i = testsBegin; i != tests.end(); ++i)
     {
-    cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str());
+    cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
     sf->SetProperty("ABSTRACT","0");
     sourceListValue += ";";
     sourceListValue += *i;
diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h
index 8b1e4de..2f6b541 100644
--- a/Source/cmCreateTestSourceList.h
+++ b/Source/cmCreateTestSourceList.h
@@ -40,7 +40,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "create_test_sourcelist";}
+  virtual std::string GetName() const {return "create_test_sourcelist";}
 
   cmTypeMacro(cmCreateTestSourceList, cmCommand);
 };
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 7f4b10f..74e17b6 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -35,18 +35,18 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmCryptoHash::HashString(const char* input)
+std::string cmCryptoHash::HashString(const std::string& input)
 {
   this->Initialize();
-  this->Append(reinterpret_cast<unsigned char const*>(input),
-               static_cast<int>(strlen(input)));
+  this->Append(reinterpret_cast<unsigned char const*>(input.c_str()),
+               static_cast<int>(input.size()));
   return this->Finalize();
 }
 
 //----------------------------------------------------------------------------
-std::string cmCryptoHash::HashFile(const char* file)
+std::string cmCryptoHash::HashFile(const std::string& file)
 {
-  cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary);
+  cmsys::ifstream fin(file.c_str(), std::ios::in | cmsys_ios_binary);
   if(!fin)
     {
     return "";
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
index 1bea9ab..88cd240 100644
--- a/Source/cmCryptoHash.h
+++ b/Source/cmCryptoHash.h
@@ -21,8 +21,8 @@
 public:
   virtual ~cmCryptoHash() {}
   static cmsys::auto_ptr<cmCryptoHash> New(const char* algo);
-  std::string HashString(const char* input);
-  std::string HashFile(const char* file);
+  std::string HashString(const std::string& input);
+  std::string HashFile(const std::string& file);
 protected:
   virtual void Initialize()=0;
   virtual void Append(unsigned char const*, int)=0;
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index b672148..c161eb6 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -17,6 +17,7 @@
 
 //----------------------------------------------------------------------------
 cmCustomCommand::cmCustomCommand()
+  : Backtrace(NULL)
 {
   this->HaveComment = false;
   this->EscapeOldStyle = true;
@@ -33,7 +34,7 @@
   WorkingDirectory(r.WorkingDirectory),
   EscapeAllowMakeVars(r.EscapeAllowMakeVars),
   EscapeOldStyle(r.EscapeOldStyle),
-  Backtrace(new cmListFileBacktrace(*r.Backtrace))
+  Backtrace(r.Backtrace)
 {
 }
 
@@ -54,11 +55,7 @@
   this->EscapeAllowMakeVars = r.EscapeAllowMakeVars;
   this->EscapeOldStyle = r.EscapeOldStyle;
   this->ImplicitDepends = r.ImplicitDepends;
-
-  cmsys::auto_ptr<cmListFileBacktrace>
-    newBacktrace(new cmListFileBacktrace(*r.Backtrace));
-  delete this->Backtrace;
-  this->Backtrace = newBacktrace.release();
+  this->Backtrace = r.Backtrace;
 
   return *this;
 }
@@ -78,20 +75,19 @@
   WorkingDirectory(workingDirectory?workingDirectory:""),
   EscapeAllowMakeVars(false),
   EscapeOldStyle(true),
-  Backtrace(new cmListFileBacktrace)
+  Backtrace(NULL)
 {
   this->EscapeOldStyle = true;
   this->EscapeAllowMakeVars = false;
   if(mf)
     {
-    mf->GetBacktrace(*this->Backtrace);
+    this->Backtrace = mf->GetBacktrace();
     }
 }
 
 //----------------------------------------------------------------------------
 cmCustomCommand::~cmCustomCommand()
 {
-  delete this->Backtrace;
 }
 
 //----------------------------------------------------------------------------
@@ -101,16 +97,6 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmCustomCommand::GetWorkingDirectory() const
-{
-  if(this->WorkingDirectory.size() == 0)
-    {
-    return 0;
-    }
-  return this->WorkingDirectory.c_str();
-}
-
-//----------------------------------------------------------------------------
 const std::vector<std::string>& cmCustomCommand::GetDepends() const
 {
   return this->Depends;
@@ -176,7 +162,7 @@
 //----------------------------------------------------------------------------
 cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
 {
-  return *this->Backtrace;
+  return this->Backtrace;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index 6851105..21dbefb 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -13,8 +13,8 @@
 #define cmCustomCommand_h
 
 #include "cmStandardIncludes.h"
+#include "cmListFileCache.h"
 class cmMakefile;
-class cmListFileBacktrace;
 
 /** \class cmCustomCommand
  * \brief A class to encapsulate a custom command
@@ -42,12 +42,13 @@
   /** Get the output file produced by the command.  */
   const std::vector<std::string>& GetOutputs() const;
 
-  /** Get the working directory.  */
-  const char* GetWorkingDirectory() const;
-
   /** Get the vector that holds the list of dependencies.  */
   const std::vector<std::string>& GetDepends() const;
 
+  /** Get the working directory.  */
+  std::string const& GetWorkingDirectory() const
+    { return this->WorkingDirectory; }
+
   /** Get the list of command lines.  */
   const cmCustomCommandLines& GetCommandLines() const;
 
@@ -72,7 +73,7 @@
   /** Backtrace of the command that created this custom command.  */
   cmListFileBacktrace const& GetBacktrace() const;
 
-  typedef std::pair<cmStdString, cmStdString> ImplicitDependsPair;
+  typedef std::pair<std::string, std::string> ImplicitDependsPair;
   class ImplicitDependsList: public std::vector<ImplicitDependsPair> {};
   void SetImplicitDepends(ImplicitDependsList const&);
   void AppendImplicitDepends(ImplicitDependsList const&);
@@ -87,7 +88,7 @@
   std::string WorkingDirectory;
   bool EscapeAllowMakeVars;
   bool EscapeOldStyle;
-  cmListFileBacktrace* Backtrace;
+  cmListFileBacktrace Backtrace;
   ImplicitDependsList ImplicitDepends;
 };
 
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index f24dfa2..1bca6e6 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -18,10 +18,10 @@
 
 //----------------------------------------------------------------------------
 cmCustomCommandGenerator::cmCustomCommandGenerator(
-  cmCustomCommand const& cc, const char* config, cmMakefile* mf):
+  cmCustomCommand const& cc, const std::string& config, cmMakefile* mf):
   CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()),
   OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()),
-  GE(new cmGeneratorExpression(cc.GetBacktrace()))
+  GE(new cmGeneratorExpression(&cc.GetBacktrace())), DependsDone(false)
 {
 }
 
@@ -63,11 +63,59 @@
     cmd += " ";
     if(this->OldStyle)
       {
-      cmd += this->LG->EscapeForShellOldStyle(arg.c_str());
+      cmd += this->LG->EscapeForShellOldStyle(arg);
       }
     else
       {
-      cmd += this->LG->EscapeForShell(arg.c_str(), this->MakeVars);
+      cmd += this->LG->EscapeForShell(arg, this->MakeVars);
       }
     }
 }
+
+//----------------------------------------------------------------------------
+const char* cmCustomCommandGenerator::GetComment() const
+{
+  return this->CC.GetComment();
+}
+
+//----------------------------------------------------------------------------
+std::string cmCustomCommandGenerator::GetWorkingDirectory() const
+{
+  return this->CC.GetWorkingDirectory();
+}
+
+//----------------------------------------------------------------------------
+std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
+{
+  return this->CC.GetOutputs();
+}
+
+//----------------------------------------------------------------------------
+std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
+{
+  if (!this->DependsDone)
+    {
+    this->DependsDone = true;
+    std::vector<std::string> depends = this->CC.GetDepends();
+    for(std::vector<std::string>::const_iterator
+          i = depends.begin();
+        i != depends.end(); ++i)
+      {
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
+                                              = this->GE->Parse(*i);
+      std::vector<std::string> result;
+      cmSystemTools::ExpandListArgument(
+                  cge->Evaluate(this->Makefile, this->Config), result);
+      for (std::vector<std::string>::iterator it = result.begin();
+          it != result.end(); ++it)
+        {
+        if (cmSystemTools::FileIsFullPath(it->c_str()))
+          {
+          *it = cmSystemTools::CollapseFullPath(*it);
+          }
+        }
+      this->Depends.insert(this->Depends.end(), result.begin(), result.end());
+      }
+    }
+  return this->Depends;
+}
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 4e89f27..0d8a0a4 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -22,19 +22,27 @@
 class cmCustomCommandGenerator
 {
   cmCustomCommand const& CC;
-  const char* Config;
+  std::string Config;
   cmMakefile* Makefile;
   cmLocalGenerator* LG;
   bool OldStyle;
   bool MakeVars;
   cmGeneratorExpression* GE;
+  mutable bool DependsDone;
+  mutable std::vector<std::string> Depends;
 public:
-  cmCustomCommandGenerator(cmCustomCommand const& cc, const char* config,
+  cmCustomCommandGenerator(cmCustomCommand const& cc,
+                           const std::string& config,
                            cmMakefile* mf);
   ~cmCustomCommandGenerator();
+  cmCustomCommand const& GetCC() const { return this->CC; }
   unsigned int GetNumberOfCommands() const;
   std::string GetCommand(unsigned int c) const;
   void AppendArguments(unsigned int c, std::string& cmd) const;
+  const char* GetComment() const;
+  std::string GetWorkingDirectory() const;
+  std::vector<std::string> const& GetOutputs() const;
+  std::vector<std::string> const& GetDepends() const;
 };
 
 #endif
diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx
index 1ad98af..6b729de 100644
--- a/Source/cmDefinePropertyCommand.cxx
+++ b/Source/cmDefinePropertyCommand.cxx
@@ -58,7 +58,7 @@
       << "Valid scopes are "
       << "GLOBAL, DIRECTORY, TARGET, SOURCE, "
       << "TEST, VARIABLE, CACHED_VARIABLE.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -102,7 +102,7 @@
       {
       cmOStringStream e;
       e << "given invalid argument \"" << args[i] << "\".";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -128,7 +128,7 @@
 
   // Actually define the property.
   this->Makefile->GetCMakeInstance()->DefineProperty
-    (this->PropertyName.c_str(), scope,
+    (this->PropertyName, scope,
      this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited);
 
   return true;
diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h
index 8dc4d96..bc5c8a4 100644
--- a/Source/cmDefinePropertyCommand.h
+++ b/Source/cmDefinePropertyCommand.h
@@ -32,7 +32,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "define_property";}
+  virtual std::string GetName() const { return "define_property";}
 
   cmTypeMacro(cmDefinePropertyCommand, cmCommand);
 private:
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 9d28700..babf1c4 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -28,7 +28,7 @@
 
 //----------------------------------------------------------------------------
 cmDefinitions::Def const&
-cmDefinitions::GetInternal(const char* key)
+cmDefinitions::GetInternal(const std::string& key)
 {
   MapType::const_iterator i = this->Map.find(key);
   if(i != this->Map.end())
@@ -46,7 +46,7 @@
 
 //----------------------------------------------------------------------------
 cmDefinitions::Def const&
-cmDefinitions::SetInternal(const char* key, Def const& def)
+cmDefinitions::SetInternal(const std::string& key, Def const& def)
 {
   if(this->Up || def.Exists)
     {
@@ -71,23 +71,23 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const char* key)
+const char* cmDefinitions::Get(const std::string& key)
 {
   Def const& def = this->GetInternal(key);
   return def.Exists? def.c_str() : 0;
 }
 
 //----------------------------------------------------------------------------
-const char* cmDefinitions::Set(const char* key, const char* value)
+const char* cmDefinitions::Set(const std::string& key, const char* value)
 {
   Def const& def = this->SetInternal(key, Def(value));
   return def.Exists? def.c_str() : 0;
 }
 
 //----------------------------------------------------------------------------
-std::set<cmStdString> cmDefinitions::LocalKeys() const
+std::set<std::string> cmDefinitions::LocalKeys() const
 {
-  std::set<cmStdString> keys;
+  std::set<std::string> keys;
   // Consider local definitions.
   for(MapType::const_iterator mi = this->Map.begin();
       mi != this->Map.end(); ++mi)
@@ -110,12 +110,12 @@
 cmDefinitions::cmDefinitions(ClosureTag const&, cmDefinitions const* root):
   Up(0)
 {
-  std::set<cmStdString> undefined;
+  std::set<std::string> undefined;
   this->ClosureImpl(undefined, root);
 }
 
 //----------------------------------------------------------------------------
-void cmDefinitions::ClosureImpl(std::set<cmStdString>& undefined,
+void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
                                 cmDefinitions const* defs)
 {
   // Consider local definitions.
@@ -145,17 +145,17 @@
 }
 
 //----------------------------------------------------------------------------
-std::set<cmStdString> cmDefinitions::ClosureKeys() const
+std::set<std::string> cmDefinitions::ClosureKeys() const
 {
-  std::set<cmStdString> defined;
-  std::set<cmStdString> undefined;
+  std::set<std::string> defined;
+  std::set<std::string> undefined;
   this->ClosureKeys(defined, undefined);
   return defined;
 }
 
 //----------------------------------------------------------------------------
-void cmDefinitions::ClosureKeys(std::set<cmStdString>& defined,
-                                std::set<cmStdString>& undefined) const
+void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
+                                std::set<std::string>& undefined) const
 {
   // Consider local definitions.
   for(MapType::const_iterator mi = this->Map.begin();
@@ -165,7 +165,7 @@
     if(defined.find(mi->first) == defined.end() &&
        undefined.find(mi->first) == undefined.end())
       {
-      std::set<cmStdString>& m = mi->second.Exists? defined : undefined;
+      std::set<std::string>& m = mi->second.Exists? defined : undefined;
       m.insert(mi->first);
       }
     }
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 4834d84..d615fb0 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -35,28 +35,32 @@
 
   /** Get the value associated with a key; null if none.
       Store the result locally if it came from a parent.  */
-  const char* Get(const char* key);
+  const char* Get(const std::string& key);
 
   /** Set (or unset if null) a value associated with a key.  */
-  const char* Set(const char* key, const char* value);
+  const char* Set(const std::string& key, const char* value);
 
   /** Get the set of all local keys.  */
-  std::set<cmStdString> LocalKeys() const;
+  std::set<std::string> LocalKeys() const;
 
   /** Compute the closure of all defined keys with values.
       This flattens the scope.  The result has no parent.  */
   cmDefinitions Closure() const;
 
   /** Compute the set of all defined keys.  */
-  std::set<cmStdString> ClosureKeys() const;
+  std::set<std::string> ClosureKeys() const;
 
 private:
   // String with existence boolean.
-  struct Def: public cmStdString
+  struct Def: public std::string
   {
-    Def(): cmStdString(), Exists(false) {}
-    Def(const char* v): cmStdString(v?v:""), Exists(v?true:false) {}
-    Def(Def const& d): cmStdString(d), Exists(d.Exists) {}
+  private:
+    typedef std::string std_string;
+  public:
+    Def(): std_string(), Exists(false) {}
+    Def(const char* v): std_string(v?v:""), Exists(v?true:false) {}
+    Def(const std_string& v): std_string(v), Exists(true) {}
+    Def(Def const& d): std_string(d), Exists(d.Exists) {}
     bool Exists;
   };
   static Def NoDef;
@@ -65,22 +69,22 @@
   cmDefinitions* Up;
 
   // Local definitions, set or unset.
-  typedef std::map<cmStdString, Def> MapType;
+  typedef std::map<std::string, Def> MapType;
   MapType Map;
 
   // Internal query and update methods.
-  Def const& GetInternal(const char* key);
-  Def const& SetInternal(const char* key, Def const& def);
+  Def const& GetInternal(const std::string& key);
+  Def const& SetInternal(const std::string& key, Def const& def);
 
   // Implementation of Closure() method.
   struct ClosureTag {};
   cmDefinitions(ClosureTag const&, cmDefinitions const* root);
-  void ClosureImpl(std::set<cmStdString>& undefined,
+  void ClosureImpl(std::set<std::string>& undefined,
                    cmDefinitions const* defs);
 
   // Implementation of ClosureKeys() method.
-  void ClosureKeys(std::set<cmStdString>& defined,
-                   std::set<cmStdString>& undefined) const;
+  void ClosureKeys(std::set<std::string>& defined,
+                   std::set<std::string>& undefined) const;
 };
 
 #endif
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 1a0e93f..50a395e 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -47,7 +47,7 @@
   std::string srcLang = "CMAKE_DEPENDS_CHECK_";
   srcLang += this->Language;
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
-  const char* srcStr = mf->GetSafeDefinition(srcLang.c_str());
+  const char* srcStr = mf->GetSafeDefinition(srcLang);
   std::vector<std::string> pairs;
   cmSystemTools::ExpandListArgument(srcStr, pairs);
 
@@ -61,7 +61,7 @@
     std::string obj = *si++;
 
     // Make sure the object file is relative to the top of the build tree.
-    obj = this->LocalGenerator->Convert(obj.c_str(),
+    obj = this->LocalGenerator->Convert(obj,
                                         cmLocalGenerator::HOME_OUTPUT,
                                         cmLocalGenerator::MAKEFILE);
     dependencies[obj].insert(src);
@@ -297,7 +297,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmDepends::SetIncludePathFromLanguage(const char* lang)
+void cmDepends::SetIncludePathFromLanguage(const std::string& lang)
 {
   // Look for the new per "TARGET_" variant first:
   const char * includePath = 0;
@@ -305,7 +305,7 @@
   includePathVar += lang;
   includePathVar += "_TARGET_INCLUDE_PATH";
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
-  includePath = mf->GetDefinition(includePathVar.c_str());
+  includePath = mf->GetDefinition(includePathVar);
   if(includePath)
     {
     cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
@@ -316,7 +316,7 @@
     includePathVar = "CMAKE_";
     includePathVar += lang;
     includePathVar += "_INCLUDE_PATH";
-    includePath = mf->GetDefinition(includePathVar.c_str());
+    includePath = mf->GetDefinition(includePathVar);
     if(includePath)
       {
       cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index d787edd..4f6517e 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -32,7 +32,7 @@
   cmDepends(cmLocalGenerator* lg=0, const char* targetDir="");
 
   /** at what level will the compile be done from */
-  void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;};
+  void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;}
 
   /** Set the local generator for the directory in which we are
       scanning dependencies.  This is not a full local generator; it
@@ -41,7 +41,7 @@
   void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
 
   /** Set the specific language to be scanned.  */
-  void SetLanguage(const char* lang) { this->Language = lang; }
+  void SetLanguage(const std::string& lang) { this->Language = lang; }
 
   /** Set the target build directory.  */
   void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
@@ -114,7 +114,7 @@
   // The include file search path.
   std::vector<std::string> IncludePath;
 
-  void SetIncludePathFromLanguage(const char* lang);
+  void SetIncludePathFromLanguage(const std::string& lang);
 
 private:
   cmDepends(cmDepends const&); // Purposely not implemented.
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 4fc5efb..d26d3a9 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -37,7 +37,7 @@
 //----------------------------------------------------------------------------
 cmDependsC::cmDependsC(cmLocalGenerator* lg,
                    const char* targetDir,
-                   const char* lang,
+                   const std::string& lang,
                    const std::map<std::string, DependencyVector>* validDeps)
 : cmDepends(lg, targetDir)
 , ValidDeps(validDeps)
@@ -54,14 +54,14 @@
   std::string scanRegexVar = "CMAKE_";
   scanRegexVar += lang;
   scanRegexVar += "_INCLUDE_REGEX_SCAN";
-  if(const char* sr = mf->GetDefinition(scanRegexVar.c_str()))
+  if(const char* sr = mf->GetDefinition(scanRegexVar))
     {
     scanRegex = sr;
     }
   std::string complainRegexVar = "CMAKE_";
   complainRegexVar += lang;
   complainRegexVar += "_INCLUDE_REGEX_COMPLAIN";
-  if(const char* cr = mf->GetDefinition(complainRegexVar.c_str()))
+  if(const char* cr = mf->GetDefinition(complainRegexVar))
     {
     complainRegex = cr;
     }
@@ -91,7 +91,7 @@
 {
   this->WriteCacheFile();
 
-  for (std::map<cmStdString, cmIncludeLines*>::iterator it=
+  for (std::map<std::string, cmIncludeLines*>::iterator it=
          this->FileCache.begin(); it!=this->FileCache.end(); ++it)
     {
     delete it->second;
@@ -116,7 +116,7 @@
     return false;
     }
 
-  std::set<cmStdString> dependencies;
+  std::set<std::string> dependencies;
   bool haveDeps = false;
 
   if (this->ValidDeps != 0)
@@ -149,7 +149,7 @@
       this->Encountered.insert(*srcIt);
       }
 
-    std::set<cmStdString> scanned;
+    std::set<std::string> scanned;
 
     // Use reserve to allocate enough memory for tempPathStr
     // so that during the loops no memory is allocated or freed
@@ -182,7 +182,7 @@
         }
       else
         {
-        std::map<cmStdString, cmStdString>::iterator
+        std::map<std::string, std::string>::iterator
           headerLocationIt=this->HeaderLocationCache.find(current.FileName);
         if (headerLocationIt!=this->HeaderLocationCache.end())
           {
@@ -224,7 +224,7 @@
         scanned.insert(fullName);
 
         // Check whether this file is already in the cache
-        std::map<cmStdString, cmIncludeLines*>::iterator fileIt=
+        std::map<std::string, cmIncludeLines*>::iterator fileIt=
           this->FileCache.find(fullName);
         if (fileIt!=this->FileCache.end())
           {
@@ -270,15 +270,15 @@
   // convert the dependencies to paths relative to the home output
   // directory.  We must do the same here.
   internalDepends << obj << std::endl;
-  for(std::set<cmStdString>::const_iterator i=dependencies.begin();
+  for(std::set<std::string>::const_iterator i=dependencies.begin();
       i != dependencies.end(); ++i)
     {
     makeDepends << obj << ": " <<
-      this->LocalGenerator->Convert(i->c_str(),
+      this->LocalGenerator->Convert(*i,
                                     cmLocalGenerator::HOME_OUTPUT,
                                     cmLocalGenerator::MAKEFILE)
                 << std::endl;
-    internalDepends << " " << i->c_str() << std::endl;
+    internalDepends << " " << *i << std::endl;
     }
   makeDepends << std::endl;
 
@@ -392,7 +392,7 @@
   cacheOut << this->IncludeRegexComplainString << "\n\n";
   cacheOut << this->IncludeRegexTransformString << "\n\n";
 
-  for (std::map<cmStdString, cmIncludeLines*>::const_iterator fileIt=
+  for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt=
          this->FileCache.begin();
        fileIt!=this->FileCache.end(); ++fileIt)
     {
@@ -421,7 +421,7 @@
 
 //----------------------------------------------------------------------------
 void cmDependsC::Scan(std::istream& is, const char* directory,
-  const cmStdString& fullName)
+  const std::string& fullName)
 {
   cmIncludeLines* newCacheEntry=new cmIncludeLines;
   newCacheEntry->Used=true;
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index 16dfad7..07d3c21 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -25,7 +25,8 @@
   /** Checking instances need to know the build directory name and the
       relative path from the build directory to the target file.  */
   cmDependsC();
-  cmDependsC(cmLocalGenerator* lg, const char* targetDir, const char* lang,
+  cmDependsC(cmLocalGenerator* lg, const char* targetDir,
+             const std::string& lang,
              const std::map<std::string, DependencyVector>* validDeps);
 
   /** Virtual destructor to cleanup subclasses properly.  */
@@ -40,7 +41,7 @@
 
   // Method to scan a single file.
   void Scan(std::istream& is, const char* directory,
-    const cmStdString& fullName);
+    const std::string& fullName);
 
   // Regular expression to identify C preprocessor include directives.
   cmsys::RegularExpression IncludeRegexLine;
@@ -56,7 +57,7 @@
   // Regex to transform #include lines.
   std::string IncludeRegexTransformString;
   cmsys::RegularExpression IncludeRegexTransform;
-  typedef std::map<cmStdString, cmStdString> TransformRulesType;
+  typedef std::map<std::string, std::string> TransformRulesType;
   TransformRulesType TransformRules;
   void SetupTransforms();
   void ParseTransform(std::string const& xform);
@@ -66,8 +67,8 @@
   // Data structures for dependency graph walk.
   struct UnscannedEntry
   {
-    cmStdString FileName;
-    cmStdString QuotedLocation;
+    std::string FileName;
+    std::string QuotedLocation;
   };
 
   struct cmIncludeLines
@@ -78,13 +79,13 @@
   };
 protected:
   const std::map<std::string, DependencyVector>* ValidDeps;
-  std::set<cmStdString> Encountered;
+  std::set<std::string> Encountered;
   std::queue<UnscannedEntry> Unscanned;
 
-  std::map<cmStdString, cmIncludeLines *> FileCache;
-  std::map<cmStdString, cmStdString> HeaderLocationCache;
+  std::map<std::string, cmIncludeLines *> FileCache;
+  std::map<std::string, std::string> HeaderLocationCache;
 
-  cmStdString CacheFileName;
+  std::string CacheFileName;
 
   void WriteCacheFile() const;
   void ReadCacheFile();
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index d5472a1..79cb560 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -34,11 +34,11 @@
   std::string Source;
 
   // Set of provided and required modules.
-  std::set<cmStdString> Provides;
-  std::set<cmStdString> Requires;
+  std::set<std::string> Provides;
+  std::set<std::string> Requires;
 
   // Set of files included in the translation unit.
-  std::set<cmStdString> Includes;
+  std::set<std::string> Includes;
 };
 
 //----------------------------------------------------------------------------
@@ -98,24 +98,24 @@
 {
 public:
   // The set of modules provided by this target.
-  std::set<cmStdString> TargetProvides;
+  std::set<std::string> TargetProvides;
 
   // Map modules required by this target to locations.
-  typedef std::map<cmStdString, cmStdString> TargetRequiresMap;
+  typedef std::map<std::string, std::string> TargetRequiresMap;
   TargetRequiresMap TargetRequires;
 
   // Information about each object file.
-  typedef std::map<cmStdString, cmDependsFortranSourceInfo> ObjectInfoMap;
+  typedef std::map<std::string, cmDependsFortranSourceInfo> ObjectInfoMap;
   ObjectInfoMap ObjectInfo;
 
   cmDependsFortranSourceInfo& CreateObjectInfo(const char* obj,
                                                const char* src)
     {
-    std::map<cmStdString, cmDependsFortranSourceInfo>::iterator i =
+    std::map<std::string, cmDependsFortranSourceInfo>::iterator i =
       this->ObjectInfo.find(obj);
     if(i == this->ObjectInfo.end())
       {
-      std::map<cmStdString, cmDependsFortranSourceInfo>::value_type
+      std::map<std::string, cmDependsFortranSourceInfo>::value_type
         entry(obj, cmDependsFortranSourceInfo());
       i = this->ObjectInfo.insert(entry).first;
       i->second.Source = src;
@@ -260,8 +260,8 @@
   cmGeneratedFileStream fiStream(fiName.c_str());
   fiStream << "# The fortran modules provided by this target.\n";
   fiStream << "provides\n";
-  std::set<cmStdString> const& provides = this->Internal->TargetProvides;
-  for(std::set<cmStdString>::const_iterator i = provides.begin();
+  std::set<std::string> const& provides = this->Internal->TargetProvides;
+  for(std::set<std::string>::const_iterator i = provides.begin();
       i != provides.end(); ++i)
     {
     fiStream << " " << *i << "\n";
@@ -275,7 +275,7 @@
     cmGeneratedFileStream fcStream(fcName.c_str());
     fcStream << "# Remove fortran modules provided by this target.\n";
     fcStream << "FILE(REMOVE";
-    for(std::set<cmStdString>::const_iterator i = provides.begin();
+    for(std::set<std::string>::const_iterator i = provides.begin();
         i != provides.end(); ++i)
       {
       std::string mod_upper = mod_dir;
@@ -292,15 +292,15 @@
       stamp += ".mod.stamp";
       fcStream << "\n";
       fcStream << "  \"" <<
-        this->LocalGenerator->Convert(mod_lower.c_str(),
+        this->LocalGenerator->Convert(mod_lower,
                                       cmLocalGenerator::START_OUTPUT)
                << "\"\n";
       fcStream << "  \"" <<
-        this->LocalGenerator->Convert(mod_upper.c_str(),
+        this->LocalGenerator->Convert(mod_upper,
                                       cmLocalGenerator::START_OUTPUT)
                << "\"\n";
       fcStream << "  \"" <<
-        this->LocalGenerator->Convert(stamp.c_str(),
+        this->LocalGenerator->Convert(stamp,
                                       cmLocalGenerator::START_OUTPUT)
                << "\"\n";
       }
@@ -319,14 +319,14 @@
       infoI != objInfo.end(); ++infoI)
     {
     cmDependsFortranSourceInfo const& info = infoI->second;
-    for(std::set<cmStdString>::const_iterator i = info.Provides.begin();
+    for(std::set<std::string>::const_iterator i = info.Provides.begin();
         i != info.Provides.end(); ++i)
       {
       // Include this module in the set provided by this target.
       this->Internal->TargetProvides.insert(*i);
       }
 
-    for(std::set<cmStdString>::const_iterator i = info.Requires.begin();
+    for(std::set<std::string>::const_iterator i = info.Requires.begin();
         i != info.Requires.end(); ++i)
       {
       // Include this module in the set required by this target.
@@ -368,8 +368,8 @@
 void cmDependsFortran::MatchLocalModules()
 {
   const char* stampDir = this->TargetDirectory.c_str();
-  std::set<cmStdString> const& provides = this->Internal->TargetProvides;
-  for(std::set<cmStdString>::const_iterator i = provides.begin();
+  std::set<std::string> const& provides = this->Internal->TargetProvides;
+  for(std::set<std::string>::const_iterator i = provides.begin();
       i != provides.end(); ++i)
     {
     this->ConsiderModule(i->c_str(), stampDir);
@@ -445,24 +445,24 @@
   // Write the include dependencies to the output stream.
   internalDepends << obj << std::endl;
   internalDepends << " " << src << std::endl;
-  for(std::set<cmStdString>::const_iterator i = info.Includes.begin();
+  for(std::set<std::string>::const_iterator i = info.Includes.begin();
       i != info.Includes.end(); ++i)
     {
     makeDepends << obj << ": " <<
-      this->LocalGenerator->Convert(i->c_str(),
+      this->LocalGenerator->Convert(*i,
                                     cmLocalGenerator::HOME_OUTPUT,
                                     cmLocalGenerator::MAKEFILE)
                 << std::endl;
-    internalDepends << " " << i->c_str() << std::endl;
+    internalDepends << " " << *i << std::endl;
     }
   makeDepends << std::endl;
 
   // Write module requirements to the output stream.
-  for(std::set<cmStdString>::const_iterator i = info.Requires.begin();
+  for(std::set<std::string>::const_iterator i = info.Requires.begin();
       i != info.Requires.end(); ++i)
     {
     // Require only modules not provided in the same source.
-    if(std::set<cmStdString>::const_iterator(info.Provides.find(*i)) !=
+    if(std::set<std::string>::const_iterator(info.Provides.find(*i)) !=
        info.Provides.end())
       {
       continue;
@@ -480,7 +480,7 @@
       proxy += "/";
       proxy += *i;
       proxy += ".mod.proxy";
-      proxy = this->LocalGenerator->Convert(proxy.c_str(),
+      proxy = this->LocalGenerator->Convert(proxy,
                                             cmLocalGenerator::HOME_OUTPUT,
                                             cmLocalGenerator::MAKEFILE);
 
@@ -497,7 +497,7 @@
       {
       // This module is known.  Depend on its timestamp file.
       std::string stampFile =
-        this->LocalGenerator->Convert(required->second.c_str(),
+        this->LocalGenerator->Convert(required->second,
                                       cmLocalGenerator::HOME_OUTPUT,
                                       cmLocalGenerator::MAKEFILE);
       makeDepends << obj << ": " << stampFile << "\n";
@@ -510,7 +510,7 @@
       if(this->FindModule(*i, module))
         {
         module =
-          this->LocalGenerator->Convert(module.c_str(),
+          this->LocalGenerator->Convert(module,
                                         cmLocalGenerator::HOME_OUTPUT,
                                         cmLocalGenerator::MAKEFILE);
         makeDepends << obj << ": " << module << "\n";
@@ -519,14 +519,14 @@
     }
 
   // Write provided modules to the output stream.
-  for(std::set<cmStdString>::const_iterator i = info.Provides.begin();
+  for(std::set<std::string>::const_iterator i = info.Provides.begin();
       i != info.Provides.end(); ++i)
     {
     std::string proxy = stamp_dir;
     proxy += "/";
     proxy += *i;
     proxy += ".mod.proxy";
-    proxy = this->LocalGenerator->Convert(proxy.c_str(),
+    proxy = this->LocalGenerator->Convert(proxy,
                                           cmLocalGenerator::HOME_OUTPUT,
                                           cmLocalGenerator::MAKEFILE);
     makeDepends << proxy << ": " << obj << ".provides" << std::endl;
@@ -538,7 +538,7 @@
     // Create a target to copy the module after the object file
     // changes.
     makeDepends << obj << ".provides.build:\n";
-    for(std::set<cmStdString>::const_iterator i = info.Provides.begin();
+    for(std::set<std::string>::const_iterator i = info.Provides.begin();
         i != info.Provides.end(); ++i)
       {
       // Include this module in the set provided by this target.
@@ -552,7 +552,7 @@
       modFile += "/";
       modFile += *i;
       modFile =
-        this->LocalGenerator->Convert(modFile.c_str(),
+        this->LocalGenerator->Convert(modFile,
                                       cmLocalGenerator::HOME_OUTPUT,
                                       cmLocalGenerator::SHELL);
       std::string stampFile = stamp_dir;
@@ -560,7 +560,7 @@
       stampFile += m;
       stampFile += ".mod.stamp";
       stampFile =
-        this->LocalGenerator->Convert(stampFile.c_str(),
+        this->LocalGenerator->Convert(stampFile,
                                       cmLocalGenerator::HOME_OUTPUT,
                                       cmLocalGenerator::SHELL);
       makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod "
@@ -582,7 +582,7 @@
     // the target finishes building.
     std::string driver = this->TargetDirectory;
     driver += "/build";
-    driver = this->LocalGenerator->Convert(driver.c_str(),
+    driver = this->LocalGenerator->Convert(driver,
                                            cmLocalGenerator::HOME_OUTPUT,
                                            cmLocalGenerator::MAKEFILE);
     makeDepends << driver << ": " << obj << ".provides.build\n";
@@ -666,7 +666,7 @@
       if(!cmSystemTools::CopyFileAlways(mod_upper.c_str(), stamp.c_str()))
         {
         std::cerr << "Error copying Fortran module from \""
-                  << mod_upper.c_str() << "\" to \"" << stamp.c_str()
+                  << mod_upper << "\" to \"" << stamp
                   << "\".\n";
         return false;
         }
@@ -681,7 +681,7 @@
       if(!cmSystemTools::CopyFileAlways(mod_lower.c_str(), stamp.c_str()))
         {
         std::cerr << "Error copying Fortran module from \""
-                  << mod_lower.c_str() << "\" to \"" << stamp.c_str()
+                  << mod_lower << "\" to \"" << stamp
                   << "\".\n";
         return false;
         }
@@ -689,9 +689,9 @@
     return true;
     }
 
-  std::cerr << "Error copying Fortran module \"" << args[2].c_str()
-            << "\".  Tried \"" << mod_upper.c_str()
-            << "\" and \"" << mod_lower.c_str() << "\".\n";
+  std::cerr << "Error copying Fortran module \"" << args[2]
+            << "\".  Tried \"" << mod_upper
+            << "\" and \"" << mod_lower << "\".\n";
   return false;
 }
 
diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx
index 1e505a5..f7676d9 100644
--- a/Source/cmDependsJavaLexer.cxx
+++ b/Source/cmDependsJavaLexer.cxx
@@ -1591,7 +1591,7 @@
       "fatal flex scanner internal error--no action found" );
   } /* end of action switch */
     } /* end of scanning one token */
-return 0; /* this should not happen but it silences a warning*/
+return 0; /* this should not happen but it quiets some compilers */
 } /* end of cmDependsJava_yylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index c30d4bd..02f2d21 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -36,10 +36,10 @@
 }
 
 void cmDependsJavaParserHelper::CurrentClass
-::AddFileNamesForPrinting(std::vector<cmStdString> *files,
+::AddFileNamesForPrinting(std::vector<std::string> *files,
                           const char* prefix, const char* sep)
 {
-  cmStdString rname = "";
+  std::string rname = "";
   if ( prefix )
     {
     rname += prefix;
@@ -76,7 +76,7 @@
     {
     return;
     }
-  std::vector<cmStdString>::iterator it;
+  std::vector<std::string>::iterator it;
   for ( it = this->ClassesFound.begin();
     it != this->ClassesFound.end();
     it ++ )
@@ -91,7 +91,7 @@
 
 void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass)
 {
-  std::vector<cmStdString>::iterator it;
+  std::vector<std::string>::iterator it;
   for ( it = this->PackagesImport.begin();
     it != this->PackagesImport.end();
     it ++ )
@@ -256,19 +256,19 @@
     std::cerr << "Error when parsing. No classes on class stack" << std::endl;
     abort();
     }
-  std::vector<cmStdString> files = this->GetFilesProduced();
-  std::vector<cmStdString>::iterator sit;
+  std::vector<std::string> files = this->GetFilesProduced();
+  std::vector<std::string>::iterator sit;
   for ( sit = files.begin();
     sit != files.end();
     ++ sit )
     {
-    std::cout << "  " << sit->c_str() << ".class" << std::endl;
+    std::cout << "  " << *sit << ".class" << std::endl;
     }
 }
 
-std::vector<cmStdString> cmDependsJavaParserHelper::GetFilesProduced()
+std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
 {
-  std::vector<cmStdString> files;
+  std::vector<std::string> files;
   CurrentClass* toplevel = &(*(this->ClassStack.begin()));
   std::vector<CurrentClass>::iterator it;
   for ( it = toplevel->NestedClasses->begin();
@@ -308,29 +308,29 @@
     if ( this->CurrentPackage.size() > 0 )
       {
       std::cout << "Current package is: " <<
-        this->CurrentPackage.c_str() << std::endl;
+        this->CurrentPackage << std::endl;
       }
     std::cout << "Imports packages:";
     if ( this->PackagesImport.size() > 0 )
       {
-      std::vector<cmStdString>::iterator it;
+      std::vector<std::string>::iterator it;
       for ( it = this->PackagesImport.begin();
         it != this->PackagesImport.end();
         ++ it )
         {
-        std::cout << " " << it->c_str();
+        std::cout << " " << *it;
         }
       }
     std::cout << std::endl;
     std::cout << "Depends on:";
     if ( this->ClassesFound.size() > 0 )
       {
-      std::vector<cmStdString>::iterator it;
+      std::vector<std::string>::iterator it;
       for ( it = this->ClassesFound.begin();
         it != this->ClassesFound.end();
         ++ it )
         {
-        std::cout << " " << it->c_str();
+        std::cout << " " << *it;
         }
       }
     std::cout << std::endl;
@@ -419,8 +419,8 @@
     return 0;
     }
 
-  cmStdString fullfile = "";
-  cmStdString line;
+  std::string fullfile = "";
+  std::string line;
   while ( cmSystemTools::GetLineFromStream(ifs, line) )
     {
     fullfile += line + "\n";
diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h
index 9807a04..5542018 100644
--- a/Source/cmDependsJavaParserHelper.h
+++ b/Source/cmDependsJavaParserHelper.h
@@ -59,15 +59,15 @@
   const char* GetCurrentCombine() { return this->CurrentCombine.c_str(); }
   void UpdateCombine(const char* str1, const char* str2);
 
-  std::vector<cmStdString>& GetClassesFound() { return this->ClassesFound; }
+  std::vector<std::string>& GetClassesFound() { return this->ClassesFound; }
 
-  std::vector<cmStdString> GetFilesProduced();
+  std::vector<std::string> GetFilesProduced();
 
 private:
   class CurrentClass
   {
   public:
-    cmStdString Name;
+    std::string Name;
     std::vector<CurrentClass>* NestedClasses;
     CurrentClass()
       {
@@ -93,16 +93,16 @@
       {
         (*this) = c;
       }
-    void AddFileNamesForPrinting(std::vector<cmStdString> *files,
+    void AddFileNamesForPrinting(std::vector<std::string> *files,
                                  const char* prefix, const char* sep);
   };
-  cmStdString CurrentPackage;
-  cmStdString::size_type InputBufferPos;
-  cmStdString InputBuffer;
+  std::string CurrentPackage;
+  std::string::size_type InputBufferPos;
+  std::string InputBuffer;
   std::vector<char> OutputBuffer;
-  std::vector<cmStdString> ClassesFound;
-  std::vector<cmStdString> PackagesImport;
-  cmStdString CurrentCombine;
+  std::vector<std::string> ClassesFound;
+  std::vector<std::string> PackagesImport;
+  std::string CurrentCombine;
 
   std::vector<CurrentClass> ClassStack;
 
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 9df1e79..8d035af 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -481,9 +481,9 @@
 }
 
 //----------------------------------------------------------------------------
-void cmDocumentation::SetName(const char* name)
+void cmDocumentation::SetName(const std::string& name)
 {
-  this->NameString = name?name:"";
+  this->NameString = name;
 }
 
 //----------------------------------------------------------------------------
@@ -676,7 +676,7 @@
   for (std::vector<std::string>::const_iterator i = files.begin();
        i != files.end(); ++i)
     {
-    found = r.ProcessFile(i->c_str()) || found;
+    found = r.ProcessFile(*i) || found;
     }
   return found;
 }
@@ -703,7 +703,7 @@
     return true;
     }
   // Argument was not a manual.  Complain.
-  os << "Argument \"" << this->CurrentArgument.c_str()
+  os << "Argument \"" << this->CurrentArgument
      << "\" to --help-manual is not an available manual.  "
      << "Use --help-manual-list to see all available manuals.\n";
   return false;
@@ -725,7 +725,7 @@
     return true;
     }
   // Argument was not a command.  Complain.
-  os << "Argument \"" << this->CurrentArgument.c_str()
+  os << "Argument \"" << this->CurrentArgument
      << "\" to --help-command is not a CMake command.  "
      << "Use --help-command-list to see all commands.\n";
   return false;
@@ -747,7 +747,7 @@
     return true;
     }
   // Argument was not a module.  Complain.
-  os << "Argument \"" << this->CurrentArgument.c_str()
+  os << "Argument \"" << this->CurrentArgument
      << "\" to --help-module is not a CMake module.\n";
   return false;
 }
@@ -782,7 +782,7 @@
     return true;
     }
   // Argument was not a property.  Complain.
-  os << "Argument \"" << this->CurrentArgument.c_str()
+  os << "Argument \"" << this->CurrentArgument
      << "\" to --help-property is not a CMake property.  "
      << "Use --help-property-list to see all properties.\n";
   return false;
@@ -806,7 +806,7 @@
     }
 
   // Argument was not a policy.  Complain.
-  os << "Argument \"" << this->CurrentArgument.c_str()
+  os << "Argument \"" << this->CurrentArgument
      << "\" to --help-policy is not a CMake policy.\n";
   return false;
 }
@@ -827,7 +827,7 @@
     return true;
     }
   // Argument was not a variable.  Complain.
-  os << "Argument \"" << this->CurrentArgument.c_str()
+  os << "Argument \"" << this->CurrentArgument
      << "\" to --help-variable is not a defined variable.  "
      << "Use --help-variable-list to see all defined variables.\n";
   return false;
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index cc16eb7..c98e48e 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -56,7 +56,7 @@
   void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
 
   /** Set the program name for standard document generation.  */
-  void SetName(const char* name);
+  void SetName(const std::string& name);
 
   /** Set a section of the documentation. Typical sections include Name,
       Usage, Description, Options */
diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h
index 636860d..d796da8 100644
--- a/Source/cmDocumentationSection.h
+++ b/Source/cmDocumentationSection.h
@@ -34,8 +34,8 @@
   void Clear() { this->Entries.clear(); }
 
   /** Return the name of this section. */
-  const char* GetName() const
-  { return this->Name.c_str(); }
+  std::string GetName() const
+  { return this->Name; }
 
   /** Return a pointer to the first entry of this section. */
   const std::vector<cmDocumentationEntry> &GetEntries() const
diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx
index 6a0ab7b..944a000 100644
--- a/Source/cmDynamicLoader.cxx
+++ b/Source/cmDynamicLoader.cxx
@@ -23,7 +23,7 @@
   static cmDynamicLoaderCache* GetInstance();
 
 private:
-  std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle> CacheMap;
+  std::map<std::string, cmsys::DynamicLoader::LibraryHandle> CacheMap;
   static cmDynamicLoaderCache* Instance;
 };
 
@@ -47,7 +47,7 @@
 bool cmDynamicLoaderCache::GetCacheFile(const char* path,
   cmsys::DynamicLoader::LibraryHandle& p)
 {
-  std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle>::iterator it
+  std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it
     = this->CacheMap.find(path);
   if ( it != this->CacheMap.end() )
     {
@@ -59,7 +59,7 @@
 
 bool cmDynamicLoaderCache::FlushCache(const char* path)
 {
-  std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle>::iterator it
+  std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it
     = this->CacheMap.find(path);
   bool ret = false;
   if ( it != this->CacheMap.end() )
@@ -73,7 +73,7 @@
 
 void cmDynamicLoaderCache::FlushCache()
 {
-  for ( std::map<cmStdString,
+  for ( std::map<std::string,
     cmsys::DynamicLoader::LibraryHandle>::iterator it
     = this->CacheMap.begin();
         it != this->CacheMap.end(); it++ )
diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h
index acf8011..d038b5c 100644
--- a/Source/cmDynamicLoader.h
+++ b/Source/cmDynamicLoader.h
@@ -36,8 +36,8 @@
   static void FlushCache();
 
 protected:
-  cmDynamicLoader() {};
-  ~cmDynamicLoader() {};
+  cmDynamicLoader() {}
+  ~cmDynamicLoader() {}
 
 private:
   cmDynamicLoader(const cmDynamicLoader&);  // Not implemented.
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index 353f2e9..cab23b7 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -23,6 +23,26 @@
 #if defined(__OpenBSD__)
 # include <stdint.h>
 # include <elf_abi.h>
+#elif defined(__HAIKU__)
+# include <elf32.h>
+# include <elf64.h>
+  typedef struct Elf32_Ehdr Elf32_Ehdr;
+  typedef struct Elf32_Shdr Elf32_Shdr;
+  typedef struct Elf32_Sym Elf32_Sym;
+  typedef struct Elf32_Rel Elf32_Rel;
+  typedef struct Elf32_Rela Elf32_Rela;
+# define ELFMAG0 0x7F
+# define ELFMAG1 'E'
+# define ELFMAG2 'L'
+# define ELFMAG3 'F'
+# define ET_NONE 0
+# define ET_REL 1
+# define ET_EXEC 2
+# define ET_DYN 3
+# define ET_CORE 4
+# define EM_386 3
+# define EM_SPARC 2
+# define EM_PPC 20
 #else
 # include <elf.h>
 #endif
@@ -104,7 +124,7 @@
   virtual unsigned int GetNumberOfSections() const = 0;
   virtual unsigned int GetDynamicEntryCount() = 0;
   virtual unsigned long GetDynamicEntryPosition(int j) = 0;
-  virtual StringEntry const* GetDynamicSectionString(int tag) = 0;
+  virtual StringEntry const* GetDynamicSectionString(unsigned int tag) = 0;
   virtual void PrintInfo(std::ostream& os) const = 0;
 
   bool ReadBytes(unsigned long pos, unsigned long size, char* buf)
@@ -167,7 +187,7 @@
     }
 
   // Store string table entry states.
-  std::map<int, StringEntry> DynamicSectionStrings;
+  std::map<unsigned int, StringEntry> DynamicSectionStrings;
 };
 
 //----------------------------------------------------------------------------
@@ -178,16 +198,18 @@
   typedef Elf32_Shdr ELF_Shdr;
   typedef Elf32_Dyn  ELF_Dyn;
   typedef Elf32_Half ELF_Half;
+  typedef cmIML_INT_uint32_t tagtype;
   static const char* GetName() { return "32-bit"; }
 };
 
-// Configure the implementation template for 32-bit ELF files.
+// Configure the implementation template for 64-bit ELF files.
 struct cmELFTypes64
 {
   typedef Elf64_Ehdr ELF_Ehdr;
   typedef Elf64_Shdr ELF_Shdr;
   typedef Elf64_Dyn  ELF_Dyn;
   typedef Elf64_Half ELF_Half;
+  typedef cmIML_INT_uint64_t tagtype;
   static const char* GetName() { return "64-bit"; }
 };
 
@@ -202,6 +224,7 @@
   typedef typename Types::ELF_Shdr ELF_Shdr;
   typedef typename Types::ELF_Dyn  ELF_Dyn;
   typedef typename Types::ELF_Half ELF_Half;
+  typedef typename Types::tagtype tagtype;
 
   // Construct with a stream and byte swap indicator.
   cmELFInternalImpl(cmELF* external,
@@ -219,7 +242,7 @@
   virtual unsigned long GetDynamicEntryPosition(int j);
 
   // Lookup a string from the dynamic section with the given tag.
-  virtual StringEntry const* GetDynamicSectionString(int tag);
+  virtual StringEntry const* GetDynamicSectionString(unsigned int tag);
 
   // Print information about the ELF file.
   virtual void PrintInfo(std::ostream& os) const
@@ -604,10 +627,10 @@
 //----------------------------------------------------------------------------
 template <class Types>
 cmELF::StringEntry const*
-cmELFInternalImpl<Types>::GetDynamicSectionString(int tag)
+cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
 {
   // Short-circuit if already checked.
-  std::map<int, StringEntry>::iterator dssi =
+  std::map<unsigned int, StringEntry>::iterator dssi =
     this->DynamicSectionStrings.find(tag);
   if(dssi != this->DynamicSectionStrings.end())
     {
@@ -645,7 +668,7 @@
       di != this->DynamicSectionEntries.end(); ++di)
     {
     ELF_Dyn& dyn = *di;
-    if(dyn.d_tag == tag)
+    if(static_cast<tagtype>(dyn.d_tag) == static_cast<tagtype>(tag))
       {
       // We found the tag requested.
       // Make sure the position given is within the string section.
diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h
index d472e99..dde5fcc 100644
--- a/Source/cmElseCommand.h
+++ b/Source/cmElseCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "else";}
+  virtual std::string GetName() const { return "else";}
 
   cmTypeMacro(cmElseCommand, cmCommand);
 };
diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h
index d811b35..c627cbe 100644
--- a/Source/cmElseIfCommand.h
+++ b/Source/cmElseIfCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "elseif";}
+  virtual std::string GetName() const { return "elseif";}
 
   cmTypeMacro(cmElseIfCommand, cmCommand);
 };
diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h
index a248042..2b09e11 100644
--- a/Source/cmEnableLanguageCommand.h
+++ b/Source/cmEnableLanguageCommand.h
@@ -43,7 +43,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "enable_language";}
+  virtual std::string GetName() const {return "enable_language";}
 
   cmTypeMacro(cmEnableLanguageCommand, cmCommand);
 };
diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h
index e102f5e..d028c59 100644
--- a/Source/cmEnableTestingCommand.h
+++ b/Source/cmEnableTestingCommand.h
@@ -48,7 +48,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "enable_testing";}
+  virtual std::string GetName() const { return "enable_testing";}
 
   cmTypeMacro(cmEnableTestingCommand, cmCommand);
 
diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h
index 44d29b5..c3be387 100644
--- a/Source/cmEndForEachCommand.h
+++ b/Source/cmEndForEachCommand.h
@@ -52,7 +52,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "endforeach";}
+  virtual std::string GetName() const { return "endforeach";}
 
   cmTypeMacro(cmEndForEachCommand, cmCommand);
 };
diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h
index 4fdca6b..3a42c17 100644
--- a/Source/cmEndFunctionCommand.h
+++ b/Source/cmEndFunctionCommand.h
@@ -52,7 +52,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "endfunction";}
+  virtual std::string GetName() const { return "endfunction";}
 
   cmTypeMacro(cmEndFunctionCommand, cmCommand);
 };
diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h
index 634da60..a8248c8 100644
--- a/Source/cmEndIfCommand.h
+++ b/Source/cmEndIfCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "endif";}
+  virtual std::string GetName() const { return "endif";}
 
   cmTypeMacro(cmEndIfCommand, cmCommand);
 };
diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h
index db15f27..fdc04ee 100644
--- a/Source/cmEndMacroCommand.h
+++ b/Source/cmEndMacroCommand.h
@@ -52,7 +52,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "endmacro";}
+  virtual std::string GetName() const { return "endmacro";}
 
   cmTypeMacro(cmEndMacroCommand, cmCommand);
 };
diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h
index 41138d1..ec1cb65 100644
--- a/Source/cmEndWhileCommand.h
+++ b/Source/cmEndWhileCommand.h
@@ -52,7 +52,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "endwhile";}
+  virtual std::string GetName() const { return "endwhile";}
 
   cmTypeMacro(cmEndWhileCommand, cmCommand);
 };
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index 6c11345..9b59088 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -132,14 +132,14 @@
       }
 
     std::string coutput = std::string(output, first, last-first+1);
-    this->Makefile->AddDefinition(output_variable.c_str(), coutput.c_str());
+    this->Makefile->AddDefinition(output_variable, coutput.c_str());
     }
 
   if ( return_variable.size() > 0 )
     {
     char buffer[100];
     sprintf(buffer, "%d", retVal);
-    this->Makefile->AddDefinition(return_variable.c_str(), buffer);
+    this->Makefile->AddDefinition(return_variable, buffer);
     }
 
   return true;
diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h
index 6d28cdc..23d10f9 100644
--- a/Source/cmExecProgramCommand.h
+++ b/Source/cmExecProgramCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const
+  virtual std::string GetName() const
     {return "exec_program";}
 
   /**
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 994c170..11f8ae5 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -191,7 +191,7 @@
       {
       cmOStringStream e;
       e << " given unknown argument \"" << args[i] << "\".";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -200,7 +200,7 @@
     {
     std::string e = "attempted to output into a file: " + output_file
       + " into a source directory.";
-    this->SetError(e.c_str());
+    this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
     }
@@ -256,10 +256,6 @@
 
   // Check the output variables.
   bool merge_output = (output_variable == error_variable);
-  if(error_variable.empty() && !error_quiet)
-    {
-    cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
-    }
   if(!input_file.empty())
     {
     cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDIN, input_file.c_str());
@@ -307,7 +303,11 @@
       }
     else if(p == cmsysProcess_Pipe_STDERR && !error_quiet)
       {
-      if(!error_variable.empty())
+      if(error_variable.empty())
+        {
+        cmSystemTools::Stderr(data, length);
+        }
+      else
         {
         cmExecuteProcessCommandAppend(tempError, data, length);
         }
@@ -326,12 +326,12 @@
   // Store the output obtained.
   if(!output_variable.empty() && tempOutput.size())
     {
-    this->Makefile->AddDefinition(output_variable.c_str(),
+    this->Makefile->AddDefinition(output_variable,
                                   &*tempOutput.begin());
     }
   if(!merge_output && !error_variable.empty() && tempError.size())
     {
-    this->Makefile->AddDefinition(error_variable.c_str(),
+    this->Makefile->AddDefinition(error_variable,
                                   &*tempError.begin());
     }
 
@@ -345,19 +345,19 @@
         int v = cmsysProcess_GetExitValue(cp);
         char buf[100];
         sprintf(buf, "%d", v);
-        this->Makefile->AddDefinition(result_variable.c_str(), buf);
+        this->Makefile->AddDefinition(result_variable, buf);
         }
         break;
       case cmsysProcess_State_Exception:
-        this->Makefile->AddDefinition(result_variable.c_str(),
+        this->Makefile->AddDefinition(result_variable,
                                   cmsysProcess_GetExceptionString(cp));
         break;
       case cmsysProcess_State_Error:
-        this->Makefile->AddDefinition(result_variable.c_str(),
+        this->Makefile->AddDefinition(result_variable,
                                   cmsysProcess_GetErrorString(cp));
         break;
       case cmsysProcess_State_Expired:
-        this->Makefile->AddDefinition(result_variable.c_str(),
+        this->Makefile->AddDefinition(result_variable,
                                   "Process terminated due to timeout");
         break;
       }
diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h
index bd0f783..6906a08 100644
--- a/Source/cmExecuteProcessCommand.h
+++ b/Source/cmExecuteProcessCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const
+  virtual std::string GetName() const
     {return "execute_process";}
 
   /**
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index 1488924..5c94a97 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -24,7 +24,7 @@
 public:
   cmTypeMacro(cmExecutionStatus, cmObject);
 
-  cmExecutionStatus() { this->Clear();};
+  cmExecutionStatus() { this->Clear();}
 
   virtual void SetReturnInvoked(bool val)
   { this->ReturnInvoked = val; }
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 308956a..30a52d4 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -18,6 +18,7 @@
 
 //----------------------------------------------------------------------------
 cmExportBuildFileGenerator::cmExportBuildFileGenerator()
+  : Backtrace(NULL)
 {
   this->Makefile = 0;
   this->ExportSet = 0;
@@ -47,7 +48,7 @@
       cmOStringStream e;
       e << "given target \"" << te->GetName() << "\" more than once.";
       this->Makefile->GetCMakeInstance()
-          ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace);
+          ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace);
       return false;
       }
     if (te->GetType() == cmTarget::INTERFACE_LIBRARY)
@@ -85,6 +86,9 @@
     this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te,
                                     cmGeneratorExpression::BuildInterface,
                                     properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te,
+                                    cmGeneratorExpression::BuildInterface,
+                                    properties, missingTargets);
     this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
                                   te, properties);
     const bool newCMP0022Behavior =
@@ -106,7 +110,7 @@
         ci = this->Configurations.begin();
       ci != this->Configurations.end(); ++ci)
     {
-    this->GenerateImportConfig(os, ci->c_str(), missingTargets);
+    this->GenerateImportConfig(os, *ci, missingTargets);
     }
 
   this->GenerateMissingTargetsCheckCode(os, missingTargets);
@@ -118,8 +122,9 @@
 void
 cmExportBuildFileGenerator
 ::GenerateImportTargetsConfig(std::ostream& os,
-                              const char* config, std::string const& suffix,
-                            std::vector<std::string> &missingTargets)
+                              const std::string& config,
+                              std::string const& suffix,
+                              std::vector<std::string> &missingTargets)
 {
   for(std::vector<cmTarget*>::const_iterator
         tei = this->Exports.begin();
@@ -166,7 +171,8 @@
 //----------------------------------------------------------------------------
 void
 cmExportBuildFileGenerator
-::SetImportLocationProperty(const char* config, std::string const& suffix,
+::SetImportLocationProperty(const std::string& config,
+                            std::string const& suffix,
                             cmTarget* target, ImportPropertyMap& properties)
 {
   // Get the makefile in which to lookup target information.
@@ -313,7 +319,7 @@
     << "consider using the APPEND option with multiple separate calls.";
 
   this->Makefile->GetCMakeInstance()
-      ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace);
+      ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace);
 }
 
 std::string
@@ -326,7 +332,7 @@
   if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
     {
     install_name_dir =
-      target->GetInstallNameDirForBuildTree(config.c_str());
+      target->GetInstallNameDirForBuildTree(config);
     }
 
   return install_name_dir;
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index cea2099..8b5694c 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -45,14 +45,14 @@
 
   void SetMakefile(cmMakefile *mf) {
     this->Makefile = mf;
-    this->Makefile->GetBacktrace(this->Backtrace);
+    this->Backtrace = this->Makefile->GetBacktrace();
   }
 
 protected:
   // Implement virtual methods from the superclass.
   virtual bool GenerateMainFile(std::ostream& os);
   virtual void GenerateImportTargetsConfig(std::ostream& os,
-                                           const char* config,
+                                           const std::string& config,
                                            std::string const& suffix,
                             std::vector<std::string> &missingTargets);
   virtual void HandleMissingTarget(std::string& link_libs,
@@ -66,7 +66,7 @@
                                   int occurrences);
 
   /** Fill in properties indicating built file locations.  */
-  void SetImportLocationProperty(const char* config,
+  void SetImportLocationProperty(const std::string& config,
                                  std::string const& suffix,
                                  cmTarget* target,
                                  ImportPropertyMap& properties);
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index db56aaf..db21c49 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -92,7 +92,7 @@
       cmOStringStream e;
       e << "FILE option given filename \"" << this->Filename.GetString()
         << "\" which does not have an extension of \".cmake\".\n";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     fname = this->Filename.GetString();
@@ -106,7 +106,7 @@
       cmOStringStream e;
       e << "FILE option given filename \"" << fname
         << "\" which is in the source tree.\n";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -128,7 +128,7 @@
       {
       cmOStringStream e;
       e << "EXPORT signature does not recognise the APPEND option.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
@@ -137,7 +137,7 @@
       cmOStringStream e;
       e << "EXPORT signature does not recognise the "
         "EXPORT_LINK_INTERFACE_LIBRARIES option.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
@@ -147,7 +147,7 @@
       {
       cmOStringStream e;
       e << "Export set \"" << setName << "\" not found.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     this->ExportSet = setMap[setName];
@@ -164,18 +164,18 @@
         cmOStringStream e;
         e << "given ALIAS target \"" << *currentTarget
           << "\" which may not be exported.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
-      if(cmTarget* target = gg->FindTarget(0, currentTarget->c_str()))
+      if(cmTarget* target = gg->FindTarget(*currentTarget))
         {
         if(target->GetType() == cmTarget::OBJECT_LIBRARY)
           {
           cmOStringStream e;
           e << "given OBJECT library \"" << *currentTarget
             << "\" which may not be exported.";
-          this->SetError(e.str().c_str());
+          this->SetError(e.str());
           return false;
           }
         }
@@ -184,7 +184,7 @@
         cmOStringStream e;
         e << "given target \"" << *currentTarget
           << "\" which is not built by this project.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       targets.push_back(*currentTarget);
@@ -223,18 +223,15 @@
   // Compute the set of configurations exported.
   std::vector<std::string> configurationTypes;
   this->Makefile->GetConfigurations(configurationTypes);
-  if(!configurationTypes.empty())
+  if(configurationTypes.empty())
     {
-    for(std::vector<std::string>::const_iterator
-          ci = configurationTypes.begin();
-        ci != configurationTypes.end(); ++ci)
-      {
-      ebfg->AddConfiguration(ci->c_str());
-      }
+    configurationTypes.push_back("");
     }
-  else
+  for(std::vector<std::string>::const_iterator
+        ci = configurationTypes.begin();
+      ci != configurationTypes.end(); ++ci)
     {
-    ebfg->AddConfiguration("");
+    ebfg->AddConfiguration(*ci);
     }
   if (this->ExportSet)
     {
@@ -266,7 +263,7 @@
       {
       cmOStringStream e;
       e << "PACKAGE given unknown argument: " << args[i];
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -284,10 +281,17 @@
     cmOStringStream e;
     e << "PACKAGE given invalid package name \"" << package << "\".  "
       << "Package names must match \"" << packageExpr << "\".";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
+  // If the CMAKE_EXPORT_NO_PACKAGE_REGISTRY variable is set the command
+  // export(PACKAGE) does nothing.
+  if(this->Makefile->IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY"))
+    {
+    return true;
+    }
+
   // We store the current build directory in the registry as a value
   // named by a hash of its own content.  This is deterministic and is
   // unique with high probability.
diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h
index c0e445f..f9506bb 100644
--- a/Source/cmExportCommand.h
+++ b/Source/cmExportCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "export";}
+  virtual std::string GetName() const { return "export";}
 
   cmTypeMacro(cmExportCommand, cmCommand);
 
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 4a161ee..9f5eee5 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -35,7 +35,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmExportFileGenerator::AddConfiguration(const char* config)
+void cmExportFileGenerator::AddConfiguration(const std::string& config)
 {
   this->Configurations.push_back(config);
 }
@@ -117,12 +117,12 @@
 
 //----------------------------------------------------------------------------
 void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
-                                    const char* config,
+                                    const std::string& config,
                                     std::vector<std::string> &missingTargets)
 {
   // Construct the property configuration suffix.
   std::string suffix = "_";
-  if(config && *config)
+  if(!config.empty())
     {
     suffix += cmSystemTools::UpperCase(config);
     }
@@ -136,7 +136,8 @@
 }
 
 //----------------------------------------------------------------------------
-void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
+void cmExportFileGenerator::PopulateInterfaceProperty(
+                                              const std::string& propName,
                                               cmTarget *target,
                                               ImportPropertyMap &properties)
 {
@@ -148,8 +149,9 @@
 }
 
 //----------------------------------------------------------------------------
-void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
-                      const char *outputName,
+void cmExportFileGenerator::PopulateInterfaceProperty(
+                      const std::string& propName,
+                      const std::string& outputName,
                       cmTarget *target,
                       cmGeneratorExpression::PreprocessContext preprocessRule,
                       ImportPropertyMap &properties,
@@ -273,27 +275,68 @@
       e << "Target \"" << target->GetName() << "\" "
            "INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n"
            "  \"" << *li << "\"";
-      target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+      target->GetMakefile()->IssueMessage(messageType, e.str());
       }
+    bool inBinary = isSubDirectory(li->c_str(), topBinaryDir);
+    bool inSource = isSubDirectory(li->c_str(), topSourceDir);
     if (isSubDirectory(li->c_str(), installDir))
       {
-      continue;
+      // The include directory is inside the install tree.  If the
+      // install tree is not inside the source tree or build tree then
+      // fall through to the checks below that the include directory is not
+      // also inside the source tree or build tree.
+      bool shouldContinue =
+        (!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
+        (!inSource || isSubDirectory(installDir, topSourceDir));
+
+      if (!shouldContinue)
+        {
+        switch(target->GetPolicyStatusCMP0052())
+          {
+          case cmPolicies::WARN:
+            {
+            cmOStringStream s;
+            s << target->GetMakefile()->GetPolicies()
+                      ->GetPolicyWarning(cmPolicies::CMP0052) << "\n";
+            s << "Directory:\n    \"" << *li << "\"\nin "
+              "INTERFACE_INCLUDE_DIRECTORIES of target \""
+              << target->GetName() << "\" is a subdirectory of the install "
+              "directory:\n    \"" << installDir << "\"\nhowever it is also "
+              "a subdirectory of the " << (inBinary ? "build" : "source")
+              << " tree:\n    \"" << (inBinary ? topBinaryDir : topSourceDir)
+              << "\"" << std::endl;
+            target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING,
+                                                s.str());
+            }
+          case cmPolicies::OLD:
+            shouldContinue = true;
+            break;
+          case cmPolicies::REQUIRED_ALWAYS:
+          case cmPolicies::REQUIRED_IF_USED:
+          case cmPolicies::NEW:
+            break;
+          }
+        }
+      if (shouldContinue)
+        {
+        continue;
+        }
       }
-    if (isSubDirectory(li->c_str(), topBinaryDir))
+    if (inBinary)
       {
       e << "Target \"" << target->GetName() << "\" "
            "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
            "  \"" << *li << "\"\nwhich is prefixed in the build directory.";
-      target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+      target->GetMakefile()->IssueMessage(messageType, e.str());
       }
     if (!inSourceBuild)
       {
-      if (isSubDirectory(li->c_str(), topSourceDir))
+      if (inSource)
         {
         e << "Target \"" << target->GetName() << "\" "
             "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
             "  \"" << *li << "\"\nwhich is prefixed in the source directory.";
-        target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+        target->GetMakefile()->IssueMessage(messageType, e.str());
         }
       }
     }
@@ -334,8 +377,7 @@
   const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";
   const char *input = target->GetProperty(propName);
 
-  cmListFileBacktrace lfbt;
-  cmGeneratorExpression ge(lfbt);
+  cmGeneratorExpression ge;
 
   std::string dirs = cmGeneratorExpression::Preprocess(
                                             tei->InterfaceIncludeDirectories,
@@ -343,7 +385,7 @@
                                             true);
   this->ReplaceInstallPrefix(dirs);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
-  std::string exportDirs = cge->Evaluate(target->GetMakefile(), 0,
+  std::string exportDirs = cge->Evaluate(target->GetMakefile(), "",
                                          false, target);
 
   if (cge->GetHadContextSensitiveCondition())
@@ -391,7 +433,8 @@
 }
 
 //----------------------------------------------------------------------------
-void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
+void cmExportFileGenerator::PopulateInterfaceProperty(
+                      const std::string& propName,
                       cmTarget *target,
                       cmGeneratorExpression::PreprocessContext preprocessRule,
                       ImportPropertyMap &properties,
@@ -403,7 +446,7 @@
 
 
 //----------------------------------------------------------------------------
-void getPropertyContents(cmTarget const* tgt, const char *prop,
+void getPropertyContents(cmTarget const* tgt, const std::string& prop,
          std::set<std::string> &ifaceProperties)
 {
   const char *p = tgt->GetProperty(prop);
@@ -423,7 +466,7 @@
 //----------------------------------------------------------------------------
 void getCompatibleInterfaceProperties(cmTarget *target,
                                       std::set<std::string> &ifaceProperties,
-                                      const char *config)
+                                      const std::string& config)
 {
   cmComputeLinkInformation *info = target->GetLinkInformation(config);
 
@@ -487,7 +530,7 @@
 
   if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
     {
-    getCompatibleInterfaceProperties(target, ifaceProperties, 0);
+    getCompatibleInterfaceProperties(target, ifaceProperties, "");
 
     std::vector<std::string> configNames;
     target->GetMakefile()->GetConfigurations(configNames);
@@ -495,14 +538,14 @@
     for (std::vector<std::string>::const_iterator ci = configNames.begin();
       ci != configNames.end(); ++ci)
       {
-      getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str());
+      getCompatibleInterfaceProperties(target, ifaceProperties, *ci);
       }
     }
 
   for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
     it != ifaceProperties.end(); ++it)
     {
-    this->PopulateInterfaceProperty(("INTERFACE_" + *it).c_str(),
+    this->PopulateInterfaceProperty("INTERFACE_" + *it,
                                     target, properties);
     }
 }
@@ -684,7 +727,7 @@
 //----------------------------------------------------------------------------
 void
 cmExportFileGenerator
-::SetImportLinkInterface(const char* config, std::string const& suffix,
+::SetImportLinkInterface(const std::string& config, std::string const& suffix,
                     cmGeneratorExpression::PreprocessContext preprocessRule,
                     cmTarget* target, ImportPropertyMap& properties,
                     std::vector<std::string>& missingTargets)
@@ -709,7 +752,7 @@
   const char *propContent;
 
   if (const char *prop_suffixed = target->GetProperty(
-                    ("LINK_INTERFACE_LIBRARIES" + suffix).c_str()))
+                    "LINK_INTERFACE_LIBRARIES" + suffix))
     {
     propContent = prop_suffixed;
     }
@@ -759,7 +802,8 @@
 //----------------------------------------------------------------------------
 void
 cmExportFileGenerator
-::SetImportDetailProperties(const char* config, std::string const& suffix,
+::SetImportDetailProperties(const std::string& config,
+                            std::string const& suffix,
                             cmTarget* target, ImportPropertyMap& properties,
                             std::vector<std::string>& missingTargets
                            )
@@ -825,7 +869,7 @@
 cmExportFileGenerator
 ::SetImportLinkProperty(std::string const& suffix,
                         cmTarget* target,
-                        const char* propName,
+                        const std::string& propName,
                         std::vector<std::string> const& entries,
                         ImportPropertyMap& properties,
                         std::vector<std::string>& missingTargets
@@ -861,11 +905,11 @@
 
 //----------------------------------------------------------------------------
 void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
-                                                     const char* config)
+                                                    const std::string& config)
 {
   os << "#----------------------------------------------------------------\n"
      << "# Generated CMake target import file";
-  if(config)
+  if(!config.empty())
     {
     os << " for configuration \"" << config << "\".\n";
     }
@@ -996,7 +1040,7 @@
 //----------------------------------------------------------------------------
 void
 cmExportFileGenerator
-::GenerateImportPropertyCode(std::ostream& os, const char* config,
+::GenerateImportPropertyCode(std::ostream& os, const std::string& config,
                              cmTarget const* target,
                              ImportPropertyMap const& properties)
 {
@@ -1010,7 +1054,7 @@
      << config << "\"\n";
   os << "set_property(TARGET " << targetName
      << " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
-  if(config && *config)
+  if(!config.empty())
     {
     os << cmSystemTools::UpperCase(config);
     }
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 57ab378..abd8ad5 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -50,32 +50,33 @@
   const char *GetMainExportFileName() const;
 
   /** Set the namespace in which to place exported target names.  */
-  void SetNamespace(const char* ns) { this->Namespace = ns; }
+  void SetNamespace(const std::string& ns) { this->Namespace = ns; }
   std::string GetNamespace() const { return this->Namespace; }
 
   void SetExportOld(bool exportOld) { this->ExportOld = exportOld; }
 
   /** Add a configuration to be exported.  */
-  void AddConfiguration(const char* config);
+  void AddConfiguration(const std::string& config);
 
   /** Actually generate the export file.  Returns whether there was an
       error.  */
   bool GenerateImportFile();
 protected:
 
-  typedef std::map<cmStdString, cmStdString> ImportPropertyMap;
+  typedef std::map<std::string, std::string> ImportPropertyMap;
 
   // Generate per-configuration target information to the given output
   // stream.
-  void GenerateImportConfig(std::ostream& os, const char* config,
+  void GenerateImportConfig(std::ostream& os, const std::string& config,
                             std::vector<std::string> &missingTargets);
 
   // Methods to implement export file code generation.
-  void GenerateImportHeaderCode(std::ostream& os, const char* config = 0);
+  void GenerateImportHeaderCode(std::ostream& os,
+                                const std::string& config = "");
   void GenerateImportFooterCode(std::ostream& os);
   void GenerateImportVersionCode(std::ostream& os);
   void GenerateImportTargetCode(std::ostream& os, cmTarget const* target);
-  void GenerateImportPropertyCode(std::ostream& os, const char* config,
+  void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
                                   cmTarget const* target,
                                   ImportPropertyMap const& properties);
   void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
@@ -90,12 +91,12 @@
 
   // Collect properties with detailed information about targets beyond
   // their location on disk.
-  void SetImportDetailProperties(const char* config,
+  void SetImportDetailProperties(const std::string& config,
                                  std::string const& suffix, cmTarget* target,
                                  ImportPropertyMap& properties,
                                  std::vector<std::string>& missingTargets);
   void SetImportLinkProperty(std::string const& suffix,
-                             cmTarget* target, const char* propName,
+                             cmTarget* target, const std::string& propName,
                              std::vector<std::string> const& entries,
                              ImportPropertyMap& properties,
                              std::vector<std::string>& missingTargets);
@@ -105,7 +106,7 @@
 
   /** Each subclass knows where the target files are located.  */
   virtual void GenerateImportTargetsConfig(std::ostream& os,
-                                           const char* config,
+                                           const std::string& config,
                                            std::string const& suffix,
                             std::vector<std::string> &missingTargets) = 0;
 
@@ -116,7 +117,7 @@
                                    cmMakefile* mf,
                                    cmTarget* depender,
                                    cmTarget* dependee) = 0;
-  void PopulateInterfaceProperty(const char *,
+  void PopulateInterfaceProperty(const std::string&,
                                  cmTarget *target,
                                  cmGeneratorExpression::PreprocessContext,
                                  ImportPropertyMap &properties,
@@ -125,7 +126,7 @@
                                  cmGeneratorExpression::PreprocessContext,
                                  ImportPropertyMap &properties,
                                  std::vector<std::string> &missingTargets);
-  void PopulateInterfaceProperty(const char *propName, cmTarget *target,
+  void PopulateInterfaceProperty(const std::string& propName, cmTarget *target,
                                  ImportPropertyMap &properties);
   void PopulateCompatibleInterfaceProperties(cmTarget *target,
                                  ImportPropertyMap &properties);
@@ -137,7 +138,8 @@
                       ImportPropertyMap &properties,
                       std::vector<std::string> &missingTargets);
 
-  void SetImportLinkInterface(const char* config, std::string const& suffix,
+  void SetImportLinkInterface(const std::string& config,
+                    std::string const& suffix,
                     cmGeneratorExpression::PreprocessContext preprocessRule,
                     cmTarget* target, ImportPropertyMap& properties,
                     std::vector<std::string>& missingTargets);
@@ -174,7 +176,7 @@
   std::set<cmTarget*> ExportedTargets;
 
 private:
-  void PopulateInterfaceProperty(const char *, const char *,
+  void PopulateInterfaceProperty(const std::string&, const std::string&,
                                  cmTarget *target,
                                  cmGeneratorExpression::PreprocessContext,
                                  ImportPropertyMap &properties,
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index b579963..89071c0 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -149,6 +149,10 @@
                                   te,
                                   cmGeneratorExpression::InstallInterface,
                                   properties, missingTargets);
+    this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES",
+                                  te,
+                                  cmGeneratorExpression::InstallInterface,
+                                  properties, missingTargets);
 
     const bool newCMP0022Behavior =
                               te->GetPolicyStatusCMP0022() != cmPolicies::WARN
@@ -211,7 +215,7 @@
           ci = this->Configurations.begin();
         ci != this->Configurations.end(); ++ci)
       {
-      if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets))
+      if(!this->GenerateImportFileConfig(*ci, missingTargets))
         {
         result = false;
         }
@@ -240,7 +244,8 @@
 
 //----------------------------------------------------------------------------
 bool
-cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config,
+cmExportInstallFileGenerator::GenerateImportFileConfig(
+                                    const std::string& config,
                                     std::vector<std::string> &missingTargets)
 {
   // Skip configurations not enabled for this export.
@@ -254,7 +259,7 @@
   fileName += "/";
   fileName += this->FileBase;
   fileName += "-";
-  if(config && *config)
+  if(!config.empty())
     {
     fileName += cmSystemTools::LowerCase(config);
     }
@@ -270,7 +275,7 @@
     {
     std::string se = cmSystemTools::GetLastSystemError();
     cmOStringStream e;
-    e << "cannot write to file \"" << fileName.c_str()
+    e << "cannot write to file \"" << fileName
       << "\": " << se;
     cmSystemTools::Error(e.str().c_str());
     return false;
@@ -296,7 +301,8 @@
 void
 cmExportInstallFileGenerator
 ::GenerateImportTargetsConfig(std::ostream& os,
-                              const char* config, std::string const& suffix,
+                              const std::string& config,
+                              std::string const& suffix,
                               std::vector<std::string> &missingTargets)
 {
   // Add each target in the set to the export.
@@ -355,7 +361,8 @@
 //----------------------------------------------------------------------------
 void
 cmExportInstallFileGenerator
-::SetImportLocationProperty(const char* config, std::string const& suffix,
+::SetImportLocationProperty(const std::string& config,
+                            std::string const& suffix,
                             cmInstallTargetGenerator* itgen,
                             ImportPropertyMap& properties,
                             std::set<std::string>& importedLocations
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index 7c634a4..b851ad5 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -41,7 +41,7 @@
   /** Get the per-config file generated for each configuraiton.  This
       maps from the configuration name to the file temporary location
       for installation.  */
-  std::map<cmStdString, cmStdString> const& GetConfigImportFiles()
+  std::map<std::string, std::string> const& GetConfigImportFiles()
     { return this->ConfigImportFiles; }
 
   /** Compute the globbing expression used to load per-config import
@@ -52,7 +52,7 @@
   // Implement virtual methods from the superclass.
   virtual bool GenerateMainFile(std::ostream& os);
   virtual void GenerateImportTargetsConfig(std::ostream& os,
-                                           const char* config,
+                                           const std::string& config,
                                            std::string const& suffix,
                             std::vector<std::string> &missingTargets);
   virtual void HandleMissingTarget(std::string& link_libs,
@@ -72,11 +72,11 @@
 
 
   /** Generate a per-configuration file for the targets.  */
-  bool GenerateImportFileConfig(const char* config,
+  bool GenerateImportFileConfig(const std::string& config,
                             std::vector<std::string> &missingTargets);
 
   /** Fill in properties indicating installed file locations.  */
-  void SetImportLocationProperty(const char* config,
+  void SetImportLocationProperty(const std::string& config,
                                  std::string const& suffix,
                                  cmInstallTargetGenerator* itgen,
                                  ImportPropertyMap& properties,
@@ -92,7 +92,7 @@
   std::string ImportPrefix;
 
   // The import file generated for each configuration.
-  std::map<cmStdString, cmStdString> ConfigImportFiles;
+  std::map<std::string, std::string> ConfigImportFiles;
 };
 
 #endif
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index 5d6f094..688d2eb 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -83,9 +83,9 @@
   cmake* cm = this->Makefile->GetCMakeInstance();
   cmGlobalGenerator* global = cm->GetGlobalGenerator();
   const std::vector<cmLocalGenerator *>& locals = global->GetLocalGenerators();
-  std::map<cmStdString, cmStdString> libDepsOld;
-  std::map<cmStdString, cmStdString> libDepsNew;
-  std::map<cmStdString, cmStdString> libTypes;
+  std::map<std::string, std::string> libDepsOld;
+  std::map<std::string, std::string> libDepsNew;
+  std::map<std::string, std::string> libTypes;
   for(std::vector<cmLocalGenerator *>::const_iterator i = locals.begin();
       i != locals.end(); ++i)
     {
@@ -138,7 +138,7 @@
             break;
           }
         std::string lib = li->first;
-        if(cmTarget* libtgt = global->FindTarget(0, lib.c_str()))
+        if(cmTarget* libtgt = global->FindTarget(lib))
           {
           // Handle simple output name changes.  This command is
           // deprecated so we do not support full target name
@@ -175,7 +175,7 @@
   fout << "# Generated by CMake " <<  cmVersion::GetCMakeVersion() << "\n\n";
   fout << "if(" << vertest << ")\n";
   fout << "  # Information for CMake 2.6 and above.\n";
-  for(std::map<cmStdString, cmStdString>::const_iterator
+  for(std::map<std::string, std::string>::const_iterator
         i = libDepsNew.begin();
       i != libDepsNew.end(); ++i)
     {
@@ -186,7 +186,7 @@
     }
   fout << "else()\n";
   fout << "  # Information for CMake 2.4 and lower.\n";
-  for(std::map<cmStdString, cmStdString>::const_iterator
+  for(std::map<std::string, std::string>::const_iterator
         i = libDepsOld.begin();
       i != libDepsOld.end(); ++i)
     {
@@ -195,7 +195,7 @@
       fout << "  set(\"" << i->first << "\" \"" << i->second << "\")\n";
       }
     }
-  for(std::map<cmStdString, cmStdString>::const_iterator i = libTypes.begin();
+  for(std::map<std::string, std::string>::const_iterator i = libTypes.begin();
       i != libTypes.end(); ++i)
     {
     if(i->second != "general")
diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h
index 29b568f..2ea4e79 100644
--- a/Source/cmExportLibraryDependenciesCommand.h
+++ b/Source/cmExportLibraryDependenciesCommand.h
@@ -21,7 +21,7 @@
   virtual cmCommand* Clone() { return new cmExportLibraryDependenciesCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
-  virtual const char* GetName() const { return "export_library_dependencies";}
+  virtual std::string GetName() const { return "export_library_dependencies";}
   virtual bool IsDiscouraged() const { return true; }
 
   virtual void FinalPass();
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index a8a91d6..eb8d193 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -46,8 +46,9 @@
   return true;
 }
 
-std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName,
-                                                cmTarget const* tgt,
+std::string cmExportTryCompileFileGenerator::FindTargets(
+                                          const std::string& propName,
+                                          cmTarget const* tgt,
                                           std::set<cmTarget const*> &emitted)
 {
   const char *prop = tgt->GetProperty(propName);
@@ -56,10 +57,9 @@
     return std::string();
     }
 
-  cmListFileBacktrace lfbt;
-  cmGeneratorExpression ge(lfbt);
+  cmGeneratorExpression ge;
 
-  cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+  cmGeneratorExpressionDAGChecker dagChecker(
                                       tgt->GetName(),
                                       propName, 0, 0);
 
@@ -101,7 +101,7 @@
       {
       const std::string libs = i->second.GetValue();
 
-      std::string evalResult = this->FindTargets(i->first.c_str(),
+      std::string evalResult = this->FindTargets(i->first,
                                                  target, emitted);
 
       std::vector<std::string> depends;
@@ -128,7 +128,7 @@
   if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
     {
     install_name_dir =
-      target->GetInstallNameDirForBuildTree(config.c_str());
+      target->GetInstallNameDirForBuildTree(config);
     }
 
   return install_name_dir;
diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h
index 71ac0dd..ec70d81 100644
--- a/Source/cmExportTryCompileFileGenerator.h
+++ b/Source/cmExportTryCompileFileGenerator.h
@@ -23,14 +23,14 @@
   /** Set the list of targets to export.  */
   void SetExports(const std::vector<cmTarget const*> &exports)
     { this->Exports = exports; }
-  void SetConfig(const char *config) { this->Config = config; }
+  void SetConfig(const std::string& config) { this->Config = config; }
 protected:
 
   // Implement virtual methods from the superclass.
   virtual bool GenerateMainFile(std::ostream& os);
 
   virtual void GenerateImportTargetsConfig(std::ostream&,
-                                           const char*,
+                                           const std::string&,
                                            std::string const&,
                             std::vector<std::string>&) {}
   virtual void HandleMissingTarget(std::string&,
@@ -46,12 +46,12 @@
   std::string InstallNameDir(cmTarget* target,
                              const std::string& config);
 private:
-  std::string FindTargets(const char *prop, cmTarget const* tgt,
+  std::string FindTargets(const std::string& prop, cmTarget const* tgt,
                    std::set<cmTarget const*> &emitted);
 
 
   std::vector<cmTarget const*> Exports;
-  const char *Config;
+  std::string Config;
 };
 
 #endif
diff --git a/Source/cmExprLexer.cxx b/Source/cmExprLexer.cxx
index aa384cd..4704f03 100644
--- a/Source/cmExprLexer.cxx
+++ b/Source/cmExprLexer.cxx
@@ -976,7 +976,7 @@
       "fatal flex scanner internal error--no action found" );
   } /* end of action switch */
     } /* end of scanning one token */
-return 0; /* this should not happen but it silences a warning*/
+return 0; /* this should not happen but it quiets some compilers */
 } /* end of cmExpr_yylex */
 
 /* yy_get_next_buffer - try to read in a new buffer
diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h
index 4b76b33..8d6b2cd 100644
--- a/Source/cmExprParserHelper.h
+++ b/Source/cmExprParserHelper.h
@@ -49,8 +49,8 @@
   const char* GetError() { return this->ErrorString.c_str(); }
 
 private:
-  cmStdString::size_type InputBufferPos;
-  cmStdString InputBuffer;
+  std::string::size_type InputBufferPos;
+  std::string InputBuffer;
   std::vector<char> OutputBuffer;
   int CurrentLine;
   int Verbose;
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx
index 0d42c35..9264671 100644
--- a/Source/cmExternalMakefileProjectGenerator.cxx
+++ b/Source/cmExternalMakefileProjectGenerator.cxx
@@ -20,13 +20,13 @@
 }
 
 std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
-                                                   const char* globalGenerator,
-                                                   const char* extraGenerator)
+                                            const std::string& globalGenerator,
+                                            const std::string& extraGenerator)
 {
   std::string fullName;
-  if (globalGenerator)
+  if (!globalGenerator.empty())
     {
-    if (extraGenerator && *extraGenerator)
+    if (!extraGenerator.empty())
       {
       fullName = extraGenerator;
       fullName += " - ";
@@ -36,22 +36,22 @@
   return fullName;
 }
 
-const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
-                                                          const char* fullName)
+std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
+                                                  const std::string& fullName)
 {
   // at least one global generator must be supported
   assert(!this->SupportedGlobalGenerators.empty());
 
-  if (fullName==0)
+  if (fullName.empty())
     {
-    return 0;
+    return "";
     }
 
   std::string currentName = fullName;
   // if we get only the short name, take the first global generator as default
   if (currentName == this->GetName())
     {
-    return this->SupportedGlobalGenerators[0].c_str();
+    return this->SupportedGlobalGenerators[0];
     }
 
   // otherwise search for the matching global generator
@@ -60,11 +60,11 @@
        it != this->SupportedGlobalGenerators.end();
        ++it)
     {
-      if (this->CreateFullGeneratorName(it->c_str(), this->GetName())
+      if (this->CreateFullGeneratorName(*it, this->GetName())
                                                                 == currentName)
       {
-        return it->c_str();
+        return *it;
       }
     }
-  return 0;
+  return "";
 }
diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h
index bce441d..cba1c76 100644
--- a/Source/cmExternalMakefileProjectGenerator.h
+++ b/Source/cmExternalMakefileProjectGenerator.h
@@ -37,10 +37,10 @@
   virtual ~cmExternalMakefileProjectGenerator() {}
 
   ///! Get the name for this generator.
-  virtual const char* GetName() const = 0;
+  virtual std::string GetName() const = 0;
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
-                                const char* fullName) const = 0;
+                                const std::string& fullName) const = 0;
   virtual void EnableLanguage(std::vector<std::string> const& languages,
                               cmMakefile *, bool optional);
 
@@ -53,12 +53,13 @@
                                       {return this->SupportedGlobalGenerators;}
 
   ///! Get the name of the global generator for the given full name
-  const char* GetGlobalGeneratorName(const char* fullName);
+  std::string GetGlobalGeneratorName(const std::string& fullName);
   /** Create a full name from the given global generator name and the
    * extra generator name
    */
-  static std::string CreateFullGeneratorName(const char* globalGenerator,
-                                             const char* extraGenerator);
+  static std::string CreateFullGeneratorName(
+                                            const std::string& globalGenerator,
+                                            const std::string& extraGenerator);
 
   ///! Generate the project files, the Makefiles have already been generated
   virtual void Generate() = 0;
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 548c88b..6f76dc4 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -38,7 +38,7 @@
 
 //----------------------------------------------------------------------------
 void cmExtraCodeBlocksGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates CodeBlocks project files.";
@@ -61,7 +61,7 @@
 void cmExtraCodeBlocksGenerator::Generate()
 {
   // for each sub project in the project create a codeblocks project
-  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+  for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
        it = this->GlobalGenerator->GetProjectMap().begin();
       it!= this->GlobalGenerator->GetProjectMap().end();
       ++it)
@@ -243,7 +243,7 @@
   Tree tree;
 
   // build tree of virtual folders
-  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+  for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
           it = this->GlobalGenerator->GetProjectMap().begin();
          it != this->GlobalGenerator->GetProjectMap().end();
          ++it)
@@ -334,7 +334,7 @@
           if (strcmp(makefile->GetStartOutputDirectory(),
                      makefile->GetHomeOutputDirectory())==0)
             {
-            this->AppendTarget(fout, ti->first.c_str(), 0,
+            this->AppendTarget(fout, ti->first, 0,
                                make.c_str(), makefile, compiler.c_str());
             }
           }
@@ -350,7 +350,7 @@
             break;
             }
 
-          this->AppendTarget(fout, ti->first.c_str(), 0,
+          this->AppendTarget(fout, ti->first, 0,
                                  make.c_str(), makefile, compiler.c_str());
           break;
         case cmTarget::EXECUTABLE:
@@ -359,11 +359,11 @@
         case cmTarget::MODULE_LIBRARY:
         case cmTarget::OBJECT_LIBRARY:
           {
-          this->AppendTarget(fout, ti->first.c_str(), &ti->second,
+          this->AppendTarget(fout, ti->first, &ti->second,
                              make.c_str(), makefile, compiler.c_str());
           std::string fastTarget = ti->first;
           fastTarget += "/fast";
-          this->AppendTarget(fout, fastTarget.c_str(), &ti->second,
+          this->AppendTarget(fout, fastTarget, &ti->second,
                              make.c_str(), makefile, compiler.c_str());
           }
           break;
@@ -399,7 +399,8 @@
         case cmTarget::UTILITY: // can have sources since 2.6.3
           {
           std::vector<cmSourceFile*> sources;
-          ti->second.GetSourceFiles(sources);
+          ti->second.GetSourceFiles(sources,
+                            makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
           for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
                si!=sources.end(); si++)
             {
@@ -411,14 +412,16 @@
 
             // check whether it is a C/C++ implementation file
             bool isCFile = false;
-            if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C'))
+            std::string lang = (*si)->GetLanguage();
+            if (lang == "C" || lang == "CXX")
               {
+              std::string srcext = (*si)->GetExtension();
               for(std::vector<std::string>::const_iterator
                   ext = mf->GetSourceExtensions().begin();
                   ext !=  mf->GetSourceExtensions().end();
                   ++ext)
                 {
-                if ((*si)->GetExtension() == *ext)
+                if (srcext == *ext)
                   {
                   isCFile = true;
                   break;
@@ -497,7 +500,7 @@
        sit!=otherFiles.end();
        ++sit)
     {
-    fout<<"      <Unit filename=\""<< sit->c_str() <<"\">\n"
+    fout<<"      <Unit filename=\""<< *sit <<"\">\n"
           "      </Unit>\n";
     }
 
@@ -536,7 +539,7 @@
 
 // Generate the xml code for one target.
 void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
-                                              const char* targetName,
+                                              const std::string& targetName,
                                               cmTarget* target,
                                               const char* make,
                                               const cmMakefile* makefile,
@@ -624,7 +627,7 @@
     if (!systemIncludeDirs.empty())
       {
       std::vector<std::string> dirs;
-      cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+      cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
       for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
           dirIt != dirs.end();
           ++dirIt)
@@ -638,7 +641,7 @@
     if (!systemIncludeDirs.empty())
       {
       std::vector<std::string> dirs;
-      cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+      cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
       for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
           dirIt != dirs.end();
           ++dirIt)
@@ -651,7 +654,7 @@
         dirIt != uniqIncludeDirs.end();
         ++dirIt)
       {
-      fout <<"            <Add directory=\"" << dirIt->c_str() << "\" />\n";
+      fout <<"            <Add directory=\"" << *dirIt << "\" />\n";
       }
 
     fout<<"         </Compiler>\n";
@@ -695,7 +698,7 @@
 
   std::string hostSystemName = mf->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
   std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
-  std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str());
+  std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
   std::string compiler = "gcc";  // default to gcc
   if (compilerId == "MSVC")
     {
@@ -713,7 +716,7 @@
     {
     compiler = "icc";
     }
-  else if (compilerId == "Watcom")
+  else if (compilerId == "Watcom" || compilerId == "OpenWatcom")
     {
     compiler = "ow";
     }
@@ -756,10 +759,12 @@
 // Create the command line for building the given target using the selected
 // make
 std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
-             const std::string& make, const char* makefile, const char* target)
+             const std::string& make, const char* makefile,
+             const std::string& target)
 {
   std::string command = make;
-  if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
+  std::string generator = this->GlobalGenerator->GetName();
+  if (generator == "NMake Makefiles")
     {
     // For Windows ConvertToOutputPath already adds quotes when required.
     // These need to be escaped, see
@@ -770,7 +775,7 @@
     command += " VERBOSE=1 ";
     command += target;
     }
-  else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
+  else if (generator == "MinGW Makefiles")
     {
     // no escaping of spaces in this case, see
     // http://public.kitware.com/Bug/view.php?id=10014
@@ -781,7 +786,7 @@
     command += " VERBOSE=1 ";
     command += target;
     }
-  else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
+  else if (generator == "Ninja")
     {
     command += " -v ";
     command += target;
diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h
index e0a64ca..0435ad8 100644
--- a/Source/cmExtraCodeBlocksGenerator.h
+++ b/Source/cmExtraCodeBlocksGenerator.h
@@ -28,14 +28,14 @@
 public:
   cmExtraCodeBlocksGenerator();
 
-  virtual const char* GetName() const
+  virtual std::string GetName() const
                          { return cmExtraCodeBlocksGenerator::GetActualName();}
-  static const char* GetActualName()                    { return "CodeBlocks";}
+  static std::string GetActualName()                    { return "CodeBlocks";}
   static cmExternalMakefileProjectGenerator* New()
                                      { return new cmExtraCodeBlocksGenerator; }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
-                                const char* fullName) const;
+                                const std::string& fullName) const;
 
   virtual void Generate();
 private:
@@ -49,9 +49,9 @@
   std::string GetCBCompilerId(const cmMakefile* mf);
   int GetCBTargetType(cmTarget* target);
   std::string BuildMakeCommand(const std::string& make, const char* makefile,
-                               const char* target);
+                               const std::string& target);
   void AppendTarget(cmGeneratedFileStream& fout,
-                    const char* targetName,
+                    const std::string& targetName,
                     cmTarget* target,
                     const char* make,
                     const cmMakefile* makefile,
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index ff84fb7..cc42bca 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -23,12 +23,12 @@
 #include <cmsys/SystemTools.hxx>
 #include <cmsys/SystemInformation.hxx>
 #include <cmsys/Directory.hxx>
+#include "cmStandardIncludes.h"
 #include "cmXMLSafe.h"
-#include <sstream>
 
 //----------------------------------------------------------------------------
 void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry,
-                                                const char*) const
+                                                const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates CodeLite project files.";
@@ -60,7 +60,7 @@
 
   // loop projects and locate the root project.
   // and extract the information for creating the worspace
-  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+  for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
        it = this->GlobalGenerator->GetProjectMap().begin();
        it!= this->GlobalGenerator->GetProjectMap().end();
        ++it)
@@ -85,7 +85,7 @@
     }
 
   // for each sub project in the workspace create a codelite project
-  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+  for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
        it = this->GlobalGenerator->GetProjectMap().begin();
        it!= this->GlobalGenerator->GetProjectMap().end();
        ++it)
@@ -214,20 +214,23 @@
         case cmTarget::MODULE_LIBRARY:
           {
           std::vector<cmSourceFile*> sources;
-          ti->second.GetSourceFiles(sources);
+          ti->second.GetSourceFiles(sources,
+                            makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
           for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
                si!=sources.end(); si++)
             {
             // check whether it is a C/C++ implementation file
             bool isCFile = false;
-            if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C'))
+            std::string lang = (*si)->GetLanguage();
+            if (lang == "C" || lang == "CXX")
               {
+              std::string srcext = (*si)->GetExtension();
               for(std::vector<std::string>::const_iterator
                   ext = mf->GetSourceExtensions().begin();
                   ext !=  mf->GetSourceExtensions().end();
                   ++ext)
                 {
-                if ((*si)->GetExtension() == *ext)
+                if (srcext == *ext)
                   {
                   isCFile = true;
                   break;
@@ -309,7 +312,7 @@
     {
     std::string relativePath =
       cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str());
-    fout<< "    <File Name=\"" << relativePath.c_str() << "\"/>\n";
+    fout<< "    <File Name=\"" << relativePath << "\"/>\n";
     }
   fout<< "  </VirtualDirectory>\n";
   fout<< "  <VirtualDirectory Name=\"include\">\n";
@@ -320,7 +323,7 @@
     {
     std::string relativePath =
       cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str());
-    fout << "    <File Name=\"" << relativePath.c_str() << "\"/>\n";
+    fout << "    <File Name=\"" << relativePath << "\"/>\n";
     }
   fout << "  </VirtualDirectory>\n";
 
@@ -402,7 +405,7 @@
     compilerIdVar = "CMAKE_C_COMPILER_ID";
     }
 
-  std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str());
+  std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
   std::string compiler = "gnu g++"; // default to g++
 
   // Since we need the compiler for parsing purposes only
@@ -440,26 +443,22 @@
 std::string
 cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const
 {
-  std::stringstream ss;
   std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
   std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   std::string buildCommand = make; // Default
-  if ( generator == "NMake Makefiles" )
+  if ( generator == "NMake Makefiles" ||
+       generator == "Ninja" )
     {
     buildCommand = make;
     }
   else if ( generator == "MinGW Makefiles" ||
             generator == "Unix Makefiles" )
     {
+    cmOStringStream ss;
     ss << make << " -j " << this->CpuCount;
     buildCommand = ss.str();
     }
-  else if ( generator == "Ninja" )
-    {
-    ss << make;
-    buildCommand = ss.str();
-    }
-    return buildCommand;
+  return buildCommand;
 }
 
 std::string
@@ -483,7 +482,7 @@
   std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
   if ( generator == "Unix Makefiles" || generator == "MinGW Makefiles" )
     {
-    std::stringstream ss;
+    cmOStringStream ss;
     ss << make << " -f$(ProjectPath)/Makefile $(CurrentFileName).cpp.o";
     buildCommand = ss.str();
     }
diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h
index 984313e..6b4965d 100644
--- a/Source/cmExtraCodeLiteGenerator.h
+++ b/Source/cmExtraCodeLiteGenerator.h
@@ -35,14 +35,14 @@
 public:
   cmExtraCodeLiteGenerator();
 
-  virtual const char* GetName() const
+  virtual std::string GetName() const
                           { return cmExtraCodeLiteGenerator::GetActualName();}
-  static const char* GetActualName()                     { return "CodeLite";}
+  static std::string GetActualName()                     { return "CodeLite";}
   static cmExternalMakefileProjectGenerator* New()
                                       { return new cmExtraCodeLiteGenerator; }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
-                                const char* fullName) const;
+                                const std::string& fullName) const;
 
   virtual void Generate();
   void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 74ba9a6..e23551e 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -45,7 +45,7 @@
 
 //----------------------------------------------------------------------------
 void cmExtraEclipseCDT4Generator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates Eclipse CDT 4.0 project files.";
@@ -205,7 +205,7 @@
   std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_";
   cacheEntryName += envVar;
   const char* cacheValue = mf->GetCacheManager()->GetCacheValue(
-                                                       cacheEntryName.c_str());
+                                                       cacheEntryName);
 
   // now we have both, decide which one to use
   std::string valueToUse;
@@ -219,7 +219,7 @@
     // The variable is in the env, but not in the cache. Use it and put it
     // in the cache
     valueToUse = envVarValue;
-    mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(),
+    mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
                            cacheEntryName.c_str(), cmCacheManager::STRING,
                            true);
     mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory());
@@ -240,7 +240,7 @@
     if (valueToUse.find(envVarValue) == std::string::npos)
       {
       valueToUse = envVarValue;
-      mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(),
+      mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
                              cacheEntryName.c_str(), cmCacheManager::STRING,
                              true);
       mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory());
@@ -560,7 +560,8 @@
           // get the files from the source lists then add them to the groups
           cmTarget* tgt = const_cast<cmTarget*>(&ti->second);
           std::vector<cmSourceFile*> files;
-          tgt->GetSourceFiles(files);
+          tgt->GetSourceFiles(files,
+                            makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
           for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
               sfIt != files.end();
               sfIt++)
@@ -624,7 +625,7 @@
   this->AppendLinkedResource(fout, "[Subprojects]",
                              "virtual:/virtual", VirtualFolder);
 
-  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+  for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
        it = this->GlobalGenerator->GetProjectMap().begin();
        it != this->GlobalGenerator->GetProjectMap().end();
        ++it)
@@ -981,7 +982,7 @@
     std::string systemIncludeDirs = mf->GetSafeDefinition(
                                 "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
     std::vector<std::string> dirs;
-    cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+    cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
     this->AppendIncludeDirectories(fout, dirs, emmited);
     }
   compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
@@ -990,7 +991,7 @@
     std::string systemIncludeDirs = mf->GetSafeDefinition(
                               "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
     std::vector<std::string> dirs;
-    cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+    cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
     this->AppendIncludeDirectories(fout, dirs, emmited);
     }
 
@@ -1292,7 +1293,7 @@
   std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path);
   fout <<
     "<target name=\"" << prefix << targetXml << "\""
-    " path=\"" << pathXml.c_str() << "\""
+    " path=\"" << pathXml << "\""
     " targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n"
     "<buildCommand>"
     << cmExtraEclipseCDT4Generator::GetEclipsePath(make)
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index d88b247..ef99760 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -33,14 +33,14 @@
     return new cmExtraEclipseCDT4Generator;
   }
 
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmExtraEclipseCDT4Generator::GetActualName();
   }
 
-  static const char* GetActualName() { return "Eclipse CDT4"; }
+  static std::string GetActualName() { return "Eclipse CDT4"; }
 
   virtual void GetDocumentation(cmDocumentationEntry& entry,
-                                const char*           fullName) const;
+                                const std::string&    fullName) const;
   virtual void EnableLanguage(std::vector<std::string> const& languages,
                               cmMakefile *, bool optional);
 
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index a0d37d4..567542e 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -25,7 +25,7 @@
 
 //----------------------------------------------------------------------------
 void cmExtraKateGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates Kate project files.";
@@ -52,7 +52,7 @@
   this->ProjectName = this->GenerateProjectName(mf->GetProjectName(),
                           mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
                           this->GetPathBasename(mf->GetHomeOutputDirectory()));
-  this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0);
+  this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja");
 
   this->CreateKateProjectFile(mf);
   this->CreateDummyKateProjectFile(mf);
diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h
index 6ced5fe..f800feb 100644
--- a/Source/cmExtraKateGenerator.h
+++ b/Source/cmExtraKateGenerator.h
@@ -28,14 +28,14 @@
 public:
   cmExtraKateGenerator();
 
-  virtual const char* GetName() const
+  virtual std::string GetName() const
                          { return cmExtraKateGenerator::GetActualName();}
-  static const char* GetActualName()                    { return "Kate";}
+  static std::string GetActualName()                    { return "Kate";}
   static cmExternalMakefileProjectGenerator* New()
                                      { return new cmExtraKateGenerator; }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
-                                const char* fullName) const;
+                                const std::string& fullName) const;
 
   virtual void Generate();
 private:
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 604bfcc..5fff0fb 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -41,7 +41,7 @@
 
 //----------------------------------------------------------------------------
 void cmExtraSublimeTextGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates Sublime Text 2 project files.";
@@ -64,7 +64,7 @@
 void cmExtraSublimeTextGenerator::Generate()
 {
   // for each sub project in the project create a sublime text 2 project
-  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+  for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
        it = this->GlobalGenerator->GetProjectMap().begin();
       it!= this->GlobalGenerator->GetProjectMap().end();
       ++it)
@@ -177,7 +177,7 @@
           if (strcmp(makefile->GetStartOutputDirectory(),
                      makefile->GetHomeOutputDirectory())==0)
             {
-            this->AppendTarget(fout, ti->first.c_str(), *lg, 0,
+            this->AppendTarget(fout, ti->first, *lg, 0,
                                make.c_str(), makefile, compiler.c_str(),
                                sourceFileFlags, false);
             }
@@ -194,7 +194,7 @@
             break;
             }
 
-          this->AppendTarget(fout, ti->first.c_str(), *lg, 0,
+          this->AppendTarget(fout, ti->first, *lg, 0,
                              make.c_str(), makefile, compiler.c_str(),
                              sourceFileFlags, false);
           break;
@@ -204,12 +204,12 @@
         case cmTarget::MODULE_LIBRARY:
         case cmTarget::OBJECT_LIBRARY:
           {
-          this->AppendTarget(fout, ti->first.c_str(), *lg, &ti->second,
+          this->AppendTarget(fout, ti->first, *lg, &ti->second,
                              make.c_str(), makefile, compiler.c_str(),
                              sourceFileFlags, false);
           std::string fastTarget = ti->first;
           fastTarget += "/fast";
-          this->AppendTarget(fout, fastTarget.c_str(), *lg, &ti->second,
+          this->AppendTarget(fout, fastTarget, *lg, &ti->second,
                              make.c_str(), makefile, compiler.c_str(),
                              sourceFileFlags, false);
           }
@@ -223,7 +223,7 @@
 
 void cmExtraSublimeTextGenerator::
   AppendTarget(cmGeneratedFileStream& fout,
-               const char* targetName,
+               const std::string& targetName,
                cmLocalGenerator* lg,
                cmTarget* target,
                const char* make,
@@ -238,7 +238,8 @@
       cmGeneratorTarget *gtgt = this->GlobalGenerator
                                     ->GetGeneratorTarget(target);
       std::vector<cmSourceFile*> sourceFiles;
-      target->GetSourceFiles(sourceFiles);
+      target->GetSourceFiles(sourceFiles,
+                             makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
       std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
         sourceFiles.end();
       for (std::vector<cmSourceFile*>::const_iterator iter =
@@ -290,7 +291,7 @@
   // Ninja uses ninja.build files (look for a way to get the output file name
   // from cmMakefile or something)
   std::string makefileName;
-  if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
+  if (this->GlobalGenerator->GetName() == "Ninja")
     {
       makefileName = "build.ninja";
     }
@@ -315,11 +316,13 @@
 // Create the command line for building the given target using the selected
 // make
 std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
-             const std::string& make, const char* makefile, const char* target)
+             const std::string& make, const char* makefile,
+             const std::string& target)
 {
   std::string command = "\"";
   command += make + "\"";
-  if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
+  std::string generator = this->GlobalGenerator->GetName();
+  if (generator == "NMake Makefiles")
     {
     std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
     command += ", \"/NOLOGO\", \"/f\", \"";
@@ -328,7 +331,7 @@
     command += target;
     command += "\"";
     }
-  else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
+  else if (generator == "Ninja")
     {
     std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
     command += ", \"-f\", \"";
@@ -340,7 +343,7 @@
   else
     {
     std::string makefileName;
-    if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
+    if (generator == "MinGW Makefiles")
       {
         // no escaping of spaces in this case, see
         // http://public.kitware.com/Bug/view.php?id=10014
@@ -369,12 +372,12 @@
   std::string flags;
 
   cmMakefile *makefile = lg->GetMakefile();
-  const char* language = source->GetLanguage();
-  if (language == NULL)
+  std::string language = source->GetLanguage();
+  if (language.empty())
    {
    language = "C";
    }
-  const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+  const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
   // Add language-specific flags.
   lg->AddLanguageFlags(flags, language, config);
 
@@ -396,7 +399,7 @@
   lg->GetIncludeDirectories(includes, gtgt, language, config);
   std::string includeFlags =
     lg->GetIncludeFlags(includes, gtgt, language, true); // full include paths
-  lg->AppendFlags(flags, includeFlags.c_str());
+  lg->AppendFlags(flags, includeFlags);
   }
 
   // Append old-style preprocessor definition flags.
@@ -423,12 +426,8 @@
 {
   std::set<std::string> defines;
   cmMakefile *makefile = lg->GetMakefile();
-  const char* language = source->GetLanguage();
-  if (language == NULL)
-   {
-   language = "";
-   }
-  const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+  const std::string& language = source->GetLanguage();
+  const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
 
   // Add the export symbol definition for shared library objects.
   if(const char* exportMacro = target->GetExportMacro())
@@ -442,7 +441,7 @@
   {
   std::string defPropName = "COMPILE_DEFINITIONS_";
   defPropName += cmSystemTools::UpperCase(config);
-  lg->AppendDefines(defines, source->GetProperty(defPropName.c_str()));
+  lg->AppendDefines(defines, source->GetProperty(defPropName));
   }
 
   std::string definesString;
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 7902593..4173b7d 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -31,15 +31,15 @@
   typedef std::map<std::string, std::vector<std::string> > MapSourceFileFlags;
   cmExtraSublimeTextGenerator();
 
-  virtual const char* GetName() const
+  virtual std::string GetName() const
                         { return cmExtraSublimeTextGenerator::GetActualName();}
-  static const char* GetActualName()
+  static std::string GetActualName()
                         { return "Sublime Text 2";}
   static cmExternalMakefileProjectGenerator* New()
                                     { return new cmExtraSublimeTextGenerator; }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
-                                const char* fullName) const;
+                                const std::string& fullName) const;
 
   virtual void Generate();
 private:
@@ -60,12 +60,12 @@
    *  specified target.
    */
   std::string BuildMakeCommand(const std::string& make, const char* makefile,
-                               const char* target);
+                               const std::string& target);
   /** Appends the specified target to the generated project file as a Sublime
    *  Text build system.
    */
   void AppendTarget(cmGeneratedFileStream& fout,
-                    const char* targetName,
+                    const std::string& targetName,
                     cmLocalGenerator* lg,
                     cmTarget* target,
                     const char* make,
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index 4dd81be..f7d8243 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -48,7 +48,7 @@
   for(std::vector<std::string>::iterator i = (newArgs.begin() + 1);
       i != newArgs.end(); i++)
     {
-    cmSourceFile *curr = this->Makefile->GetSource(i->c_str());
+    cmSourceFile *curr = this->Makefile->GetSource(*i);
     // if we should use the source GUI
     // to generate .cxx and .h files
     if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
@@ -78,19 +78,19 @@
       commandLines.push_back(commandLine);
 
       // Add command for generating the .h and .cxx files
-      const char* no_main_dependency = 0;
+      std::string no_main_dependency = "";
       const char* no_comment = 0;
       const char* no_working_dir = 0;
-      this->Makefile->AddCustomCommandToOutput(cxxres.c_str(),
+      this->Makefile->AddCustomCommandToOutput(cxxres,
                                            depends, no_main_dependency,
                                            commandLines, no_comment,
                                            no_working_dir);
-      this->Makefile->AddCustomCommandToOutput(hname.c_str(),
+      this->Makefile->AddCustomCommandToOutput(hname,
                                            depends, no_main_dependency,
                                            commandLines, no_comment,
                                            no_working_dir);
 
-      cmSourceFile *sf = this->Makefile->GetSource(cxxres.c_str());
+      cmSourceFile *sf = this->Makefile->GetSource(cxxres);
       sf->AddDepend(hname.c_str());
       sf->AddDepend(origname.c_str());
       this->GeneratedSourcesClasses.push_back(sf);
@@ -110,7 +110,7 @@
     }
   std::string varName = this->Target;
   varName += "_FLTK_UI_SRCS";
-  this->Makefile->AddDefinition(varName.c_str(), sourceListValue.c_str());
+  this->Makefile->AddDefinition(varName, sourceListValue.c_str());
 
   return true;
 }
@@ -133,7 +133,7 @@
     return;
     }
   std::vector<cmSourceFile*> srcs;
-  target->GetSourceFiles(srcs);
+  target->GetSourceFiles(srcs, "");
   bool found = false;
   for (unsigned int i = 0; i < srcs.size(); ++i)
     {
@@ -168,7 +168,7 @@
     for(size_t classNum = 0; classNum < lastHeadersClass; classNum++)
       {
       this->Makefile->GetTargets()[this->Target]
-        .AddSourceFile(this->GeneratedSourcesClasses[classNum]);
+        .AddSource(this->GeneratedSourcesClasses[classNum]->GetFullPath());
       }
     }
 }
diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h
index b94390c..617fcd9 100644
--- a/Source/cmFLTKWrapUICommand.h
+++ b/Source/cmFLTKWrapUICommand.h
@@ -52,7 +52,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "fltk_wrap_ui";}
+  virtual std::string GetName() const { return "fltk_wrap_ui";}
 
 private:
   /**
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index e79bc6c..655f3ba 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -174,7 +174,7 @@
     }
 
   std::string e = "does not recognize sub-command "+subCommand;
-  this->SetError(e.c_str());
+  this->SetError(e);
   return false;
 }
 
@@ -205,7 +205,7 @@
     std::string e
       = "attempted to write a file: " + fileName +
       " into a source directory.";
-    this->SetError(e.c_str());
+    this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
     }
@@ -232,10 +232,11 @@
   cmsys::ofstream file(fileName.c_str(), append?std::ios::app: std::ios::out);
   if ( !file )
     {
-    std::string error = "Internal CMake error when trying to open file: ";
-    error += fileName.c_str();
-    error += " for writing.";
-    this->SetError(error.c_str());
+    std::string error = "failed to open for writing (";
+    error += cmSystemTools::GetLastSystemError();
+    error += "):\n  ";
+    error += fileName;
+    this->SetError(error);
     return false;
     }
   file << message;
@@ -292,10 +293,11 @@
 
   if ( !file )
     {
-    std::string error = "Internal CMake error when trying to open file: ";
-    error += fileName.c_str();
-    error += " for reading.";
-    this->SetError(error.c_str());
+    std::string error = "failed to open for reading (";
+    error += cmSystemTools::GetLastSystemError();
+    error += "):\n  ";
+    error += fileName;
+    this->SetError(error);
     return false;
     }
 
@@ -359,7 +361,7 @@
         }
       }
     }
-  this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+  this->Makefile->AddDefinition(variable, output.c_str());
   return true;
 }
 
@@ -371,23 +373,23 @@
     {
     cmOStringStream e;
     e << args[0] << " requires a file name and output variable";
-    this->SetError(e.str().c_str());
+    this->SetError(e.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());
+    std::string out = hash->HashFile(args[1]);
     if(!out.empty())
       {
-      this->Makefile->AddDefinition(args[2].c_str(), out.c_str());
+      this->Makefile->AddDefinition(args[2], out.c_str());
       return true;
       }
     cmOStringStream e;
     e << args[0] << " failed to read file \"" << args[1] << "\": "
       << cmSystemTools::GetLastSystemError();
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     }
   return false;
 #else
@@ -481,7 +483,7 @@
         cmOStringStream e;
         e << "STRINGS option LIMIT_INPUT value \""
           << args[i] << "\" is not an unsigned integer.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       arg_mode = arg_none;
@@ -494,7 +496,7 @@
         cmOStringStream e;
         e << "STRINGS option LIMIT_OUTPUT value \""
           << args[i] << "\" is not an unsigned integer.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       arg_mode = arg_none;
@@ -507,7 +509,7 @@
         cmOStringStream e;
         e << "STRINGS option LIMIT_COUNT value \""
           << args[i] << "\" is not an unsigned integer.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       limit_count = count;
@@ -521,7 +523,7 @@
         cmOStringStream e;
         e << "STRINGS option LENGTH_MINIMUM value \""
           << args[i] << "\" is not an unsigned integer.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       minlen = len;
@@ -535,7 +537,7 @@
         cmOStringStream e;
         e << "STRINGS option LENGTH_MAXIMUM value \""
           << args[i] << "\" is not an unsigned integer.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       maxlen = len;
@@ -548,7 +550,7 @@
         cmOStringStream e;
         e << "STRINGS option REGEX value \""
           << args[i] << "\" could not be compiled.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       have_regex = true;
@@ -559,7 +561,7 @@
       cmOStringStream e;
       e << "STRINGS given unknown argument \""
         << args[i] << "\"";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -586,7 +588,7 @@
     {
     cmOStringStream e;
     e << "STRINGS file \"" << fileName << "\" cannot be read.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -709,7 +711,7 @@
     }
 
   // Save the output in a makefile variable.
-  this->Makefile->AddDefinition(outVar.c_str(), output.c_str());
+  this->Makefile->AddDefinition(outVar, output.c_str());
   return true;
 }
 
@@ -844,7 +846,7 @@
       }
     }
 
-  this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+  this->Makefile->AddDefinition(variable, output.c_str());
   return true;
 }
 
@@ -873,14 +875,14 @@
       {
       std::string e = "attempted to create a directory: " + *cdir
         + " into a source directory.";
-      this->SetError(e.c_str());
+      this->SetError(e);
       cmSystemTools::SetFatalErrorOccured();
       return false;
       }
     if ( !cmSystemTools::MakeDirectory(cdir->c_str()) )
       {
       std::string error = "problem creating directory: " + *cdir;
-      this->SetError(error.c_str());
+      this->SetError(error);
       return false;
       }
     }
@@ -926,7 +928,7 @@
       {
       cmOStringStream e;
       e << "DIFFERENT given unknown argument " << args[i];
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -1041,7 +1043,7 @@
       {
       cmOStringStream e;
       e << this->Name << " cannot set permissions on \"" << toFile << "\"";
-      this->FileCommand->SetError(e.str().c_str());
+      this->FileCommand->SetError(e.str());
       return false;
       }
     return true;
@@ -1065,7 +1067,7 @@
       {
       cmOStringStream e;
       e << this->Name << " given invalid permission \"" << arg << "\".";
-      this->FileCommand->SetError(e.str().c_str());
+      this->FileCommand->SetError(e.str());
       return false;
       }
     return true;
@@ -1092,7 +1094,7 @@
     // The input file does not exist and installation is not optional.
     cmOStringStream e;
     e << this->Name << " cannot find \"" << fromFile << "\".";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     return false;
     }
 
@@ -1125,14 +1127,14 @@
     {
     cmOStringStream e;
     e << "option " << arg << " may not appear before PATTERN or REGEX.";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     this->Doing = DoingError;
     }
   void NotAfterMatch(std::string const& arg)
     {
     cmOStringStream e;
     e << "option " << arg << " may not appear after PATTERN or REGEX.";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     this->Doing = DoingError;
     }
   virtual void DefaultFilePermissions()
@@ -1170,7 +1172,7 @@
       {
       cmOStringStream e;
       e << "called with unknown argument \"" << args[i] << "\".";
-      this->FileCommand->SetError(e.str().c_str());
+      this->FileCommand->SetError(e.str());
       return false;
       }
 
@@ -1186,7 +1188,7 @@
     {
     cmOStringStream e;
     e << this->Name << " given no DESTINATION";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     return false;
     }
 
@@ -1366,7 +1368,7 @@
         {
         cmOStringStream e;
         e << "could not compile PATTERN \"" << arg << "\".";
-        this->FileCommand->SetError(e.str().c_str());
+        this->FileCommand->SetError(e.str());
         this->Doing = DoingError;
         }
       }
@@ -1382,7 +1384,7 @@
         {
         cmOStringStream e;
         e << "could not compile REGEX \"" << arg << "\".";
-        this->FileCommand->SetError(e.str().c_str());
+        this->FileCommand->SetError(e.str());
         this->Doing = DoingError;
         }
       break;
@@ -1462,7 +1464,7 @@
     {
     cmOStringStream e;
     e << "INSTALL encountered an empty string input file name.";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     return false;
     }
 
@@ -1504,7 +1506,7 @@
     cmOStringStream e;
     e << this->Name << " cannot read symlink \"" << fromFile
       << "\" to duplicate at \"" << toFile << "\".";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     return false;
     }
 
@@ -1537,7 +1539,7 @@
       cmOStringStream e;
       e << this->Name <<  " cannot duplicate symlink \"" << fromFile
         << "\" at \"" << toFile << "\".";
-      this->FileCommand->SetError(e.str().c_str());
+      this->FileCommand->SetError(e.str());
       return false;
       }
     }
@@ -1569,7 +1571,7 @@
     cmOStringStream e;
     e << this->Name << " cannot copy file \"" << fromFile
       << "\" to \"" << toFile << "\".";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     return false;
     }
 
@@ -1588,7 +1590,7 @@
       cmOStringStream e;
       e << this->Name << " cannot set modification time on \""
         << toFile << "\"";
-      this->FileCommand->SetError(e.str().c_str());
+      this->FileCommand->SetError(e.str());
       return false;
       }
     }
@@ -1619,7 +1621,7 @@
     cmOStringStream e;
     e << this->Name << " cannot make directory \"" << destination << "\": "
       << cmSystemTools::GetLastSystemError();
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     return false;
     }
 
@@ -1910,7 +1912,7 @@
     e << "INSTALL called with old-style " << arg << " argument.  "
       << "This script was generated with an older version of CMake.  "
       << "Re-run this cmake version on your build tree.";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     this->Doing = DoingError;
     }
   else
@@ -1976,7 +1978,7 @@
     {
     cmOStringStream e;
     e << "Option TYPE given unknown value \"" << stype << "\".";
-    this->FileCommand->SetError(e.str().c_str());
+    this->FileCommand->SetError(e.str());
     return false;
     }
   return true;
@@ -2047,7 +2049,7 @@
           "absolute path or remove DESTDIR environment variable."
           "\nDESTINATION=\n";
         message += destination;
-        this->FileCommand->SetError(message.c_str());
+        this->FileCommand->SetError(message);
         return false;
         }
       }
@@ -2061,7 +2063,7 @@
       {
       std::string errstring = "cannot create directory: " + destination +
           ". Maybe need administrative privileges.";
-      this->FileCommand->SetError(errstring.c_str());
+      this->FileCommand->SetError(errstring);
       return false;
       }
     }
@@ -2069,7 +2071,7 @@
     {
     std::string errstring = "INSTALL destination: " + destination +
         " is not a directory.";
-    this->FileCommand->SetError(errstring.c_str());
+    this->FileCommand->SetError(errstring);
     return false;
     }
   return true;
@@ -2118,7 +2120,7 @@
       {
       cmOStringStream e;
       e << "RPATH_CHANGE given unknown argument " << args[i];
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -2141,7 +2143,7 @@
     {
     cmOStringStream e;
     e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
   bool success = true;
@@ -2157,7 +2159,7 @@
       << "to the file:\n"
       << "  " << file << "\n"
       << emsg;
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     success = false;
     }
   if(success)
@@ -2203,7 +2205,7 @@
       {
       cmOStringStream e;
       e << "RPATH_REMOVE given unknown argument " << args[i];
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -2216,7 +2218,7 @@
     {
     cmOStringStream e;
     e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
   bool success = true;
@@ -2230,7 +2232,7 @@
     e << "RPATH_REMOVE could not remove RPATH from file:\n"
       << "  " << file << "\n"
       << emsg;
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     success = false;
     }
   if(success)
@@ -2284,7 +2286,7 @@
       {
       cmOStringStream e;
       e << "RPATH_CHECK given unknown argument " << args[i];
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -2337,7 +2339,7 @@
     std::string errstring =
       "RELATIVE_PATH must be passed a full path to the directory: "
       + directoryName;
-    this->SetError(errstring.c_str());
+    this->SetError(errstring);
     return false;
     }
   if(!cmSystemTools::FileIsFullPath(fileName.c_str()))
@@ -2345,13 +2347,13 @@
     std::string errstring =
       "RELATIVE_PATH must be passed a full path to the file: "
       + fileName;
-    this->SetError(errstring.c_str());
+    this->SetError(errstring);
     return false;
     }
 
   std::string res = cmSystemTools::RelativePath(directoryName.c_str(),
                                                 fileName.c_str());
-  this->Makefile->AddDefinition(outVar.c_str(),
+  this->Makefile->AddDefinition(outVar,
     res.c_str());
   return true;
 }
@@ -2389,7 +2391,7 @@
       << "to\n"
       << "  " << newname << "\n"
       << "because: " << err << "\n";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
   return true;
@@ -2539,6 +2541,11 @@
       if (total > 0.0)
         {
         this->CurrentPercentage = static_cast<int>(value/total*100.0 + 0.5);
+        if(this->CurrentPercentage > 100)
+          {
+          // Avoid extra progress reports for unexpected data beyond total.
+          this->CurrentPercentage = 100;
+          }
         }
 
       bool updated = (OldPercentage != this->CurrentPercentage);
@@ -2649,7 +2656,7 @@
     {                                     \
     std::string e(errstr);                \
     e += ::curl_easy_strerror(result);    \
-    this->SetError(e.c_str());            \
+    this->SetError(e);            \
     return false;                         \
     }
 
@@ -2785,7 +2792,7 @@
         std::string err =
           "DOWNLOAD EXPECTED_HASH expects ALGO=value but got: ";
         err += *i;
-        this->SetError(err.c_str());
+        this->SetError(err);
         return false;
         }
       std::string algo = i->substr(0, pos);
@@ -2795,7 +2802,7 @@
         {
         std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
         err += algo;
-        this->SetError(err.c_str());
+        this->SetError(err);
         return false;
         }
       hashMatchMSG = algo + " hash";
@@ -2809,7 +2816,7 @@
   if(cmSystemTools::FileExists(file.c_str()) && hash.get())
     {
     std::string msg;
-    std::string actualHash = hash->HashFile(file.c_str());
+    std::string actualHash = hash->HashFile(file);
     if(actualHash == expectedHash)
       {
       msg = "returning early; file already exists with expected ";
@@ -2819,7 +2826,7 @@
         {
         cmOStringStream result;
         result << (int)0 << ";\"" << msg;
-        this->Makefile->AddDefinition(statusVar.c_str(),
+        this->Makefile->AddDefinition(statusVar,
                                       result.str().c_str());
         }
       return true;
@@ -2828,14 +2835,14 @@
   // Make sure parent directory exists so we can write to the file
   // as we receive downloaded bits from curl...
   //
-  std::string dir = cmSystemTools::GetFilenamePath(file.c_str());
+  std::string dir = cmSystemTools::GetFilenamePath(file);
   if(!cmSystemTools::FileExists(dir.c_str()) &&
      !cmSystemTools::MakeDirectory(dir.c_str()))
     {
     std::string errstring = "DOWNLOAD error: cannot create directory '"
       + dir + "' - Specify file by full path name and verify that you "
       "have directory creation and file write privileges.";
-    this->SetError(errstring.c_str());
+    this->SetError(errstring);
     return false;
     }
 
@@ -2954,7 +2961,7 @@
     {
     cmOStringStream result;
     result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
-    this->Makefile->AddDefinition(statusVar.c_str(),
+    this->Makefile->AddDefinition(statusVar,
                                   result.str().c_str());
     }
 
@@ -2969,7 +2976,7 @@
   //
   if (hash.get())
     {
-    std::string actualHash = hash->HashFile(file.c_str());
+    std::string actualHash = hash->HashFile(file);
     if (actualHash.size() == 0)
       {
       this->SetError("DOWNLOAD cannot compute hash on downloaded file");
@@ -2986,7 +2993,7 @@
         << "           status: [" << (int)res << ";\""
           << ::curl_easy_strerror(res) << "\"]" << std::endl
         ;
-      this->SetError(oss.str().c_str());
+      this->SetError(oss.str());
       return false;
       }
     }
@@ -3000,12 +3007,12 @@
 
       if(verboseLog.size())
         {
-        this->Makefile->AddDefinition(verboseLog.c_str(),
+        this->Makefile->AddDefinition(verboseLog,
                                       &*chunkDebug.begin());
         }
       }
 
-    this->Makefile->AddDefinition(verboseLog.c_str(),
+    this->Makefile->AddDefinition(verboseLog,
                                   &*chunkDebug.begin());
     }
 
@@ -3102,7 +3109,7 @@
     {
     std::string errStr = "UPLOAD cannot open file '";
     errStr += filename + "' for reading.";
-    this->SetError(errStr.c_str());
+    this->SetError(errStr);
     return false;
     }
 
@@ -3111,7 +3118,7 @@
     {
     std::string errStr = "UPLOAD cannot stat file '";
     errStr += filename + "'.";
-    this->SetError(errStr.c_str());
+    this->SetError(errStr);
     fclose(fin);
     return false;
     }
@@ -3217,7 +3224,7 @@
     {
     cmOStringStream result;
     result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
-    this->Makefile->AddDefinition(statusVar.c_str(),
+    this->Makefile->AddDefinition(statusVar,
                                   result.str().c_str());
     }
 
@@ -3246,7 +3253,7 @@
       log += "\n";
       }
 
-    this->Makefile->AddDefinition(logVar.c_str(), log.c_str());
+    this->Makefile->AddDefinition(logVar, log.c_str());
     }
 
   return true;
@@ -3263,14 +3270,13 @@
                                       bool inputIsContent
                                      )
 {
-  cmListFileBacktrace lfbt;
-  this->Makefile->GetBacktrace(lfbt);
+  cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
 
-  cmGeneratorExpression outputGe(lfbt);
+  cmGeneratorExpression outputGe(&lfbt);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge
                                                 = outputGe.Parse(outputExpr);
 
-  cmGeneratorExpression conditionGe(lfbt);
+  cmGeneratorExpression conditionGe(&lfbt);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> conditionCge
                                               = conditionGe.Parse(condition);
 
@@ -3368,7 +3374,7 @@
       {
       std::string e = " TIMESTAMP sub-command does not recognize option " +
           args[argsIndex] + ".";
-      this->SetError(e.c_str());
+      this->SetError(e);
       return false;
       }
     }
@@ -3376,7 +3382,7 @@
   cmTimestamp timestamp;
   std::string result = timestamp.FileModificationTime(
     filename.c_str(), formatString, utcFlag);
-  this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str());
+  this->Makefile->AddDefinition(outputVariable, result.c_str());
 
   return true;
 }
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index ba45815..8d66fdf 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -46,7 +46,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "file";}
+  virtual std::string GetName() const { return "file";}
 
   cmTypeMacro(cmFileCommand, cmCommand);
 
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 02f10c0..5727470 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -43,13 +43,13 @@
   class HashString
     {
   public:
-    size_t operator()(const cmStdString& s) const
+    size_t operator()(const std::string& s) const
       {
       return h(s.c_str());
       }
     cmsys::hash<const char*> h;
     };
-  typedef cmsys::hash_map<cmStdString,
+  typedef cmsys::hash_map<std::string,
                           cmFileTimeComparison_Type, HashString> FileStatsMap;
   FileStatsMap Files;
 #endif
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index ae15ee7..e4e819a 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -237,7 +237,7 @@
   for(std::vector<std::string>::const_iterator it = in_paths.begin();
       it != in_paths.end(); ++it)
     {
-    std::string dir = it->c_str();
+    std::string dir = *it;
     if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/')
       {
       dir += "/";
@@ -268,7 +268,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmFindBase::AddCMakePrefixPath(const char* variable)
+void cmFindBase::AddCMakePrefixPath(const std::string& variable)
 {
   // Get a path from a CMake variable.
   if(const char* varPath = this->Makefile->GetDefinition(variable))
@@ -280,11 +280,11 @@
 }
 
 //----------------------------------------------------------------------------
-void cmFindBase::AddEnvPrefixPath(const char* variable)
+void cmFindBase::AddEnvPrefixPath(const std::string& variable)
 {
   // Get a path from the environment.
   std::vector<std::string> tmp;
-  cmSystemTools::GetPath(tmp, variable);
+  cmSystemTools::GetPath(tmp, variable.c_str());
   this->AddPrefixPaths(tmp, EnvPath);
 }
 
@@ -323,7 +323,7 @@
     var += this->CMakePathName;
     var += "_PATH";
     this->AddCMakePrefixPath("CMAKE_PREFIX_PATH");
-    this->AddCMakePath(var.c_str());
+    this->AddCMakePath(var);
 
     if(this->CMakePathName == "PROGRAM")
       {
@@ -360,7 +360,7 @@
     var += this->CMakePathName;
     var += "_PATH";
     this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
-    this->AddCMakePath(var.c_str());
+    this->AddCMakePath(var);
 
     if(this->CMakePathName == "PROGRAM")
       {
@@ -466,7 +466,7 @@
 bool cmFindBase::CheckForVariableInCache()
 {
   if(const char* cacheValue =
-     this->Makefile->GetDefinition(this->VariableName.c_str()))
+     this->Makefile->GetDefinition(this->VariableName))
     {
     cmCacheManager::CacheIterator it =
       this->Makefile->GetCacheManager()->
diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h
index 0562b1b..42d9bc1 100644
--- a/Source/cmFindBase.h
+++ b/Source/cmFindBase.h
@@ -42,14 +42,14 @@
   bool CheckForVariableInCache();
 
   // use by command during find
-  cmStdString VariableDocumentation;
-  cmStdString VariableName;
+  std::string VariableDocumentation;
+  std::string VariableName;
   std::vector<std::string> Names;
   bool NamesPerDir;
   bool NamesPerDirAllowed;
 
   // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM
-  cmStdString EnvironmentPath; // LIB,INCLUDE
+  std::string EnvironmentPath; // LIB,INCLUDE
 
   bool AlreadyInCache;
   bool AlreadyInCacheWithoutMetaInfo;
@@ -63,8 +63,8 @@
   void AddUserGuessPath();
 
   // Helpers.
-  void AddCMakePrefixPath(const char* variable);
-  void AddEnvPrefixPath(const char* variable);
+  void AddCMakePrefixPath(const std::string& variable);
+  void AddEnvPrefixPath(const std::string& variable);
   void AddPrefixPaths(std::vector<std::string> const& in_paths,
                       PathType pathType);
 };
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index e8c8da3..10241f2 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -51,7 +51,7 @@
   std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_";
   findRootPathVar += this->CMakePathName;
   std::string rootPathMode =
-    this->Makefile->GetSafeDefinition(findRootPathVar.c_str());
+    this->Makefile->GetSafeDefinition(findRootPathVar);
   if (rootPathMode=="NEVER")
     {
     this->FindRootPathMode = RootPathModeNoRootPath;
@@ -361,7 +361,7 @@
   // Expand using the view of the target application.
   std::string expanded = p;
   cmSystemTools::ExpandRegistryValues(expanded, view);
-  cmSystemTools::GlobDirs(expanded.c_str(), paths);
+  cmSystemTools::GlobDirs(expanded, paths);
 
   // Executables can be either 32-bit or 64-bit, so expand using the
   // alternative view.
@@ -369,12 +369,12 @@
     {
     expanded = p;
     cmSystemTools::ExpandRegistryValues(expanded, other_view);
-    cmSystemTools::GlobDirs(expanded.c_str(), paths);
+    cmSystemTools::GlobDirs(expanded, paths);
     }
 }
 
 //----------------------------------------------------------------------------
-void cmFindCommon::AddCMakePath(const char* variable)
+void cmFindCommon::AddCMakePath(const std::string& variable)
 {
   // Get a path from a CMake variable.
   if(const char* varPath = this->Makefile->GetDefinition(variable))
@@ -433,7 +433,7 @@
   // Insert the path if has not already been emitted.
   if(this->SearchPathsEmitted.insert(fullPath).second)
     {
-    this->SearchPaths.push_back(fullPath.c_str());
+    this->SearchPaths.push_back(fullPath);
     }
 }
 
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 6109a9f..5a905cd 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -56,14 +56,14 @@
   /** Compute the current default bundle/framework search policy.  */
   void SelectDefaultMacMode();
 
-  cmStdString CMakePathName;
+  std::string CMakePathName;
   RootPathMode FindRootPathMode;
 
   bool CheckCommonArgument(std::string const& arg);
   void AddPathSuffix(std::string const& arg);
   void AddUserPath(std::string const& p,
                    std::vector<std::string>& paths);
-  void AddCMakePath(const char* variable);
+  void AddCMakePath(const std::string& variable);
   void AddEnvPath(const char* variable);
   void AddPathsInternal(std::vector<std::string> const& in_paths,
                         PathType pathType);
@@ -81,7 +81,7 @@
   std::vector<std::string> UserPaths;
   std::vector<std::string> UserHints;
   std::vector<std::string> SearchPaths;
-  std::set<cmStdString> SearchPathsEmitted;
+  std::set<std::string> SearchPathsEmitted;
 
   bool SearchFrameworkFirst;
   bool SearchFrameworkOnly;
diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h
index 3f0baa2..daf1d65 100644
--- a/Source/cmFindFileCommand.h
+++ b/Source/cmFindFileCommand.h
@@ -33,7 +33,7 @@
     {
     return new cmFindFileCommand;
     }
-  virtual const char* GetName() const { return "find_file";}
+  virtual std::string GetName() const { return "find_file";}
 
   cmTypeMacro(cmFindFileCommand, cmFindPathCommand);
 };
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index de52df7..fe5e45f 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -37,7 +37,7 @@
     // value.
     if(this->AlreadyInCacheWithoutMetaInfo)
       {
-      this->Makefile->AddCacheDefinition(this->VariableName.c_str(), "",
+      this->Makefile->AddCacheDefinition(this->VariableName, "",
                                          this->VariableDocumentation.c_str(),
                                          cmCacheManager::FILEPATH);
       }
@@ -69,14 +69,14 @@
   if(library != "")
     {
     // Save the value in the cache
-    this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
+    this->Makefile->AddCacheDefinition(this->VariableName,
                                        library.c_str(),
                                        this->VariableDocumentation.c_str(),
                                        cmCacheManager::FILEPATH);
     return true;
     }
   std::string notfound = this->VariableName + "-NOTFOUND";
-  this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
+  this->Makefile->AddCacheDefinition(this->VariableName,
                                      notfound.c_str(),
                                      this->VariableDocumentation.c_str(),
                                      cmCacheManager::FILEPATH);
@@ -368,8 +368,8 @@
   // Search for a file matching the library name regex.
   std::string dir = path;
   cmSystemTools::ConvertToUnixSlashes(dir);
-  std::set<cmStdString> const& files = this->GG->GetDirectoryContent(dir);
-  for(std::set<cmStdString>::const_iterator fi = files.begin();
+  std::set<std::string> const& files = this->GG->GetDirectoryContent(dir);
+  for(std::set<std::string>::const_iterator fi = files.begin();
       fi != files.end(); ++fi)
     {
     std::string const& origName = *fi;
diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h
index a9ec40e..e257174 100644
--- a/Source/cmFindLibraryCommand.h
+++ b/Source/cmFindLibraryCommand.h
@@ -49,7 +49,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "find_library";}
+  virtual std::string GetName() const {return "find_library";}
 
   cmTypeMacro(cmFindLibraryCommand, cmFindBase);
 
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 73eba51..55a61f5 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -90,6 +90,18 @@
     this->UseLib64Paths = true;
     }
 
+  // Check if User Package Registry should be disabled
+  if(this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY"))
+    {
+    this->NoUserRegistry = true;
+    }
+
+  // Check if System Package Registry should be disabled
+  if(this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY"))
+    {
+    this->NoSystemRegistry = true;
+    }
+
   // Find the current root path mode.
   this->SelectDefaultRootPathMode();
 
@@ -223,7 +235,7 @@
         }
 
       std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i];
-      this->AddFindDefinition(req_var.c_str(), isRequired);
+      this->AddFindDefinition(req_var, isRequired);
 
       // Append to the list of required components.
       components += components_sep;
@@ -255,7 +267,7 @@
         e << "given CONFIGS option followed by invalid file name \""
           << args[i] << "\".  The names given must be file names without "
           << "a path and with a \".cmake\" extension.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       this->Configs.push_back(args[i]);
@@ -268,8 +280,8 @@
     else
       {
       cmOStringStream e;
-      e << "called with invalid argument \"" << args[i].c_str() << "\"";
-      this->SetError(e.str().c_str());
+      e << "called with invalid argument \"" << args[i] << "\"";
+      this->SetError(e.str());
       return false;
       }
     }
@@ -286,7 +298,7 @@
       {
       e << "  " << doubledComponents[i] << "\n";
       }
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -309,7 +321,7 @@
       e << "  " << args[*si] << "\n";
       }
     e << "The options are incompatible.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -327,7 +339,7 @@
     // another find_package(<name>) call.
     std::string mod = this->Name;
     mod += "_FIND_MODULE";
-    if(this->Makefile->IsOn(mod.c_str()))
+    if(this->Makefile->IsOn(mod))
       {
       if(this->Version.empty())
         {
@@ -335,17 +347,17 @@
         // Requested version string.
         std::string ver = this->Name;
         ver += "_FIND_VERSION";
-        this->Version = this->Makefile->GetSafeDefinition(ver.c_str());
+        this->Version = this->Makefile->GetSafeDefinition(ver);
 
         // Whether an exact version is required.
         std::string exact = this->Name;
         exact += "_FIND_VERSION_EXACT";
-        this->VersionExact = this->Makefile->IsOn(exact.c_str());
+        this->VersionExact = this->Makefile->IsOn(exact);
         }
       if(components.empty())
         {
         std::string components_var = this->Name + "_FIND_COMPONENTS";
-        components = this->Makefile->GetSafeDefinition(components_var.c_str());
+        components = this->Makefile->GetSafeDefinition(components_var);
         }
       }
     }
@@ -373,7 +385,7 @@
 
   std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_";
   disableFindPackageVar += this->Name;
-  if(this->Makefile->IsOn(disableFindPackageVar.c_str()))
+  if(this->Makefile->IsOn(disableFindPackageVar))
     {
     if (this->Required)
       {
@@ -381,7 +393,7 @@
       e << "for module " << this->Name << " called with REQUIRED, but "
         << disableFindPackageVar
         << " is enabled. A REQUIRED package cannot be disabled.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
 
@@ -488,7 +500,7 @@
 
   // Store the list of components.
   std::string components_var = this->Name + "_FIND_COMPONENTS";
-  this->AddFindDefinition(components_var.c_str(), components.c_str());
+  this->AddFindDefinition(components_var, components.c_str());
 
   if(this->Quiet)
     {
@@ -496,7 +508,7 @@
     // quietly.
     std::string quietly = this->Name;
     quietly += "_FIND_QUIETLY";
-    this->AddFindDefinition(quietly.c_str(), "1");
+    this->AddFindDefinition(quietly, "1");
     }
 
   if(this->Required)
@@ -505,7 +517,7 @@
     // a fatal error if the package is not found.
     std::string req = this->Name;
     req += "_FIND_REQUIRED";
-    this->AddFindDefinition(req.c_str(), "1");
+    this->AddFindDefinition(req, "1");
     }
 
   if(!this->Version.empty())
@@ -514,28 +526,29 @@
     // package has been requested.
     std::string ver = this->Name;
     ver += "_FIND_VERSION";
-    this->AddFindDefinition(ver.c_str(), this->Version.c_str());
+    this->AddFindDefinition(ver, this->Version.c_str());
     char buf[64];
     sprintf(buf, "%u", this->VersionMajor);
-    this->AddFindDefinition((ver+"_MAJOR").c_str(), buf);
+    this->AddFindDefinition(ver+"_MAJOR", buf);
     sprintf(buf, "%u", this->VersionMinor);
-    this->AddFindDefinition((ver+"_MINOR").c_str(), buf);
+    this->AddFindDefinition(ver+"_MINOR", buf);
     sprintf(buf, "%u", this->VersionPatch);
-    this->AddFindDefinition((ver+"_PATCH").c_str(), buf);
+    this->AddFindDefinition(ver+"_PATCH", buf);
     sprintf(buf, "%u", this->VersionTweak);
-    this->AddFindDefinition((ver+"_TWEAK").c_str(), buf);
+    this->AddFindDefinition(ver+"_TWEAK", buf);
     sprintf(buf, "%u", this->VersionCount);
-    this->AddFindDefinition((ver+"_COUNT").c_str(), buf);
+    this->AddFindDefinition(ver+"_COUNT", buf);
 
     // Tell the module whether an exact version has been requested.
     std::string exact = this->Name;
     exact += "_FIND_VERSION_EXACT";
-    this->AddFindDefinition(exact.c_str(), this->VersionExact? "1":"0");
+    this->AddFindDefinition(exact, this->VersionExact? "1":"0");
    }
 }
 
 //----------------------------------------------------------------------------
-void cmFindPackageCommand::AddFindDefinition(const char* var, const char* val)
+void cmFindPackageCommand::AddFindDefinition(const std::string& var,
+                                             const char* val)
 {
   if(const char* old = this->Makefile->GetDefinition(var))
     {
@@ -552,17 +565,17 @@
 //----------------------------------------------------------------------------
 void cmFindPackageCommand::RestoreFindDefinitions()
 {
-  for(std::map<cmStdString, OriginalDef>::iterator
+  for(std::map<std::string, OriginalDef>::iterator
         i = this->OriginalDefs.begin(); i != this->OriginalDefs.end(); ++i)
     {
     OriginalDef const& od = i->second;
     if(od.exists)
       {
-      this->Makefile->AddDefinition(i->first.c_str(), od.value.c_str());
+      this->Makefile->AddDefinition(i->first, od.value.c_str());
       }
     else
       {
-      this->Makefile->RemoveDefinition(i->first.c_str());
+      this->Makefile->RemoveDefinition(i->first);
       }
     }
 }
@@ -581,9 +594,9 @@
     found = true;
     std::string var = this->Name;
     var += "_FIND_MODULE";
-    this->Makefile->AddDefinition(var.c_str(), "1");
+    this->Makefile->AddDefinition(var, "1");
     bool result = this->ReadListFile(mfile.c_str(), DoPolicyScope);
-    this->Makefile->RemoveDefinition(var.c_str());
+    this->Makefile->RemoveDefinition(var);
     return result;
     }
   return true;
@@ -601,7 +614,7 @@
   upperFound += "_FOUND";
 
   // Try to find the config file.
-  const char* def = this->Makefile->GetDefinition(this->Variable.c_str());
+  const char* def = this->Makefile->GetDefinition(this->Variable);
 
   // Try to load the config file if the directory is known
   bool fileFound = false;
@@ -626,14 +639,14 @@
         this->FileFound = file;
         fileFound = true;
         }
-      def = this->Makefile->GetDefinition(this->Variable.c_str());
+      def = this->Makefile->GetDefinition(this->Variable);
       }
 
     // Search for the config file if it is not already found.
     if(cmSystemTools::IsOff(def) || !fileFound)
       {
       fileFound = this->FindConfig();
-      def = this->Makefile->GetDefinition(this->Variable.c_str());
+      def = this->Makefile->GetDefinition(this->Variable);
       }
 
     // Sanity check.
@@ -658,16 +671,16 @@
 
   if(fileFound)
     {
-    if ((this->Makefile->IsDefinitionSet(foundVar.c_str()))
-      && (this->Makefile->IsOn(foundVar.c_str()) == false))
+    if ((this->Makefile->IsDefinitionSet(foundVar))
+      && (this->Makefile->IsOn(foundVar) == false))
       {
       // by removing Foo_FOUND here if it is FALSE, we don't really change
       // the situation for the Config file which is about to be included,
       // but we make it possible to detect later on whether the Config file
       // has set Foo_FOUND to FALSE itself:
-      this->Makefile->RemoveDefinition(foundVar.c_str());
+      this->Makefile->RemoveDefinition(foundVar);
       }
-    this->Makefile->RemoveDefinition(notFoundMessageVar.c_str());
+    this->Makefile->RemoveDefinition(notFoundMessageVar);
 
     // Set the version variables before loading the config file.
     // It may override them.
@@ -680,14 +693,14 @@
       found = true;
 
       // Check whether the Config file has set Foo_FOUND to FALSE:
-      if ((this->Makefile->IsDefinitionSet(foundVar.c_str()))
-           && (this->Makefile->IsOn(foundVar.c_str()) == false))
+      if ((this->Makefile->IsDefinitionSet(foundVar))
+           && (this->Makefile->IsOn(foundVar) == false))
         {
         // we get here if the Config file has set Foo_FOUND actively to FALSE
         found = false;
         configFileSetFOUNDFalse = true;
         notFoundMessage = this->Makefile->GetSafeDefinition(
-                                                   notFoundMessageVar.c_str());
+                                                   notFoundMessageVar);
         }
       }
     else
@@ -809,18 +822,18 @@
     }
 
   // Set a variable marking whether the package was found.
-  this->Makefile->AddDefinition(foundVar.c_str(), found? "1":"0");
+  this->Makefile->AddDefinition(foundVar, found? "1":"0");
 
   // Set a variable naming the configuration file that was found.
   std::string fileVar = this->Name;
   fileVar += "_CONFIG";
   if(found)
     {
-    this->Makefile->AddDefinition(fileVar.c_str(), this->FileFound.c_str());
+    this->Makefile->AddDefinition(fileVar, this->FileFound.c_str());
     }
   else
     {
-    this->Makefile->RemoveDefinition(fileVar.c_str());
+    this->Makefile->RemoveDefinition(fileVar);
     }
 
   std::string consideredConfigsVar = this->Name;
@@ -842,10 +855,10 @@
     sep = ";";
     }
 
-  this->Makefile->AddDefinition(consideredConfigsVar.c_str(),
+  this->Makefile->AddDefinition(consideredConfigsVar,
                                 consideredConfigFiles.c_str());
 
-  this->Makefile->AddDefinition(consideredVersionsVar.c_str(),
+  this->Makefile->AddDefinition(consideredVersionsVar,
                                 consideredVersions.c_str());
 
   return result;
@@ -905,7 +918,7 @@
   help += this->Name;
   help += ".";
   // We force the value since we do not get here if it was already set.
-  this->Makefile->AddCacheDefinition(this->Variable.c_str(),
+  this->Makefile->AddCacheDefinition(this->Variable,
                                      init.c_str(), help.c_str(),
                                      cmCacheManager::PATH, true);
   return found;
@@ -967,7 +980,7 @@
   std::string e = "Error reading CMake code from \"";
   e += f;
   e += "\".";
-  this->SetError(e.c_str());
+  this->SetError(e);
   return false;
 }
 
@@ -1047,14 +1060,14 @@
   std::string transitivePropName = "_CMAKE_";
   transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY";
   this->Makefile->GetCMakeInstance()
-                ->SetProperty(transitivePropName.c_str(), "False");
+                ->SetProperty(transitivePropName, "False");
   }
   std::string found = this->Name;
   found += "_FOUND";
   std::string upperFound = cmSystemTools::UpperCase(found);
 
-  const char* upperResult = this->Makefile->GetDefinition(upperFound.c_str());
-  const char* result = this->Makefile->GetDefinition(found.c_str());
+  const char* upperResult = this->Makefile->GetDefinition(upperFound);
+  const char* result = this->Makefile->GetDefinition(found);
   bool packageFound = ((cmSystemTools::IsOn(result))
                                         || (cmSystemTools::IsOn(upperResult)));
 
@@ -1065,7 +1078,7 @@
   std::string quietInfoPropName = "_CMAKE_";
   quietInfoPropName += this->Name;
   quietInfoPropName += "_QUIET";
-  this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName.c_str(),
+  this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName,
                                                this->Quiet ? "TRUE" : "FALSE");
 
   // set a global property to record the required version of this package
@@ -1079,7 +1092,7 @@
     versionInfo += " ";
     versionInfo += this->Version;
     }
-  this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName.c_str(),
+  this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName,
                                                   versionInfo.c_str());
   if (this->Required)
     {
@@ -1087,7 +1100,7 @@
     requiredInfoPropName += this->Name;
     requiredInfoPropName += "_TYPE";
     this->Makefile->GetCMakeInstance()->SetProperty(
-                                     requiredInfoPropName.c_str(), "REQUIRED");
+                                     requiredInfoPropName, "REQUIRED");
     }
 
 
@@ -1647,25 +1660,25 @@
   ver += "_VERSION";
   if(this->VersionFound.empty())
     {
-    this->Makefile->RemoveDefinition(ver.c_str());
+    this->Makefile->RemoveDefinition(ver);
     }
   else
     {
-    this->Makefile->AddDefinition(ver.c_str(), this->VersionFound.c_str());
+    this->Makefile->AddDefinition(ver, this->VersionFound.c_str());
     }
 
   // Store the version components.
   char buf[64];
   sprintf(buf, "%u", this->VersionFoundMajor);
-  this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
+  this->Makefile->AddDefinition(ver+"_MAJOR", buf);
   sprintf(buf, "%u", this->VersionFoundMinor);
-  this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
+  this->Makefile->AddDefinition(ver+"_MINOR", buf);
   sprintf(buf, "%u", this->VersionFoundPatch);
-  this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
+  this->Makefile->AddDefinition(ver+"_PATCH", buf);
   sprintf(buf, "%u", this->VersionFoundTweak);
-  this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf);
+  this->Makefile->AddDefinition(ver+"_TWEAK", buf);
   sprintf(buf, "%u", this->VersionFoundCount);
-  this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf);
+  this->Makefile->AddDefinition(ver+"_COUNT", buf);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 0d80e48..2249459 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -49,7 +49,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "find_package";}
+  virtual std::string GetName() const { return "find_package";}
 
   cmTypeMacro(cmFindPackageCommand, cmFindCommon);
 private:
@@ -57,7 +57,7 @@
   void AppendToFoundProperty(bool found);
   void SetModuleVariables(const std::string& components);
   bool FindModule(bool& found);
-  void AddFindDefinition(const char* var, const char* val);
+  void AddFindDefinition(const std::string& var, const char* val);
   void RestoreFindDefinitions();
   bool HandlePackageMode();
   bool FindConfig();
@@ -96,19 +96,19 @@
   friend class cmFindPackageFileList;
 
   struct OriginalDef { bool exists; std::string value; };
-  std::map<cmStdString, OriginalDef> OriginalDefs;
+  std::map<std::string, OriginalDef> OriginalDefs;
 
-  cmStdString Name;
-  cmStdString Variable;
-  cmStdString Version;
+  std::string Name;
+  std::string Variable;
+  std::string Version;
   unsigned int VersionMajor;
   unsigned int VersionMinor;
   unsigned int VersionPatch;
   unsigned int VersionTweak;
   unsigned int VersionCount;
   bool VersionExact;
-  cmStdString FileFound;
-  cmStdString VersionFound;
+  std::string FileFound;
+  std::string VersionFound;
   unsigned int VersionFoundMajor;
   unsigned int VersionFoundMinor;
   unsigned int VersionFoundPatch;
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index 8459995..5531cdf 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -38,7 +38,7 @@
     if(this->AlreadyInCacheWithoutMetaInfo)
       {
       this->Makefile->AddCacheDefinition(
-        this->VariableName.c_str(), "",
+        this->VariableName, "",
         this->VariableDocumentation.c_str(),
         (this->IncludeFileInPath ?
          cmCacheManager::FILEPATH :cmCacheManager::PATH)
@@ -51,14 +51,14 @@
   if(result.size() != 0)
     {
     this->Makefile->AddCacheDefinition
-      (this->VariableName.c_str(), result.c_str(),
+      (this->VariableName, result.c_str(),
        this->VariableDocumentation.c_str(),
        (this->IncludeFileInPath) ?
        cmCacheManager::FILEPATH :cmCacheManager::PATH);
     return true;
     }
   this->Makefile->AddCacheDefinition
-    (this->VariableName.c_str(),
+    (this->VariableName,
      (this->VariableName + "-NOTFOUND").c_str(),
      this->VariableDocumentation.c_str(),
      (this->IncludeFileInPath) ?
@@ -89,9 +89,9 @@
 cmFindPathCommand::FindHeaderInFramework(std::string const& file,
                                          std::string const& dir)
 {
-  cmStdString fileName = file;
-  cmStdString frameWorkName;
-  cmStdString::size_type pos = fileName.find("/");
+  std::string fileName = file;
+  std::string frameWorkName;
+  std::string::size_type pos = fileName.find("/");
   // if there is a / in the name try to find the header as a framework
   // For example bar/foo.h would look for:
   // bar.framework/Headers/foo.h
@@ -128,7 +128,7 @@
     }
   // if it is not found yet or not a framework header, then do a glob search
   // for all frameworks in the directory: dir/*.framework/Headers/<file>
-  cmStdString glob = dir;
+  std::string glob = dir;
   glob += "*.framework/Headers/";
   glob += file;
   cmsys::Glob globIt;
@@ -136,7 +136,7 @@
   std::vector<std::string> files = globIt.GetFiles();
   if(files.size())
     {
-    cmStdString fheader = cmSystemTools::CollapseFullPath(files[0].c_str());
+    std::string fheader = cmSystemTools::CollapseFullPath(files[0].c_str());
     if(this->IncludeFileInPath)
       {
       return fheader;
diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h
index 8df4540..a51da79 100644
--- a/Source/cmFindPathCommand.h
+++ b/Source/cmFindPathCommand.h
@@ -49,7 +49,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "find_path";}
+  virtual std::string GetName() const {return "find_path";}
 
   cmTypeMacro(cmFindPathCommand, cmFindBase);
   bool IncludeFileInPath;
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index bb27753..f6e37f6 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -35,7 +35,7 @@
     // value.
     if(this->AlreadyInCacheWithoutMetaInfo)
       {
-      this->Makefile->AddCacheDefinition(this->VariableName.c_str(), "",
+      this->Makefile->AddCacheDefinition(this->VariableName, "",
                                          this->VariableDocumentation.c_str(),
                                          cmCacheManager::FILEPATH);
       }
@@ -46,14 +46,14 @@
   if(result != "")
     {
     // Save the value in the cache
-    this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
+    this->Makefile->AddCacheDefinition(this->VariableName,
                                        result.c_str(),
                                        this->VariableDocumentation.c_str(),
                                        cmCacheManager::FILEPATH);
 
     return true;
     }
-  this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
+  this->Makefile->AddCacheDefinition(this->VariableName,
                                  (this->VariableName + "-NOTFOUND").c_str(),
                                  this->VariableDocumentation.c_str(),
                                  cmCacheManager::FILEPATH);
diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h
index 7f4811c..70f758f 100644
--- a/Source/cmFindProgramCommand.h
+++ b/Source/cmFindProgramCommand.h
@@ -48,7 +48,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "find_program";}
+  virtual std::string GetName() const { return "find_program";}
 
   cmTypeMacro(cmFindProgramCommand, cmFindBase);
 
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index d697067..e3f66c1 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -35,9 +35,9 @@
       // at end of for each execute recorded commands
       // store the old value
       std::string oldDef;
-      if (mf.GetDefinition(this->Args[0].c_str()))
+      if (mf.GetDefinition(this->Args[0]))
         {
-        oldDef = mf.GetDefinition(this->Args[0].c_str());
+        oldDef = mf.GetDefinition(this->Args[0]);
         }
       std::vector<std::string>::const_iterator j = this->Args.begin();
       ++j;
@@ -47,7 +47,7 @@
       for( ; j != this->Args.end(); ++j)
         {
         // set the variable to the loop value
-        mf.AddDefinition(this->Args[0].c_str(),j->c_str());
+        mf.AddDefinition(this->Args[0],j->c_str());
         // Invoke all the functions that were collected in the block.
         cmExecutionStatus status;
         for(unsigned int c = 0; c < this->Functions.size(); ++c)
@@ -58,13 +58,13 @@
             {
             inStatus.SetReturnInvoked(true);
             // restore the variable to its prior value
-            mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
+            mf.AddDefinition(this->Args[0],oldDef.c_str());
             return true;
             }
           if (status.GetBreakInvoked())
             {
             // restore the variable to its prior value
-            mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
+            mf.AddDefinition(this->Args[0],oldDef.c_str());
             return true;
             }
           if(cmSystemTools::GetFatalErrorOccured() )
@@ -74,7 +74,7 @@
           }
         }
       // restore the variable to its prior value
-      mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
+      mf.AddDefinition(this->Args[0],oldDef.c_str());
       return true;
       }
     else
@@ -166,7 +166,7 @@
         cmOStringStream str;
         str << "called with incorrect range specification: start ";
         str << start << ", stop " << stop << ", step " << step;
-        this->SetError(str.str().c_str());
+        this->SetError(str.str());
         return false;
         }
       std::vector<std::string> range;
@@ -226,7 +226,7 @@
       }
     else if(doing == DoingLists)
       {
-      const char* value = this->Makefile->GetDefinition(args[i].c_str());
+      const char* value = this->Makefile->GetDefinition(args[i]);
       if(value && *value)
         {
         cmSystemTools::ExpandListArgument(value, f->Args, true);
diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h
index e548ba8..9b7c85a 100644
--- a/Source/cmForEachCommand.h
+++ b/Source/cmForEachCommand.h
@@ -59,7 +59,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "foreach";}
+  virtual std::string GetName() const { return "foreach";}
 
   cmTypeMacro(cmForEachCommand, cmCommand);
 private:
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index 85b89d9..3580374 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -20,7 +20,7 @@
   cmFunctionHelperCommand() {}
 
   ///! clean up any memory allocated by the function
-  ~cmFunctionHelperCommand() {};
+  ~cmFunctionHelperCommand() {}
 
   /**
    * This is used to avoid including this command
@@ -59,12 +59,12 @@
                                  cmExecutionStatus &);
 
   virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) { return false; };
+                           cmExecutionStatus &) { return false; }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return this->Args[0].c_str(); }
+  virtual std::string GetName() const { return this->Args[0]; }
 
   cmTypeMacro(cmFunctionHelperCommand, cmCommand);
 
@@ -89,7 +89,7 @@
     std::string errorMsg =
       "Function invoked with incorrect arguments for function named: ";
     errorMsg += this->Args[0];
-    this->SetError(errorMsg.c_str());
+    this->SetError(errorMsg);
     return false;
     }
 
@@ -113,15 +113,15 @@
     {
     cmOStringStream tmpStream;
     tmpStream << "ARGV" << t;
-    this->Makefile->AddDefinition(tmpStream.str().c_str(),
+    this->Makefile->AddDefinition(tmpStream.str(),
                                   expandedArgs[t].c_str());
-    this->Makefile->MarkVariableAsUsed(tmpStream.str().c_str());
+    this->Makefile->MarkVariableAsUsed(tmpStream.str());
     }
 
   // define the formal arguments
   for (unsigned int j = 1; j < this->Args.size(); ++j)
     {
-    this->Makefile->AddDefinition(this->Args[j].c_str(),
+    this->Makefile->AddDefinition(this->Args[j],
                                   expandedArgs[j-1].c_str());
     }
 
@@ -219,8 +219,8 @@
         }
 
       std::string newName = "_" + this->Args[0];
-      mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(),
-                                           newName.c_str());
+      mf.GetCMakeInstance()->RenameCommand(this->Args[0],
+                                           newName);
       mf.AddCommand(f);
 
       // remove the function blocker now that the function is defined
diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h
index a8bd3e7..2df435e 100644
--- a/Source/cmFunctionCommand.h
+++ b/Source/cmFunctionCommand.h
@@ -57,7 +57,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "function";}
+  virtual std::string GetName() const { return "function";}
 
   cmTypeMacro(cmFunctionCommand, cmCommand);
 };
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 34efc15..78ad4b2 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -249,12 +249,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratedFileStream::SetName(const char* fname)
+void cmGeneratedFileStream::SetName(const std::string& fname)
 {
-  if ( !fname )
-    {
-    this->Name = "";
-    return;
-    }
   this->Name = fname;
 }
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index 99f3b47..7adee7b 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -140,7 +140,7 @@
    * Set name of the file that will hold the actual output. This method allows
    * the output file to be changed during the use of cmGeneratedFileStream.
    */
-  void SetName(const char* fname);
+  void SetName(const std::string& fname);
 
 private:
   cmGeneratedFileStream(cmGeneratedFileStream const&); // not implemented
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 2e66d78..028d229 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -24,7 +24,7 @@
 
 //----------------------------------------------------------------------------
 cmGeneratorExpression::cmGeneratorExpression(
-  cmListFileBacktrace const& backtrace):
+  cmListFileBacktrace const* backtrace):
   Backtrace(backtrace)
 {
 }
@@ -33,17 +33,25 @@
 cmsys::auto_ptr<cmCompiledGeneratorExpression>
 cmGeneratorExpression::Parse(std::string const& input)
 {
-  return this->Parse(input.c_str());
+#if !defined(__BORLANDC__)
+  return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
+    new cmCompiledGeneratorExpression(
+      this->Backtrace ? *this->Backtrace : cmListFileBacktrace(NULL),
+      input));
+#else
+  cmListFileBacktrace emptyBacktrace(NULL);
+  return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
+    new cmCompiledGeneratorExpression(
+      this->Backtrace ? *this->Backtrace : emptyBacktrace,
+      input));
+#endif
 }
 
 //----------------------------------------------------------------------------
 cmsys::auto_ptr<cmCompiledGeneratorExpression>
 cmGeneratorExpression::Parse(const char* input)
 {
-  return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
-                                      new cmCompiledGeneratorExpression(
-                                        this->Backtrace,
-                                        input));
+  return this->Parse(std::string(input ? input : ""));
 }
 
 cmGeneratorExpression::~cmGeneratorExpression()
@@ -52,7 +60,7 @@
 
 //----------------------------------------------------------------------------
 const char *cmCompiledGeneratorExpression::Evaluate(
-  cmMakefile* mf, const char* config, bool quiet,
+  cmMakefile* mf, const std::string& config, bool quiet,
   cmTarget const* headTarget,
   cmGeneratorExpressionDAGChecker *dagChecker) const
 {
@@ -66,7 +74,7 @@
 
 //----------------------------------------------------------------------------
 const char *cmCompiledGeneratorExpression::Evaluate(
-  cmMakefile* mf, const char* config, bool quiet,
+  cmMakefile* mf, const std::string& config, bool quiet,
   cmTarget const* headTarget,
   cmTarget const* currentTarget,
   cmGeneratorExpressionDAGChecker *dagChecker) const
@@ -90,6 +98,7 @@
   context.HadError = false;
   context.HadContextSensitiveCondition = false;
   context.HeadTarget = headTarget;
+  context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
   context.CurrentTarget = currentTarget ? currentTarget : headTarget;
   context.Backtrace = this->Backtrace;
 
@@ -97,7 +106,7 @@
     {
     this->Output += (*it)->Evaluate(&context, dagChecker);
 
-    for(std::set<cmStdString>::const_iterator
+    for(std::set<std::string>::const_iterator
           p = context.SeenTargetProperties.begin();
           p != context.SeenTargetProperties.end(); ++p)
       {
@@ -109,6 +118,9 @@
       break;
       }
     }
+
+  this->MaxLanguageStandard = context.MaxLanguageStandard;
+
   if (!context.HadError)
     {
     this->HadContextSensitiveCondition = context.HadContextSensitiveCondition;
@@ -122,13 +134,14 @@
 
 cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
               cmListFileBacktrace const& backtrace,
-              const char *input)
-  : Backtrace(backtrace), Input(input ? input : ""),
-    HadContextSensitiveCondition(false)
+              const std::string& input)
+  : Backtrace(backtrace), Input(input),
+    HadContextSensitiveCondition(false),
+    EvaluateForBuildsystem(false)
 {
   cmGeneratorExpressionLexer l;
   std::vector<cmGeneratorExpressionToken> tokens =
-                                              l.Tokenize(this->Input.c_str());
+                                              l.Tokenize(this->Input);
   this->NeedsEvaluation = l.GetSawGeneratorExpression();
 
   if (this->NeedsEvaluation)
@@ -157,17 +170,24 @@
 std::string cmGeneratorExpression::StripEmptyListElements(
                                                     const std::string &input)
 {
+  if (input.find(';') == input.npos)
+    {
+    return input;
+    }
   std::string result;
+  result.reserve(input.size());
 
   const char *c = input.c_str();
+  const char *last = c;
   bool skipSemiColons = true;
   for ( ; *c; ++c)
     {
-    if(c[0] == ';')
+    if(*c == ';')
       {
       if(skipSemiColons)
         {
-        continue;
+        result.append(last, c - last);
+        last = c + 1;
         }
       skipSemiColons = true;
       }
@@ -175,8 +195,8 @@
       {
       skipSemiColons = false;
       }
-    result += *c;
     }
+  result.append(last);
 
   if (!result.empty() && *(result.end() - 1) == ';')
     {
@@ -372,7 +392,7 @@
         }
       if(!part.empty())
         {
-        cmSystemTools::ExpandListArgument(part.c_str(), output);
+        cmSystemTools::ExpandListArgument(part, output);
         }
       }
     pos += 2;
@@ -456,3 +476,17 @@
 
   return targetNameValidator.find(input.c_str());
 }
+
+//----------------------------------------------------------------------------
+void
+cmCompiledGeneratorExpression::GetMaxLanguageStandard(cmTarget const* tgt,
+                  std::map<std::string, std::string>& mapping)
+{
+  typedef std::map<cmTarget const*,
+                   std::map<std::string, std::string> > MapType;
+  MapType::const_iterator it = this->MaxLanguageStandard.find(tgt);
+  if (it != this->MaxLanguageStandard.end())
+    {
+    mapping = it->second;
+    }
+}
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 4992e93..324d23c 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -16,8 +16,6 @@
 #include "cmStandardIncludes.h"
 #include "cmListFileCache.h"
 
-#include <stack>
-
 #include <cmsys/RegularExpression.hxx>
 #include <cmsys/auto_ptr.hxx>
 
@@ -43,7 +41,7 @@
 {
 public:
   /** Construct. */
-  cmGeneratorExpression(cmListFileBacktrace const& backtrace);
+  cmGeneratorExpression(cmListFileBacktrace const* backtrace = NULL);
   ~cmGeneratorExpression();
 
   cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(
@@ -72,18 +70,18 @@
   cmGeneratorExpression(const cmGeneratorExpression &);
   void operator=(const cmGeneratorExpression &);
 
-  cmListFileBacktrace const& Backtrace;
+  cmListFileBacktrace const* Backtrace;
 };
 
 class cmCompiledGeneratorExpression
 {
 public:
-  const char* Evaluate(cmMakefile* mf, const char* config,
+  const char* Evaluate(cmMakefile* mf, const std::string& config,
                        bool quiet = false,
                        cmTarget const* headTarget = 0,
                        cmTarget const* currentTarget = 0,
                        cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
-  const char* Evaluate(cmMakefile* mf, const char* config,
+  const char* Evaluate(cmMakefile* mf, const std::string& config,
                        bool quiet,
                        cmTarget const* headTarget,
                        cmGeneratorExpressionDAGChecker *dagChecker) const;
@@ -92,7 +90,7 @@
   std::set<cmTarget*> const& GetTargets() const
     { return this->DependTargets; }
 
-  std::set<cmStdString> const& GetSeenTargetProperties() const
+  std::set<std::string> const& GetSeenTargetProperties() const
     { return this->SeenTargetProperties; }
 
   std::set<cmTarget const*> const& GetAllTargetsSeen() const
@@ -100,7 +98,7 @@
 
   ~cmCompiledGeneratorExpression();
 
-  std::string GetInput() const
+  std::string const& GetInput() const
   {
     return this->Input;
   }
@@ -114,9 +112,17 @@
     return this->HadContextSensitiveCondition;
   }
 
+  void SetEvaluateForBuildsystem(bool eval)
+  {
+    this->EvaluateForBuildsystem = eval;
+  }
+
+  void GetMaxLanguageStandard(cmTarget const* tgt,
+                    std::map<std::string, std::string>& mapping);
+
 private:
   cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
-              const char *input);
+              const std::string& input);
 
   friend class cmGeneratorExpression;
 
@@ -130,9 +136,12 @@
 
   mutable std::set<cmTarget*> DependTargets;
   mutable std::set<cmTarget const*> AllTargetsSeen;
-  mutable std::set<cmStdString> SeenTargetProperties;
+  mutable std::set<std::string> SeenTargetProperties;
+  mutable std::map<cmTarget const*, std::map<std::string, std::string> >
+                                                          MaxLanguageStandard;
   mutable std::string Output;
   mutable bool HadContextSensitiveCondition;
+  bool EvaluateForBuildsystem;
 };
 
 #endif
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index e7e1d34..75a84cb 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -24,6 +24,25 @@
   : Parent(parent), Target(target), Property(property),
     Content(content), Backtrace(backtrace), TransitivePropertiesOnly(false)
 {
+  Initialize();
+}
+
+//----------------------------------------------------------------------------
+cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
+                const std::string &target,
+                const std::string &property,
+                const GeneratorExpressionContent *content,
+                cmGeneratorExpressionDAGChecker *parent)
+  : Parent(parent), Target(target), Property(property),
+    Content(content), Backtrace(NULL), TransitivePropertiesOnly(false)
+{
+  Initialize();
+}
+
+//----------------------------------------------------------------------------
+void
+cmGeneratorExpressionDAGChecker::Initialize()
+{
   const cmGeneratorExpressionDAGChecker *top = this;
   const cmGeneratorExpressionDAGChecker *p = this->Parent;
   while (p)
@@ -42,12 +61,13 @@
      )
 #undef TEST_TRANSITIVE_PROPERTY_METHOD
     {
-    std::map<cmStdString, std::set<cmStdString> >::const_iterator it
-                                                    = top->Seen.find(target);
+    std::map<std::string, std::set<std::string> >::const_iterator it
+                                              = top->Seen.find(this->Target);
     if (it != top->Seen.end())
       {
-      const std::set<cmStdString> &propSet = it->second;
-      const std::set<cmStdString>::const_iterator i = propSet.find(property);
+      const std::set<std::string> &propSet = it->second;
+      const std::set<std::string>::const_iterator i
+          = propSet.find(this->Property);
       if (i != propSet.end())
         {
         this->CheckResult = ALREADY_SEEN;
@@ -55,7 +75,7 @@
         }
       }
     const_cast<cmGeneratorExpressionDAGChecker *>(top)
-                                            ->Seen[target].insert(property);
+      ->Seen[this->Target].insert(this->Property);
     }
 }
 
@@ -92,7 +112,7 @@
       << "Self reference on target \""
       << context->HeadTarget->GetName() << "\".\n";
     context->Makefile->GetCMakeInstance()
-      ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
+      ->IssueMessage(cmake::FATAL_ERROR, e.str(),
                       parent->Backtrace);
     return;
     }
@@ -103,7 +123,7 @@
     << "  " << expr << "\n"
     << "Dependency loop found.";
   context->Makefile->GetCMakeInstance()
-    ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
+    ->IssueMessage(cmake::FATAL_ERROR, e.str(),
                     context->Backtrace);
   }
 
@@ -116,7 +136,7 @@
       << (parent->Content ? parent->Content->GetOriginalExpression() : expr)
       << "\n";
     context->Makefile->GetCMakeInstance()
-      ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
+      ->IssueMessage(cmake::FATAL_ERROR, e.str(),
                       parent->Backtrace);
     parent = parent->Parent;
     ++loopStep;
@@ -179,6 +199,18 @@
        || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0;
 }
 
+std::string cmGeneratorExpressionDAGChecker::TopTarget() const
+{
+  const cmGeneratorExpressionDAGChecker *top = this;
+  const cmGeneratorExpressionDAGChecker *parent = this->Parent;
+  while (parent)
+    {
+    top = parent;
+    parent = parent->Parent;
+    }
+  return top->Target;
+}
+
 enum TransitiveProperty {
 #define DEFINE_ENUM_ENTRY(NAME) NAME,
   CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(DEFINE_ENUM_ENTRY)
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index b6effa1..10f9fa7 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -25,7 +25,9 @@
   SELECT(F, EvaluatingSystemIncludeDirectories, SYSTEM_INCLUDE_DIRECTORIES) \
   SELECT(F, EvaluatingCompileDefinitions,       COMPILE_DEFINITIONS) \
   SELECT(F, EvaluatingCompileOptions,           COMPILE_OPTIONS) \
-  SELECT(F, EvaluatingAutoUicOptions,           AUTOUIC_OPTIONS)
+  SELECT(F, EvaluatingAutoUicOptions,           AUTOUIC_OPTIONS) \
+  SELECT(F, EvaluatingSources,                  SOURCES) \
+  SELECT(F, EvaluatingCompileFeatures,          COMPILE_FEATURES)
 
 #define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \
   CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH)
@@ -44,6 +46,10 @@
                                   const std::string &property,
                                   const GeneratorExpressionContent *content,
                                   cmGeneratorExpressionDAGChecker *parent);
+  cmGeneratorExpressionDAGChecker(const std::string &target,
+                                  const std::string &property,
+                                  const GeneratorExpressionContent *content,
+                                  cmGeneratorExpressionDAGChecker *parent);
 
   enum Result {
     DAG,
@@ -70,14 +76,17 @@
   void SetTransitivePropertiesOnly()
     { this->TransitivePropertiesOnly = true; }
 
+  std::string TopTarget() const;
+
 private:
   Result CheckGraph() const;
+  void Initialize();
 
 private:
   const cmGeneratorExpressionDAGChecker * const Parent;
   const std::string Target;
   const std::string Property;
-  std::map<cmStdString, std::set<cmStdString> > Seen;
+  std::map<std::string, std::set<std::string> > Seen;
   const GeneratorExpressionContent * const Content;
   const cmListFileBacktrace Backtrace;
   Result CheckResult;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index bf85870..f9067cf 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -13,6 +13,7 @@
 #include "cmGeneratorExpressionEvaluationFile.h"
 
 #include "cmMakefile.h"
+#include "cmGeneratedFileStream.h"
 #include <cmsys/FStream.hxx>
 
 #include <assert.h>
@@ -33,7 +34,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorExpressionEvaluationFile::Generate(const char *config,
+void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
               cmCompiledGeneratorExpression* inputExpression,
               std::map<std::string, std::string> &outputFiles)
 {
@@ -50,7 +51,7 @@
       cmOStringStream e;
       e << "Evaluation file condition \"" << rawCondition << "\" did "
           "not evaluate to valid content. Got \"" << condResult << "\".";
-      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
       }
     }
@@ -72,26 +73,16 @@
     cmOStringStream e;
     e << "Evaluation file to be written multiple times for different "
          "configurations with different content:\n  " << outputFileName;
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
     }
 
   this->Files.push_back(outputFileName);
   outputFiles[outputFileName] = outputContent;
 
-  cmsys::ofstream fout(outputFileName.c_str());
-
-  if(!fout)
-    {
-    cmOStringStream e;
-    e << "Evaluation file \"" << outputFileName << "\" cannot be written.";
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
-    return;
-    }
-
+  cmGeneratedFileStream fout(outputFileName.c_str());
+  fout.SetCopyIfDifferent(true);
   fout << outputContent;
-
-  fout.close();
 }
 
 //----------------------------------------------------------------------------
@@ -109,7 +100,7 @@
       {
       cmOStringStream e;
       e << "Evaluation file \"" << this->Input << "\" cannot be read.";
-      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
       }
 
@@ -124,7 +115,7 @@
     }
 
   cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace();
-  cmGeneratorExpression contentGE(lfbt);
+  cmGeneratorExpression contentGE(&lfbt);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> inputExpression
                                               = contentGE.Parse(inputContent);
 
@@ -135,18 +126,15 @@
 
   if (allConfigs.empty())
     {
-    this->Generate(0, inputExpression.get(), outputFiles);
+    allConfigs.push_back("");
     }
-  else
+  for(std::vector<std::string>::const_iterator li = allConfigs.begin();
+      li != allConfigs.end(); ++li)
     {
-    for(std::vector<std::string>::const_iterator li = allConfigs.begin();
-        li != allConfigs.end(); ++li)
+    this->Generate(*li, inputExpression.get(), outputFiles);
+    if(cmSystemTools::GetFatalErrorOccured())
       {
-      this->Generate(li->c_str(), inputExpression.get(), outputFiles);
-      if(cmSystemTools::GetFatalErrorOccured())
-        {
-        return;
-        }
+      return;
       }
     }
 }
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index 20ee5cb..f939916 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -32,7 +32,7 @@
   std::vector<std::string> GetFiles() const { return this->Files; }
 
 private:
-  void Generate(const char *config,
+  void Generate(const std::string& config,
               cmCompiledGeneratorExpression* inputExpression,
               std::map<std::string, std::string> &outputFiles);
 
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 7036992..c54922d 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -15,6 +15,8 @@
 #include "cmGeneratorExpressionParser.h"
 #include "cmGeneratorExpressionDAGChecker.h"
 #include "cmGeneratorExpression.h"
+#include "cmLocalGenerator.h"
+#include "cmSourceFile.h"
 
 #include <cmsys/String.h>
 
@@ -39,7 +41,7 @@
     << "  " << expr << "\n"
     << result;
   context->Makefile->GetCMakeInstance()
-    ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
+    ->IssueMessage(cmake::FATAL_ERROR, e.str(),
                     context->Backtrace);
 }
 
@@ -393,8 +395,8 @@
                        const std::string &lang) const
   {
     const char *compilerId = context->Makefile ?
-                              context->Makefile->GetSafeDefinition((
-                              "CMAKE_" + lang + "_COMPILER_ID").c_str()) : "";
+                              context->Makefile->GetSafeDefinition(
+                                      "CMAKE_" + lang + "_COMPILER_ID") : "";
     if (parameters.size() == 0)
       {
       return compilerId ? compilerId : "";
@@ -428,7 +430,7 @@
                       ->GetPolicyWarning(cmPolicies::CMP0044);
           context->Makefile->GetCMakeInstance()
                  ->IssueMessage(cmake::AUTHOR_WARNING,
-                                e.str().c_str(), context->Backtrace);
+                                e.str(), context->Backtrace);
           }
         case cmPolicies::OLD:
           return "1";
@@ -455,8 +457,8 @@
     if (!context->HeadTarget)
       {
       reportError(context, content->GetOriginalExpression(),
-          "$<C_COMPILER_ID> may only be used with targets.  It may not "
-          "be used with add_custom_command.");
+          "$<C_COMPILER_ID> may only be used with binary targets.  It may "
+          "not be used with add_custom_command or add_custom_target.");
       return std::string();
       }
     return this->EvaluateWithLanguage(parameters, context, content,
@@ -477,8 +479,8 @@
     if (!context->HeadTarget)
       {
       reportError(context, content->GetOriginalExpression(),
-          "$<CXX_COMPILER_ID> may only be used with targets.  It may not "
-          "be used with add_custom_command.");
+          "$<CXX_COMPILER_ID> may only be used with binary targets.  It may "
+          "not be used with add_custom_command or add_custom_target.");
       return std::string();
       }
     return this->EvaluateWithLanguage(parameters, context, content,
@@ -500,8 +502,8 @@
                        const std::string &lang) const
   {
     const char *compilerVersion = context->Makefile ?
-                              context->Makefile->GetSafeDefinition((
-                        "CMAKE_" + lang + "_COMPILER_VERSION").c_str()) : "";
+                              context->Makefile->GetSafeDefinition(
+                                  "CMAKE_" + lang + "_COMPILER_VERSION") : "";
     if (parameters.size() == 0)
       {
       return compilerVersion ? compilerVersion : "";
@@ -539,8 +541,8 @@
     if (!context->HeadTarget)
       {
       reportError(context, content->GetOriginalExpression(),
-          "$<C_COMPILER_VERSION> may only be used with targets.  It may not "
-          "be used with add_custom_command.");
+          "$<C_COMPILER_VERSION> may only be used with binary targets.  It "
+          "may not be used with add_custom_command or add_custom_target.");
       return std::string();
       }
     return this->EvaluateWithLanguage(parameters, context, content,
@@ -561,8 +563,8 @@
     if (!context->HeadTarget)
       {
       reportError(context, content->GetOriginalExpression(),
-          "$<CXX_COMPILER_VERSION> may only be used with targets.  It may "
-          "not be used with add_custom_command.");
+          "$<CXX_COMPILER_VERSION> may only be used with binary targets.  It "
+          "may not be used with add_custom_command or add_custom_target.");
       return std::string();
       }
     return this->EvaluateWithLanguage(parameters, context, content,
@@ -689,7 +691,7 @@
                        cmGeneratorExpressionDAGChecker *) const
   {
     context->HadContextSensitiveCondition = true;
-    return context->Config ? context->Config : "";
+    return context->Config;
   }
 } configurationNode;
 
@@ -718,13 +720,13 @@
       return std::string();
       }
     context->HadContextSensitiveCondition = true;
-    if (!context->Config)
+    if (context->Config.empty())
       {
       return parameters.front().empty() ? "1" : "0";
       }
 
     if (cmsysString_strcasecmp(parameters.begin()->c_str(),
-                                  context->Config) == 0)
+                               context->Config.c_str()) == 0)
       {
       return "1";
       }
@@ -747,7 +749,7 @@
         std::string mapProp = "MAP_IMPORTED_CONFIG_";
         mapProp += cmSystemTools::UpperCase(context->Config);
         if(const char* mapValue =
-                        context->CurrentTarget->GetProperty(mapProp.c_str()))
+                        context->CurrentTarget->GetProperty(mapProp))
           {
           cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue),
                                             mappedConfigs);
@@ -800,34 +802,32 @@
 
 #undef TRANSITIVE_PROPERTY_NAME
 
-std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
+std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets,
                                   cmTarget const* target,
                                   cmTarget const* headTarget,
                                   cmGeneratorExpressionContext *context,
                                   cmGeneratorExpressionDAGChecker *dagChecker,
                                   const std::string &interfacePropertyName)
 {
-  cmGeneratorExpression ge(context->Backtrace);
+  cmGeneratorExpression ge(&context->Backtrace);
 
   std::string sep;
   std::string depString;
-  for (std::vector<std::string>::const_iterator
-      it = libraries.begin();
-      it != libraries.end(); ++it)
+  for (std::vector<cmTarget*>::const_iterator
+      it = targets.begin();
+      it != targets.end(); ++it)
     {
-    if (*it == target->GetName())
+    if (*it == target)
       {
       // Broken code can have a target in its own link interface.
       // Don't follow such link interface entries so as not to create a
       // self-referencing loop.
       continue;
       }
-    if (context->Makefile->FindTargetToUse(*it))
-      {
-      depString +=
-        sep + "$<TARGET_PROPERTY:" + *it + "," + interfacePropertyName + ">";
-      sep = ";";
-      }
+    depString +=
+      sep + "$<TARGET_PROPERTY:" +
+        (*it)->GetName() + "," + interfacePropertyName + ">";
+    sep = ";";
     }
   cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString);
   std::string linkedTargetsContent = cge->Evaluate(context->Makefile,
@@ -843,6 +843,27 @@
   return linkedTargetsContent;
 }
 
+std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
+                                  cmTarget const* target,
+                                  cmTarget const* headTarget,
+                                  cmGeneratorExpressionContext *context,
+                                  cmGeneratorExpressionDAGChecker *dagChecker,
+                                  const std::string &interfacePropertyName)
+{
+  std::vector<cmTarget*> tgts;
+  for (std::vector<std::string>::const_iterator
+      it = libraries.begin();
+      it != libraries.end(); ++it)
+    {
+    if (cmTarget *tgt = context->Makefile->FindTargetToUse(*it))
+      {
+      tgts.push_back(tgt);
+      }
+    }
+  return getLinkedTargetsContent(tgts, target, headTarget, context,
+                                 dagChecker, interfacePropertyName);
+}
+
 //----------------------------------------------------------------------------
 static const struct TargetPropertyNode : public cmGeneratorExpressionNode
 {
@@ -872,10 +893,10 @@
     if (!target && parameters.size() == 1)
       {
       reportError(context, content->GetOriginalExpression(),
-          "$<TARGET_PROPERTY:prop> may only be used with targets.  It may not "
-          "be used with add_custom_command.  Specify the target to read a "
-          "property from using the $<TARGET_PROPERTY:tgt,prop> signature "
-          "instead.");
+          "$<TARGET_PROPERTY:prop>  may only be used with binary targets.  "
+          "It may not be used with add_custom_command or add_custom_target.  "
+          "Specify the target to read a property from using the "
+          "$<TARGET_PROPERTY:tgt,prop> signature instead.");
       return std::string();
       }
 
@@ -964,15 +985,15 @@
     if (propertyName == "LINKER_LANGUAGE")
       {
       if (target->LinkLanguagePropagatesToDependents() &&
-          dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries())
+          dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries()
+            || dagCheckerParent->EvaluatingSources()))
         {
         reportError(context, content->GetOriginalExpression(),
             "LINKER_LANGUAGE target property can not be used while evaluating "
             "link libraries for a static library");
         return std::string();
         }
-      const char *lang = target->GetLinkerLanguage(context->Config);
-      return lang ? lang : "";
+      return target->GetLinkerLanguage(context->Config);
       }
 
     cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
@@ -1004,7 +1025,7 @@
       break;
       }
 
-    const char *prop = target->GetProperty(propertyName.c_str());
+    const char *prop = target->GetProperty(propertyName);
 
     if (dagCheckerParent)
       {
@@ -1065,13 +1086,13 @@
                      cmStrCmp(propertyName)) != transEnd)
       {
 
-      std::vector<std::string> libs;
-      target->GetTransitivePropertyLinkLibraries(context->Config,
-                                                 headTarget, libs);
-      if (!libs.empty())
+      std::vector<cmTarget*> tgts;
+      target->GetTransitivePropertyTargets(context->Config,
+                                                 headTarget, tgts);
+      if (!tgts.empty())
         {
         linkedTargetsContent =
-                  getLinkedTargetsContent(libs, target,
+                  getLinkedTargetsContent(tgts, target,
                                           headTarget,
                                           context, &dagChecker,
                                           interfacePropertyName);
@@ -1080,9 +1101,9 @@
     else if (std::find_if(transBegin, transEnd,
                           cmStrCmp(interfacePropertyName)) != transEnd)
       {
-      const cmTarget::LinkImplementation *impl = target->GetLinkImplementation(
-                                                    context->Config,
-                                                    headTarget);
+      const cmTarget::LinkImplementation *impl
+          = target->GetLinkImplementationLibraries(context->Config,
+                                                   headTarget);
       if(impl)
         {
         linkedTargetsContent =
@@ -1175,7 +1196,7 @@
       {
       if (targetPropertyTransitiveWhitelist[i] == interfacePropertyName)
         {
-        cmGeneratorExpression ge(context->Backtrace);
+        cmGeneratorExpression ge(&context->Backtrace);
         cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
         std::string result = cge->Evaluate(context->Makefile,
                             context->Config,
@@ -1222,6 +1243,165 @@
 } targetNameNode;
 
 //----------------------------------------------------------------------------
+static const struct TargetObjectsNode : public cmGeneratorExpressionNode
+{
+  TargetObjectsNode() {}
+
+  std::string Evaluate(const std::vector<std::string> &parameters,
+                       cmGeneratorExpressionContext *context,
+                       const GeneratorExpressionContent *content,
+                       cmGeneratorExpressionDAGChecker *) const
+  {
+    if (!context->EvaluateForBuildsystem)
+      {
+      cmOStringStream e;
+      e << "The evaluation of the TARGET_OBJECTS generator expression "
+        "is only suitable for consumption by CMake.  It is not suitable "
+        "for writing out elsewhere.";
+      reportError(context, content->GetOriginalExpression(), e.str());
+      return std::string();
+      }
+
+    std::string tgtName = parameters.front();
+    cmGeneratorTarget* gt =
+                context->Makefile->FindGeneratorTargetToUse(tgtName.c_str());
+    if (!gt)
+      {
+      cmOStringStream e;
+      e << "Objects of target \"" << tgtName
+        << "\" referenced but no such target exists.";
+      reportError(context, content->GetOriginalExpression(), e.str());
+      return std::string();
+      }
+    if (gt->GetType() != cmTarget::OBJECT_LIBRARY)
+      {
+      cmOStringStream e;
+      e << "Objects of target \"" << tgtName
+        << "\" referenced but is not an OBJECT library.";
+      reportError(context, content->GetOriginalExpression(), e.str());
+      return std::string();
+      }
+
+    std::vector<cmSourceFile const*> objectSources;
+    gt->GetObjectSources(objectSources, context->Config);
+    std::map<cmSourceFile const*, std::string> mapping;
+
+    for(std::vector<cmSourceFile const*>::const_iterator it
+        = objectSources.begin(); it != objectSources.end(); ++it)
+      {
+      mapping[*it];
+      }
+
+    gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
+
+    std::string obj_dir = gt->ObjectDirectory;
+    std::string result;
+    const char* sep = "";
+    for(std::map<cmSourceFile const*, std::string>::const_iterator it
+        = mapping.begin(); it != mapping.end(); ++it)
+      {
+      assert(!it->second.empty());
+      result += sep;
+      std::string objFile = obj_dir + it->second;
+      cmSourceFile* sf = context->Makefile->GetOrCreateSource(objFile, true);
+      sf->SetObjectLibrary(tgtName);
+      sf->SetProperty("EXTERNAL_OBJECT", "1");
+      result += objFile;
+      sep = ";";
+      }
+    return result;
+  }
+} targetObjectsNode;
+
+//----------------------------------------------------------------------------
+static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
+{
+  CompileFeaturesNode() {}
+
+  virtual int NumExpectedParameters() const { return OneOrMoreParameters; }
+
+  std::string Evaluate(const std::vector<std::string> &parameters,
+                       cmGeneratorExpressionContext *context,
+                       const GeneratorExpressionContent *content,
+                       cmGeneratorExpressionDAGChecker *dagChecker) const
+  {
+    cmTarget const* target = context->HeadTarget;
+    if (!target)
+      {
+      reportError(context, content->GetOriginalExpression(),
+          "$<COMPILE_FEATURE> may only be used with binary targets.  It may "
+          "not be used with add_custom_command or add_custom_target.");
+      return std::string();
+      }
+
+    typedef std::map<std::string, std::vector<std::string> > LangMap;
+    static LangMap availableFeatures;
+
+    LangMap testedFeatures;
+
+    for (std::vector<std::string>::const_iterator it = parameters.begin();
+        it != parameters.end(); ++it)
+      {
+      std::string error;
+      std::string lang;
+      if (!context->Makefile->CompileFeatureKnown(context->HeadTarget,
+                                                  *it, lang, &error))
+        {
+        reportError(context, content->GetOriginalExpression(), error);
+        return std::string();
+        }
+      testedFeatures[lang].push_back(*it);
+
+      if (availableFeatures.find(lang) == availableFeatures.end())
+        {
+        const char* featuresKnown
+                  = context->Makefile->CompileFeaturesAvailable(lang, &error);
+        if (!featuresKnown)
+          {
+          reportError(context, content->GetOriginalExpression(), error);
+          return std::string();
+          }
+        cmSystemTools::ExpandListArgument(featuresKnown,
+                                          availableFeatures[lang]);
+        }
+      }
+
+    bool evalLL = dagChecker && dagChecker->EvaluatingLinkLibraries();
+
+    std::string result;
+
+    for (LangMap::const_iterator lit = testedFeatures.begin();
+          lit != testedFeatures.end(); ++lit)
+      {
+      for (std::vector<std::string>::const_iterator it = lit->second.begin();
+          it != lit->second.end(); ++it)
+        {
+        if (!context->Makefile->HaveFeatureAvailable(target,
+                                                      lit->first, *it))
+          {
+          if (evalLL)
+            {
+            const char* l = target->GetProperty(lit->first + "_STANDARD");
+            if (!l)
+              {
+              l = context->Makefile
+                  ->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
+              }
+            assert(l);
+            context->MaxLanguageStandard[target][lit->first] = l;
+            }
+          else
+            {
+            return "0";
+            }
+          }
+        }
+      }
+    return "1";
+  }
+} compileFeaturesNode;
+
+//----------------------------------------------------------------------------
 static const char* targetPolicyWhitelist[] = {
   0
 #define TARGET_POLICY_STRING(POLICY) \
@@ -1280,8 +1460,8 @@
     if (!context->HeadTarget)
       {
       reportError(context, content->GetOriginalExpression(),
-          "$<TARGET_POLICY:prop> may only be used with targets.  It may not "
-          "be used with add_custom_command.");
+          "$<TARGET_POLICY:prop> may only be used with binary targets.  It "
+          "may not be used with add_custom_command or add_custom_target.");
       return std::string();
       }
 
@@ -1488,7 +1668,9 @@
                   "Target \"" + name + "\" is not an executable or library.");
       return std::string();
       }
-    if (dagChecker && dagChecker->EvaluatingLinkLibraries(name.c_str()))
+    if (dagChecker && (dagChecker->EvaluatingLinkLibraries(name.c_str())
+        || (dagChecker->EvaluatingSources()
+          && name == dagChecker->TopTarget())))
       {
       ::reportError(context, content->GetOriginalExpression(),
                     "Expressions which require the linker language may not "
@@ -1536,89 +1718,60 @@
 static const
 cmGeneratorExpressionNode* GetNode(const std::string &identifier)
 {
-  if (identifier == "0")
-    return &zeroNode;
-  else if (identifier == "1")
-    return &oneNode;
-  else if (identifier == "AND")
-    return &andNode;
-  else if (identifier == "OR")
-    return &orNode;
-  else if (identifier == "NOT")
-    return &notNode;
-  else if (identifier == "C_COMPILER_ID")
-    return &cCompilerIdNode;
-  else if (identifier == "CXX_COMPILER_ID")
-    return &cxxCompilerIdNode;
-  else if (identifier == "VERSION_GREATER")
-    return &versionGreaterNode;
-  else if (identifier == "VERSION_LESS")
-    return &versionLessNode;
-  else if (identifier == "VERSION_EQUAL")
-    return &versionEqualNode;
-  else if (identifier == "C_COMPILER_VERSION")
-    return &cCompilerVersionNode;
-  else if (identifier == "CXX_COMPILER_VERSION")
-    return &cxxCompilerVersionNode;
-  else if (identifier == "PLATFORM_ID")
-    return &platformIdNode;
-  else if (identifier == "CONFIGURATION")
-    return &configurationNode;
-  else if (identifier == "CONFIG")
-    return &configurationTestNode;
-  else if (identifier == "TARGET_FILE")
-    return &targetFileNode;
-  else if (identifier == "TARGET_LINKER_FILE")
-    return &targetLinkerFileNode;
-  else if (identifier == "TARGET_SONAME_FILE")
-    return &targetSoNameFileNode;
-  else if (identifier == "TARGET_FILE_NAME")
-    return &targetFileNameNode;
-  else if (identifier == "TARGET_LINKER_FILE_NAME")
-    return &targetLinkerFileNameNode;
-  else if (identifier == "TARGET_SONAME_FILE_NAME")
-    return &targetSoNameFileNameNode;
-  else if (identifier == "TARGET_FILE_DIR")
-    return &targetFileDirNode;
-  else if (identifier == "TARGET_LINKER_FILE_DIR")
-    return &targetLinkerFileDirNode;
-  else if (identifier == "TARGET_SONAME_FILE_DIR")
-    return &targetSoNameFileDirNode;
-  else if (identifier == "STREQUAL")
-    return &strEqualNode;
-  else if (identifier == "EQUAL")
-    return &equalNode;
-  else if (identifier == "LOWER_CASE")
-    return &lowerCaseNode;
-  else if (identifier == "UPPER_CASE")
-    return &upperCaseNode;
-  else if (identifier == "MAKE_C_IDENTIFIER")
-    return &makeCIdentifierNode;
-  else if (identifier == "BOOL")
-    return &boolNode;
-  else if (identifier == "ANGLE-R")
-    return &angle_rNode;
-  else if (identifier == "COMMA")
-    return &commaNode;
-  else if (identifier == "SEMICOLON")
-    return &semicolonNode;
-  else if (identifier == "TARGET_PROPERTY")
-    return &targetPropertyNode;
-  else if (identifier == "TARGET_NAME")
-    return &targetNameNode;
-  else if (identifier == "TARGET_POLICY")
-    return &targetPolicyNode;
-  else if (identifier == "BUILD_INTERFACE")
-    return &buildInterfaceNode;
-  else if (identifier == "INSTALL_INTERFACE")
-    return &installInterfaceNode;
-  else if (identifier == "INSTALL_PREFIX")
-    return &installPrefixNode;
-  else if (identifier == "JOIN")
-    return &joinNode;
-  else if (identifier == "LINK_ONLY")
-    return &linkOnlyNode;
-  return 0;
+  typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap;
+  static NodeMap nodeMap;
+  if (nodeMap.empty())
+    {
+    nodeMap["0"] = &zeroNode;
+    nodeMap["1"] = &oneNode;
+    nodeMap["AND"] = &andNode;
+    nodeMap["OR"] = &orNode;
+    nodeMap["NOT"] = &notNode;
+    nodeMap["C_COMPILER_ID"] = &cCompilerIdNode;
+    nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode;
+    nodeMap["VERSION_GREATER"] = &versionGreaterNode;
+    nodeMap["VERSION_LESS"] = &versionLessNode;
+    nodeMap["VERSION_EQUAL"] = &versionEqualNode;
+    nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
+    nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;
+    nodeMap["PLATFORM_ID"] = &platformIdNode;
+    nodeMap["COMPILE_FEATURES"] = &compileFeaturesNode;
+    nodeMap["CONFIGURATION"] = &configurationNode;
+    nodeMap["CONFIG"] = &configurationTestNode;
+    nodeMap["TARGET_FILE"] = &targetFileNode;
+    nodeMap["TARGET_LINKER_FILE"] = &targetLinkerFileNode;
+    nodeMap["TARGET_SONAME_FILE"] = &targetSoNameFileNode;
+    nodeMap["TARGET_FILE_NAME"] = &targetFileNameNode;
+    nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerFileNameNode;
+    nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameFileNameNode;
+    nodeMap["TARGET_FILE_DIR"] = &targetFileDirNode;
+    nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerFileDirNode;
+    nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameFileDirNode;
+    nodeMap["STREQUAL"] = &strEqualNode;
+    nodeMap["EQUAL"] = &equalNode;
+    nodeMap["LOWER_CASE"] = &lowerCaseNode;
+    nodeMap["UPPER_CASE"] = &upperCaseNode;
+    nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
+    nodeMap["BOOL"] = &boolNode;
+    nodeMap["ANGLE-R"] = &angle_rNode;
+    nodeMap["COMMA"] = &commaNode;
+    nodeMap["SEMICOLON"] = &semicolonNode;
+    nodeMap["TARGET_PROPERTY"] = &targetPropertyNode;
+    nodeMap["TARGET_NAME"] = &targetNameNode;
+    nodeMap["TARGET_OBJECTS"] = &targetObjectsNode;
+    nodeMap["TARGET_POLICY"] = &targetPolicyNode;
+    nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode;
+    nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode;
+    nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
+    nodeMap["JOIN"] = &joinNode;
+    nodeMap["LINK_ONLY"] = &linkOnlyNode;
+    }
+  NodeMap::const_iterator i = nodeMap.find(identifier);
+  if (i == nodeMap.end())
+    {
+    return 0;
+    }
+  return i->second;
 
 }
 
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index 49e52df..0ffb860 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -22,18 +22,26 @@
 //----------------------------------------------------------------------------
 struct cmGeneratorExpressionContext
 {
+  cmGeneratorExpressionContext()
+    : Backtrace(NULL)
+  {
+  }
+
   cmListFileBacktrace Backtrace;
   std::set<cmTarget*> DependTargets;
   std::set<cmTarget const*> AllTargets;
-  std::set<cmStdString> SeenTargetProperties;
+  std::set<std::string> SeenTargetProperties;
+  std::map<cmTarget const*, std::map<std::string, std::string> >
+                                                          MaxLanguageStandard;
   cmMakefile *Makefile;
-  const char *Config;
+  std::string Config;
   cmTarget const* HeadTarget; // The target whose property is being evaluated.
   cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears
                                  // directly or indirectly in the property.
   bool Quiet;
   bool HadError;
   bool HadContextSensitiveCondition;
+  bool EvaluateForBuildsystem;
 };
 
 struct cmGeneratorExpressionDAGChecker;
diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx
index cd71ec0..1c83466 100644
--- a/Source/cmGeneratorExpressionLexer.cxx
+++ b/Source/cmGeneratorExpressionLexer.cxx
@@ -32,52 +32,50 @@
 
 //----------------------------------------------------------------------------
 std::vector<cmGeneratorExpressionToken>
-cmGeneratorExpressionLexer::Tokenize(const char *input)
+cmGeneratorExpressionLexer::Tokenize(const std::string& input)
 {
   std::vector<cmGeneratorExpressionToken> result;
-  if (!input)
-    return result;
 
-  const char *c = input;
+  const char *c = input.c_str();
   const char *upto = c;
 
   for ( ; *c; ++c)
-  {
-  if(c[0] == '$' && c[1] == '<')
     {
-    InsertText(upto, c, result);
-    upto = c;
-    result.push_back(cmGeneratorExpressionToken(
-                      cmGeneratorExpressionToken::BeginExpression, upto, 2));
-    upto = c + 2;
-    ++c;
-    SawBeginExpression = true;
-    }
-  else if(c[0] == '>')
-    {
-    InsertText(upto, c, result);
-    upto = c;
-    result.push_back(cmGeneratorExpressionToken(
-                        cmGeneratorExpressionToken::EndExpression, upto, 1));
-    upto = c + 1;
-    SawGeneratorExpression = SawBeginExpression;
-    }
-  else if(c[0] == ':')
-    {
-    InsertText(upto, c, result);
-    upto = c;
-    result.push_back(cmGeneratorExpressionToken(
-                        cmGeneratorExpressionToken::ColonSeparator, upto, 1));
-    upto = c + 1;
-    }
-  else if(c[0] == ',')
-    {
-    InsertText(upto, c, result);
-    upto = c;
-    result.push_back(cmGeneratorExpressionToken(
-                        cmGeneratorExpressionToken::CommaSeparator, upto, 1));
-    upto = c + 1;
-    }
+    switch(*c)
+      {
+      case '$':
+        if(c[1] == '<')
+          {
+          InsertText(upto, c, result);
+          result.push_back(cmGeneratorExpressionToken(
+                           cmGeneratorExpressionToken::BeginExpression, c, 2));
+          upto = c + 2;
+          ++c;
+          SawBeginExpression = true;
+          }
+        break;
+      case '>':
+        InsertText(upto, c, result);
+        result.push_back(cmGeneratorExpressionToken(
+                            cmGeneratorExpressionToken::EndExpression, c, 1));
+        upto = c + 1;
+        SawGeneratorExpression = SawBeginExpression;
+        break;
+      case ':':
+        InsertText(upto, c, result);
+        result.push_back(cmGeneratorExpressionToken(
+                            cmGeneratorExpressionToken::ColonSeparator, c, 1));
+        upto = c + 1;
+        break;
+      case ',':
+        InsertText(upto, c, result);
+        result.push_back(cmGeneratorExpressionToken(
+                            cmGeneratorExpressionToken::CommaSeparator, c, 1));
+        upto = c + 1;
+        break;
+      default:
+        break;
+      }
   }
   InsertText(upto, c, result);
 
diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h
index 83d661d..1e2e8c2 100644
--- a/Source/cmGeneratorExpressionLexer.h
+++ b/Source/cmGeneratorExpressionLexer.h
@@ -43,7 +43,7 @@
 public:
   cmGeneratorExpressionLexer();
 
-  std::vector<cmGeneratorExpressionToken> Tokenize(const char *input);
+  std::vector<cmGeneratorExpressionToken> Tokenize(const std::string& input);
 
   bool GetSawGeneratorExpression() const
   {
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 175bb0e..a7576ed 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -19,13 +19,203 @@
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorExpressionDAGChecker.h"
 #include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
 
 #include <queue>
 
 #include "assert.h"
 
 //----------------------------------------------------------------------------
-cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t)
+void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib,
+                     cmTarget *target, cmake *cm)
+{
+  if(!badObjLib.empty())
+    {
+    cmOStringStream e;
+    e << "OBJECT library \"" << target->GetName() << "\" contains:\n";
+    for(std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
+        i != badObjLib.end(); ++i)
+      {
+      e << "  " << (*i)->GetLocation().GetName() << "\n";
+      }
+    e << "but may contain only headers and sources that compile.";
+    cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
+                     target->GetBacktrace());
+    }
+}
+
+struct ObjectSourcesTag {};
+struct CustomCommandsTag {};
+struct ExtraSourcesTag {};
+struct HeaderSourcesTag {};
+struct ExternalObjectsTag {};
+struct IDLSourcesTag {};
+struct ResxTag {};
+struct ModuleDefinitionFileTag {};
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1310
+template<typename Tag, typename OtherTag>
+struct IsSameTag
+{
+  enum {
+    Result = false
+  };
+};
+
+template<typename Tag>
+struct IsSameTag<Tag, Tag>
+{
+  enum {
+    Result = true
+  };
+};
+#else
+struct IsSameTagBase
+{
+  typedef char (&no_type)[1];
+  typedef char (&yes_type)[2];
+  template<typename T> struct Check;
+  template<typename T> static yes_type check(Check<T>*, Check<T>*);
+  static no_type check(...);
+};
+template<typename Tag1, typename Tag2>
+struct IsSameTag: public IsSameTagBase
+{
+  enum {
+    Result = (sizeof(check(static_cast< Check<Tag1>* >(0),
+                           static_cast< Check<Tag2>* >(0))) ==
+              sizeof(yes_type))
+  };
+};
+#endif
+
+template<bool>
+struct DoAccept
+{
+  template <typename T> static void Do(T&, cmSourceFile*) {}
+};
+
+template<>
+struct DoAccept<true>
+{
+  static void Do(std::vector<cmSourceFile const*>& files, cmSourceFile* f)
+    {
+    files.push_back(f);
+    }
+  static void Do(cmGeneratorTarget::ResxData& data, cmSourceFile* f)
+    {
+    // Build and save the name of the corresponding .h file
+    // This relationship will be used later when building the project files.
+    // Both names would have been auto generated from Visual Studio
+    // where the user supplied the file name and Visual Studio
+    // appended the suffix.
+    std::string resx = f->GetFullPath();
+    std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h";
+    data.ExpectedResxHeaders.insert(hFileName);
+    data.ResxSources.push_back(f);
+    }
+  static void Do(std::string& data, cmSourceFile* f)
+    {
+    data = f->GetFullPath();
+    }
+};
+
+//----------------------------------------------------------------------------
+template<typename Tag, typename DataType = std::vector<cmSourceFile const*> >
+struct TagVisitor
+{
+  DataType& Data;
+  std::vector<cmSourceFile*> BadObjLibFiles;
+  cmTarget *Target;
+  cmGlobalGenerator *GlobalGenerator;
+  cmsys::RegularExpression Header;
+  bool IsObjLib;
+
+  TagVisitor(cmTarget *target, DataType& data)
+    : Data(data), Target(target),
+    GlobalGenerator(target->GetMakefile()
+                          ->GetLocalGenerator()->GetGlobalGenerator()),
+    Header(CM_HEADER_REGEX),
+    IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY)
+  {
+  }
+
+  ~TagVisitor()
+  {
+    reportBadObjLib(this->BadObjLibFiles, this->Target,
+                    this->GlobalGenerator->GetCMakeInstance());
+  }
+
+  void Accept(cmSourceFile *sf)
+  {
+    std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
+    if(sf->GetCustomCommand())
+      {
+      DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf);
+      }
+    else if(this->Target->GetType() == cmTarget::UTILITY)
+      {
+      DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+      }
+    else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY"))
+      {
+      DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
+      }
+    else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
+      {
+      DoAccept<IsSameTag<Tag, ExternalObjectsTag>::Result>::Do(this->Data, sf);
+      if(this->IsObjLib)
+        {
+        this->BadObjLibFiles.push_back(sf);
+        }
+      }
+    else if(!sf->GetLanguage().empty())
+      {
+      DoAccept<IsSameTag<Tag, ObjectSourcesTag>::Result>::Do(this->Data, sf);
+      }
+    else if(ext == "def")
+      {
+      DoAccept<IsSameTag<Tag, ModuleDefinitionFileTag>::Result>::Do(this->Data,
+                                                                    sf);
+      if(this->IsObjLib)
+        {
+        this->BadObjLibFiles.push_back(sf);
+        }
+      }
+    else if(ext == "idl")
+      {
+      DoAccept<IsSameTag<Tag, IDLSourcesTag>::Result>::Do(this->Data, sf);
+      if(this->IsObjLib)
+        {
+        this->BadObjLibFiles.push_back(sf);
+        }
+      }
+    else if(ext == "resx")
+      {
+      DoAccept<IsSameTag<Tag, ResxTag>::Result>::Do(this->Data, sf);
+      }
+    else if(this->Header.find(sf->GetFullPath().c_str()))
+      {
+      DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
+      }
+    else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str()))
+      {
+      DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+      }
+    else
+      {
+      DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+      if(this->IsObjLib && ext != "txt")
+        {
+        this->BadObjLibFiles.push_back(sf);
+        }
+      }
+  }
+};
+
+//----------------------------------------------------------------------------
+cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t),
+  SourceFileFlagsConstructed(false)
 {
   this->Makefile = this->Target->GetMakefile();
   this->LocalGenerator = this->Makefile->GetLocalGenerator();
@@ -39,20 +229,20 @@
 }
 
 //----------------------------------------------------------------------------
-const char *cmGeneratorTarget::GetName() const
+std::string cmGeneratorTarget::GetName() const
 {
   return this->Target->GetName();
 }
 
 //----------------------------------------------------------------------------
-const char *cmGeneratorTarget::GetProperty(const char *prop) const
+const char *cmGeneratorTarget::GetProperty(const std::string& prop) const
 {
   return this->Target->GetProperty(prop);
 }
 
 //----------------------------------------------------------------------------
 std::vector<cmSourceFile*> const*
-cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const
+cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const
 {
   SourceEntriesType::const_iterator i = this->SourceEntries.find(sf);
   if(i != this->SourceEntries.end())
@@ -62,25 +252,17 @@
   return 0;
 }
 
-static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name,
-                                  const char *config, cmTarget *headTarget,
+static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt,
+                                  const std::string& config,
+                                  cmTarget *headTarget,
                                   cmGeneratorExpressionDAGChecker *dagChecker,
                                   std::vector<std::string>& result,
                                   bool excludeImported)
 {
-  cmTarget* depTgt = mf->FindTargetToUse(name);
-
-  if (!depTgt)
-    {
-    return;
-    }
-
-  cmListFileBacktrace lfbt;
-
   if (const char* dirs =
           depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"))
     {
-    cmGeneratorExpression ge(lfbt);
+    cmGeneratorExpression ge;
     cmSystemTools::ExpandListArgument(ge.Parse(dirs)
                                       ->Evaluate(mf,
                                       config, false, headTarget,
@@ -94,7 +276,7 @@
   if (const char* dirs =
                 depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES"))
     {
-    cmGeneratorExpression ge(lfbt);
+    cmGeneratorExpression ge;
     cmSystemTools::ExpandListArgument(ge.Parse(dirs)
                                       ->Evaluate(mf,
                                       config, false, headTarget,
@@ -102,26 +284,77 @@
     }
 }
 
+#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \
+  { \
+  std::vector<cmSourceFile*> sourceFiles; \
+  this->Target->GetSourceFiles(sourceFiles, config); \
+  TagVisitor<DATA ## Tag DATATYPE> visitor(this->Target, data); \
+  for(std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \
+      si != sourceFiles.end(); ++si) \
+    { \
+    visitor.Accept(*si); \
+    } \
+  } \
+
+
+#define IMPLEMENT_VISIT(DATA) \
+  IMPLEMENT_VISIT_IMPL(DATA, EMPTY) \
+
+#define EMPTY
+#define COMMA ,
+
 //----------------------------------------------------------------------------
 void
-cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &objs) const
+cmGeneratorTarget
+::GetObjectSources(std::vector<cmSourceFile const*> &data,
+                   const std::string& config) const
 {
-  objs = this->ObjectSources;
+  IMPLEMENT_VISIT(ObjectSources);
+
+  if (!this->Objects.empty())
+    {
+    return;
+    }
+
+  for(std::vector<cmSourceFile const*>::const_iterator it = data.begin();
+      it != data.end(); ++it)
+    {
+    this->Objects[*it];
+    }
+
+  this->LocalGenerator->ComputeObjectFilenames(this->Objects, this);
+}
+
+void cmGeneratorTarget::ComputeObjectMapping()
+{
+  if(!this->Objects.empty())
+    {
+    return;
+    }
+
+  std::vector<std::string> configs;
+  this->Makefile->GetConfigurations(configs);
+  if (configs.empty())
+    {
+    configs.push_back("");
+    }
+  for(std::vector<std::string>::const_iterator ci = configs.begin();
+      ci != configs.end(); ++ci)
+    {
+    std::vector<cmSourceFile const*> sourceFiles;
+    this->GetObjectSources(sourceFiles, *ci);
+    }
 }
 
 //----------------------------------------------------------------------------
 const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file)
 {
+  this->ComputeObjectMapping();
   return this->Objects[file];
 }
 
-void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name)
-{
-    this->Objects[sf] = name;
-}
-
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf)
+void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf)
 {
   this->ExplicitObjectName.insert(sf);
 }
@@ -129,64 +362,82 @@
 //----------------------------------------------------------------------------
 bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
 {
+  const_cast<cmGeneratorTarget*>(this)->ComputeObjectMapping();
   std::set<cmSourceFile const*>::const_iterator it
                                         = this->ExplicitObjectName.find(file);
   return it != this->ExplicitObjectName.end();
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const
+void cmGeneratorTarget
+::GetIDLSources(std::vector<cmSourceFile const*>& data,
+                const std::string& config) const
 {
-  srcs = this->ResxSources;
-}
-
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& srcs) const
-{
-  srcs = this->IDLSources;
+  IMPLEMENT_VISIT(IDLSources);
 }
 
 //----------------------------------------------------------------------------
 void
-cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& srcs) const
+cmGeneratorTarget
+::GetHeaderSources(std::vector<cmSourceFile const*>& data,
+                   const std::string& config) const
 {
-  srcs = this->HeaderSources;
+  IMPLEMENT_VISIT(HeaderSources);
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& srcs) const
+void cmGeneratorTarget
+::GetExtraSources(std::vector<cmSourceFile const*>& data,
+                  const std::string& config) const
 {
-  srcs = this->ExtraSources;
+  IMPLEMENT_VISIT(ExtraSources);
 }
 
 //----------------------------------------------------------------------------
 void
-cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& srcs) const
+cmGeneratorTarget
+::GetCustomCommands(std::vector<cmSourceFile const*>& data,
+                    const std::string& config) const
 {
-  srcs = this->CustomCommands;
+  IMPLEMENT_VISIT(CustomCommands);
 }
 
 //----------------------------------------------------------------------------
 void
-cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const
+cmGeneratorTarget
+::GetExternalObjects(std::vector<cmSourceFile const*>& data,
+                     const std::string& config) const
 {
-  srcs = this->ExpectedResxHeaders;
+  IMPLEMENT_VISIT(ExternalObjects);
 }
 
 //----------------------------------------------------------------------------
 void
-cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& srcs) const
+cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs,
+                                          const std::string& config) const
 {
-  srcs = this->ExternalObjects;
+  ResxData data;
+  IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
+  srcs = data.ExpectedResxHeaders;
 }
 
 //----------------------------------------------------------------------------
-bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
-                                                 const char *config) const
+void cmGeneratorTarget
+::GetResxSources(std::vector<cmSourceFile const*>& srcs,
+                 const std::string& config) const
+{
+  ResxData data;
+  IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
+  srcs = data.ResxSources;
+}
+
+//----------------------------------------------------------------------------
+bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
+                                              const std::string& config) const
 {
   assert(this->GetType() != cmTarget::INTERFACE_LIBRARY);
   std::string config_upper;
-  if(config && *config)
+  if(!config.empty())
     {
     config_upper = cmSystemTools::UpperCase(config);
     }
@@ -204,8 +455,7 @@
       return false;
       }
 
-    cmListFileBacktrace lfbt;
-    cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+    cmGeneratorExpressionDAGChecker dagChecker(
                                         this->GetName(),
                                         "SYSTEM_INCLUDE_DIRECTORIES", 0, 0);
 
@@ -213,37 +463,36 @@
                 = this->Target->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
 
     std::vector<std::string> result;
-    for (std::set<cmStdString>::const_iterator
+    for (std::set<std::string>::const_iterator
         it = this->Target->GetSystemIncludeDirectories().begin();
         it != this->Target->GetSystemIncludeDirectories().end(); ++it)
       {
-      cmGeneratorExpression ge(lfbt);
+      cmGeneratorExpression ge;
       cmSystemTools::ExpandListArgument(ge.Parse(*it)
                                           ->Evaluate(this->Makefile,
                                           config, false, this->Target,
                                           &dagChecker), result);
       }
 
-    std::set<cmStdString> uniqueDeps;
+    std::set<cmTarget*> uniqueDeps;
     for(std::vector<std::string>::const_iterator li = impl->Libraries.begin();
         li != impl->Libraries.end(); ++li)
       {
-      if (uniqueDeps.insert(*li).second)
+      cmTarget* tgt = this->Makefile->FindTargetToUse(*li);
+      if (!tgt)
         {
-        cmTarget* tgt = this->Makefile->FindTargetToUse(*li);
+        continue;
+        }
 
-        if (!tgt)
-          {
-          continue;
-          }
-
-        handleSystemIncludesDep(this->Makefile, *li, config, this->Target,
+      if (uniqueDeps.insert(tgt).second)
+        {
+        handleSystemIncludesDep(this->Makefile, tgt, config, this->Target,
                                 &dagChecker, result, excludeImported);
 
-        std::vector<std::string> deps;
-        tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps);
+        std::vector<cmTarget*> deps;
+        tgt->GetTransitivePropertyTargets(config, this->Target, deps);
 
-        for(std::vector<std::string>::const_iterator di = deps.begin();
+        for(std::vector<cmTarget*>::const_iterator di = deps.begin();
             di != deps.end(); ++di)
           {
           if (uniqueDeps.insert(*di).second)
@@ -254,7 +503,7 @@
           }
         }
       }
-    std::set<cmStdString> unique;
+    std::set<std::string> unique;
     for(std::vector<std::string>::iterator li = result.begin();
         li != result.end(); ++li)
       {
@@ -262,7 +511,7 @@
       unique.insert(*li);
       }
     result.clear();
-    for(std::set<cmStdString>::iterator li = unique.begin();
+    for(std::set<std::string>::iterator li = unique.begin();
         li != unique.end(); ++li)
       {
       result.push_back(*li);
@@ -278,179 +527,61 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const
+bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const
 {
   return this->Target->GetPropertyAsBool(prop);
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
+void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
+                                       const std::string& config) const
 {
-  this->Target->GetSourceFiles(files);
+  this->Target->GetSourceFiles(files, config);
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::ClassifySources()
+std::string
+cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const
 {
-  cmsys::RegularExpression header(CM_HEADER_REGEX);
-
-  cmTarget::TargetType targetType = this->Target->GetType();
-  bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY;
-
-  std::vector<cmSourceFile*> badObjLib;
-  std::vector<cmSourceFile*> sources;
-  this->Target->GetSourceFiles(sources);
-  for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
-      si != sources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
-    if(sf->GetCustomCommand())
-      {
-      this->CustomCommands.push_back(sf);
-      }
-    else if(targetType == cmTarget::UTILITY)
-      {
-      this->ExtraSources.push_back(sf);
-      }
-    else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY"))
-      {
-      this->HeaderSources.push_back(sf);
-      }
-    else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
-      {
-      this->ExternalObjects.push_back(sf);
-      if(isObjLib) { badObjLib.push_back(sf); }
-      }
-    else if(sf->GetLanguage())
-      {
-      this->ObjectSources.push_back(sf);
-      }
-    else if(ext == "def")
-      {
-      this->ModuleDefinitionFile = sf->GetFullPath();
-      if(isObjLib) { badObjLib.push_back(sf); }
-      }
-    else if(ext == "idl")
-      {
-      this->IDLSources.push_back(sf);
-      if(isObjLib) { badObjLib.push_back(sf); }
-      }
-    else if(ext == "resx")
-      {
-      // Build and save the name of the corresponding .h file
-      // This relationship will be used later when building the project files.
-      // Both names would have been auto generated from Visual Studio
-      // where the user supplied the file name and Visual Studio
-      // appended the suffix.
-      std::string resx = sf->GetFullPath();
-      std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h";
-      this->ExpectedResxHeaders.insert(hFileName);
-      this->ResxSources.push_back(sf);
-      }
-    else if(header.find(sf->GetFullPath().c_str()))
-      {
-      this->HeaderSources.push_back(sf);
-      }
-    else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str()))
-      {
-      // We only get here if a source file is not an external object
-      // and has an extension that is listed as an ignored file type.
-      // No message or diagnosis should be given.
-      this->ExtraSources.push_back(sf);
-      }
-    else
-      {
-      this->ExtraSources.push_back(sf);
-      if(isObjLib && ext != "txt")
-        {
-        badObjLib.push_back(sf);
-        }
-      }
-    }
-
-  if(!badObjLib.empty())
-    {
-    cmOStringStream e;
-    e << "OBJECT library \"" << this->Target->GetName() << "\" contains:\n";
-    for(std::vector<cmSourceFile*>::iterator i = badObjLib.begin();
-        i != badObjLib.end(); ++i)
-      {
-      e << "  " << (*i)->GetLocation().GetName() << "\n";
-      }
-    e << "but may contain only headers and sources that compile.";
-    this->GlobalGenerator->GetCMakeInstance()
-      ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                     this->Target->GetBacktrace());
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmGeneratorTarget::LookupObjectLibraries()
-{
-  std::vector<std::string> const& objLibs =
-    this->Target->GetObjectLibraries();
-  for(std::vector<std::string>::const_iterator oli = objLibs.begin();
-      oli != objLibs.end(); ++oli)
-    {
-    std::string const& objLibName = *oli;
-    if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName))
-      {
-      if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
-        {
-        if(this->Target->GetType() != cmTarget::EXECUTABLE &&
-           this->Target->GetType() != cmTarget::STATIC_LIBRARY &&
-           this->Target->GetType() != cmTarget::SHARED_LIBRARY &&
-           this->Target->GetType() != cmTarget::MODULE_LIBRARY)
-          {
-          this->GlobalGenerator->GetCMakeInstance()
-            ->IssueMessage(cmake::FATAL_ERROR,
-                           "Only executables and non-OBJECT libraries may "
-                           "reference target objects.",
-                           this->Target->GetBacktrace());
-          return;
-          }
-        this->Target->AddUtility(objLib->GetName());
-        this->ObjectLibraries.push_back(objLib);
-        }
-      else
-        {
-        cmOStringStream e;
-        e << "Objects of target \"" << objLibName
-          << "\" referenced but is not an OBJECT library.";
-        this->GlobalGenerator->GetCMakeInstance()
-          ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                         this->Target->GetBacktrace());
-        return;
-        }
-      }
-    else
-      {
-      cmOStringStream e;
-      e << "Objects of target \"" << objLibName
-        << "\" referenced but no such target exists.";
-      this->GlobalGenerator->GetCMakeInstance()
-        ->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                       this->Target->GetBacktrace());
-      return;
-      }
-    }
+  std::string data;
+  IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string)
+  return data;
 }
 
 //----------------------------------------------------------------------------
 void
-cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const
+cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs,
+                                      const std::string &config) const
 {
+  std::vector<cmSourceFile const*> objectFiles;
+  this->GetExternalObjects(objectFiles, config);
+  std::vector<cmTarget*> objectLibraries;
+  std::set<cmTarget*> emitted;
+  for(std::vector<cmSourceFile const*>::const_iterator
+      it = objectFiles.begin(); it != objectFiles.end(); ++it)
+    {
+    std::string objLib = (*it)->GetObjectLibrary();
+    if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
+      {
+      if (emitted.insert(tgt).second)
+        {
+        objectLibraries.push_back(tgt);
+        }
+      }
+    }
+
   for(std::vector<cmTarget*>::const_iterator
-        ti = this->ObjectLibraries.begin();
-      ti != this->ObjectLibraries.end(); ++ti)
+        ti = objectLibraries.begin();
+      ti != objectLibraries.end(); ++ti)
     {
     cmTarget* objLib = *ti;
     cmGeneratorTarget* ogt =
       this->GlobalGenerator->GetGeneratorTarget(objLib);
-    for(std::vector<cmSourceFile*>::const_iterator
-          si = ogt->ObjectSources.begin();
-        si != ogt->ObjectSources.end(); ++si)
+    std::vector<cmSourceFile const*> objectSources;
+    ogt->GetObjectSources(objectSources, config);
+    for(std::vector<cmSourceFile const*>::const_iterator
+          si = objectSources.begin();
+        si != objectSources.end(); ++si)
       {
       std::string obj = ogt->ObjectDirectory;
       obj += ogt->Objects[*si];
@@ -474,8 +605,9 @@
   SourceEntry* CurrentEntry;
   std::queue<cmSourceFile*> SourceQueue;
   std::set<cmSourceFile*> SourcesQueued;
-  typedef std::map<cmStdString, cmSourceFile*> NameMapType;
+  typedef std::map<std::string, cmSourceFile*> NameMapType;
   NameMapType NameMap;
+  std::vector<std::string> NewSources;
 
   void QueueSource(cmSourceFile* sf);
   void FollowName(std::string const& name);
@@ -483,6 +615,9 @@
   bool IsUtility(std::string const& dep);
   void CheckCustomCommand(cmCustomCommand const& cc);
   void CheckCustomCommands(const std::vector<cmCustomCommand>& commands);
+  void FollowCommandDepends(cmCustomCommand const& cc,
+                            const std::string& config,
+                            std::set<std::string>& emitted);
 };
 
 //----------------------------------------------------------------------------
@@ -497,14 +632,29 @@
   this->CurrentEntry = 0;
 
   // Queue all the source files already specified for the target.
-  std::vector<cmSourceFile*> sources;
   if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY)
     {
-    this->Target->GetSourceFiles(sources);
-    for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
-        si != sources.end(); ++si)
+    std::vector<std::string> configs;
+    this->Makefile->GetConfigurations(configs);
+    if (configs.empty())
       {
-      this->QueueSource(*si);
+      configs.push_back("");
+      }
+    std::set<cmSourceFile*> emitted;
+    for(std::vector<std::string>::const_iterator ci = configs.begin();
+        ci != configs.end(); ++ci)
+      {
+      std::vector<cmSourceFile*> sources;
+      this->Target->GetSourceFiles(sources, *ci);
+      for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
+          si != sources.end(); ++si)
+        {
+        cmSourceFile* sf = *si;
+        if(emitted.insert(sf).second && this->SourcesQueued.insert(sf).second)
+          {
+          this->SourceQueue.push(sf);
+          }
+        }
       }
     }
 
@@ -546,6 +696,8 @@
       }
     }
   this->CurrentEntry = 0;
+
+  this->Target->AddTracedSources(this->NewSources);
 }
 
 //----------------------------------------------------------------------------
@@ -555,8 +707,8 @@
     {
     this->SourceQueue.push(sf);
 
-    // Make sure this file is in the target.
-    this->Target->AddSourceFile(sf);
+    // Make sure this file is in the target at the end.
+    this->NewSources.push_back(sf->GetFullPath());
     }
 }
 
@@ -567,7 +719,7 @@
   if(i == this->NameMap.end())
     {
     // Check if we know how to generate this file.
-    cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str());
+    cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name);
     NameMapType::value_type entry(name, sf);
     i = this->NameMap.insert(entry).first;
     }
@@ -578,7 +730,6 @@
       {
       this->CurrentEntry->Depends.push_back(sf);
       }
-
     this->QueueSource(sf);
     }
 }
@@ -622,14 +773,14 @@
         {
         // This is really only for compatibility so we do not need to
         // worry about configuration names and output names.
-        std::string tLocation = t->GetLocation(0);
+        std::string tLocation = t->GetLocationForBuild();
         tLocation = cmSystemTools::GetFilenamePath(tLocation);
         std::string depLocation = cmSystemTools::GetFilenamePath(dep);
         depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
         tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
         if(depLocation == tLocation)
           {
-          this->Target->AddUtility(util.c_str());
+          this->Target->AddUtility(util);
           return true;
           }
         }
@@ -638,7 +789,7 @@
       {
       // The original name of the dependency was not a full path.  It
       // must name a target, so add the target-level dependency.
-      this->Target->AddUtility(util.c_str());
+      this->Target->AddUtility(util);
       return true;
       }
     }
@@ -654,7 +805,7 @@
 {
   // Transform command names that reference targets built in this
   // project to corresponding target-level dependencies.
-  cmGeneratorExpression ge(cc.GetBacktrace());
+  cmGeneratorExpression ge(&cc.GetBacktrace());
 
   // Add target-level dependencies referenced by generator expressions.
   std::set<cmTarget*> targets;
@@ -672,7 +823,7 @@
         // this project.  Add the target-level dependency to make
         // sure the executable is up to date before this custom
         // command possibly runs.
-        this->Target->AddUtility(command.c_str());
+        this->Target->AddUtility(command);
         }
       }
 
@@ -682,7 +833,7 @@
       {
       const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
                                                               = ge.Parse(*cli);
-      cge->Evaluate(this->Makefile, 0, true);
+      cge->Evaluate(this->Makefile, "", true);
       std::set<cmTarget*> geTargets = cge->GetTargets();
       for(std::set<cmTarget*>::const_iterator it = geTargets.begin();
           it != geTargets.end(); ++it)
@@ -699,16 +850,41 @@
     }
 
   // Queue the custom command dependencies.
-  std::vector<std::string> const& depends = cc.GetDepends();
+  std::vector<std::string> configs;
+  std::set<std::string> emitted;
+  this->Makefile->GetConfigurations(configs);
+  if (configs.empty())
+    {
+    configs.push_back("");
+    }
+  for(std::vector<std::string>::const_iterator ci = configs.begin();
+      ci != configs.end(); ++ci)
+    {
+    this->FollowCommandDepends(cc, *ci, emitted);
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc,
+                                              const std::string& config,
+                                              std::set<std::string>& emitted)
+{
+  cmCustomCommandGenerator ccg(cc, config, this->Makefile);
+
+  const std::vector<std::string>& depends = ccg.GetDepends();
+
   for(std::vector<std::string>::const_iterator di = depends.begin();
       di != depends.end(); ++di)
     {
     std::string const& dep = *di;
-    if(!this->IsUtility(dep))
+    if(emitted.insert(dep).second)
       {
-      // The dependency does not name a target and may be a file we
-      // know how to generate.  Queue it.
-      this->FollowName(dep);
+      if(!this->IsUtility(dep))
+        {
+        // The dependency does not name a target and may be a file we
+        // know how to generate.  Queue it.
+        this->FollowName(dep);
+        }
       }
     }
 }
@@ -743,15 +919,15 @@
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::GetAppleArchs(const char* config,
+void cmGeneratorTarget::GetAppleArchs(const std::string& config,
                              std::vector<std::string>& archVec) const
 {
   const char* archs = 0;
-  if(config && *config)
+  if(!config.empty())
     {
     std::string defVarName = "OSX_ARCHITECTURES_";
     defVarName += cmSystemTools::UpperCase(config);
-    archs = this->Target->GetProperty(defVarName.c_str());
+    archs = this->Target->GetProperty(defVarName);
     }
   if(!archs)
     {
@@ -764,18 +940,32 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmGeneratorTarget::GetCreateRuleVariable() const
+std::string
+cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang,
+                                         std::string const& config) const
 {
   switch(this->GetType())
     {
     case cmTarget::STATIC_LIBRARY:
-      return "_CREATE_STATIC_LIBRARY";
+      {
+      std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY";
+      if(this->Target->GetFeatureAsBool(
+           "INTERPROCEDURAL_OPTIMIZATION", config))
+        {
+        std::string varIPO = var + "_IPO";
+        if(this->Makefile->GetDefinition(varIPO))
+          {
+          return varIPO;
+          }
+        }
+      return var;
+      }
     case cmTarget::SHARED_LIBRARY:
-      return "_CREATE_SHARED_LIBRARY";
+      return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY";
     case cmTarget::MODULE_LIBRARY:
-      return "_CREATE_SHARED_MODULE";
+      return "CMAKE_" + lang + "_CREATE_SHARED_MODULE";
     case cmTarget::EXECUTABLE:
-      return "_LINK_EXECUTABLE";
+      return "CMAKE_" + lang + "_LINK_EXECUTABLE";
     default:
       break;
     }
@@ -784,13 +974,14 @@
 
 //----------------------------------------------------------------------------
 std::vector<std::string>
-cmGeneratorTarget::GetIncludeDirectories(const char *config) const
+cmGeneratorTarget::GetIncludeDirectories(const std::string& config) const
 {
   return this->Target->GetIncludeDirectories(config);
 }
 
 //----------------------------------------------------------------------------
-void cmGeneratorTarget::GenerateTargetManifest(const char* config) const
+void cmGeneratorTarget::GenerateTargetManifest(
+                                              const std::string& config) const
 {
   if (this->Target->IsImported())
     {
@@ -833,42 +1024,42 @@
     f = dir;
     f += "/";
     f += name;
-    gg->AddToManifest(config? config:"", f);
+    gg->AddToManifest(config, f);
     }
   if(!soName.empty())
     {
     f = dir;
     f += "/";
     f += soName;
-    gg->AddToManifest(config? config:"", f);
+    gg->AddToManifest(config, f);
     }
   if(!realName.empty())
     {
     f = dir;
     f += "/";
     f += realName;
-    gg->AddToManifest(config? config:"", f);
+    gg->AddToManifest(config, f);
     }
   if(!pdbName.empty())
     {
     f = dir;
     f += "/";
     f += pdbName;
-    gg->AddToManifest(config? config:"", f);
+    gg->AddToManifest(config, f);
     }
   if(!impName.empty())
     {
     f = this->Target->GetDirectory(config, true);
     f += "/";
     f += impName;
-    gg->AddToManifest(config? config:"", f);
+    gg->AddToManifest(config, f);
     }
 }
 
 bool cmStrictTargetComparison::operator()(cmTarget const* t1,
                                           cmTarget const* t2) const
 {
-  int nameResult = strcmp(t1->GetName(), t2->GetName());
+  int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
   if (nameResult == 0)
     {
     return strcmp(t1->GetMakefile()->GetStartOutputDirectory(),
@@ -876,3 +1067,97 @@
     }
   return nameResult < 0;
 }
+
+//----------------------------------------------------------------------------
+struct cmGeneratorTarget::SourceFileFlags
+cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
+{
+  struct SourceFileFlags flags;
+  this->ConstructSourceFileFlags();
+  std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
+    this->SourceFlagsMap.find(sf);
+  if(si != this->SourceFlagsMap.end())
+    {
+    flags = si->second;
+    }
+  else
+    {
+    // Handle the MACOSX_PACKAGE_LOCATION property on source files that
+    // were not listed in one of the other lists.
+    if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION"))
+      {
+      flags.MacFolder = location;
+      if(strcmp(location, "Resources") == 0)
+        {
+        flags.Type = cmGeneratorTarget::SourceFileTypeResource;
+        }
+      else
+        {
+        flags.Type = cmGeneratorTarget::SourceFileTypeMacContent;
+        }
+      }
+    }
+  return flags;
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::ConstructSourceFileFlags() const
+{
+  if(this->SourceFileFlagsConstructed)
+    {
+    return;
+    }
+  this->SourceFileFlagsConstructed = true;
+
+  // Process public headers to mark the source files.
+  if(const char* files = this->Target->GetProperty("PUBLIC_HEADER"))
+    {
+    std::vector<std::string> relFiles;
+    cmSystemTools::ExpandListArgument(files, relFiles);
+    for(std::vector<std::string>::iterator it = relFiles.begin();
+        it != relFiles.end(); ++it)
+      {
+      if(cmSourceFile* sf = this->Makefile->GetSource(*it))
+        {
+        SourceFileFlags& flags = this->SourceFlagsMap[sf];
+        flags.MacFolder = "Headers";
+        flags.Type = cmGeneratorTarget::SourceFileTypePublicHeader;
+        }
+      }
+    }
+
+  // Process private headers after public headers so that they take
+  // precedence if a file is listed in both.
+  if(const char* files = this->Target->GetProperty("PRIVATE_HEADER"))
+    {
+    std::vector<std::string> relFiles;
+    cmSystemTools::ExpandListArgument(files, relFiles);
+    for(std::vector<std::string>::iterator it = relFiles.begin();
+        it != relFiles.end(); ++it)
+      {
+      if(cmSourceFile* sf = this->Makefile->GetSource(*it))
+        {
+        SourceFileFlags& flags = this->SourceFlagsMap[sf];
+        flags.MacFolder = "PrivateHeaders";
+        flags.Type = cmGeneratorTarget::SourceFileTypePrivateHeader;
+        }
+      }
+    }
+
+  // Mark sources listed as resources.
+  if(const char* files = this->Target->GetProperty("RESOURCE"))
+    {
+    std::vector<std::string> relFiles;
+    cmSystemTools::ExpandListArgument(files, relFiles);
+    for(std::vector<std::string>::iterator it = relFiles.begin();
+        it != relFiles.end(); ++it)
+      {
+      if(cmSourceFile* sf = this->Makefile->GetSource(*it))
+        {
+        SourceFileFlags& flags = this->SourceFlagsMap[sf];
+        flags.MacFolder = "Resources";
+        flags.Type = cmGeneratorTarget::SourceFileTypeResource;
+        }
+      }
+    }
+}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index a4caba1..29aa410 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -27,54 +27,67 @@
   cmGeneratorTarget(cmTarget*);
 
   int GetType() const;
-  const char *GetName() const;
-  const char *GetProperty(const char *prop) const;
-  bool GetPropertyAsBool(const char *prop) const;
-  void GetSourceFiles(std::vector<cmSourceFile*>& files) const;
+  std::string GetName() const;
+  const char *GetProperty(const std::string& prop) const;
+  bool GetPropertyAsBool(const std::string& prop) const;
+  void GetSourceFiles(std::vector<cmSourceFile*>& files,
+                      const std::string& config) const;
 
-  void GetObjectSources(std::vector<cmSourceFile*> &) const;
+  void GetObjectSources(std::vector<cmSourceFile const*> &,
+                        const std::string& config) const;
   const std::string& GetObjectName(cmSourceFile const* file);
 
-  void AddObject(cmSourceFile *sf, std::string const&name);
   bool HasExplicitObjectName(cmSourceFile const* file) const;
-  void AddExplicitObjectName(cmSourceFile* sf);
+  void AddExplicitObjectName(cmSourceFile const* sf);
 
-  void GetResxSources(std::vector<cmSourceFile*>&) const;
-  void GetIDLSources(std::vector<cmSourceFile*>&) const;
-  void GetExternalObjects(std::vector<cmSourceFile*>&) const;
-  void GetHeaderSources(std::vector<cmSourceFile*>&) const;
-  void GetExtraSources(std::vector<cmSourceFile*>&) const;
-  void GetCustomCommands(std::vector<cmSourceFile*>&) const;
-  void GetExpectedResxHeaders(std::set<std::string>&) const;
+  void GetResxSources(std::vector<cmSourceFile const*>&,
+                      const std::string& config) const;
+  void GetIDLSources(std::vector<cmSourceFile const*>&,
+                     const std::string& config) const;
+  void GetExternalObjects(std::vector<cmSourceFile const*>&,
+                          const std::string& config) const;
+  void GetHeaderSources(std::vector<cmSourceFile const*>&,
+                        const std::string& config) const;
+  void GetExtraSources(std::vector<cmSourceFile const*>&,
+                       const std::string& config) const;
+  void GetCustomCommands(std::vector<cmSourceFile const*>&,
+                         const std::string& config) const;
+  void GetExpectedResxHeaders(std::set<std::string>&,
+                              const std::string& config) const;
+
+  void ComputeObjectMapping();
 
   cmTarget* Target;
   cmMakefile* Makefile;
   cmLocalGenerator* LocalGenerator;
   cmGlobalGenerator const* GlobalGenerator;
 
-  std::string ModuleDefinitionFile;
+  std::string GetModuleDefinitionFile(const std::string& config) const;
 
   /** Full path with trailing slash to the top-level directory
       holding object files for this target.  Includes the build
       time config name placeholder if needed for the generator.  */
   std::string ObjectDirectory;
 
-  void UseObjectLibraries(std::vector<std::string>& objs) const;
+  void UseObjectLibraries(std::vector<std::string>& objs,
+                          const std::string& config) const;
 
-  void GetAppleArchs(const char* config,
+  void GetAppleArchs(const std::string& config,
                      std::vector<std::string>& archVec) const;
 
-  ///! Return the rule variable used to create this type of target,
-  //  need to add CMAKE_(LANG) for full name.
-  const char* GetCreateRuleVariable() const;
+  /** Return the rule variable used to create this type of target.  */
+  std::string GetCreateRuleVariable(std::string const& lang,
+                                    std::string const& config) const;
 
   /** Get the include directories for this target.  */
-  std::vector<std::string> GetIncludeDirectories(const char *config) const;
+  std::vector<std::string> GetIncludeDirectories(
+      const std::string& config) const;
 
-  bool IsSystemIncludeDirectory(const char *dir, const char *config) const;
+  bool IsSystemIncludeDirectory(const std::string& dir,
+                                const std::string& config) const;
 
   /** Add the target output files to the global generator manifest.  */
-  void GenerateTargetManifest(const char* config) const;
+  void GenerateTargetManifest(const std::string& config) const;
 
   /**
    * Trace through the source files in this target and add al source files
@@ -82,31 +95,53 @@
    */
   void TraceDependencies();
 
-  void ClassifySources();
-  void LookupObjectLibraries();
-
   /** Get sources that must be built before the given source.  */
-  std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const;
+  std::vector<cmSourceFile*> const*
+  GetSourceDepends(cmSourceFile const* sf) const;
 
+  /**
+   * Flags for a given source file as used in this target. Typically assigned
+   * via SET_TARGET_PROPERTIES when the property is a list of source files.
+   */
+  enum SourceFileType
+  {
+    SourceFileTypeNormal,
+    SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
+    SourceFileTypePublicHeader,  // is in "PUBLIC_HEADER" target property
+    SourceFileTypeResource,      // is in "RESOURCE" target property *or*
+                                 // has MACOSX_PACKAGE_LOCATION=="Resources"
+    SourceFileTypeMacContent     // has MACOSX_PACKAGE_LOCATION!="Resources"
+  };
+  struct SourceFileFlags
+  {
+    SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
+    SourceFileFlags(SourceFileFlags const& r):
+      Type(r.Type), MacFolder(r.MacFolder) {}
+    SourceFileType Type;
+    const char* MacFolder; // location inside Mac content folders
+  };
+
+  struct SourceFileFlags
+  GetTargetSourceFileFlags(const cmSourceFile* sf) const;
+
+  struct ResxData {
+    mutable std::set<std::string> ExpectedResxHeaders;
+    mutable std::vector<cmSourceFile const*> ResxSources;
+  };
 private:
   friend class cmTargetTraceDependencies;
   struct SourceEntry { std::vector<cmSourceFile*> Depends; };
-  typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType;
+  typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
   SourceEntriesType SourceEntries;
 
-  std::vector<cmSourceFile*> CustomCommands;
-  std::vector<cmSourceFile*> ExtraSources;
-  std::vector<cmSourceFile*> HeaderSources;
-  std::vector<cmSourceFile*> ExternalObjects;
-  std::vector<cmSourceFile*> IDLSources;
-  std::vector<cmSourceFile*> ResxSources;
-  std::map<cmSourceFile const*, std::string> Objects;
+  mutable std::map<cmSourceFile const*, std::string> Objects;
   std::set<cmSourceFile const*> ExplicitObjectName;
-  std::set<std::string> ExpectedResxHeaders;
-  std::vector<cmSourceFile*> ObjectSources;
-  std::vector<cmTarget*> ObjectLibraries;
   mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
 
+  void ConstructSourceFileFlags() const;
+  mutable bool SourceFileFlagsConstructed;
+  mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
+
   cmGeneratorTarget(cmGeneratorTarget const&);
   void operator=(cmGeneratorTarget const&);
 };
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index e7ad91a..e88f498 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -49,10 +49,10 @@
     }
   else if ( args[1] == "COMPONENTS" )
     {
-    const std::set<cmStdString>* components
+    const std::set<std::string>* components
       = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
         ->GetInstallComponents();
-    std::set<cmStdString>::const_iterator compIt;
+    std::set<std::string>::const_iterator compIt;
     output = "";
     for (compIt = components->begin(); compIt != components->end(); ++compIt)
       {
@@ -66,14 +66,14 @@
   else
     {
     const char *prop =
-      this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str());
+      this->Makefile->GetCMakeInstance()->GetProperty(args[1]);
     if (prop)
       {
       output = prop;
       }
     }
 
-  this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+  this->Makefile->AddDefinition(variable, output.c_str());
 
   return true;
 }
diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h
index 6c58bb4..1511406 100644
--- a/Source/cmGetCMakePropertyCommand.h
+++ b/Source/cmGetCMakePropertyCommand.h
@@ -37,7 +37,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "get_cmake_property";}
+  virtual std::string GetName() const { return "get_cmake_property";}
 
   cmTypeMacro(cmGetCMakePropertyCommand, cmCommand);
 };
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index 9e76e1b..fcc3da1 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -54,7 +54,7 @@
     // lookup the makefile from the directory name
     cmLocalGenerator *lg =
       this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
-      FindLocalGenerator(sd.c_str());
+      FindLocalGenerator(sd);
     if (!lg)
       {
       this->SetError
@@ -79,18 +79,18 @@
                      "providing the name of the variable to get.");
       return false;
       }
-    output = dir->GetSafeDefinition(i->c_str());
-    this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+    output = dir->GetSafeDefinition(*i);
+    this->Makefile->AddDefinition(variable, output.c_str());
     return true;
     }
 
-  const char *prop = dir->GetProperty(i->c_str());
+  const char *prop = dir->GetProperty(*i);
   if (prop)
     {
-    this->Makefile->AddDefinition(variable.c_str(), prop);
+    this->Makefile->AddDefinition(variable, prop);
     return true;
     }
-  this->Makefile->AddDefinition(variable.c_str(), "");
+  this->Makefile->AddDefinition(variable, "");
   return true;
 }
 
diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h
index aea04ad..6c5750a 100644
--- a/Source/cmGetDirectoryPropertyCommand.h
+++ b/Source/cmGetDirectoryPropertyCommand.h
@@ -37,7 +37,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "get_directory_property";}
+  virtual std::string GetName() const { return "get_directory_property";}
 
   cmTypeMacro(cmGetDirectoryPropertyCommand, cmCommand);
 };
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index 1d7fefc..10406d2 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -26,7 +26,7 @@
   // already, if so use that value
   if(args.size() == 4 && args[3] == "CACHE")
     {
-    const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str());
+    const char* cacheValue = this->Makefile->GetDefinition(args[0]);
     if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
       {
       return true;
@@ -107,7 +107,7 @@
   else
     {
     std::string err = "unknown component " + args[2];
-    this->SetError(err.c_str());
+    this->SetError(err);
     return false;
     }
 
@@ -116,12 +116,12 @@
     if(programArgs.size() && storeArgs.size())
       {
       this->Makefile->AddCacheDefinition
-        (storeArgs.c_str(), programArgs.c_str(),
+        (storeArgs, programArgs.c_str(),
          "", args[2] == "PATH" ? cmCacheManager::FILEPATH
          : cmCacheManager::STRING);
       }
     this->Makefile->AddCacheDefinition
-      (args[0].c_str(), result.c_str(), "",
+      (args[0], result.c_str(), "",
        args[2] == "PATH" ? cmCacheManager::FILEPATH
        : cmCacheManager::STRING);
     }
@@ -129,9 +129,9 @@
     {
     if(programArgs.size() && storeArgs.size())
       {
-      this->Makefile->AddDefinition(storeArgs.c_str(), programArgs.c_str());
+      this->Makefile->AddDefinition(storeArgs, programArgs.c_str());
       }
-    this->Makefile->AddDefinition(args[0].c_str(), result.c_str());
+    this->Makefile->AddDefinition(args[0], result.c_str());
     }
 
   return true;
diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h
index e2cd219..534de53 100644
--- a/Source/cmGetFilenameComponentCommand.h
+++ b/Source/cmGetFilenameComponentCommand.h
@@ -46,7 +46,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "get_filename_component";}
+  virtual std::string GetName() const { return "get_filename_component";}
 
   cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);
 };
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 810802a..9a88191 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -67,13 +67,17 @@
     {
     scope = cmProperty::CACHE;
     }
+  else if(args[1] == "INSTALL")
+    {
+    scope = cmProperty::INSTALL;
+    }
   else
     {
     cmOStringStream e;
     e << "given invalid scope " << args[1] << ".  "
       << "Valid scopes are "
-      << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE.";
-    this->SetError(e.str().c_str());
+      << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL.";
+    this->SetError(e.str());
     return false;
     }
 
@@ -120,7 +124,7 @@
       {
       cmOStringStream e;
       e << "given invalid argument \"" << args[i] << "\".";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -139,7 +143,7 @@
     std::string output;
     if(cmPropertyDefinition* def =
        this->Makefile->GetCMakeInstance()->
-       GetPropertyDefinition(this->PropertyName.c_str(), scope))
+       GetPropertyDefinition(this->PropertyName, scope))
       {
       output = def->GetShortDescription();
       }
@@ -147,7 +151,7 @@
       {
       output = "NOTFOUND";
       }
-    this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str());
+    this->Makefile->AddDefinition(this->Variable, output.c_str());
     }
   else if(this->InfoType == OutFullDoc)
     {
@@ -155,7 +159,7 @@
     std::string output;
     if(cmPropertyDefinition* def =
        this->Makefile->GetCMakeInstance()->
-       GetPropertyDefinition(this->PropertyName.c_str(), scope))
+       GetPropertyDefinition(this->PropertyName, scope))
       {
       output = def->GetFullDescription();
       }
@@ -163,19 +167,19 @@
       {
       output = "NOTFOUND";
       }
-    this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str());
+    this->Makefile->AddDefinition(this->Variable, output.c_str());
     }
   else if(this->InfoType == OutDefined)
     {
     // Lookup if the property is defined
     if(this->Makefile->GetCMakeInstance()->
-       GetPropertyDefinition(this->PropertyName.c_str(), scope))
+       GetPropertyDefinition(this->PropertyName, scope))
       {
-      this->Makefile->AddDefinition(this->Variable.c_str(), "1");
+      this->Makefile->AddDefinition(this->Variable, "1");
       }
     else
       {
-      this->Makefile->AddDefinition(this->Variable.c_str(), "0");
+      this->Makefile->AddDefinition(this->Variable, "0");
       }
     }
   else
@@ -190,6 +194,7 @@
       case cmProperty::TEST:        return this->HandleTestMode();
       case cmProperty::VARIABLE:    return this->HandleVariableMode();
       case cmProperty::CACHE:       return this->HandleCacheMode();
+      case cmProperty::INSTALL:       return this->HandleInstallMode();
 
       case cmProperty::CACHED_VARIABLE:
         break; // should never happen
@@ -204,17 +209,17 @@
 {
   if(this->InfoType == OutSet)
     {
-    this->Makefile->AddDefinition(this->Variable.c_str(), value? "1":"0");
+    this->Makefile->AddDefinition(this->Variable, value? "1":"0");
     }
   else // if(this->InfoType == OutValue)
     {
     if(value)
       {
-      this->Makefile->AddDefinition(this->Variable.c_str(), value);
+      this->Makefile->AddDefinition(this->Variable, value);
       }
     else
       {
-      this->Makefile->RemoveDefinition(this->Variable.c_str());
+      this->Makefile->RemoveDefinition(this->Variable);
       }
     }
   return true;
@@ -231,7 +236,7 @@
 
   // Get the property.
   cmake* cm = this->Makefile->GetCMakeInstance();
-  return this->StoreResult(cm->GetProperty(this->PropertyName.c_str()));
+  return this->StoreResult(cm->GetProperty(this->PropertyName));
 }
 
 //----------------------------------------------------------------------------
@@ -259,7 +264,7 @@
     // Lookup the generator.
     if(cmLocalGenerator* lg =
        (this->Makefile->GetLocalGenerator()
-        ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str())))
+        ->GetGlobalGenerator()->FindLocalGenerator(dir)))
       {
       // Use the makefile for the directory found.
       mf = lg->GetMakefile();
@@ -276,7 +281,7 @@
     }
 
   // Get the property.
-  return this->StoreResult(mf->GetProperty(this->PropertyName.c_str()));
+  return this->StoreResult(mf->GetProperty(this->PropertyName));
 }
 
 //----------------------------------------------------------------------------
@@ -295,14 +300,14 @@
       if(cmTarget* target =
                           this->Makefile->FindTargetToUse(this->Name))
         {
-        return this->StoreResult(target->GetName());
+        return this->StoreResult(target->GetName().c_str());
         }
       }
     return this->StoreResult((this->Variable + "-NOTFOUND").c_str());
     }
   if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name))
     {
-    return this->StoreResult(target->GetProperty(this->PropertyName.c_str(),
+    return this->StoreResult(target->GetProperty(this->PropertyName,
                                                  this->Makefile));
     }
   else
@@ -310,7 +315,7 @@
     cmOStringStream e;
     e << "could not find TARGET " << this->Name
       << ".  Perhaps it has not yet been created.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 }
@@ -326,17 +331,17 @@
 
   // Get the source file.
   if(cmSourceFile* sf =
-     this->Makefile->GetOrCreateSource(this->Name.c_str()))
+     this->Makefile->GetOrCreateSource(this->Name))
     {
     return
-      this->StoreResult(sf->GetPropertyForUser(this->PropertyName.c_str()));
+      this->StoreResult(sf->GetPropertyForUser(this->PropertyName));
     }
   else
     {
     cmOStringStream e;
     e << "given SOURCE name that could not be found or created: "
       << this->Name;
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 }
@@ -351,15 +356,15 @@
     }
 
   // Loop over all tests looking for matching names.
-  if(cmTest* test = this->Makefile->GetTest(this->Name.c_str()))
+  if(cmTest* test = this->Makefile->GetTest(this->Name))
     {
-    return this->StoreResult(test->GetProperty(this->PropertyName.c_str()));
+    return this->StoreResult(test->GetProperty(this->PropertyName));
     }
 
   // If not found it is an error.
   cmOStringStream e;
   e << "given TEST name that does not exist: " << this->Name;
-  this->SetError(e.str().c_str());
+  this->SetError(e.str());
   return false;
 }
 
@@ -373,7 +378,7 @@
     }
 
   return this->StoreResult
-    (this->Makefile->GetDefinition(this->PropertyName.c_str()));
+    (this->Makefile->GetDefinition(this->PropertyName));
 }
 
 //----------------------------------------------------------------------------
@@ -390,8 +395,38 @@
     this->Makefile->GetCacheManager()->GetCacheIterator(this->Name.c_str());
   if(!it.IsAtEnd())
     {
-    value = it.GetProperty(this->PropertyName.c_str());
+    value = it.GetProperty(this->PropertyName);
     }
   this->StoreResult(value);
   return true;
 }
+
+//----------------------------------------------------------------------------
+bool cmGetPropertyCommand::HandleInstallMode()
+{
+  if(this->Name.empty())
+    {
+    this->SetError("not given name for INSTALL scope.");
+    return false;
+    }
+
+  // Get the installed file.
+  cmake* cm = this->Makefile->GetCMakeInstance();
+
+  if(cmInstalledFile* file = cm->GetOrCreateInstalledFile(
+    this->Makefile, this->Name))
+    {
+    std::string value;
+    bool isSet = file->GetProperty(this->PropertyName, value);
+
+    return this->StoreResult(isSet ? value.c_str() : 0);
+    }
+  else
+    {
+    cmOStringStream e;
+    e << "given INSTALL name that could not be found or created: "
+      << this->Name;
+    this->SetError(e.str());
+    return false;
+    }
+}
diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h
index e1630ff..40b7dbc 100644
--- a/Source/cmGetPropertyCommand.h
+++ b/Source/cmGetPropertyCommand.h
@@ -39,7 +39,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "get_property";}
+  virtual std::string GetName() const { return "get_property";}
 
   cmTypeMacro(cmGetPropertyCommand, cmCommand);
 private:
@@ -60,6 +60,7 @@
   bool HandleTestMode();
   bool HandleVariableMode();
   bool HandleCacheMode();
+  bool HandleInstallMode();
 };
 
 #endif
diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx
index 3d85e6d..8a96289 100644
--- a/Source/cmGetSourceFilePropertyCommand.cxx
+++ b/Source/cmGetSourceFilePropertyCommand.cxx
@@ -35,10 +35,10 @@
     {
     if(args[2] == "LANGUAGE")
       {
-      this->Makefile->AddDefinition(var, sf->GetLanguage());
+      this->Makefile->AddDefinition(var, sf->GetLanguage().c_str());
       return true;
       }
-    const char *prop = sf->GetPropertyForUser(args[2].c_str());
+    const char *prop = sf->GetPropertyForUser(args[2]);
     if (prop)
       {
       this->Makefile->AddDefinition(var, prop);
diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h
index 338318e..ab8ce36 100644
--- a/Source/cmGetSourceFilePropertyCommand.h
+++ b/Source/cmGetSourceFilePropertyCommand.h
@@ -32,7 +32,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "get_source_file_property";}
+  virtual std::string GetName() const { return "get_source_file_property";}
 
   cmTypeMacro(cmGetSourceFilePropertyCommand, cmCommand);
 };
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 272607e..aa6f0c1 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -20,9 +20,9 @@
     this->SetError("called with incorrect number of arguments");
     return false;
     }
-  std::string var = args[0].c_str();
+  std::string var = args[0];
   const std::string& targetName = args[1];
-  const char *prop = 0;
+  std::string prop;
 
   if(args[2] == "ALIASED_TARGET")
     {
@@ -38,7 +38,11 @@
   else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
     {
     cmTarget& target = *tgt;
-    prop = target.GetProperty(args[2].c_str(), this->Makefile);
+    const char* prop_cstr = target.GetProperty(args[2], this->Makefile);
+    if(prop_cstr)
+      {
+      prop = prop_cstr;
+      }
     }
   else
     {
@@ -63,19 +67,19 @@
       {
       e << "get_target_property() called with non-existent target \""
         << targetName <<  "\".";
-      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      this->Makefile->IssueMessage(messageType, e.str());
       if (messageType == cmake::FATAL_ERROR)
         {
         return false;
         }
       }
     }
-  if (prop)
+  if (!prop.empty())
     {
-    this->Makefile->AddDefinition(var.c_str(), prop);
+    this->Makefile->AddDefinition(var, prop.c_str());
     return true;
     }
-  this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str());
+  this->Makefile->AddDefinition(var, (var+"-NOTFOUND").c_str());
   return true;
 }
 
diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h
index 4985b3c..a35c6fe 100644
--- a/Source/cmGetTargetPropertyCommand.h
+++ b/Source/cmGetTargetPropertyCommand.h
@@ -32,7 +32,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "get_target_property";}
+  virtual std::string GetName() const { return "get_target_property";}
 
   cmTypeMacro(cmGetTargetPropertyCommand, cmCommand);
 };
diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx
index 0e0e2c0..b3df4c3 100644
--- a/Source/cmGetTestPropertyCommand.cxx
+++ b/Source/cmGetTestPropertyCommand.cxx
@@ -26,17 +26,17 @@
 
   std::string testName = args[0];
   std::string var = args[2];
-  cmTest *test = this->Makefile->GetTest(testName.c_str());
+  cmTest *test = this->Makefile->GetTest(testName);
   if (test)
     {
-    const char *prop = test->GetProperty(args[1].c_str());
+    const char *prop = test->GetProperty(args[1]);
     if (prop)
       {
-      this->Makefile->AddDefinition(var.c_str(), prop);
+      this->Makefile->AddDefinition(var, prop);
       return true;
       }
     }
-  this->Makefile->AddDefinition(var.c_str(), "NOTFOUND");
+  this->Makefile->AddDefinition(var, "NOTFOUND");
   return true;
 }
 
diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h
index 2dccabe..2819492 100644
--- a/Source/cmGetTestPropertyCommand.h
+++ b/Source/cmGetTestPropertyCommand.h
@@ -32,7 +32,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "get_test_property";}
+  virtual std::string GetName() const { return "get_test_property";}
 
   cmTypeMacro(cmGetTestPropertyCommand, cmCommand);
 };
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index 70004ea..470dea4 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -28,9 +28,9 @@
       <cmGlobalBorlandMakefileGenerator>(); }
 
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalBorlandMakefileGenerator::GetActualName();}
-  static const char* GetActualName() {return "Borland Makefiles";}
+  static std::string GetActualName() {return "Borland Makefiles";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index beb10da..6c8be72 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -28,6 +28,7 @@
 #include "cmGeneratorExpression.h"
 #include "cmGeneratorExpressionEvaluationFile.h"
 #include "cmExportBuildFileGenerator.h"
+#include "cmCPackPropertiesGenerator.h"
 
 #include <cmsys/Directory.hxx>
 #include <cmsys/FStream.hxx>
@@ -75,7 +76,8 @@
     }
 }
 
-bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts)
+bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
+                                            cmMakefile* mf)
 {
   cmOStringStream e;
   e <<
@@ -84,24 +86,29 @@
     "does not support toolset specification, but toolset\n"
     "  " << ts << "\n"
     "was specified.";
-  this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                                    cmListFileBacktrace());
+  mf->IssueMessage(cmake::FATAL_ERROR, e.str());
   return false;
 }
 
-std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram,
-                                                 std::string makeDefault) const
+std::string cmGlobalGenerator::SelectMakeProgram(
+                                          const std::string& inMakeProgram,
+                                          const std::string& makeDefault) const
 {
-  if(cmSystemTools::IsOff(makeProgram))
+  std::string makeProgram = inMakeProgram;
+  if(cmSystemTools::IsOff(makeProgram.c_str()))
     {
-    makeProgram =
+    const char* makeProgramCSTR =
       this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
-    if(cmSystemTools::IsOff(makeProgram))
+    if(cmSystemTools::IsOff(makeProgramCSTR))
       {
-      makeProgram = makeDefault.c_str();
+      makeProgram = makeDefault;
       }
-    if(cmSystemTools::IsOff(makeProgram) &&
-       !(makeProgram && *makeProgram))
+    else
+      {
+      makeProgram = makeProgramCSTR;
+      }
+    if(cmSystemTools::IsOff(makeProgram.c_str()) &&
+       !makeProgram.empty())
       {
       makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND";
       }
@@ -117,7 +124,7 @@
   langComp += lang;
   langComp += "_COMPILER";
 
-  if(!mf->GetDefinition(langComp.c_str()))
+  if(!mf->GetDefinition(langComp))
     {
     if(!optional)
       {
@@ -126,7 +133,7 @@
       }
     return;
     }
-  const char* name = mf->GetRequiredDefinition(langComp.c_str());
+  const char* name = mf->GetRequiredDefinition(langComp);
   std::string path;
   if(!cmSystemTools::FileIsFullPath(name))
     {
@@ -144,7 +151,7 @@
   std::string doc = lang;
   doc += " compiler.";
   const char* cname = this->GetCMakeInstance()->
-    GetCacheManager()->GetCacheValue(langComp.c_str());
+    GetCacheManager()->GetCacheValue(langComp);
   std::string changeVars;
   if(cname && !optional)
     {
@@ -179,7 +186,7 @@
         changeVars.c_str());
       }
     }
-  mf->AddCacheDefinition(langComp.c_str(), path.c_str(),
+  mf->AddCacheDefinition(langComp, path.c_str(),
                          doc.c_str(), cmCacheManager::FILEPATH);
 }
 
@@ -210,6 +217,11 @@
   return false;
 }
 
+void cmGlobalGenerator::ForceLinkerLanguages()
+{
+
+}
+
 bool
 cmGlobalGenerator::IsExportedTargetsFile(const std::string &filename) const
 {
@@ -308,6 +320,9 @@
 //   CMakeSystem.cmake - configured file created by
 //                       CMakeDetermineSystem.cmake IF CMAKE_SYSTEM_LOADED
 
+// CMakeSystemSpecificInitialize.cmake
+//   - includes Platform/${CMAKE_SYSTEM_NAME}-Initialize.cmake
+
 // Next try and enable all languages found in the languages vector
 //
 // FOREACH LANG in languages
@@ -432,8 +447,29 @@
     fpath += "/CMakeSystem.cmake";
     mf->ReadListFile(0,fpath.c_str());
     }
-  std::map<cmStdString, bool> needTestLanguage;
-  std::map<cmStdString, bool> needSetLanguageEnabledMaps;
+
+  // Tell the generator about the toolset, if any.
+  std::string toolset = mf->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET");
+  if(!toolset.empty() &&
+     !this->SetGeneratorToolset(toolset, mf))
+    {
+    cmSystemTools::SetFatalErrorOccured();
+    return;
+    }
+
+  // **** Load the system specific initialization if not yet loaded
+  if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED"))
+    {
+    fpath = mf->GetModulesFile("CMakeSystemSpecificInitialize.cmake");
+    if(!mf->ReadListFile(0,fpath.c_str()))
+      {
+      cmSystemTools::Error("Could not find cmake module file: ",
+                           fpath.c_str());
+      }
+    }
+
+  std::map<std::string, bool> needTestLanguage;
+  std::map<std::string, bool> needSetLanguageEnabledMaps;
   // foreach language
   // load the CMakeDetermine(LANG)Compiler.cmake file to find
   // the compiler
@@ -451,7 +487,7 @@
     std::string loadedLang = "CMAKE_";
     loadedLang +=  lang;
     loadedLang += "_COMPILER_LOADED";
-    if(!mf->GetDefinition(loadedLang.c_str()))
+    if(!mf->GetDefinition(loadedLang))
       {
       fpath = rootBin;
       fpath += "/CMake";
@@ -512,9 +548,9 @@
         std::string compilerEnv = "CMAKE_";
         compilerEnv += lang;
         compilerEnv += "_COMPILER_ENV_VAR";
-        std::string envVar = mf->GetRequiredDefinition(compilerEnv.c_str());
+        std::string envVar = mf->GetRequiredDefinition(compilerEnv);
         std::string envVarValue =
-          mf->GetRequiredDefinition(compilerName.c_str());
+          mf->GetRequiredDefinition(compilerName);
         std::string env = envVar;
         env += "=";
         env += envVarValue;
@@ -572,7 +608,7 @@
     compilerEnv += lang;
     compilerEnv += "_COMPILER_ENV_VAR";
     cmOStringStream noCompiler;
-    const char* compilerFile = mf->GetDefinition(compilerName.c_str());
+    const char* compilerFile = mf->GetDefinition(compilerName);
     if(!compilerFile || !*compilerFile ||
        cmSystemTools::IsNOTFOUND(compilerFile))
       {
@@ -615,7 +651,7 @@
         if(!this->CMakeInstance->GetIsInTryCompile())
           {
           this->PrintCompilerAdvice(noCompiler, lang,
-                                    mf->GetDefinition(compilerEnv.c_str()));
+                                    mf->GetDefinition(compilerEnv));
           mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str());
           fatalError = true;
           }
@@ -625,7 +661,7 @@
     std::string langLoadedVar = "CMAKE_";
     langLoadedVar += lang;
     langLoadedVar += "_INFORMATION_LOADED";
-    if (!mf->GetDefinition(langLoadedVar.c_str()))
+    if (!mf->GetDefinition(langLoadedVar))
       {
       fpath = "CMake";
       fpath +=  lang;
@@ -672,7 +708,7 @@
         // if the compiler did not work, then remove the
         // CMake(LANG)Compiler.cmake file so that it will get tested the
         // next time cmake is run
-        if(!mf->IsOn(compilerWorks.c_str()))
+        if(!mf->IsOn(compilerWorks))
           {
           std::string compilerLangFile = rootBin;
           compilerLangFile += "/CMake";
@@ -687,7 +723,7 @@
     sharedLibFlagsVar += lang;
     sharedLibFlagsVar += "_FLAGS";
     const char* sharedLibFlags =
-      mf->GetSafeDefinition(sharedLibFlagsVar.c_str());
+      mf->GetSafeDefinition(sharedLibFlagsVar);
     if (sharedLibFlags)
       {
       this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags;
@@ -722,7 +758,7 @@
 
 //----------------------------------------------------------------------------
 void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os,
-                                            std::string lang,
+                                            std::string const& lang,
                                             const char* envVar) const
 {
   // Subclasses override this method if they do not support this advice.
@@ -744,10 +780,10 @@
 
 //----------------------------------------------------------------------------
 void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
-                                                     std::string lang) const
+                                                std::string const& lang) const
 {
   std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
-  const char* compilerId = mf->GetDefinition(compilerIdVar.c_str());
+  const char* compilerId = mf->GetDefinition(compilerIdVar);
   if(!compilerId)
     {
     return;
@@ -771,7 +807,7 @@
           }
       case cmPolicies::OLD:
         // OLD behavior is to convert AppleClang to Clang.
-        mf->AddDefinition(compilerIdVar.c_str(), "Clang");
+        mf->AddDefinition(compilerIdVar, "Clang");
         break;
       case cmPolicies::REQUIRED_IF_USED:
       case cmPolicies::REQUIRED_ALWAYS:
@@ -803,7 +839,7 @@
           }
       case cmPolicies::OLD:
         // OLD behavior is to convert QCC to GNU.
-        mf->AddDefinition(compilerIdVar.c_str(), "GNU");
+        mf->AddDefinition(compilerIdVar, "GNU");
         break;
       case cmPolicies::REQUIRED_IF_USED:
       case cmPolicies::REQUIRED_ALWAYS:
@@ -819,17 +855,18 @@
 }
 
 //----------------------------------------------------------------------------
-const char*
+std::string
 cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const
 {
-  if(const char* lang = source.GetLanguage())
+  const std::string& lang = source.GetLanguage();
+  if(!lang.empty())
     {
-    std::map<cmStdString, cmStdString>::const_iterator it =
+    std::map<std::string, std::string>::const_iterator it =
                                   this->LanguageToOutputExtension.find(lang);
 
     if(it != this->LanguageToOutputExtension.end())
       {
-      return it->second.c_str();
+      return it->second;
       }
     }
   else
@@ -842,7 +879,7 @@
       {
       if(this->OutputExtensions.count(ext))
         {
-        return ext.c_str();
+        return ext;
         }
       }
     }
@@ -850,7 +887,7 @@
 }
 
 
-const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
+std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
 {
   // if there is an extension and it starts with . then move past the
   // . because the extensions are not stored with a .  in the map
@@ -858,13 +895,13 @@
     {
     ++ext;
     }
-  std::map<cmStdString, cmStdString>::const_iterator it
+  std::map<std::string, std::string>::const_iterator it
                                         = this->ExtensionToLanguage.find(ext);
   if(it != this->ExtensionToLanguage.end())
     {
-    return it->second.c_str();
+    return it->second;
     }
-  return 0;
+  return "";
 }
 
 /* SetLanguageEnabled() is now split in two parts:
@@ -879,13 +916,15 @@
 (CMAKE_<LANG>_OUTPUT_EXTENSION) before the CMake variables were copied
 to the C++ maps.
 */
-void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
+void cmGlobalGenerator::SetLanguageEnabled(const std::string& l,
+                                           cmMakefile* mf)
 {
   this->SetLanguageEnabledFlag(l, mf);
   this->SetLanguageEnabledMaps(l, mf);
 }
 
-void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf)
+void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l,
+                                               cmMakefile* mf)
 {
   this->LanguageEnabled[l] = true;
 
@@ -897,7 +936,8 @@
   this->FillExtensionToLanguageMap(l, mf);
 }
 
-void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
+void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
+                                               cmMakefile* mf)
 {
   // use LanguageToLinkerPreference to detect whether this functions has
   // run before
@@ -909,7 +949,7 @@
 
   std::string linkerPrefVar = std::string("CMAKE_") +
     std::string(l) + std::string("_LINKER_PREFERENCE");
-  const char* linkerPref = mf->GetDefinition(linkerPrefVar.c_str());
+  const char* linkerPref = mf->GetDefinition(linkerPrefVar);
   int preference = 0;
   if(linkerPref)
     {
@@ -942,7 +982,7 @@
 
   std::string outputExtensionVar = std::string("CMAKE_") +
     std::string(l) + std::string("_OUTPUT_EXTENSION");
-  const char* outputExtension = mf->GetDefinition(outputExtensionVar.c_str());
+  const char* outputExtension = mf->GetDefinition(outputExtensionVar);
   if(outputExtension)
     {
     this->LanguageToOutputExtension[l] = outputExtension;
@@ -960,7 +1000,7 @@
 
   std::string ignoreExtensionsVar = std::string("CMAKE_") +
     std::string(l) + std::string("_IGNORE_EXTENSIONS");
-  std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar.c_str());
+  std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar);
   std::vector<std::string> extensionList;
   cmSystemTools::ExpandListArgument(ignoreExts, extensionList);
   for(std::vector<std::string>::iterator i = extensionList.begin();
@@ -971,12 +1011,12 @@
 
 }
 
-void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l,
+void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
                                                    cmMakefile* mf)
 {
   std::string extensionsVar = std::string("CMAKE_") +
     std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS");
-  std::string exts = mf->GetSafeDefinition(extensionsVar.c_str());
+  std::string exts = mf->GetSafeDefinition(extensionsVar);
   std::vector<std::string> extensionList;
   cmSystemTools::ExpandListArgument(exts, extensionList);
   for(std::vector<std::string>::iterator i = extensionList.begin();
@@ -986,16 +1026,16 @@
     }
 }
 
-bool cmGlobalGenerator::IgnoreFile(const char* l) const
+bool cmGlobalGenerator::IgnoreFile(const char* ext) const
 {
-  if(this->GetLanguageFromExtension(l))
+  if(!this->GetLanguageFromExtension(ext).empty())
     {
     return false;
     }
-  return (this->IgnoreExtensions.count(l) > 0);
+  return (this->IgnoreExtensions.count(ext) > 0);
 }
 
-bool cmGlobalGenerator::GetLanguageEnabled(const char* l) const
+bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const
 {
   return (this->LanguageEnabled.find(l)!= this->LanguageEnabled.end());
 }
@@ -1005,11 +1045,11 @@
   this->LanguageEnabled.clear();
 }
 
-bool cmGlobalGenerator::IsDependedOn(const char* project,
+bool cmGlobalGenerator::IsDependedOn(const std::string& project,
                                      cmTarget const* targetIn)
 {
   // Get all local gens for this project
-  std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator it =
+  std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it =
                                               this->ProjectMap.find(project);
   if (it == this->ProjectMap.end())
     {
@@ -1150,12 +1190,6 @@
     return;
     }
 
-  // Check that all targets are valid.
-  if(!this->CheckTargets())
-    {
-    return;
-    }
-
   this->FinalizeTargetCompileInfo();
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
@@ -1192,6 +1226,8 @@
   // Create per-target generator information.
   this->CreateGeneratorTargets();
 
+  this->ForceLinkerLanguages();
+
 #ifdef CMAKE_BUILD_WITH_CMAKE
   for (AutogensType::iterator it = autogens.begin(); it != autogens.end();
        ++it)
@@ -1213,8 +1249,6 @@
     this->LocalGenerators[i]->GenerateTargetManifest();
     }
 
-  this->ComputeGeneratorTargetObjects();
-
   this->ProcessEvaluationFiles();
 
   // Compute the inter-target dependencies.
@@ -1245,6 +1279,12 @@
     }
   this->SetCurrentLocalGenerator(0);
 
+  if(!this->GenerateCPackPropertiesFile())
+    {
+    this->GetCMakeInstance()->IssueMessage(
+      cmake::FATAL_ERROR, "Could not write CPack properties file.");
+    }
+
   for (std::map<std::string, cmExportBuildFileGenerator*>::iterator
       it = this->BuildExportSets.begin(); it != this->BuildExportSets.end();
       ++it)
@@ -1253,8 +1293,7 @@
         && !cmSystemTools::GetErrorOccuredFlag())
       {
       this->GetCMakeInstance()
-          ->IssueMessage(cmake::FATAL_ERROR, "Could not write export file.",
-                        cmListFileBacktrace());
+          ->IssueMessage(cmake::FATAL_ERROR, "Could not write export file.");
       return;
       }
     }
@@ -1283,8 +1322,7 @@
       {
       w << " " << *iter << "\n";
       }
-    this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
-                                           cmListFileBacktrace());
+    this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
     }
 
   this->CMakeInstance->UpdateProgress("Generating done", -1);
@@ -1308,35 +1346,6 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmGlobalGenerator::CheckTargets()
-{
-  // Make sure all targets can find their source files.
-  for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
-    {
-    cmTargets& targets =
-      this->LocalGenerators[i]->GetMakefile()->GetTargets();
-    for(cmTargets::iterator ti = targets.begin();
-        ti != targets.end(); ++ti)
-      {
-      cmTarget& target = ti->second;
-      if(target.GetType() == cmTarget::EXECUTABLE ||
-         target.GetType() == cmTarget::STATIC_LIBRARY ||
-         target.GetType() == cmTarget::SHARED_LIBRARY ||
-         target.GetType() == cmTarget::MODULE_LIBRARY ||
-         target.GetType() == cmTarget::OBJECT_LIBRARY ||
-         target.GetType() == cmTarget::UTILITY)
-        {
-        if(!target.FindSourceFiles())
-          {
-          return false;
-          }
-        }
-      }
-    }
-  return true;
-}
-
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
@@ -1416,8 +1425,8 @@
           {
           std::string defPropName = "COMPILE_DEFINITIONS_";
           defPropName += cmSystemTools::UpperCase(*ci);
-          t->AppendProperty(defPropName.c_str(),
-                            mf->GetProperty(defPropName.c_str()));
+          t->AppendProperty(defPropName,
+                            mf->GetProperty(defPropName));
           }
         }
       }
@@ -1434,6 +1443,7 @@
     {
     cmTarget* t = &ti->second;
     cmGeneratorTarget* gt = new cmGeneratorTarget(t);
+    this->ComputeTargetObjectDirectory(gt);
     this->GeneratorTargets[t] = gt;
     generatorTargets[t] = gt;
     }
@@ -1459,29 +1469,6 @@
     }
 }
 
-//----------------------------------------------------------------------------
-void cmGlobalGenerator::ComputeGeneratorTargetObjects()
-{
-  // Construct per-target generator information.
-  for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
-    {
-    cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
-    cmGeneratorTargetsType targets = mf->GetGeneratorTargets();
-    for(cmGeneratorTargetsType::iterator ti = targets.begin();
-        ti != targets.end(); ++ti)
-      {
-      if (ti->second->Target->IsImported()
-          || ti->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
-        {
-        continue;
-        }
-      cmGeneratorTarget* gt = ti->second;
-      gt->ClassifySources();
-      gt->LookupObjectLibraries();
-      this->ComputeTargetObjects(gt);
-      }
-    }
-}
 
 //----------------------------------------------------------------------------
 void cmGlobalGenerator::ClearGeneratorMembers()
@@ -1535,23 +1522,21 @@
   if(ti == this->GeneratorTargets.end())
     {
     this->CMakeInstance->IssueMessage(
-      cmake::INTERNAL_ERROR, "Missing cmGeneratorTarget instance!",
-      cmListFileBacktrace());
+      cmake::INTERNAL_ERROR, "Missing cmGeneratorTarget instance!");
     return 0;
     }
   return ti->second;
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const
+void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
 {
-  // Implemented in generator subclasses that need this.
 }
 
 void cmGlobalGenerator::CheckLocalGenerators()
 {
-  std::map<cmStdString, cmStdString> notFoundMap;
-//  std::set<cmStdString> notFoundMap;
+  std::map<std::string, std::string> notFoundMap;
+//  std::set<std::string> notFoundMap;
   // after it is all done do a ConfigureFinalPass
   cmCacheManager* manager = 0;
   for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
@@ -1600,7 +1585,7 @@
       std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp,
                         cmGeneratorExpression::StripAllGeneratorExpressions);
 
-      cmSystemTools::ExpandListArgument(incDirs.c_str(), incs);
+      cmSystemTools::ExpandListArgument(incDirs, incs);
 
       for( std::vector<std::string>::const_iterator incDir = incs.begin();
             incDir != incs.end(); ++incDir)
@@ -1631,7 +1616,7 @@
   if(notFoundMap.size())
     {
     std::string notFoundVars;
-    for(std::map<cmStdString, cmStdString>::const_iterator
+    for(std::map<std::string, std::string>::const_iterator
         ii = notFoundMap.begin();
         ii != notFoundMap.end();
         ++ii)
@@ -1648,9 +1633,10 @@
     }
 }
 
-int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
-                                  const char *projectName,
-                                  const char *target, bool fast,
+int cmGlobalGenerator::TryCompile(const std::string& srcdir,
+                                  const std::string& bindir,
+                                  const std::string& projectName,
+                                  const std::string& target, bool fast,
                                   std::string *output, cmMakefile *mf)
 {
   // if this is not set, then this is a first time configure
@@ -1674,7 +1660,7 @@
     }
 
   std::string newTarget;
-  if (target && strlen(target))
+  if (!target.empty())
     {
     newTarget += target;
 #if 0
@@ -1689,27 +1675,30 @@
 #endif // WIN32
 #endif
     }
-  const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
+  std::string config =
+    mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
   return this->Build(srcdir,bindir,projectName,
-                     newTarget.c_str(),
-                     output,0,config,false,fast,
+                     newTarget,
+                     output,"",config,false,fast,
                      this->TryCompileTimeout);
 }
 
 void cmGlobalGenerator::GenerateBuildCommand(
-  std::vector<std::string>& makeCommand, const char*, const char*, const char*,
-  const char*, const char*, bool, std::vector<std::string> const&)
+  std::vector<std::string>& makeCommand, const std::string&,
+  const std::string&, const std::string&, const std::string&,
+  const std::string&, bool,
+  std::vector<std::string> const&)
 {
   makeCommand.push_back(
     "cmGlobalGenerator::GenerateBuildCommand not implemented");
 }
 
 int cmGlobalGenerator::Build(
-  const char *, const char *bindir,
-  const char *projectName, const char *target,
+  const std::string&, const std::string& bindir,
+  const std::string& projectName, const std::string& target,
   std::string *output,
-  const char *makeCommandCSTR,
-  const char *config,
+  const std::string& makeCommandCSTR,
+  const std::string& config,
   bool clean, bool fast,
   double timeout,
   cmSystemTools::OutputOption outputflag,
@@ -1719,7 +1708,7 @@
    * Run an executable command and put the stdout in output.
    */
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(bindir);
+  cmSystemTools::ChangeDirectory(bindir.c_str());
   if(output)
     {
     *output += "Change Dir: ";
@@ -1821,19 +1810,20 @@
 
 //----------------------------------------------------------------------------
 std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
-  const char* target, const char* config, const char* native,
+  const std::string& target, const std::string& config,
+  const std::string& native,
   bool ignoreErrors)
 {
   std::string makeCommand = cmSystemTools::GetCMakeCommand();
   makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
   makeCommand += " --build .";
-  if(config && *config)
+  if(!config.empty())
     {
     makeCommand += " --config \"";
     makeCommand += config;
     makeCommand += "\"";
     }
-  if(target && *target)
+  if(!target.empty())
     {
     makeCommand += " --target \"";
     makeCommand += target;
@@ -1850,7 +1840,7 @@
       sep = " ";
       }
     }
-  if(native && *native)
+  if(!native.empty())
     {
     makeCommand += sep;
     makeCommand += native;
@@ -1989,16 +1979,16 @@
 void
 cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const
 {
-  for(std::map<cmStdString, bool>::const_iterator i =
+  for(std::map<std::string, bool>::const_iterator i =
         this->LanguageEnabled.begin(); i != this->LanguageEnabled.end(); ++i)
     {
     lang.push_back(i->first);
     }
 }
 
-int cmGlobalGenerator::GetLinkerPreference(const char* lang) const
+int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
 {
-  std::map<cmStdString, int>::const_iterator it =
+  std::map<std::string, int>::const_iterator it =
                                    this->LanguageToLinkerPreference.find(lang);
   if (it != this->LanguageToLinkerPreference.end())
     {
@@ -2075,7 +2065,7 @@
 
 ///! Find a local generator by its startdirectory
 cmLocalGenerator*
-cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const
+cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
 {
   for(std::vector<cmLocalGenerator*>::const_iterator it =
       this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it)
@@ -2090,60 +2080,39 @@
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt)
+void cmGlobalGenerator::AddAlias(const std::string& name, cmTarget *tgt)
 {
   this->AliasTargets[name] = tgt;
 }
 
 //----------------------------------------------------------------------------
-bool cmGlobalGenerator::IsAlias(const char *name) const
+bool cmGlobalGenerator::IsAlias(const std::string& name) const
 {
   return this->AliasTargets.find(name) != this->AliasTargets.end();
 }
 
 //----------------------------------------------------------------------------
 cmTarget*
-cmGlobalGenerator::FindTarget(const char* project, const char* name,
+cmGlobalGenerator::FindTarget(const std::string& name,
                               bool excludeAliases) const
 {
-  // if project specific
-  if(project)
+  if (!excludeAliases)
     {
-    std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
-      gens = this->ProjectMap.find(project);
-    for(unsigned int i = 0; i < gens->second.size(); ++i)
+    TargetMap::const_iterator ai = this->AliasTargets.find(name);
+    if (ai != this->AliasTargets.end())
       {
-      cmTarget* ret = (gens->second)[i]->GetMakefile()->FindTarget(name,
-                                                            excludeAliases);
-      if(ret)
-        {
-        return ret;
-        }
+      return ai->second;
       }
     }
-  // if all projects/directories
-  else
+  TargetMap::const_iterator i = this->TotalTargets.find ( name );
+  if ( i != this->TotalTargets.end() )
     {
-    if (!excludeAliases)
-      {
-      std::map<cmStdString, cmTarget*>::const_iterator ai
-                                              = this->AliasTargets.find(name);
-      if (ai != this->AliasTargets.end())
-        {
-        return ai->second;
-        }
-      }
-    std::map<cmStdString,cmTarget *>::const_iterator i =
-      this->TotalTargets.find ( name );
-    if ( i != this->TotalTargets.end() )
-      {
-      return i->second;
-      }
-    i = this->ImportedTargets.find(name);
-    if ( i != this->ImportedTargets.end() )
-      {
-      return i->second;
-      }
+    return i->second;
+    }
+  i = this->ImportedTargets.find(name);
+  if ( i != this->ImportedTargets.end() )
+    {
+    return i->second;
     }
   return 0;
 }
@@ -2157,7 +2126,7 @@
     return true;
     }
 
-  if(cmTarget* tgt = this->FindTarget(0, libname.c_str()))
+  if(cmTarget* tgt = this->FindTarget(libname))
     {
     if(tgt->IsFrameworkOnApple())
        {
@@ -2346,7 +2315,7 @@
     {
     if(!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.')
       {
-      std::set<cmStdString>* componentsSet = &this->InstallComponents;
+      std::set<std::string>* componentsSet = &this->InstallComponents;
       cpackCommandLines.erase(cpackCommandLines.begin(),
         cpackCommandLines.end());
       depends.erase(depends.begin(), depends.end());
@@ -2354,20 +2323,20 @@
       if ( componentsSet->size() > 0 )
         {
         ostr << "Available install components are:";
-        std::set<cmStdString>::iterator it;
+        std::set<std::string>::iterator it;
         for (
           it = componentsSet->begin();
           it != componentsSet->end();
           ++ it )
           {
-          ostr << " \"" << it->c_str() << "\"";
+          ostr << " \"" << *it << "\"";
           }
         }
       else
         {
         ostr << "Only default component available";
         }
-      singleLine.push_back(ostr.str().c_str());
+      singleLine.push_back(ostr.str());
       (*targets)["list_install_components"]
         = this->CreateGlobalTarget("list_install_components",
           ostr.str().c_str(),
@@ -2398,7 +2367,7 @@
       // automatically convert this name to the build-time location.
       cmd = "cmake";
       }
-    singleLine.push_back(cmd.c_str());
+    singleLine.push_back(cmd);
     if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' )
       {
       std::string cfgArg = "-DBUILD_TYPE=";
@@ -2515,7 +2484,7 @@
 
 //----------------------------------------------------------------------------
 cmTarget cmGlobalGenerator::CreateGlobalTarget(
-  const char* name, const char* message,
+  const std::string& name, const char* message,
   const cmCustomCommandLines* commandLines,
   std::vector<std::string> depends,
   const char* workingDirectory)
@@ -2536,7 +2505,7 @@
   std::vector<std::string>::iterator dit;
   for ( dit = depends.begin(); dit != depends.end(); ++ dit )
     {
-    target.AddUtility(dit->c_str());
+    target.AddUtility(*dit);
     }
 
   // Organize in the "predefined targets" folder:
@@ -2568,7 +2537,7 @@
 std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage(
                                                   std::string const& l) const
 {
-  std::map<cmStdString, cmStdString>::const_iterator it =
+  std::map<std::string, std::string>::const_iterator it =
                               this->LanguageToOriginalSharedLibFlags.find(l);
   if(it != this->LanguageToOriginalSharedLibFlags.end())
     {
@@ -2578,8 +2547,10 @@
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*,
-                                                 const char*, std::string&)
+void cmGlobalGenerator::AppendDirectoryForConfig(const std::string&,
+                                                 const std::string&,
+                                                 const std::string&,
+                                                 std::string&)
 {
   // Subclasses that support multiple configurations should implement
   // this method to append the subdirectory for the given build
@@ -2646,9 +2617,9 @@
     }
 }
 
-const char* cmGlobalGenerator::GetExtraGeneratorName() const
+std::string cmGlobalGenerator::GetExtraGeneratorName() const
 {
-  return this->ExtraGenerator==0 ? 0 : this->ExtraGenerator->GetName();
+  return this->ExtraGenerator? this->ExtraGenerator->GetName() : std::string();
 }
 
 void cmGlobalGenerator::FileReplacedDuringGenerate(const std::string& filename)
@@ -2706,7 +2677,7 @@
 bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const
 {
   return (target->GetType() == cmTarget::GLOBAL_TARGET ||
-          strcmp(target->GetName(), this->GetAllTargetName()) == 0);
+          target->GetName() == this->GetAllTargetName());
 }
 
 //----------------------------------------------------------------------------
@@ -2729,7 +2700,7 @@
 
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::AddToManifest(const char* config,
+void cmGlobalGenerator::AddToManifest(const std::string& config,
                                       std::string const& f)
 {
   // Add to the main manifest for this configuration.
@@ -2742,7 +2713,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::set<cmStdString> const&
+std::set<std::string> const&
 cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk)
 {
   DirectoryContent& dc = this->DirectoryContentMap[dir];
@@ -2794,7 +2765,7 @@
 
   // Shorten the output name (in expected use case).
   cmLocalGenerator* lg = this->GetLocalGenerators()[0];
-  std::string fname = lg->Convert(outputs[0].c_str(),
+  std::string fname = lg->Convert(outputs[0],
                                   cmLocalGenerator::HOME_OUTPUT);
 
   // Associate the hash with this output.
@@ -2848,7 +2819,7 @@
     fname = line.substr(33, line.npos);
 
     // Look for a hash for this file's rule.
-    std::map<cmStdString, RuleHash>::const_iterator rhi =
+    std::map<std::string, RuleHash>::const_iterator rhi =
       this->RuleHashes.find(fname);
     if(rhi != this->RuleHashes.end())
       {
@@ -2893,7 +2864,7 @@
     {
     cmGeneratedFileStream fout(pfile.c_str());
     fout << "# Hashes of file build rules.\n";
-    for(std::map<cmStdString, RuleHash>::const_iterator
+    for(std::map<std::string, RuleHash>::const_iterator
           rhi = this->RuleHashes.begin(); rhi != this->RuleHashes.end(); ++rhi)
       {
       fout.write(rhi->second.Data, 32);
@@ -2914,7 +2885,7 @@
   cmGeneratedFileStream fout(fname.c_str());
 
   // Generate summary information files for each target.
-  for(std::map<cmStdString,cmTarget *>::const_iterator ti =
+  for(TargetMap::const_iterator ti =
         this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
     {
     if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY)
@@ -2957,10 +2928,25 @@
     // List the source files with any per-source labels.
     fout << "# Source files and their labels\n";
     std::vector<cmSourceFile*> sources;
-    target->GetSourceFiles(sources);
+    std::vector<std::string> configs;
+    target->GetMakefile()->GetConfigurations(configs);
+    if (configs.empty())
+      {
+      configs.push_back("");
+      }
+    for(std::vector<std::string>::const_iterator ci = configs.begin();
+        ci != configs.end(); ++ci)
+      {
+      target->GetSourceFiles(sources, *ci);
+      }
+    std::set<cmSourceFile*> emitted;
     for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
         si != sources.end(); ++si)
       {
+      if (!emitted.insert(*si).second)
+        {
+        continue;
+        }
       cmSourceFile* sf = *si;
       fout << sf->GetFullPath() << "\n";
       if(const char* svalue = sf->GetProperty("LABELS"))
@@ -3041,3 +3027,39 @@
 {
   return str;
 }
+
+//----------------------------------------------------------------------------
+bool cmGlobalGenerator::GenerateCPackPropertiesFile()
+{
+  cmake::InstalledFilesMap const& installedFiles =
+    this->CMakeInstance->GetInstalledFiles();
+
+  cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
+
+  std::vector<std::string> configs;
+  std::string config = mf->GetConfigurations(configs, false);
+
+  std::string path = this->CMakeInstance->GetStartOutputDirectory();
+  path += "/CPackProperties.cmake";
+
+  if(!cmSystemTools::FileExists(path.c_str()) && installedFiles.empty())
+    {
+      return true;
+    }
+
+  cmGeneratedFileStream file(path.c_str());
+  file << "# CPack properties\n";
+
+  for(cmake::InstalledFilesMap::const_iterator i = installedFiles.begin();
+    i != installedFiles.end(); ++i)
+    {
+    cmInstalledFile const& installedFile = i->second;
+
+    cmCPackPropertiesGenerator cpackPropertiesGenerator(
+      mf, installedFile, configs);
+
+    cpackPropertiesGenerator.Generate(file, config, configs);
+    }
+
+  return true;
+}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 753eebf..67bd378 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -22,6 +22,10 @@
 #include "cmGeneratorTarget.h"
 #include "cmGeneratorExpression.h"
 
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+# include <cmsys/hash_map.hxx>
+#endif
+
 class cmake;
 class cmGeneratorTarget;
 class cmGeneratorExpressionEvaluationFile;
@@ -51,15 +55,15 @@
   virtual cmLocalGenerator *CreateLocalGenerator();
 
   ///! Get the name for this generator
-  virtual const char *GetName() const { return "Generic"; };
+  virtual std::string GetName() const { return "Generic"; }
 
   /** Check whether the given name matches the current generator.  */
-  virtual bool MatchesGeneratorName(const char* name) const
-  { return strcmp(this->GetName(), name) == 0; }
+  virtual bool MatchesGeneratorName(const std::string& name) const
+  { return this->GetName() == name; }
 
   /** Set the generator-specific toolset name.  Returns true if toolset
       is supported and false otherwise.  */
-  virtual bool SetGeneratorToolset(std::string const& ts);
+  virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
 
   /**
    * Create LocalGenerators and process the CMakeLists files. This does not
@@ -77,8 +81,8 @@
   /**
    * Set/Get and Clear the enabled languages.
    */
-  void SetLanguageEnabled(const char*, cmMakefile* mf);
-  bool GetLanguageEnabled(const char*) const;
+  void SetLanguageEnabled(const std::string&, cmMakefile* mf);
+  bool GetLanguageEnabled(const std::string&) const;
   void ClearEnabledLanguages();
   void GetEnabledLanguages(std::vector<std::string>& lang) const;
   /**
@@ -105,8 +109,9 @@
    * Try running cmake and building a file. This is used for dynamically
    * loaded commands, not as part of the usual build process.
    */
-  virtual int TryCompile(const char *srcdir, const char *bindir,
-                         const char *projectName, const char *targetName,
+  virtual int TryCompile(const std::string& srcdir, const std::string& bindir,
+                         const std::string& projectName,
+                         const std::string& targetName,
                          bool fast, std::string *output, cmMakefile* mf);
 
 
@@ -116,10 +121,10 @@
    * empty then all is assumed. clean indicates if a "make clean" should be
    * done first.
    */
-  int Build(const char *srcdir, const char *bindir,
-            const char *projectName, const char *targetName,
+  int Build(const std::string& srcdir, const std::string& bindir,
+            const std::string& projectName, const std::string& targetName,
             std::string *output,
-            const char *makeProgram, const char *config,
+            const std::string& makeProgram, const std::string& config,
             bool clean, bool fast,
             double timeout,
             cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE,
@@ -128,16 +133,16 @@
 
   virtual void GenerateBuildCommand(
     std::vector<std::string>& makeCommand,
-    const char* makeProgram,
-    const char *projectName, const char *projectDir,
-    const char *targetName, const char* config, bool fast,
+    const std::string& makeProgram,
+    const std::string& projectName, const std::string& projectDir,
+    const std::string& targetName, const std::string& config, bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
 
   /** Generate a "cmake --build" call for a given target and config.  */
-  std::string GenerateCMakeBuildCommand(const char* target,
-                                        const char* config,
-                                        const char* native,
+  std::string GenerateCMakeBuildCommand(const std::string& target,
+                                        const std::string& config,
+                                        const std::string& native,
                                         bool ignoreErrors);
 
   ///! Set the CMake instance
@@ -162,17 +167,17 @@
   void SetExternalMakefileProjectGenerator(
                            cmExternalMakefileProjectGenerator *extraGenerator);
 
-  const char* GetExtraGeneratorName() const;
+  std::string GetExtraGeneratorName() const;
 
   void AddInstallComponent(const char* component);
 
-  const std::set<cmStdString>* GetInstallComponents() const
+  const std::set<std::string>* GetInstallComponents() const
     { return &this->InstallComponents; }
 
   cmExportSetMap& GetExportSets() {return this->ExportSets;}
 
   /** Add a file to the manifest of generated targets for a configuration.  */
-  void AddToManifest(const char* config, std::string const& f);
+  void AddToManifest(const std::string& config, std::string const& f);
 
   void EnableInstallTarget();
 
@@ -182,13 +187,13 @@
   bool GetToolSupportsColor() const { return this->ToolSupportsColor; }
 
   ///! return the language for the given extension
-  const char* GetLanguageFromExtension(const char* ext) const;
+  std::string GetLanguageFromExtension(const char* ext) const;
   ///! is an extension to be ignored
   bool IgnoreFile(const char* ext) const;
   ///! What is the preference for linkers and this language (None or Prefered)
-  int GetLinkerPreference(const char* lang) const;
+  int GetLinkerPreference(const std::string& lang) const;
   ///! What is the object file extension for a given source file?
-  const char* GetLanguageOutputExtension(cmSourceFile const&) const;
+  std::string GetLanguageOutputExtension(cmSourceFile const&) const;
 
   ///! What is the configurations directory variable called?
   virtual const char* GetCMakeCFGIntDir() const { return "."; }
@@ -210,11 +215,11 @@
   virtual void FindMakeProgram(cmMakefile*);
 
   ///! Find a target by name by searching the local generators.
-  cmTarget* FindTarget(const char* project, const char* name,
+  cmTarget* FindTarget(const std::string& name,
                        bool excludeAliases = false) const;
 
-  void AddAlias(const char *name, cmTarget *tgt);
-  bool IsAlias(const char *name) const;
+  void AddAlias(const std::string& name, cmTarget *tgt);
+  bool IsAlias(const std::string& name) const;
 
   /** Determine if a name resolves to a framework on disk or a built target
       that is a framework. */
@@ -222,16 +227,16 @@
 
   /** If check to see if the target is linked to by any other
       target in the project */
-  bool IsDependedOn(const char* project, cmTarget const* target);
+  bool IsDependedOn(const std::string& project, cmTarget const* target);
   ///! Find a local generator by its startdirectory
-  cmLocalGenerator* FindLocalGenerator(const char* start_dir) const;
+  cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const;
 
   /** Append the subdirectory for the given configuration.  If anything is
       appended the given prefix and suffix will be appended around it, which
       is useful for leading or trailing slashes.  */
-  virtual void AppendDirectoryForConfig(const char* prefix,
-                                        const char* config,
-                                        const char* suffix,
+  virtual void AppendDirectoryForConfig(const std::string& prefix,
+                                        const std::string& config,
+                                        const std::string& suffix,
                                         std::string& dir);
 
   /** Get the manifest of all targets that will be built for each
@@ -243,7 +248,7 @@
       from disk at most once and cached.  During the generation step
       the content will include the target files to be built even if
       they do not yet exist.  */
-  std::set<cmStdString> const& GetDirectoryContent(std::string const& dir,
+  std::set<std::string> const& GetDirectoryContent(std::string const& dir,
                                                    bool needDisk = true);
 
   void AddTarget(cmTarget* t);
@@ -275,7 +280,7 @@
   /** Get per-target generator information.  */
   cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const;
 
-  const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap()
+  const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap()
                                                const {return this->ProjectMap;}
 
   // track files replaced during a Generate
@@ -286,12 +291,12 @@
                    std::string const& content);
 
   /** Return whether the given binary directory is unused.  */
-  bool BinaryDirectoryIsNew(const char* dir)
+  bool BinaryDirectoryIsNew(const std::string& dir)
     {
     return this->BinaryDirectories.insert(dir).second;
     }
   /** Supported systems creates a GUID for the given name */
-  virtual void CreateGUID(const char*) {}
+  virtual void CreateGUID(const std::string&) {}
 
   /** Return true if the generated build tree may contain multiple builds.
       i.e. "Can I build Debug and Release in the same tree?" */
@@ -322,6 +327,10 @@
   GetExportedTargetsFile(const std::string &filename) const;
   void AddCMP0042WarnTarget(const std::string& target);
 
+  virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+
+  bool GenerateCPackPropertiesFile();
+
 protected:
   typedef std::vector<cmLocalGenerator*> GeneratorVector;
   // for a project collect all its targets by following depend
@@ -332,21 +341,20 @@
   bool IsRootOnlyTarget(cmTarget* target) const;
   void AddTargetDepends(cmTarget const* target,
                         TargetDependSet& projectTargets);
-  void SetLanguageEnabledFlag(const char* l, cmMakefile* mf);
-  void SetLanguageEnabledMaps(const char* l, cmMakefile* mf);
-  void FillExtensionToLanguageMap(const char* l, cmMakefile* mf);
+  void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf);
+  void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf);
+  void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf);
 
   virtual bool ComputeTargetDepends();
 
   virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
 
-  bool CheckTargets();
   typedef std::vector<std::pair<cmQtAutoGenerators,
                                 cmTarget const*> > AutogensType;
   void CreateQtAutoGeneratorsTargets(AutogensType& autogens);
 
-  std::string SelectMakeProgram(const char* makeProgram,
-                                std::string makeDefault = "") const;
+  std::string SelectMakeProgram(const std::string& makeProgram,
+                                const std::string& makeDefault = "") const;
 
   // Fill the ProjectMap, this must be called after LocalGenerators
   // has been populated.
@@ -356,7 +364,7 @@
   bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const;
   void FillLocalGeneratorToTargetMap();
   void CreateDefaultGlobalTargets(cmTargets* targets);
-  cmTarget CreateGlobalTarget(const char* name, const char* message,
+  cmTarget CreateGlobalTarget(const std::string& name, const char* message,
     const cmCustomCommandLines* commandLines,
     std::vector<std::string> depends, const char* workingDir);
 
@@ -364,18 +372,18 @@
   bool UseLinkScript;
   bool ForceUnixPaths;
   bool ToolSupportsColor;
-  cmStdString FindMakeProgramFile;
-  cmStdString ConfiguredFilesPath;
+  std::string FindMakeProgramFile;
+  std::string ConfiguredFilesPath;
   cmake *CMakeInstance;
   std::vector<cmLocalGenerator *> LocalGenerators;
   cmLocalGenerator* CurrentLocalGenerator;
   // map from project name to vector of local generators in that project
-  std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap;
+  std::map<std::string, std::vector<cmLocalGenerator*> > ProjectMap;
   std::map<cmLocalGenerator*, std::set<cmTarget const*> >
                                                     LocalGeneratorToTargetMap;
 
   // Set of named installation components requested by the project.
-  std::set<cmStdString> InstallComponents;
+  std::set<std::string> InstallComponents;
   bool InstallTargetEnabled;
   // Sets of named target exports
   cmExportSetMap ExportSets;
@@ -387,9 +395,14 @@
   cmTargetManifest TargetManifest;
 
   // All targets in the entire project.
-  std::map<cmStdString,cmTarget *> TotalTargets;
-  std::map<cmStdString,cmTarget *> AliasTargets;
-  std::map<cmStdString,cmTarget *> ImportedTargets;
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+  typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
+#else
+  typedef std::map<std::string,cmTarget *> TargetMap;
+#endif
+  TargetMap TotalTargets;
+  TargetMap AliasTargets;
+  TargetMap ImportedTargets;
   std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
 
   virtual const char* GetPredefinedTargetsFolder();
@@ -401,18 +414,18 @@
   float FirstTimeProgress;
   // If you add a new map here, make sure it is copied
   // in EnableLanguagesFromGenerator
-  std::map<cmStdString, bool> IgnoreExtensions;
-  std::map<cmStdString, bool> LanguageEnabled;
-  std::set<cmStdString> LanguagesReady; // Ready for try_compile
-  std::map<cmStdString, cmStdString> OutputExtensions;
-  std::map<cmStdString, cmStdString> LanguageToOutputExtension;
-  std::map<cmStdString, cmStdString> ExtensionToLanguage;
-  std::map<cmStdString, int> LanguageToLinkerPreference;
-  std::map<cmStdString, cmStdString> LanguageToOriginalSharedLibFlags;
+  std::map<std::string, bool> IgnoreExtensions;
+  std::map<std::string, bool> LanguageEnabled;
+  std::set<std::string> LanguagesReady; // Ready for try_compile
+  std::map<std::string, std::string> OutputExtensions;
+  std::map<std::string, std::string> LanguageToOutputExtension;
+  std::map<std::string, std::string> ExtensionToLanguage;
+  std::map<std::string, int> LanguageToLinkerPreference;
+  std::map<std::string, std::string> LanguageToOriginalSharedLibFlags;
 
   // Record hashes for rules and outputs.
   struct RuleHash { char Data[32]; };
-  std::map<cmStdString, RuleHash> RuleHashes;
+  std::map<std::string, RuleHash> RuleHashes;
   void CheckRuleHashes();
   void CheckRuleHashes(std::string const& pfile, std::string const& home);
   void WriteRuleHashes(std::string const& pfile);
@@ -421,9 +434,12 @@
   void WriteSummary(cmTarget* target);
   void FinalizeTargetCompileInfo();
 
-  virtual void PrintCompilerAdvice(std::ostream& os, std::string lang,
+  virtual void ForceLinkerLanguages();
+
+  virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
                                    const char* envVar) const;
-  void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang) const;
+  void CheckCompilerIdCompatibility(cmMakefile* mf,
+                                    std::string const& lang) const;
 
   cmExternalMakefileProjectGenerator* ExtraGenerator;
 
@@ -439,26 +455,24 @@
   friend class cmake;
   void CreateGeneratorTargets(cmMakefile* mf);
   void CreateGeneratorTargets();
-  void ComputeGeneratorTargetObjects();
-  virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 
   void ClearGeneratorMembers();
 
   virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; }
 
   // Cache directory content and target files to be built.
-  struct DirectoryContent: public std::set<cmStdString>
+  struct DirectoryContent: public std::set<std::string>
   {
-    typedef std::set<cmStdString> derived;
+    typedef std::set<std::string> derived;
     bool LoadedFromDisk;
     DirectoryContent(): LoadedFromDisk(false) {}
     DirectoryContent(DirectoryContent const& dc):
       derived(dc), LoadedFromDisk(dc.LoadedFromDisk) {}
   };
-  std::map<cmStdString, DirectoryContent> DirectoryContentMap;
+  std::map<std::string, DirectoryContent> DirectoryContentMap;
 
   // Set of binary directories on disk.
-  std::set<cmStdString> BinaryDirectories;
+  std::set<std::string> BinaryDirectories;
 
   // track targets to issue CMP0042 warning for.
   std::set<std::string> CMP0042WarnTargets;
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index fd1d65f..3c2cd60 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -29,7 +29,8 @@
   virtual ~cmGlobalGeneratorFactory() {}
 
   /** Create a GlobalGenerator */
-  virtual cmGlobalGenerator* CreateGlobalGenerator(const char* n) const = 0;
+  virtual cmGlobalGenerator* CreateGlobalGenerator(
+      const std::string& n) const = 0;
 
   /** Get the documentation entry for this factory */
   virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
@@ -43,8 +44,9 @@
 {
 public:
   /** Create a GlobalGenerator */
-  virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
-    if (strcmp(name, T::GetActualName())) return 0;
+  virtual cmGlobalGenerator* CreateGlobalGenerator(
+                                              const std::string& name) const {
+    if (name != T::GetActualName()) return 0;
     return new T; }
 
   /** Get the documentation entry for this factory */
diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h
index 28893bf..344e013 100644
--- a/Source/cmGlobalJOMMakefileGenerator.h
+++ b/Source/cmGlobalJOMMakefileGenerator.h
@@ -27,11 +27,11 @@
     return new cmGlobalGeneratorSimpleFactory
       <cmGlobalJOMMakefileGenerator>(); }
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalJOMMakefileGenerator::GetActualName();}
   // use NMake Makefiles in the name so that scripts/tests that depend on the
   // name NMake Makefiles will work
-  static const char* GetActualName() {return "NMake Makefiles JOM";}
+  static std::string GetActualName() {return "NMake Makefiles JOM";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx
index ed0e15b..89d25c4 100644
--- a/Source/cmGlobalKdevelopGenerator.cxx
+++ b/Source/cmGlobalKdevelopGenerator.cxx
@@ -25,7 +25,7 @@
 
 //----------------------------------------------------------------------------
 void cmGlobalKdevelopGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
 {
   entry.Name = this->GetName();
   entry.Brief = "Generates KDevelop 3 project files.";
@@ -44,7 +44,7 @@
 {
   // for each sub project in the project create
   // a kdevelop project
-  for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+  for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
        it = this->GlobalGenerator->GetProjectMap().begin();
       it!= this->GlobalGenerator->GetProjectMap().end();
       ++it)
@@ -76,7 +76,7 @@
         {
         if (ti->second.GetType()==cmTarget::EXECUTABLE)
           {
-          executable = ti->second.GetLocation(0);
+          executable = ti->second.GetLocation("");
           break;
           }
         }
@@ -103,7 +103,7 @@
   std::string projectDir = projectDirIn + "/";
   std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist";
 
-  std::set<cmStdString> files;
+  std::set<std::string> files;
   std::string tmp;
 
   for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
@@ -139,7 +139,8 @@
          ti != targets.end(); ti++)
       {
       std::vector<cmSourceFile*> sources;
-      ti->second.GetSourceFiles(sources);
+      ti->second.GetSourceFiles(sources, ti->second.GetMakefile()
+                                    ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
       for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
            si!=sources.end(); si++)
         {
@@ -183,7 +184,7 @@
             (strstr(tmp.c_str(),
                     cmake::GetCMakeFilesDirectoryPostSlash())==0))
           {
-          files.insert(tmp.c_str());
+          files.insert(tmp);
           }
         }
       }
@@ -217,7 +218,7 @@
     }
 
   fileToOpen="";
-  for (std::set<cmStdString>::const_iterator it=files.begin();
+  for (std::set<std::string>::const_iterator it=files.begin();
        it!=files.end(); it++)
     {
     // get the full path to the file
@@ -360,7 +361,7 @@
     if (strstr(line, "<general>"))
       {
       fout<< "  <projectmanagement>KDevCustomProject</projectmanagement>\n";
-      fout<< "  <projectdirectory>" <<projectDir.c_str()
+      fout<< "  <projectdirectory>" <<projectDir
           << "</projectdirectory>\n";   //this one is important
       fout<<"  <absoluteprojectpath>true</absoluteprojectpath>\n";
       //and this one
@@ -368,14 +369,14 @@
     // inside kdevcustomproject the <filelistdirectory> must be put
     if (strstr(line, "<kdevcustomproject>"))
       {
-      fout<<"    <filelistdirectory>"<<outputDir.c_str()
+      fout<<"    <filelistdirectory>"<<outputDir
           <<"</filelistdirectory>\n";
       }
     // buildtool and builddir go inside <build>
     if (strstr(line, "<build>"))
       {
       fout<<"      <buildtool>make</buildtool>\n";
-      fout<<"      <builddir>"<<outputDir.c_str()<<"</builddir>\n";
+      fout<<"      <builddir>"<<outputDir<<"</builddir>\n";
       }
     }
 }
@@ -417,7 +418,7 @@
         "  <projectmanagement>KDevCustomProject</projectmanagement>\n"
         "  <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
         "  <ignoreparts/>\n"
-        "  <projectdirectory>" << projectDir.c_str() <<
+        "  <projectdirectory>" << projectDir <<
         "</projectdirectory>\n";   //this one is important
   fout<<"  <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
 
@@ -444,12 +445,12 @@
 
   fout<<"  </general>\n"
         "  <kdevcustomproject>\n"
-        "    <filelistdirectory>" << outputDir.c_str() <<
+        "    <filelistdirectory>" << outputDir <<
         "</filelistdirectory>\n"
         "    <run>\n"
-        "      <mainprogram>" << executable.c_str() << "</mainprogram>\n"
+        "      <mainprogram>" << executable << "</mainprogram>\n"
         "      <directoryradio>custom</directoryradio>\n"
-        "      <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"
+        "      <customdirectory>"<<outputDir<<"</customdirectory>\n"
         "      <programargs></programargs>\n"
         "      <terminal>false</terminal>\n"
         "      <autocompile>true</autocompile>\n"
@@ -457,7 +458,7 @@
         "    </run>\n"
         "    <build>\n"
         "      <buildtool>make</buildtool>\n"; //this one is important
-  fout<<"      <builddir>"<<outputDir.c_str()<<"</builddir>\n";  //and this one
+  fout<<"      <builddir>"<<outputDir<<"</builddir>\n";  //and this one
   fout<<"    </build>\n"
         "    <make>\n"
         "      <abortonerror>false</abortonerror>\n"
@@ -480,7 +481,7 @@
       dirIt != this->Blacklist.end();
       ++dirIt)
     {
-    fout<<"      <path>" << dirIt->c_str() << "</path>\n";
+    fout<<"      <path>" << *dirIt << "</path>\n";
     }
   fout<<"    </blacklist>\n";
 
@@ -558,7 +559,7 @@
   // command
   fout<<"  <kdevfileview>\n"
         "    <groups>\n"
-        "      <group pattern=\"" << cmakeFilePattern.c_str() <<
+        "      <group pattern=\"" << cmakeFilePattern <<
         "\" name=\"CMake\" />\n";
 
   if (enableCxx)
@@ -601,7 +602,7 @@
           "<!DOCTYPE KDevPrjSession>\n"
           "<KDevPrjSession>\n"
           " <DocsAndViews NumberOfDocuments=\"1\" >\n"
-          "  <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen.c_str() <<
+          "  <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen <<
           "\" >\n"
           "   <View0 line=\"0\" Type=\"Source\" />\n"
           "  </Doc0>\n"
diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h
index a1ad39d..0d59fc5 100644
--- a/Source/cmGlobalKdevelopGenerator.h
+++ b/Source/cmGlobalKdevelopGenerator.h
@@ -33,14 +33,14 @@
 public:
   cmGlobalKdevelopGenerator();
 
-  virtual const char* GetName() const
+  virtual std::string GetName() const
                           { return cmGlobalKdevelopGenerator::GetActualName();}
-  static const char* GetActualName()                     { return "KDevelop3";}
+  static std::string GetActualName()                     { return "KDevelop3";}
   static cmExternalMakefileProjectGenerator* New()
                                       { return new cmGlobalKdevelopGenerator; }
   /** Get the documentation entry for this generator.  */
   virtual void GetDocumentation(cmDocumentationEntry& entry,
-                                const char* fullName) const;
+                                const std::string& fullName) const;
 
   virtual void Generate();
 private:
diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h
index 659de11..c4825bd 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.h
+++ b/Source/cmGlobalMSYSMakefileGenerator.h
@@ -28,9 +28,9 @@
       <cmGlobalMSYSMakefileGenerator>(); }
 
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalMSYSMakefileGenerator::GetActualName();}
-  static const char* GetActualName() {return "MSYS Makefiles";}
+  static std::string GetActualName() {return "MSYS Makefiles";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h
index 7951e98..4289422 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.h
+++ b/Source/cmGlobalMinGWMakefileGenerator.h
@@ -27,9 +27,9 @@
     return new cmGlobalGeneratorSimpleFactory
       <cmGlobalMinGWMakefileGenerator>(); }
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalMinGWMakefileGenerator::GetActualName();}
-  static const char* GetActualName() {return "MinGW Makefiles";}
+  static std::string GetActualName() {return "MinGW Makefiles";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index 5756fbd..2ff44e3 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -27,9 +27,9 @@
     return new cmGlobalGeneratorSimpleFactory
       <cmGlobalNMakeMakefileGenerator>(); }
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalNMakeMakefileGenerator::GetActualName();}
-  static const char* GetActualName() {return "NMake Makefiles";}
+  static std::string GetActualName() {return "NMake Makefiles";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 731bc00..a0caf0e 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -19,6 +19,7 @@
 #include "cmVersion.h"
 
 #include <algorithm>
+#include <assert.h>
 
 const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja";
 const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja";
@@ -140,7 +141,7 @@
 
   cmGlobalNinjaGenerator::WriteComment(os, comment);
 
-  cmOStringStream arguments;
+  std::string arguments;
 
   // TODO: Better formatting for when there are multiple input/output files.
 
@@ -149,7 +150,7 @@
       i != explicitDeps.end();
       ++i)
     {
-    arguments  << " " << EncodeIdent(EncodePath(*i), os);
+    arguments += " " + EncodeIdent(EncodePath(*i), os);
 
     //we need to track every dependency that comes in, since we are trying
     //to find dependencies that are side effects of build commands
@@ -160,39 +161,39 @@
   // Write implicit dependencies.
   if(!implicitDeps.empty())
     {
-    arguments << " |";
+    arguments += " |";
     for(cmNinjaDeps::const_iterator i = implicitDeps.begin();
         i != implicitDeps.end();
         ++i)
-      arguments  << " " << EncodeIdent(EncodePath(*i), os);
+      arguments += " " + EncodeIdent(EncodePath(*i), os);
     }
 
   // Write order-only dependencies.
   if(!orderOnlyDeps.empty())
     {
-    arguments << " ||";
+    arguments += " ||";
     for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
         i != orderOnlyDeps.end();
         ++i)
-      arguments  << " " << EncodeIdent(EncodePath(*i), os);
+      arguments += " " + EncodeIdent(EncodePath(*i), os);
     }
 
-  arguments << "\n";
+  arguments += "\n";
 
-  cmOStringStream build;
+  std::string build;
 
   // Write outputs files.
-  build << "build";
+  build += "build";
   for(cmNinjaDeps::const_iterator i = outputs.begin();
       i != outputs.end(); ++i)
     {
-    build << " " << EncodeIdent(EncodePath(*i), os);
+    build += " " + EncodeIdent(EncodePath(*i), os);
     this->CombinedBuildOutputs.insert( EncodePath(*i) );
     }
-  build << ":";
+  build += ":";
 
   // Write the rule.
-  build << " " << rule;
+  build += " " + rule;
 
   // Write the variables bound to this build statement.
   cmOStringStream variable_assignments;
@@ -202,9 +203,9 @@
                                           i->first, i->second, "", 1);
 
   // check if a response file rule should be used
-  std::string buildstr = build.str();
+  std::string buildstr = build;
   std::string assignments = variable_assignments.str();
-  const std::string args = arguments.str();
+  const std::string& args = arguments;
   if (cmdLineLimit > 0
       && args.size() + buildstr.size() + assignments.size()
                                                     > (size_t) cmdLineLimit) {
@@ -551,11 +552,11 @@
 //   cmGlobalGenerator::Build()
 void cmGlobalNinjaGenerator
 ::GenerateBuildCommand(std::vector<std::string>& makeCommand,
-                       const char* makeProgram,
-                       const char* /*projectName*/,
-                       const char* /*projectDir*/,
-                       const char* targetName,
-                       const char* /*config*/,
+                       const std::string& makeProgram,
+                       const std::string& /*projectName*/,
+                       const std::string& /*projectDir*/,
+                       const std::string& targetName,
+                       const std::string& /*config*/,
                        bool /*fast*/,
                        std::vector<std::string> const& makeOptions)
 {
@@ -565,9 +566,9 @@
 
   makeCommand.insert(makeCommand.end(),
                      makeOptions.begin(), makeOptions.end());
-  if(targetName && *targetName)
+  if(!targetName.empty())
     {
-    if(strcmp(targetName, "clean") == 0)
+    if(targetName == "clean")
       {
       makeCommand.push_back("-t");
       makeCommand.push_back("clean");
@@ -631,31 +632,19 @@
   return cmSystemTools::GetCMakeGUICommand();
 }
 
-// TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl.
-void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
+//----------------------------------------------------------------------------
+void cmGlobalNinjaGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
 {
   cmTarget* target = gt->Target;
 
   // Compute full path to object file directory for this target.
-  std::string dir_max;
-  dir_max += gt->Makefile->GetCurrentOutputDirectory();
-  dir_max += "/";
-  dir_max += gt->LocalGenerator->GetTargetDirectory(*target);
-  dir_max += "/";
-  gt->ObjectDirectory = dir_max;
-
-  std::vector<cmSourceFile*> objectSources;
-  gt->GetObjectSources(objectSources);
-  // Compute the name of each object file.
-  for(std::vector<cmSourceFile*>::iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    std::string objectName = gt->LocalGenerator
-      ->GetObjectFileNameWithoutTarget(*sf, dir_max);
-    gt->AddObject(sf, objectName);
-    }
+  std::string dir;
+  dir += gt->Makefile->GetCurrentOutputDirectory();
+  dir += "/";
+  dir += gt->LocalGenerator->GetTargetDirectory(*target);
+  dir += "/";
+  gt->ObjectDirectory = dir;
 }
 
 //----------------------------------------------------------------------------
@@ -834,8 +823,8 @@
 cmGlobalNinjaGenerator
 ::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs)
 {
-  const char* configName =
-    target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE");
+  std::string configName =
+    target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
   cmLocalNinjaGenerator *ng =
     static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]);
 
@@ -886,7 +875,7 @@
   if (target->GetType() == cmTarget::GLOBAL_TARGET) {
     // Global targets only depend on other utilities, which may not appear in
     // the TargetDepends set (e.g. "all").
-    std::set<cmStdString> const& utils = target->GetUtilities();
+    std::set<std::string> const& utils = target->GetUtilities();
     std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
   } else {
     cmTargetDependSet const& targetDeps =
@@ -1159,7 +1148,7 @@
 {
   WriteRule(*this->RulesFileStream,
             "CLEAN",
-            (ninjaCmd() + " -t clean").c_str(),
+            ninjaCmd() + " -t clean",
             "Cleaning all built files...",
             "Rule for cleaning all built files.",
             /*depfile=*/ "",
@@ -1182,7 +1171,7 @@
 {
   WriteRule(*this->RulesFileStream,
             "HELP",
-            (ninjaCmd() + " -t targets").c_str(),
+            ninjaCmd() + " -t targets",
             "All primary targets available:",
             "Rule for printing all primary targets available.",
             /*depfile=*/ "",
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 0d5fb44..f2643af 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -173,11 +173,11 @@
   virtual cmLocalGenerator* CreateLocalGenerator();
 
   /// Overloaded methods. @see cmGlobalGenerator::GetName().
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalNinjaGenerator::GetActualName(); }
 
   /// @return the name of this generator.
-  static const char* GetActualName() { return "Ninja"; }
+  static std::string GetActualName() { return "Ninja"; }
 
   /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -193,11 +193,11 @@
   /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand()
   virtual void GenerateBuildCommand(
     std::vector<std::string>& makeCommand,
-    const char* makeProgram,
-    const char* projectName,
-    const char* projectDir,
-    const char* targetName,
-    const char* config,
+    const std::string& makeProgram,
+    const std::string& projectName,
+    const std::string& projectDir,
+    const std::string& targetName,
+    const std::string& config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
@@ -299,7 +299,7 @@
 
   void AddTargetAlias(const std::string& alias, cmTarget* target);
 
-
+  virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
 
   /// Overloaded methods.
@@ -310,8 +310,6 @@
 private:
   virtual std::string GetEditCacheCommand() const;
 
-  /// @see cmGlobalGenerator::ComputeTargetObjects
-  virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 
   void OpenBuildFileStream();
   void CloseBuildFileStream();
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 0b37a07..8dae81b 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -72,7 +72,7 @@
 {
   // If generating for an extra IDE, the edit_cache target cannot
   // launch a terminal-interactive tool, so always use cmake-gui.
-  if(this->GetExtraGeneratorName())
+  if(!this->GetExtraGeneratorName().empty())
     {
     return cmSystemTools::GetCMakeGUICommand();
     }
@@ -106,35 +106,17 @@
 //----------------------------------------------------------------------------
 void
 cmGlobalUnixMakefileGenerator3
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
 {
   cmTarget* target = gt->Target;
-  cmLocalUnixMakefileGenerator3* lg =
-    static_cast<cmLocalUnixMakefileGenerator3*>(gt->LocalGenerator);
 
   // Compute full path to object file directory for this target.
-  std::string dir_max;
-  dir_max += gt->Makefile->GetCurrentOutputDirectory();
-  dir_max += "/";
-  dir_max += gt->LocalGenerator->GetTargetDirectory(*target);
-  dir_max += "/";
-  gt->ObjectDirectory = dir_max;
-
-  std::vector<cmSourceFile*> objectSources;
-  gt->GetObjectSources(objectSources);
-  // Compute the name of each object file.
-  for(std::vector<cmSourceFile*>::iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    bool hasSourceExtension = true;
-    std::string objectName = gt->LocalGenerator
-      ->GetObjectFileNameWithoutTarget(*sf, dir_max,
-                                       &hasSourceExtension);
-    gt->AddObject(sf, objectName);
-    lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension);
-    }
+  std::string dir;
+  dir += gt->Makefile->GetCurrentOutputDirectory();
+  dir += "/";
+  dir += gt->LocalGenerator->GetTargetDirectory(*target);
+  dir += "/";
+  gt->ObjectDirectory = dir;
 }
 
 void cmGlobalUnixMakefileGenerator3::Configure()
@@ -356,14 +338,14 @@
     << "# The top level Makefile was generated from the following files:\n"
     << "set(CMAKE_MAKEFILE_DEPENDS\n"
     << "  \""
-    << lg->Convert(cache.c_str(),
-                   cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
+    << lg->Convert(cache,
+                   cmLocalGenerator::START_OUTPUT) << "\"\n";
   for(std::vector<std::string>::const_iterator i = lfiles.begin();
       i !=  lfiles.end(); ++i)
     {
     cmakefileStream
       << "  \""
-      << lg->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT).c_str()
+      << lg->Convert(*i, cmLocalGenerator::START_OUTPUT)
       << "\"\n";
     }
   cmakefileStream
@@ -379,11 +361,11 @@
     << "# The corresponding makefile is:\n"
     << "set(CMAKE_MAKEFILE_OUTPUTS\n"
     << "  \""
-    << lg->Convert(makefileName.c_str(),
-                   cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"
+    << lg->Convert(makefileName,
+                   cmLocalGenerator::START_OUTPUT) << "\"\n"
     << "  \""
-    << lg->Convert(check.c_str(),
-                   cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
+    << lg->Convert(check,
+                   cmLocalGenerator::START_OUTPUT) << "\"\n";
   cmakefileStream << "  )\n\n";
 
   // CMake must rerun if a byproduct is missing.
@@ -397,7 +379,7 @@
       k != outfiles.end(); ++k)
     {
     cmakefileStream << "  \"" <<
-      lg->Convert(k->c_str(),cmLocalGenerator::HOME_OUTPUT).c_str()
+      lg->Convert(*k,cmLocalGenerator::HOME_OUTPUT)
                     << "\"\n";
     }
 
@@ -411,7 +393,7 @@
     tmpStr += cmake::GetCMakeFilesDirectory();
     tmpStr += "/CMakeDirectoryInformation.cmake";
     cmakefileStream << "  \"" <<
-      lg->Convert(tmpStr.c_str(),cmLocalGenerator::HOME_OUTPUT).c_str()
+      lg->Convert(tmpStr,cmLocalGenerator::HOME_OUTPUT)
                     << "\"\n";
     }
   cmakefileStream << "  )\n\n";
@@ -450,7 +432,7 @@
         std::string tname = lg->GetRelativeTargetDirectory(l->second);
         tname += "/DependInfo.cmake";
         cmSystemTools::ConvertToUnixSlashes(tname);
-        cmakefileStream << "  \"" << tname.c_str() << "\"\n";
+        cmakefileStream << "  \"" << tname << "\"\n";
         }
       }
     }
@@ -477,24 +459,26 @@
   for(cmGeneratorTargetsType::iterator l = targets.begin();
       l != targets.end(); ++l)
     {
-    if((l->second->GetType() == cmTarget::EXECUTABLE) ||
-       (l->second->GetType() == cmTarget::STATIC_LIBRARY) ||
-       (l->second->GetType() == cmTarget::SHARED_LIBRARY) ||
-       (l->second->GetType() == cmTarget::MODULE_LIBRARY) ||
-       (l->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
-       (l->second->GetType() == cmTarget::UTILITY))
+    cmGeneratorTarget* gtarget = l->second;
+    int type = gtarget->GetType();
+    if((type == cmTarget::EXECUTABLE) ||
+       (type == cmTarget::STATIC_LIBRARY) ||
+       (type == cmTarget::SHARED_LIBRARY) ||
+       (type == cmTarget::MODULE_LIBRARY) ||
+       (type == cmTarget::OBJECT_LIBRARY) ||
+       (type == cmTarget::UTILITY))
       {
-      if(l->second->Target->IsImported())
+      if(gtarget->Target->IsImported())
         {
         continue;
         }
       // Add this to the list of depends rules in this directory.
-      if((!check_all || !l->second->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
+      if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
          (!check_relink ||
-          l->second->Target
-                   ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())))
+          gtarget->Target
+                   ->NeedRelinkBeforeInstall(lg->ConfigurationName)))
         {
-        std::string tname = lg->GetRelativeTargetDirectory(*l->second->Target);
+        std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target);
         tname += "/";
         tname += pass;
         depends.push_back(tname);
@@ -528,7 +512,7 @@
   doc += "\" pass in the directory.";
   std::vector<std::string> no_commands;
   lg->WriteMakeRule(ruleFileStream, doc.c_str(),
-                    makeTarget.c_str(), depends, no_commands, true);
+                    makeTarget, depends, no_commands, true);
 }
 
 //----------------------------------------------------------------------------
@@ -545,7 +529,7 @@
 
   // Begin the directory-level rules section.
   std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
-  dir = lg->Convert(dir.c_str(), cmLocalGenerator::HOME_OUTPUT,
+  dir = lg->Convert(dir, cmLocalGenerator::HOME_OUTPUT,
                     cmLocalGenerator::MAKEFILE);
   lg->WriteDivider(ruleFileStream);
   ruleFileStream
@@ -565,11 +549,11 @@
 //----------------------------------------------------------------------------
 void cmGlobalUnixMakefileGenerator3
 ::GenerateBuildCommand(std::vector<std::string>& makeCommand,
-                       const char* makeProgram,
-                       const char* /*projectName*/,
-                       const char* /*projectDir*/,
-                       const char* targetName,
-                       const char* /*config*/,
+                       const std::string& makeProgram,
+                       const std::string& /*projectName*/,
+                       const std::string& /*projectDir*/,
+                       const std::string& targetName,
+                       const std::string& /*config*/,
                        bool fast,
                        std::vector<std::string> const& makeOptions)
 {
@@ -579,13 +563,13 @@
 
   // Since we have full control over the invocation of nmake, let us
   // make it quiet.
-  if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
+  if ( this->GetName() == "NMake Makefiles" )
     {
     makeCommand.push_back("/NOLOGO");
     }
   makeCommand.insert(makeCommand.end(),
                      makeOptions.begin(), makeOptions.end());
-  if ( targetName && strlen(targetName))
+  if (!targetName.empty())
     {
     cmLocalUnixMakefileGenerator3 *lg;
     if (this->LocalGenerators.size())
@@ -610,7 +594,7 @@
       {
       tname += "/fast";
       }
-    tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT);
+    tname = lg->Convert(tname,cmLocalGenerator::HOME_OUTPUT);
     cmSystemTools::ConvertToOutputSlashes(tname);
     makeCommand.push_back(tname);
     if (!this->LocalGenerators.size())
@@ -624,7 +608,7 @@
 void
 cmGlobalUnixMakefileGenerator3
 ::WriteConvenienceRules(std::ostream& ruleFileStream,
-                        std::set<cmStdString> &emitted)
+                        std::set<std::string> &emitted)
 {
   std::vector<std::string> depends;
   std::vector<std::string> commands;
@@ -643,46 +627,48 @@
     for(cmGeneratorTargetsType::iterator t = targets.begin();
         t != targets.end(); ++t)
       {
-      if(t->second->Target->IsImported())
+      cmGeneratorTarget* gtarget = t->second;
+      if(gtarget->Target->IsImported())
         {
         continue;
         }
       // Don't emit the same rule twice (e.g. two targets with the same
       // simple name)
-      if(t->second->GetName() &&
-         strlen(t->second->GetName()) &&
-         emitted.insert(t->second->GetName()).second &&
+      int type = gtarget->GetType();
+      std::string name = gtarget->GetName();
+      if(!name.empty() &&
+         emitted.insert(name).second &&
          // Handle user targets here.  Global targets are handled in
          // the local generator on a per-directory basis.
-         ((t->second->GetType() == cmTarget::EXECUTABLE) ||
-          (t->second->GetType() == cmTarget::STATIC_LIBRARY) ||
-          (t->second->GetType() == cmTarget::SHARED_LIBRARY) ||
-          (t->second->GetType() == cmTarget::MODULE_LIBRARY) ||
-          (t->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
-          (t->second->GetType() == cmTarget::UTILITY)))
+         ((type == cmTarget::EXECUTABLE) ||
+          (type == cmTarget::STATIC_LIBRARY) ||
+          (type == cmTarget::SHARED_LIBRARY) ||
+          (type == cmTarget::MODULE_LIBRARY) ||
+          (type == cmTarget::OBJECT_LIBRARY) ||
+          (type == cmTarget::UTILITY)))
         {
         // Add a rule to build the target by name.
         lg->WriteDivider(ruleFileStream);
         ruleFileStream
           << "# Target rules for targets named "
-          << t->second->GetName() << "\n\n";
+          << name << "\n\n";
 
         // Write the rule.
         commands.clear();
         std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
         tmp += "Makefile2";
         commands.push_back(lg->GetRecursiveMakeCall
-                            (tmp.c_str(),t->second->GetName()));
+                            (tmp.c_str(),name));
         depends.clear();
         depends.push_back("cmake_check_build_system");
         lg->WriteMakeRule(ruleFileStream,
                           "Build rule for target.",
-                          t->second->GetName(), depends, commands,
+                          name, depends, commands,
                           true);
 
         // Add a fast rule to build the target
         std::string localName =
-                          lg->GetRelativeTargetDirectory(*t->second->Target);
+                          lg->GetRelativeTargetDirectory(*gtarget->Target);
         std::string makefileName;
         makefileName = localName;
         makefileName += "/build.make";
@@ -690,29 +676,29 @@
         commands.clear();
         std::string makeTargetName = localName;
         makeTargetName += "/build";
-        localName = t->second->GetName();
+        localName = name;
         localName += "/fast";
         commands.push_back(lg->GetRecursiveMakeCall
-                            (makefileName.c_str(), makeTargetName.c_str()));
+                            (makefileName.c_str(), makeTargetName));
         lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
-                          localName.c_str(), depends, commands, true);
+                          localName, depends, commands, true);
 
         // Add a local name for the rule to relink the target before
         // installation.
-        if(t->second->Target
-                    ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))
+        if(gtarget->Target
+                    ->NeedRelinkBeforeInstall(lg->ConfigurationName))
           {
-          makeTargetName = lg->GetRelativeTargetDirectory(*t->second->Target);
+          makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target);
           makeTargetName += "/preinstall";
-          localName = t->second->GetName();
+          localName = name;
           localName += "/preinstall";
           depends.clear();
           commands.clear();
           commands.push_back(lg->GetRecursiveMakeCall
-                             (makefileName.c_str(), makeTargetName.c_str()));
+                             (makefileName.c_str(), makeTargetName));
           lg->WriteMakeRule(ruleFileStream,
                             "Manual pre-install relink rule for target.",
-                            localName.c_str(), depends, commands, true);
+                            localName, depends, commands, true);
           }
         }
       }
@@ -742,26 +728,28 @@
   for(cmGeneratorTargetsType::iterator t = targets.begin();
       t != targets.end(); ++t)
     {
-    if(t->second->Target->IsImported())
+    cmGeneratorTarget* gtarget = t->second;
+    if(gtarget->Target->IsImported())
       {
       continue;
       }
-    if (t->second->GetName()
-     && strlen(t->second->GetName())
-     && ((t->second->GetType() == cmTarget::EXECUTABLE)
-        || (t->second->GetType() == cmTarget::STATIC_LIBRARY)
-        || (t->second->GetType() == cmTarget::SHARED_LIBRARY)
-        || (t->second->GetType() == cmTarget::MODULE_LIBRARY)
-        || (t->second->GetType() == cmTarget::OBJECT_LIBRARY)
-        || (t->second->GetType() == cmTarget::UTILITY)))
+    int type = gtarget->GetType();
+    std::string name = gtarget->GetName();
+    if (!name.empty()
+     && (  (type == cmTarget::EXECUTABLE)
+        || (type == cmTarget::STATIC_LIBRARY)
+        || (type == cmTarget::SHARED_LIBRARY)
+        || (type == cmTarget::MODULE_LIBRARY)
+        || (type == cmTarget::OBJECT_LIBRARY)
+        || (type == cmTarget::UTILITY)))
       {
       std::string makefileName;
       // Add a rule to build the target by name.
-      localName = lg->GetRelativeTargetDirectory(*t->second->Target);
+      localName = lg->GetRelativeTargetDirectory(*gtarget->Target);
       makefileName = localName;
       makefileName += "/build.make";
 
-      bool needRequiresStep = this->NeedRequiresStep(*t->second->Target);
+      bool needRequiresStep = this->NeedRequiresStep(*gtarget->Target);
 
       lg->WriteDivider(ruleFileStream);
       ruleFileStream
@@ -772,7 +760,7 @@
       makeTargetName = localName;
       makeTargetName += "/depend";
       commands.push_back(lg->GetRecursiveMakeCall
-                         (makefileName.c_str(),makeTargetName.c_str()));
+                         (makefileName.c_str(),makeTargetName));
 
       // add requires if we need it for this generator
       if (needRequiresStep)
@@ -780,12 +768,12 @@
         makeTargetName = localName;
         makeTargetName += "/requires";
         commands.push_back(lg->GetRecursiveMakeCall
-                          (makefileName.c_str(),makeTargetName.c_str()));
+                          (makefileName.c_str(),makeTargetName));
         }
       makeTargetName = localName;
       makeTargetName += "/build";
       commands.push_back(lg->GetRecursiveMakeCall
-                         (makefileName.c_str(),makeTargetName.c_str()));
+                         (makefileName.c_str(),makeTargetName));
 
       // Write the rule.
       localName += "/all";
@@ -798,12 +786,12 @@
         cmOStringStream progCmd;
         progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
         // all target counts
-        progCmd << lg->Convert(progressDir.c_str(),
+        progCmd << lg->Convert(progressDir,
                                 cmLocalGenerator::FULL,
                                 cmLocalGenerator::SHELL);
         progCmd << " ";
         std::vector<unsigned long>& progFiles =
-          this->ProgressMap[t->second->Target].Marks;
+          this->ProgressMap[gtarget->Target].Marks;
         for (std::vector<unsigned long>::iterator i = progFiles.begin();
               i != progFiles.end(); ++i)
           {
@@ -812,15 +800,15 @@
         commands.push_back(progCmd.str());
         }
       progressDir = "Built target ";
-      progressDir += t->second->GetName();
+      progressDir += name;
       lg->AppendEcho(commands,progressDir.c_str());
 
-      this->AppendGlobalTargetDepends(depends,*t->second->Target);
+      this->AppendGlobalTargetDepends(depends,*gtarget->Target);
       lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
-                        localName.c_str(), depends, commands, true);
+                        localName, depends, commands, true);
 
       // add the all/all dependency
-      if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target))
+      if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target))
         {
         depends.clear();
         depends.push_back(localName);
@@ -839,23 +827,23 @@
       cmOStringStream progCmd;
       progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
       // # in target
-      progCmd << lg->Convert(progressDir.c_str(),
+      progCmd << lg->Convert(progressDir,
                               cmLocalGenerator::FULL,
                               cmLocalGenerator::SHELL);
       //
       std::set<cmTarget const*> emitted;
       progCmd << " "
-              << this->CountProgressMarksInTarget(t->second->Target, emitted);
+              << this->CountProgressMarksInTarget(gtarget->Target, emitted);
       commands.push_back(progCmd.str());
       }
       std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
       tmp += "Makefile2";
       commands.push_back(lg->GetRecursiveMakeCall
-                          (tmp.c_str(),localName.c_str()));
+                          (tmp.c_str(),localName));
       {
       cmOStringStream progCmd;
       progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
-      progCmd << lg->Convert(progressDir.c_str(),
+      progCmd << lg->Convert(progressDir,
                               cmLocalGenerator::FULL,
                               cmLocalGenerator::SHELL);
       progCmd << " 0";
@@ -863,34 +851,34 @@
       }
       depends.clear();
       depends.push_back("cmake_check_build_system");
-      localName = lg->GetRelativeTargetDirectory(*t->second->Target);
+      localName = lg->GetRelativeTargetDirectory(*gtarget->Target);
       localName += "/rule";
       lg->WriteMakeRule(ruleFileStream,
                         "Build rule for subdir invocation for target.",
-                        localName.c_str(), depends, commands, true);
+                        localName, depends, commands, true);
 
       // Add a target with the canonical name (no prefix, suffix or path).
       commands.clear();
       depends.clear();
       depends.push_back(localName);
       lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
-                        t->second->GetName(), depends, commands, true);
+                        name, depends, commands, true);
 
       // Add rules to prepare the target for installation.
-      if(t->second->Target
-                  ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))
+      if(gtarget->Target
+                  ->NeedRelinkBeforeInstall(lg->ConfigurationName))
         {
-        localName = lg->GetRelativeTargetDirectory(*t->second->Target);
+        localName = lg->GetRelativeTargetDirectory(*gtarget->Target);
         localName += "/preinstall";
         depends.clear();
         commands.clear();
         commands.push_back(lg->GetRecursiveMakeCall
-                            (makefileName.c_str(), localName.c_str()));
+                            (makefileName.c_str(), localName));
         lg->WriteMakeRule(ruleFileStream,
                           "Pre-install relink rule for target.",
-                          localName.c_str(), depends, commands, true);
+                          localName, depends, commands, true);
 
-        if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target))
+        if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target))
           {
           depends.clear();
           depends.push_back(localName);
@@ -901,15 +889,15 @@
         }
 
       // add the clean rule
-      localName = lg->GetRelativeTargetDirectory(*t->second->Target);
+      localName = lg->GetRelativeTargetDirectory(*gtarget->Target);
       makeTargetName = localName;
       makeTargetName += "/clean";
       depends.clear();
       commands.clear();
       commands.push_back(lg->GetRecursiveMakeCall
-                          (makefileName.c_str(), makeTargetName.c_str()));
+                          (makefileName.c_str(), makeTargetName));
       lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
-                        makeTargetName.c_str(), depends, commands, true);
+                        makeTargetName, depends, commands, true);
       commands.clear();
       depends.push_back(makeTargetName);
       lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
@@ -970,21 +958,6 @@
 }
 
 //----------------------------------------------------------------------------
-bool
-cmGlobalUnixMakefileGenerator3::ProgressMapCompare
-::operator()(cmTarget const* l, cmTarget const* r) const
-{
-  // Order by target name.
-  if(int c = strcmp(l->GetName(), r->GetName()))
-    {
-    return c < 0;
-    }
-  // Order duplicate targets by binary directory.
-  return strcmp(l->GetMakefile()->GetCurrentOutputDirectory(),
-                r->GetMakefile()->GetCurrentOutputDirectory()) < 0;
-}
-
-//----------------------------------------------------------------------------
 void
 cmGlobalUnixMakefileGenerator3::TargetProgress
 ::WriteProgressVariables(unsigned long total, unsigned long &current)
@@ -1051,7 +1024,7 @@
   lg->AppendEcho(commands,"... depend");
 
   // Keep track of targets already listed.
-  std::set<cmStdString> emittedTargets;
+  std::set<std::string> emittedTargets;
 
   // for each local generator
   unsigned int i;
@@ -1068,26 +1041,29 @@
       cmTargets& targets = lg2->GetMakefile()->GetTargets();
       for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
         {
-        if((t->second.GetType() == cmTarget::EXECUTABLE) ||
-           (t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
-           (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
-           (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
-           (t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
-           (t->second.GetType() == cmTarget::GLOBAL_TARGET) ||
-           (t->second.GetType() == cmTarget::UTILITY))
+        cmTarget const& target = t->second;
+        cmTarget::TargetType type = target.GetType();
+        if((type == cmTarget::EXECUTABLE) ||
+           (type == cmTarget::STATIC_LIBRARY) ||
+           (type == cmTarget::SHARED_LIBRARY) ||
+           (type == cmTarget::MODULE_LIBRARY) ||
+           (type == cmTarget::OBJECT_LIBRARY) ||
+           (type == cmTarget::GLOBAL_TARGET) ||
+           (type == cmTarget::UTILITY))
           {
-          if(emittedTargets.insert(t->second.GetName()).second)
+          std::string name = target.GetName();
+          if(emittedTargets.insert(name).second)
             {
             path = "... ";
-            path += t->second.GetName();
+            path += name;
             lg->AppendEcho(commands,path.c_str());
             }
           }
         }
       }
     }
-  std::vector<cmStdString> const& localHelp = lg->GetLocalHelp();
-  for(std::vector<cmStdString>::const_iterator o = localHelp.begin();
+  std::vector<std::string> const& localHelp = lg->GetLocalHelp();
+  for(std::vector<std::string>::const_iterator o = localHelp.begin();
       o != localHelp.end(); ++o)
     {
     path = "... ";
@@ -1104,15 +1080,16 @@
 bool cmGlobalUnixMakefileGenerator3
 ::NeedRequiresStep(cmTarget const& target)
 {
-  std::set<cmStdString> languages;
-  target.GetLanguages(languages);
-  for(std::set<cmStdString>::const_iterator l = languages.begin();
+  std::set<std::string> languages;
+  target.GetLanguages(languages,
+                target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+  for(std::set<std::string>::const_iterator l = languages.begin();
       l != languages.end(); ++l)
     {
     std::string var = "CMAKE_NEEDS_REQUIRES_STEP_";
     var += *l;
     var += "_FLAG";
-    if(target.GetMakefile()->GetDefinition(var.c_str()))
+    if(target.GetMakefile()->GetDefinition(var))
       {
       return true;
       }
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 9173751..f44dd12 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -60,9 +60,9 @@
       <cmGlobalUnixMakefileGenerator3>(); }
 
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalUnixMakefileGenerator3::GetActualName();}
-  static const char* GetActualName() {return "Unix Makefiles";}
+  static std::string GetActualName() {return "Unix Makefiles";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -96,7 +96,7 @@
 
   // write the top level target rules
   void WriteConvenienceRules(std::ostream& ruleFileStream,
-                             std::set<cmStdString> &emitted);
+                             std::set<std::string> &emitted);
 
   /** Get the command to use for a target that has no rule.  This is
       used for multiple output dependencies and for cmake_force.  */
@@ -109,11 +109,11 @@
   // change the build command for speed
   virtual void GenerateBuildCommand(
     std::vector<std::string>& makeCommand,
-    const char* makeProgram,
-    const char* projectName,
-    const char* projectDir,
-    const char* targetName,
-    const char* config,
+    const std::string& makeProgram,
+    const std::string& projectName,
+    const std::string& projectDir,
+    const std::string& targetName,
+    const std::string& config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
@@ -128,6 +128,7 @@
   /** Does the make tool tolerate .NOTPARALLEL? */
   virtual bool AllowNotParallel() const { return true; }
 
+  virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
   void WriteMainMakefile2();
   void WriteMainCMakefile();
@@ -184,10 +185,8 @@
     std::vector<unsigned long> Marks;
     void WriteProgressVariables(unsigned long total, unsigned long& current);
   };
-  struct ProgressMapCompare { bool operator()(cmTarget const*,
-                                              cmTarget const*) const; };
   typedef std::map<cmTarget const*, TargetProgress,
-                   ProgressMapCompare> ProgressMapType;
+                   cmStrictTargetComparison> ProgressMapType;
   ProgressMapType ProgressMap;
 
   size_t CountProgressMarksInTarget(cmTarget const* target,
@@ -198,7 +197,6 @@
 private:
   virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; }
   virtual std::string GetEditCacheCommand() const;
-  virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 };
 
 #endif
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 6983ef9..86d0de3 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -21,13 +21,14 @@
 static const char vs10generatorName[] = "Visual Studio 10 2010";
 
 // Map generator name without year to name with year.
-static const char* cmVS10GenName(const char* name, std::string& genName)
+static const char* cmVS10GenName(const std::string& name, std::string& genName)
 {
-  if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0)
+  if(strncmp(name.c_str(), vs10generatorName,
+             sizeof(vs10generatorName)-6) != 0)
     {
     return 0;
     }
-  const char* p = name + sizeof(vs10generatorName) - 6;
+  const char* p = name.c_str() + sizeof(vs10generatorName) - 6;
   if(cmHasLiteralPrefix(p, " 2010"))
     {
     p += 5;
@@ -40,27 +41,27 @@
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
+  virtual cmGlobalGenerator* CreateGlobalGenerator(
+                                            const std::string& name) const
     {
     std::string genName;
     const char* p = cmVS10GenName(name, genName);
     if(!p)
       { return 0; }
-    name = genName.c_str();
     if(strcmp(p, "") == 0)
       {
       return new cmGlobalVisualStudio10Generator(
-        name, NULL, NULL);
+        genName, "", "");
       }
     if(strcmp(p, " Win64") == 0)
       {
       return new cmGlobalVisualStudio10Generator(
-        name, "x64", "CMAKE_FORCE_WIN64");
+        genName, "x64", "CMAKE_FORCE_WIN64");
       }
     if(strcmp(p, " IA64") == 0)
       {
       return new cmGlobalVisualStudio10Generator(
-        name, "Itanium", "CMAKE_FORCE_IA64");
+        genName, "Itanium", "CMAKE_FORCE_IA64");
       }
     return 0;
     }
@@ -87,8 +88,8 @@
 
 //----------------------------------------------------------------------------
 cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
-  const char* name, const char* platformName,
-  const char* additionalPlatformDefinition)
+  const std::string& name, const std::string& platformName,
+  const std::string& additionalPlatformDefinition)
   : cmGlobalVisualStudio8Generator(name, platformName,
                                    additionalPlatformDefinition)
 {
@@ -102,7 +103,8 @@
 
 //----------------------------------------------------------------------------
 bool
-cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const
+cmGlobalVisualStudio10Generator::MatchesGeneratorName(
+                                               const std::string& name) const
 {
   std::string genName;
   if(cmVS10GenName(name, genName))
@@ -114,9 +116,11 @@
 
 //----------------------------------------------------------------------------
 bool
-cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts)
+cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts,
+                                                     cmMakefile* mf)
 {
-  this->PlatformToolset = ts;
+  this->GeneratorToolset = ts;
+  this->AddVSPlatformToolsetDefinition(mf);
   return true;
 }
 
@@ -124,10 +128,16 @@
 void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
 {
   cmGlobalVisualStudio8Generator::AddPlatformDefinitions(mf);
-  if(!this->PlatformToolset.empty())
+  this->AddVSPlatformToolsetDefinition(mf);
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalVisualStudio10Generator
+::AddVSPlatformToolsetDefinition(cmMakefile* mf) const
+{
+  if(const char* toolset = this->GetPlatformToolset())
     {
-    mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET",
-                      this->PlatformToolset.c_str());
+    mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset);
     }
 }
 
@@ -213,11 +223,15 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmGlobalVisualStudio10Generator::GetPlatformToolset()
+const char* cmGlobalVisualStudio10Generator::GetPlatformToolset() const
 {
-  if(!this->PlatformToolset.empty())
+  if(!this->GeneratorToolset.empty())
     {
-    return this->PlatformToolset.c_str();
+    return this->GeneratorToolset.c_str();
+    }
+  if(!this->DefaultPlatformToolset.empty())
+    {
+    return this->DefaultPlatformToolset.c_str();
     }
   return 0;
 }
@@ -310,11 +324,11 @@
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
   std::vector<std::string>& makeCommand,
-  const char* makeProgram,
-  const char* projectName,
-  const char* projectDir,
-  const char* targetName,
-  const char* config,
+  const std::string& makeProgram,
+  const std::string& projectName,
+  const std::string& projectDir,
+  const std::string& targetName,
+  const std::string& config,
   bool fast,
   std::vector<std::string> const& makeOptions)
 {
@@ -334,7 +348,7 @@
   cmSlnData slnData;
   {
   std::string slnFile;
-  if(projectDir && *projectDir)
+  if(!projectDir.empty())
     {
     slnFile = projectDir;
     slnFile += "/";
@@ -369,25 +383,26 @@
 
   makeCommand.push_back(makeProgramSelected);
 
+  std::string realTarget = targetName;
   // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
-  if(!targetName || strlen(targetName) == 0)
+  if(realTarget.empty())
     {
-    targetName = "ALL_BUILD";
+    realTarget = "ALL_BUILD";
     }
-  if ( targetName && strcmp(targetName, "clean") == 0 )
+  if ( realTarget == "clean" )
     {
     makeCommand.push_back(std::string(projectName)+".sln");
     makeCommand.push_back("/t:Clean");
     }
   else
     {
-    std::string targetProject(targetName);
+    std::string targetProject(realTarget);
     targetProject += ".vcxproj";
     if (targetProject.find('/') == std::string::npos)
       {
       // it might be in a subdir
       if (cmSlnProjectEntry const* proj =
-          slnData.GetProjectByName(targetName))
+          slnData.GetProjectByName(realTarget))
         {
         targetProject = proj->GetRelativePath();
         cmSystemTools::ConvertToUnixSlashes(targetProject);
@@ -396,7 +411,7 @@
     makeCommand.push_back(targetProject);
     }
   std::string configArg = "/p:Configuration=";
-  if(config && strlen(config))
+  if(!config.empty())
     {
     configArg += config;
     }
@@ -414,7 +429,7 @@
 //----------------------------------------------------------------------------
 bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
 {
-  if(!this->PlatformToolset.empty())
+  if(this->GetPlatformToolset())
     {
     return true;
     }
@@ -432,7 +447,7 @@
     cmOStringStream m;
     m << "Found Windows SDK v7.1: " << winSDK_7_1;
     mf->DisplayStatus(m.str().c_str(), -1);
-    this->PlatformToolset = "Windows7.1SDK";
+    this->DefaultPlatformToolset = "Windows7.1SDK";
     return true;
     }
   else
@@ -467,7 +482,7 @@
 
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudio10Generator::PathTooLong(
-  cmTarget* target, cmSourceFile* sf, std::string const& sfRel)
+  cmTarget* target, cmSourceFile const* sf, std::string const& sfRel)
 {
   size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) +
                 1 + sfRel.length());
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 976d41f..b4dcc7e 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -24,21 +24,22 @@
   public cmGlobalVisualStudio8Generator
 {
 public:
-  cmGlobalVisualStudio10Generator(const char* name,
-    const char* platformName, const char* additionalPlatformDefinition);
+  cmGlobalVisualStudio10Generator(const std::string& name,
+    const std::string& platformName,
+    const std::string& additionalPlatformDefinition);
   static cmGlobalGeneratorFactory* NewFactory();
 
-  virtual bool MatchesGeneratorName(const char* name) const;
+  virtual bool MatchesGeneratorName(const std::string& name) const;
 
-  virtual bool SetGeneratorToolset(std::string const& ts);
+  virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
 
   virtual void GenerateBuildCommand(
     std::vector<std::string>& makeCommand,
-    const char* makeProgram,
-    const char* projectName,
-    const char* projectDir,
-    const char* targetName,
-    const char* config,
+    const std::string& makeProgram,
+    const std::string& projectName,
+    const std::string& projectDir,
+    const std::string& targetName,
+    const std::string& config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
@@ -65,7 +66,7 @@
   bool IsMasmEnabled() const { return this->MasmEnabled; }
 
   /** The toolset name for the target platform.  */
-  const char* GetPlatformToolset();
+  const char* GetPlatformToolset() const;
 
   /**
    * Where does this version of Visual Studio look for macros for the
@@ -86,7 +87,7 @@
   /** Generate an <output>.rule file path for a given command output.  */
   virtual std::string GenerateRuleFile(std::string const& output) const;
 
-  void PathTooLong(cmTarget* target, cmSourceFile* sf,
+  void PathTooLong(cmTarget* target, cmSourceFile const* sf,
                    std::string const& sfRel);
 
   virtual const char* GetToolsVersion() { return "4.0"; }
@@ -98,7 +99,8 @@
 
   std::string const& GetMSBuildCommand();
 
-  std::string PlatformToolset;
+  std::string GeneratorToolset;
+  std::string DefaultPlatformToolset;
   bool ExpressEdition;
   bool MasmEnabled;
 
@@ -111,7 +113,7 @@
     LongestSourcePath(): Length(0), Target(0), SourceFile(0) {}
     size_t Length;
     cmTarget* Target;
-    cmSourceFile* SourceFile;
+    cmSourceFile const* SourceFile;
     std::string SourceRel;
   };
   LongestSourcePath LongestSource;
@@ -121,5 +123,6 @@
   virtual std::string FindMSBuildCommand();
   virtual std::string FindDevEnvCommand();
   virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); }
+  void AddVSPlatformToolsetDefinition(cmMakefile* mf) const;
 };
 #endif
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 1f0c47a..7033f2a 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -16,13 +16,14 @@
 static const char vs11generatorName[] = "Visual Studio 11 2012";
 
 // Map generator name without year to name with year.
-static const char* cmVS11GenName(const char* name, std::string& genName)
+static const char* cmVS11GenName(const std::string& name, std::string& genName)
 {
-  if(strncmp(name, vs11generatorName, sizeof(vs11generatorName)-6) != 0)
+  if(strncmp(name.c_str(), vs11generatorName,
+             sizeof(vs11generatorName)-6) != 0)
     {
     return 0;
     }
-  const char* p = name + sizeof(vs11generatorName) - 6;
+  const char* p = name.c_str() + sizeof(vs11generatorName) - 6;
   if(cmHasLiteralPrefix(p, " 2012"))
     {
     p += 5;
@@ -35,27 +36,27 @@
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
+  virtual cmGlobalGenerator* CreateGlobalGenerator(
+                                                const std::string& name) const
     {
     std::string genName;
     const char* p = cmVS11GenName(name, genName);
     if(!p)
       { return 0; }
-    name = genName.c_str();
     if(strcmp(p, "") == 0)
       {
       return new cmGlobalVisualStudio11Generator(
-        name, NULL, NULL);
+        genName, "", "");
       }
     if(strcmp(p, " Win64") == 0)
       {
       return new cmGlobalVisualStudio11Generator(
-        name, "x64", "CMAKE_FORCE_WIN64");
+        genName, "x64", "CMAKE_FORCE_WIN64");
       }
     if(strcmp(p, " ARM") == 0)
       {
       return new cmGlobalVisualStudio11Generator(
-        name, "ARM", NULL);
+        genName, "ARM", "");
       }
 
     if(*p++ != ' ')
@@ -107,8 +108,8 @@
 
 //----------------------------------------------------------------------------
 cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
-  const char* name, const char* platformName,
-  const char* additionalPlatformDefinition)
+  const std::string& name, const std::string& platformName,
+  const std::string& additionalPlatformDefinition)
   : cmGlobalVisualStudio10Generator(name, platformName,
                                    additionalPlatformDefinition)
 {
@@ -116,12 +117,13 @@
   this->ExpressEdition = cmSystemTools::ReadRegistryValue(
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;"
     "ProductDir", vc11Express, cmSystemTools::KeyWOW64_32);
-  this->PlatformToolset = "v110";
+  this->DefaultPlatformToolset = "v110";
 }
 
 //----------------------------------------------------------------------------
 bool
-cmGlobalVisualStudio11Generator::MatchesGeneratorName(const char* name) const
+cmGlobalVisualStudio11Generator::MatchesGeneratorName(
+                                                const std::string& name) const
 {
   std::string genName;
   if(cmVS11GenName(name, genName))
diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h
index 7ef77e7..48ea489 100644
--- a/Source/cmGlobalVisualStudio11Generator.h
+++ b/Source/cmGlobalVisualStudio11Generator.h
@@ -20,11 +20,12 @@
   public cmGlobalVisualStudio10Generator
 {
 public:
-  cmGlobalVisualStudio11Generator(const char* name,
-    const char* platformName, const char* additionalPlatformDefinition);
+  cmGlobalVisualStudio11Generator(const std::string& name,
+    const std::string& platformName,
+    const std::string& additionalPlatformDefinition);
   static cmGlobalGeneratorFactory* NewFactory();
 
-  virtual bool MatchesGeneratorName(const char* name) const;
+  virtual bool MatchesGeneratorName(const std::string& name) const;
 
   virtual void WriteSLNHeader(std::ostream& fout);
 
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 3074794..40f8b05 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -16,13 +16,14 @@
 static const char vs12generatorName[] = "Visual Studio 12 2013";
 
 // Map generator name without year to name with year.
-static const char* cmVS12GenName(const char* name, std::string& genName)
+static const char* cmVS12GenName(const std::string& name, std::string& genName)
 {
-  if(strncmp(name, vs12generatorName, sizeof(vs12generatorName)-6) != 0)
+  if(strncmp(name.c_str(), vs12generatorName,
+             sizeof(vs12generatorName)-6) != 0)
     {
     return 0;
     }
-  const char* p = name + sizeof(vs12generatorName) - 6;
+  const char* p = name.c_str() + sizeof(vs12generatorName) - 6;
   if(cmHasLiteralPrefix(p, " 2013"))
     {
     p += 5;
@@ -35,27 +36,27 @@
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
+  virtual cmGlobalGenerator* CreateGlobalGenerator(
+                                                const std::string& name) const
     {
     std::string genName;
     const char* p = cmVS12GenName(name, genName);
     if(!p)
       { return 0; }
-    name = genName.c_str();
     if(strcmp(p, "") == 0)
       {
       return new cmGlobalVisualStudio12Generator(
-        name, NULL, NULL);
+        genName, "", "");
       }
     if(strcmp(p, " Win64") == 0)
       {
       return new cmGlobalVisualStudio12Generator(
-        name, "x64", "CMAKE_FORCE_WIN64");
+        genName, "x64", "CMAKE_FORCE_WIN64");
       }
     if(strcmp(p, " ARM") == 0)
       {
       return new cmGlobalVisualStudio12Generator(
-        name, "ARM", NULL);
+        genName, "ARM", "");
       }
     return 0;
     }
@@ -82,8 +83,8 @@
 
 //----------------------------------------------------------------------------
 cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
-  const char* name, const char* platformName,
-  const char* additionalPlatformDefinition)
+  const std::string& name, const std::string& platformName,
+  const std::string& additionalPlatformDefinition)
   : cmGlobalVisualStudio11Generator(name, platformName,
                                    additionalPlatformDefinition)
 {
@@ -91,12 +92,13 @@
   this->ExpressEdition = cmSystemTools::ReadRegistryValue(
     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;"
     "ProductDir", vc12Express, cmSystemTools::KeyWOW64_32);
-  this->PlatformToolset = "v120";
+  this->DefaultPlatformToolset = "v120";
 }
 
 //----------------------------------------------------------------------------
 bool
-cmGlobalVisualStudio12Generator::MatchesGeneratorName(const char* name) const
+cmGlobalVisualStudio12Generator::MatchesGeneratorName(
+                                                const std::string& name) const
 {
   std::string genName;
   if(cmVS12GenName(name, genName))
diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h
index 5a4a78d..4557f28 100644
--- a/Source/cmGlobalVisualStudio12Generator.h
+++ b/Source/cmGlobalVisualStudio12Generator.h
@@ -20,11 +20,12 @@
   public cmGlobalVisualStudio11Generator
 {
 public:
-  cmGlobalVisualStudio12Generator(const char* name,
-    const char* platformName, const char* additionalPlatformDefinition);
+  cmGlobalVisualStudio12Generator(const std::string& name,
+    const std::string& platformName,
+    const std::string& additionalPlatformDefinition);
   static cmGlobalGeneratorFactory* NewFactory();
 
-  virtual bool MatchesGeneratorName(const char* name) const;
+  virtual bool MatchesGeneratorName(const std::string& name) const;
 
   virtual void WriteSLNHeader(std::ostream& fout);
 
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index 6c458c3..7397bbb 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -116,11 +116,11 @@
 void
 cmGlobalVisualStudio6Generator::GenerateBuildCommand(
   std::vector<std::string>& makeCommand,
-  const char* makeProgram,
-  const char* projectName,
-  const char* /*projectDir*/,
-  const char* targetName,
-  const char* config,
+  const std::string& makeProgram,
+  const std::string& projectName,
+  const std::string& /*projectDir*/,
+  const std::string& targetName,
+  const std::string& config,
   bool /*fast*/,
   std::vector<std::string> const& makeOptions
   )
@@ -134,21 +134,22 @@
   makeCommand.push_back("/MAKE");
   std::string targetArg;
   bool clean = false;
-  if ( targetName && strcmp(targetName, "clean") == 0 )
+  std::string realTarget = targetName;
+  if ( realTarget == "clean" )
     {
     clean = true;
-    targetName = "ALL_BUILD";
+    realTarget = "ALL_BUILD";
     }
-  if (targetName && strlen(targetName))
+  if (!realTarget.empty())
     {
-    targetArg += targetName;
+    targetArg += realTarget;
     }
   else
     {
     targetArg += "ALL_BUILD";
     }
   targetArg += " - ";
-  if(config && strlen(config))
+  if(!config.empty())
     {
     targetArg += config;
     }
@@ -259,7 +260,7 @@
 // output the DSW file
 void cmGlobalVisualStudio6Generator::OutputDSWFile()
 {
-  std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+  std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
     {
     this->OutputDSWFile(it->second[0], it->second);
@@ -270,7 +271,7 @@
 // Note, that dependencies from executables to
 // the libraries it uses are also done here
 void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
-                                                  const char* dspname,
+                                                  const std::string& dspname,
                                                   const char* dir,
                                                   cmTarget const& target)
 {
@@ -315,9 +316,9 @@
 // Note, that dependencies from executables to
 // the libraries it uses are also done here
 void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout,
-                               const char* name,
+                               const std::string& name,
                                const char* location,
-                               const std::set<cmStdString>& dependencies)
+                               const std::set<std::string>& dependencies)
 {
  fout << "#########################################################"
     "######################\n\n";
@@ -328,7 +329,7 @@
   fout << "{{{\n";
 
 
-  std::set<cmStdString>::const_iterator i, end;
+  std::set<std::string>::const_iterator i, end;
   // write dependencies.
   i = dependencies.begin();
   end = dependencies.end();
@@ -417,12 +418,12 @@
 //----------------------------------------------------------------------------
 void
 cmGlobalVisualStudio6Generator
-::AppendDirectoryForConfig(const char* prefix,
-                           const char* config,
-                           const char* suffix,
+::AppendDirectoryForConfig(const std::string& prefix,
+                           const std::string& config,
+                           const std::string& suffix,
                            std::string& dir)
 {
-  if(config)
+  if(!config.empty())
     {
     dir += prefix;
     dir += config;
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
index 5521410..2797e11 100644
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ b/Source/cmGlobalVisualStudio6Generator.h
@@ -31,9 +31,9 @@
       <cmGlobalVisualStudio6Generator>(); }
 
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalVisualStudio6Generator::GetActualName();}
-  static const char* GetActualName() {return "Visual Studio 6";}
+  static std::string GetActualName() {return "Visual Studio 6";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -54,11 +54,11 @@
    */
   virtual void GenerateBuildCommand(
     std::vector<std::string>& makeCommand,
-    const char* makeProgram,
-    const char* projectName,
-    const char* projectDir,
-    const char* targetName,
-    const char* config,
+    const std::string& makeProgram,
+    const std::string& projectName,
+    const std::string& projectDir,
+    const std::string& targetName,
+    const std::string& config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
@@ -81,9 +81,9 @@
                             std::vector<cmLocalGenerator*>& generators);
 
   /** Append the subdirectory for the given configuration.  */
-  virtual void AppendDirectoryForConfig(const char* prefix,
-                                        const char* config,
-                                        const char* suffix,
+  virtual void AppendDirectoryForConfig(const std::string& prefix,
+                                        const std::string& config,
+                                        const std::string& suffix,
                                         std::string& dir);
 
   ///! What is the configurations directory variable called?
@@ -99,10 +99,11 @@
   void WriteDSWFile(std::ostream& fout);
   void WriteDSWHeader(std::ostream& fout);
   void WriteProject(std::ostream& fout,
-                    const char* name, const char* path, cmTarget const& t);
+                    const std::string& name, const char* path,
+                    cmTarget const& t);
   void WriteExternalProject(std::ostream& fout,
-                            const char* name, const char* path,
-                            const std::set<cmStdString>& dependencies);
+                            const std::string& name, const char* path,
+                            const std::set<std::string>& dependencies);
   void WriteDSWFooter(std::ostream& fout);
   virtual std::string WriteUtilityDepend(cmTarget const* target);
   std::string MSDevCommand;
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 22e4f08..4bea5ac 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -17,7 +17,8 @@
 
 //----------------------------------------------------------------------------
 cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(
-  const char* platformName) : cmGlobalVisualStudio7Generator(platformName)
+  const std::string& platformName)
+  : cmGlobalVisualStudio7Generator(platformName)
 {
   this->ProjectConfigurationSectionName = "ProjectConfiguration";
 }
@@ -155,7 +156,7 @@
 // the libraries it uses are also done here
 void
 cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
-                                              const char* dspname,
+                                              const std::string& dspname,
                                               const char* dir,
                                               cmTarget const& t)
 {
@@ -208,7 +209,7 @@
 void
 cmGlobalVisualStudio71Generator
 ::WriteProjectDepends(std::ostream& fout,
-                      const char*,
+                      const std::string&,
                       const char*, cmTarget const& target)
 {
   VSDependSet const& depends = this->VSTargetDepends[&target];
@@ -234,10 +235,10 @@
 // executables to the libraries it uses are also done here
 void cmGlobalVisualStudio71Generator
 ::WriteExternalProject(std::ostream& fout,
-                       const char* name,
+                       const std::string& name,
                        const char* location,
                        const char* typeGuid,
-                       const std::set<cmStdString>& depends)
+                       const std::set<std::string>& depends)
 {
   fout << "Project(\"{"
        << (typeGuid ? typeGuid : this->ExternalProjectType(location))
@@ -252,7 +253,7 @@
   if(!depends.empty())
     {
     fout << "\tProjectSection(ProjectDependencies) = postProject\n";
-    std::set<cmStdString>::const_iterator it;
+    std::set<std::string>::const_iterator it;
     for(it = depends.begin(); it != depends.end(); ++it)
       {
       if(it->size() > 0)
@@ -277,12 +278,12 @@
 // executables to the libraries it uses are also done here
 void cmGlobalVisualStudio71Generator
 ::WriteProjectConfigurations(
-  std::ostream& fout, const char* name, cmTarget::TargetType,
+  std::ostream& fout, const std::string& name, cmTarget::TargetType,
   const std::set<std::string>& configsPartOfDefaultBuild,
-  const char* platformMapping)
+  std::string const& platformMapping)
 {
-  const char* platformName =
-    platformMapping ? platformMapping : this->GetPlatformName();
+  const std::string& platformName =
+    !platformMapping.empty() ? platformMapping : this->GetPlatformName();
   std::string guid = this->GetGUID(name);
   for(std::vector<std::string>::iterator i = this->Configurations.begin();
       i != this->Configurations.end(); ++i)
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 04e3a55..2b5259a 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -23,15 +23,15 @@
 class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator
 {
 public:
-  cmGlobalVisualStudio71Generator(const char* platformName = NULL);
+  cmGlobalVisualStudio71Generator(const std::string& platformName = "");
   static cmGlobalGeneratorFactory* NewFactory() {
     return new cmGlobalGeneratorSimpleFactory
       <cmGlobalVisualStudio71Generator>(); }
 
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalVisualStudio71Generator::GetActualName();}
-  static const char* GetActualName() {return "Visual Studio 7 .NET 2003";}
+  static std::string GetActualName() {return "Visual Studio 7 .NET 2003";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -59,20 +59,20 @@
                             std::vector<cmLocalGenerator*>& generators);
   virtual void WriteSolutionConfigurations(std::ostream& fout);
   virtual void WriteProject(std::ostream& fout,
-                            const char* name, const char* path,
+                            const std::string& name, const char* path,
                             cmTarget const& t);
   virtual void WriteProjectDepends(std::ostream& fout,
-                           const char* name, const char* path,
+                           const std::string& name, const char* path,
                            cmTarget const& t);
   virtual void WriteProjectConfigurations(
-    std::ostream& fout, const char* name, cmTarget::TargetType type,
+    std::ostream& fout, const std::string& name, cmTarget::TargetType type,
     const std::set<std::string>& configsPartOfDefaultBuild,
-    const char* platformMapping = NULL);
+    const std::string& platformMapping = "");
   virtual void WriteExternalProject(std::ostream& fout,
-                                    const char* name,
+                                    const std::string& name,
                                     const char* path,
                                     const char* typeGuid,
-                                    const std::set<cmStdString>& depends);
+                                    const std::set<std::string>& depends);
   virtual void WriteSLNHeader(std::ostream& fout);
 
   std::string ProjectConfigurationSectionName;
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index bb63289..b581147 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -19,16 +19,19 @@
 #include <cmsys/Encoding.hxx>
 
 cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
-  const char* platformName)
+  const std::string& platformName)
 {
   this->IntelProjectVersion = 0;
   this->DevEnvCommandInitialized = false;
 
-  if (!platformName)
+  if (platformName.empty())
     {
-    platformName = "Win32";
+    this->PlatformName = "Win32";
     }
-  this->PlatformName = platformName;
+  else
+    {
+    this->PlatformName = platformName;
+    }
 }
 
 cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
@@ -183,11 +186,11 @@
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
   std::vector<std::string>& makeCommand,
-  const char* makeProgram,
-  const char* projectName,
-  const char* /*projectDir*/,
-  const char* targetName,
-  const char* config,
+  const std::string& makeProgram,
+  const std::string& projectName,
+  const std::string& /*projectDir*/,
+  const std::string& targetName,
+  const std::string& config,
   bool /*fast*/,
   std::vector<std::string> const& makeOptions)
 {
@@ -208,11 +211,12 @@
   makeCommand.push_back(makeProgramSelected);
 
   makeCommand.push_back(std::string(projectName) + ".sln");
+  std::string realTarget = targetName;
   bool clean = false;
-  if ( targetName && strcmp(targetName, "clean") == 0 )
+  if ( realTarget == "clean" )
     {
     clean = true;
-    targetName = "ALL_BUILD";
+    realTarget = "ALL_BUILD";
     }
   if(clean)
     {
@@ -223,7 +227,7 @@
     makeCommand.push_back("/build");
     }
 
-  if(config && strlen(config))
+  if(!config.empty())
     {
     makeCommand.push_back(config);
     }
@@ -233,9 +237,9 @@
     }
   makeCommand.push_back("/project");
 
-  if (targetName && strlen(targetName))
+  if (!realTarget.empty())
     {
-    makeCommand.push_back(targetName);
+    makeCommand.push_back(realTarget);
     }
   else
     {
@@ -259,7 +263,7 @@
 void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf)
 {
   cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf);
-  mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName());
+  mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str());
   mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION",
                     this->GetIntelProjectVersion());
 }
@@ -352,7 +356,7 @@
 // output the SLN file
 void cmGlobalVisualStudio7Generator::OutputSLNFile()
 {
-  std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+  std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
     {
     this->OutputSLNFile(it->second[0], it->second);
@@ -380,9 +384,10 @@
       {
       std::set<std::string> allConfigurations(this->Configurations.begin(),
                                               this->Configurations.end());
+      const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
       this->WriteProjectConfigurations(
-        fout, target->GetName(), target->GetType(),
-        allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING"));
+        fout, target->GetName().c_str(), target->GetType(),
+        allConfigurations, mapping ? mapping : "");
       }
     else
       {
@@ -653,7 +658,7 @@
 // Note, that dependencies from executables to
 // the libraries it uses are also done here
 void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
-                               const char* dspname,
+                               const std::string& dspname,
                                const char* dir, cmTarget const& target)
 {
    // check to see if this is a fortran build
@@ -693,7 +698,7 @@
 void
 cmGlobalVisualStudio7Generator
 ::WriteProjectDepends(std::ostream& fout,
-                      const char* dspname,
+                      const std::string& dspname,
                       const char*, cmTarget const& target)
 {
   int depcount = 0;
@@ -729,12 +734,12 @@
 // executables to the libraries it uses are also done here
 void cmGlobalVisualStudio7Generator
 ::WriteProjectConfigurations(
-  std::ostream& fout, const char* name, cmTarget::TargetType,
+  std::ostream& fout, const std::string& name, cmTarget::TargetType,
   const std::set<std::string>& configsPartOfDefaultBuild,
-  const char* platformMapping)
+  const std::string& platformMapping)
 {
-  const char* platformName =
-    platformMapping ? platformMapping : this->GetPlatformName();
+  const std::string& platformName =
+    !platformMapping.empty() ? platformMapping : this->GetPlatformName();
   std::string guid = this->GetGUID(name);
   for(std::vector<std::string>::iterator i = this->Configurations.begin();
       i != this->Configurations.end(); ++i)
@@ -757,10 +762,10 @@
 // Note, that dependencies from executables to
 // the libraries it uses are also done here
 void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
-                               const char* name,
+                               const std::string& name,
                                const char* location,
                                const char* typeGuid,
-                               const std::set<cmStdString>&)
+                               const std::set<std::string>&)
 {
   std::string d = cmSystemTools::ConvertToOutputPath(location);
   fout << "Project("
@@ -868,7 +873,8 @@
   std::string guid = this->GetGUID(pname.c_str());
 
   fout <<
-    "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
+    "<?xml version=\"1.0\" encoding = \""
+    << this->Encoding() << "\"?>\n"
     "<VisualStudioProject\n"
     "\tProjectType=\"Visual C++\"\n"
     "\tVersion=\"" << this->GetIDEVersion() << "0\"\n"
@@ -907,7 +913,7 @@
   return pname;
 }
 
-std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name)
+std::string cmGlobalVisualStudio7Generator::GetGUID(const std::string& name)
 {
   std::string guidStoreName = name;
   guidStoreName += "_GUID_CMAKE";
@@ -918,12 +924,12 @@
     return std::string(storedGUID);
     }
   cmSystemTools::Error("Unknown Target referenced : ",
-                       name);
+                       name.c_str());
   return "";
 }
 
 
-void cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
+void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name)
 {
   std::string guidStoreName = name;
   guidStoreName += "_GUID_CMAKE";
@@ -960,12 +966,12 @@
 //----------------------------------------------------------------------------
 void
 cmGlobalVisualStudio7Generator
-::AppendDirectoryForConfig(const char* prefix,
-                           const char* config,
-                           const char* suffix,
+::AppendDirectoryForConfig(const std::string& prefix,
+                           const std::string& config,
+                           const std::string& suffix,
                            std::string& dir)
 {
-  if(config)
+  if(!config.empty())
     {
     dir += prefix;
     dir += config;
@@ -974,8 +980,9 @@
 }
 
 std::set<std::string>
-cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
-                                                     cmTarget const* target)
+cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
+                                                    const std::string& project,
+                                                    cmTarget const* target)
 {
   std::set<std::string> activeConfigs;
   // if it is a utilitiy target then only make it part of the
@@ -1017,11 +1024,11 @@
    cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},
   {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "",
    cmVS7FlagTable::UserValueRequired},
-  {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "TRUE", 0},
+  {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "true", 0},
 
   // Exception handling mode.  If no entries match, it will be FALSE.
-  {"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE", 0},
-  {"ExceptionHandling", "EHsc", "enable c++ exceptions", "TRUE", 0},
+  {"ExceptionHandling", "GX", "enable c++ exceptions", "true", 0},
+  {"ExceptionHandling", "EHsc", "enable c++ exceptions", "true", 0},
   // The EHa option does not have an IDE setting.  Let it go to false,
   // and have EHa passed on the command line by leaving out the table
   // entry.
@@ -1032,3 +1039,14 @@
 {
   return cmVS7ExtraFlagTable;
 }
+
+std::string cmGlobalVisualStudio7Generator::Encoding()
+{
+  std::ostringstream encoding;
+#ifdef CMAKE_ENCODING_UTF8
+  encoding << "UTF-8";
+#else
+  encoding << "Windows-1252";
+#endif
+  return encoding.str();
+}
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index f69bd84..1dc709d 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -26,7 +26,7 @@
 class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
 {
 public:
-  cmGlobalVisualStudio7Generator(const char* platformName = NULL);
+  cmGlobalVisualStudio7Generator(const std::string& platformName = "");
   ~cmGlobalVisualStudio7Generator();
 
   static cmGlobalGeneratorFactory* NewFactory() {
@@ -34,12 +34,12 @@
       <cmGlobalVisualStudio7Generator>(); }
 
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalVisualStudio7Generator::GetActualName();}
-  static const char* GetActualName() {return "Visual Studio 7";}
+  static std::string GetActualName() {return "Visual Studio 7";}
 
   ///! Get the name for the platform.
-  const char* GetPlatformName() const { return this->PlatformName.c_str(); }
+  const std::string& GetPlatformName() const { return this->PlatformName; }
 
   ///! Create a local generator appropriate to this Global Generator
   virtual cmLocalGenerator *CreateLocalGenerator();
@@ -62,11 +62,11 @@
    */
   virtual void GenerateBuildCommand(
     std::vector<std::string>& makeCommand,
-    const char* makeProgram,
-    const char* projectName,
-    const char* projectDir,
-    const char* targetName,
-    const char* config,
+    const std::string& makeProgram,
+    const std::string& projectName,
+    const std::string& projectDir,
+    const std::string& targetName,
+    const std::string& config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
@@ -89,13 +89,13 @@
   std::vector<std::string> *GetConfigurations();
 
   ///! Create a GUID or get an existing one.
-  void CreateGUID(const char* name);
-  std::string GetGUID(const char* name);
+  void CreateGUID(const std::string& name);
+  std::string GetGUID(const std::string& name);
 
   /** Append the subdirectory for the given configuration.  */
-  virtual void AppendDirectoryForConfig(const char* prefix,
-                                        const char* config,
-                                        const char* suffix,
+  virtual void AppendDirectoryForConfig(const std::string& prefix,
+                                        const std::string& config,
+                                        const std::string& suffix,
                                         std::string& dir);
 
   ///! What is the configurations directory variable called?
@@ -109,6 +109,9 @@
 
   virtual void FindMakeProgram(cmMakefile*);
 
+  // Encoding for Visual Studio files
+  virtual std::string Encoding();
+
 protected:
   virtual const char* GetIDEVersion() { return "7.0"; }
 
@@ -123,15 +126,15 @@
   virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
                             std::vector<cmLocalGenerator*>& generators);
   virtual void WriteProject(std::ostream& fout,
-                            const char* name, const char* path,
+                            const std::string& name, const char* path,
                             cmTarget const& t);
   virtual void WriteProjectDepends(std::ostream& fout,
-                           const char* name, const char* path,
+                           const std::string& name, const char* path,
                            cmTarget const&t);
   virtual void WriteProjectConfigurations(
-    std::ostream& fout, const char* name, cmTarget::TargetType type,
+    std::ostream& fout, const std::string& name, cmTarget::TargetType type,
     const std::set<std::string>& configsPartOfDefaultBuild,
-    const char* platformMapping = NULL);
+    const std::string& platformMapping = "");
   virtual void WriteSLNGlobalSections(std::ostream& fout,
                                       cmLocalGenerator* root);
   virtual void WriteSLNFooter(std::ostream& fout);
@@ -153,18 +156,18 @@
   void GenerateConfigurations(cmMakefile* mf);
 
   virtual void WriteExternalProject(std::ostream& fout,
-                                    const char* name,
+                                    const std::string& name,
                                     const char* path,
                                     const char* typeGuid,
-                                    const std::set<cmStdString>&
+                                    const std::set<std::string>&
                                     dependencies);
 
   std::string ConvertToSolutionPath(const char* path);
 
-  std::set<std::string> IsPartOfDefaultBuild(const char* project,
+  std::set<std::string> IsPartOfDefaultBuild(const std::string& project,
                                              cmTarget const* target);
   std::vector<std::string> Configurations;
-  std::map<cmStdString, cmStdString> GUIDMap;
+  std::map<std::string, std::string> GUIDMap;
 
   virtual void WriteFolders(std::ostream& fout);
   virtual void WriteFoldersContent(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 12c240b..e6672a8 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -16,6 +16,7 @@
 #include "cmVisualStudioWCEPlatformParser.h"
 #include "cmake.h"
 #include "cmGeneratedFileStream.h"
+#include "cmSourceFile.h"
 
 static const char vs8generatorName[] = "Visual Studio 8 2005";
 
@@ -23,17 +24,19 @@
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
-    if(strstr(name, vs8generatorName) != name)
+  virtual cmGlobalGenerator* CreateGlobalGenerator(
+                                              const std::string& name) const {
+    if(strncmp(name.c_str(), vs8generatorName,
+               sizeof(vs8generatorName) - 1) != 0)
       {
       return 0;
       }
 
-    const char* p = name + sizeof(vs8generatorName) - 1;
+    const char* p = name.c_str() + sizeof(vs8generatorName) - 1;
     if(p[0] == '\0')
       {
       return new cmGlobalVisualStudio8Generator(
-        name, NULL, NULL);
+        name, "", "");
       }
 
     if(p[0] != ' ')
@@ -57,7 +60,7 @@
       }
 
     cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator(
-      name, p, NULL);
+      name, p, "");
     ret->WindowsCEVersion = parser.GetOSVersion();
     return ret;
   }
@@ -90,14 +93,14 @@
 
 //----------------------------------------------------------------------------
 cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(
-  const char* name, const char* platformName,
-  const char* additionalPlatformDefinition)
+  const std::string& name, const std::string& platformName,
+  const std::string& additionalPlatformDefinition)
   : cmGlobalVisualStudio71Generator(platformName)
 {
   this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
   this->Name = name;
 
-  if (additionalPlatformDefinition)
+  if (!additionalPlatformDefinition.empty())
     {
     this->AdditionalPlatformDefinition = additionalPlatformDefinition;
     }
@@ -314,14 +317,14 @@
   // file as the main dependency because it would get
   // overwritten by the CreateVCProjBuildRule.
   // (this could be avoided with per-target source files)
-  const char* no_main_dependency = 0;
+  std::string no_main_dependency = "";
   if(cmSourceFile* file =
      mf->AddCustomCommandToOutput(
        stamps, listFiles,
        no_main_dependency, commandLines, "Checking Build System",
        no_working_directory, true))
     {
-    tgt->AddSourceFile(file);
+    tgt->AddSource(file->GetFullPath());
     }
   else
     {
@@ -338,7 +341,7 @@
   if(this->AddCheckTarget())
     {
     // All targets depend on the build-system check target.
-    for(std::map<cmStdString,cmTarget *>::const_iterator
+    for(TargetMap::const_iterator
           ti = this->TotalTargets.begin();
         ti != this->TotalTargets.end(); ++ti)
       {
@@ -372,9 +375,9 @@
 void
 cmGlobalVisualStudio8Generator
 ::WriteProjectConfigurations(
-  std::ostream& fout, const char* name, cmTarget::TargetType type,
+  std::ostream& fout, const std::string& name, cmTarget::TargetType type,
   const std::set<std::string>& configsPartOfDefaultBuild,
-  const char* platformMapping)
+  std::string const& platformMapping)
 {
   std::string guid = this->GetGUID(name);
   for(std::vector<std::string>::iterator i = this->Configurations.begin();
@@ -382,7 +385,8 @@
     {
     fout << "\t\t{" << guid << "}." << *i
          << "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"
-         << (platformMapping ? platformMapping : this->GetPlatformName())
+         << (!platformMapping.empty()?
+             platformMapping : this->GetPlatformName())
          << "\n";
       std::set<std::string>::const_iterator
         ci = configsPartOfDefaultBuild.find(*i);
@@ -390,7 +394,8 @@
       {
       fout << "\t\t{" << guid << "}." << *i
            << "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|"
-           << (platformMapping ? platformMapping : this->GetPlatformName())
+           << (!platformMapping.empty()?
+               platformMapping : this->GetPlatformName())
            << "\n";
       }
     bool needsDeploy = (type == cmTarget::EXECUTABLE ||
@@ -399,7 +404,8 @@
       {
       fout << "\t\t{" << guid << "}." << *i
            << "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|"
-           << (platformMapping ? platformMapping : this->GetPlatformName())
+           << (!platformMapping.empty()?
+               platformMapping : this->GetPlatformName())
            << "\n";
       }
     }
@@ -415,7 +421,7 @@
 
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudio8Generator::WriteProjectDepends(
-  std::ostream& fout, const char*, const char*, cmTarget const& t)
+  std::ostream& fout, const std::string&, const char*, cmTarget const& t)
 {
   TargetDependSet const& unordered = this->GetTargetDirectDepends(t);
   OrderedTargetDependSet depends(unordered);
@@ -426,7 +432,7 @@
       {
       continue;
       }
-    std::string guid = this->GetGUID((*i)->GetName());
+    std::string guid = this->GetGUID((*i)->GetName().c_str());
     fout << "\t\t{" << guid << "} = {" << guid << "}\n";
     }
 }
@@ -436,11 +442,11 @@
   cmTarget& target)
 {
   // Look for utility dependencies that magically link.
-  for(std::set<cmStdString>::const_iterator ui =
+  for(std::set<std::string>::const_iterator ui =
         target.GetUtilities().begin();
       ui != target.GetUtilities().end(); ++ui)
     {
-    if(cmTarget* depTarget = this->FindTarget(0, ui->c_str()))
+    if(cmTarget* depTarget = this->FindTarget(ui->c_str()))
       {
       if(depTarget->GetType() != cmTarget::INTERFACE_LIBRARY
           && depTarget->GetProperty("EXTERNAL_MSPROJECT"))
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index 5b952c4..2459c05 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -23,12 +23,13 @@
 class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
 {
 public:
-  cmGlobalVisualStudio8Generator(const char* name,
-    const char* platformName, const char* additionalPlatformDefinition);
+  cmGlobalVisualStudio8Generator(const std::string& name,
+    const std::string& platformName,
+    const std::string& additionalPlatformDefinition);
   static cmGlobalGeneratorFactory* NewFactory();
 
   ///! Get the name for the generator.
-  virtual const char* GetName() const {return this->Name.c_str();}
+  virtual std::string GetName() const {return this->Name;}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -79,11 +80,12 @@
   virtual void WriteSLNHeader(std::ostream& fout);
   virtual void WriteSolutionConfigurations(std::ostream& fout);
   virtual void WriteProjectConfigurations(
-    std::ostream& fout, const char* name, cmTarget::TargetType type,
+    std::ostream& fout, const std::string& name, cmTarget::TargetType type,
     const std::set<std::string>& configsPartOfDefaultBuild,
-    const char* platformMapping = NULL);
+    const std::string& platformMapping = "");
   virtual bool ComputeTargetDepends();
-  virtual void WriteProjectDepends(std::ostream& fout, const char* name,
+  virtual void WriteProjectDepends(std::ostream& fout,
+                                   const std::string& name,
                                    const char* path, cmTarget const& t);
 
   std::string Name;
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index ccc27ad..c0051c7 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -22,17 +22,19 @@
   : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
-    if(strstr(name, vs9generatorName) != name)
+  virtual cmGlobalGenerator* CreateGlobalGenerator(
+                                              const std::string& name) const {
+    if(strncmp(name.c_str(), vs9generatorName,
+               sizeof(vs9generatorName) - 1) != 0)
       {
       return 0;
       }
 
-    const char* p = name + sizeof(vs9generatorName) - 1;
+    const char* p = name.c_str() + sizeof(vs9generatorName) - 1;
     if(p[0] == '\0')
       {
       return new cmGlobalVisualStudio9Generator(
-        name, NULL, NULL);
+        name, "", "");
       }
 
     if(p[0] != ' ')
@@ -96,8 +98,8 @@
 
 //----------------------------------------------------------------------------
 cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
-  const char* name, const char* platformName,
-  const char* additionalPlatformDefinition)
+  const std::string& name, const std::string& platformName,
+  const std::string& additionalPlatformDefinition)
   : cmGlobalVisualStudio8Generator(name, platformName,
                                    additionalPlatformDefinition)
 {
diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h
index 202aa8d..fb87bbe 100644
--- a/Source/cmGlobalVisualStudio9Generator.h
+++ b/Source/cmGlobalVisualStudio9Generator.h
@@ -24,8 +24,9 @@
   public cmGlobalVisualStudio8Generator
 {
 public:
-  cmGlobalVisualStudio9Generator(const char* name,
-    const char* platformName, const char* additionalPlatformDefinition);
+  cmGlobalVisualStudio9Generator(const std::string& name,
+    const std::string& platformName,
+    const std::string& additionalPlatformDefinition);
   static cmGlobalGeneratorFactory* NewFactory();
 
   ///! create the correct local generator
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 0c5f35b..c5a0e29 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -1,3 +1,4 @@
+
 /*============================================================================
   CMake - Cross Platform Makefile Generator
   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
@@ -22,7 +23,7 @@
 //----------------------------------------------------------------------------
 cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator()
 {
-  this->AdditionalPlatformDefinition = NULL;
+  this->AdditionalPlatformDefinition = "";
 }
 
 //----------------------------------------------------------------------------
@@ -53,7 +54,7 @@
   const char* no_working_dir = 0;
   std::vector<std::string> no_depends;
   cmCustomCommandLines no_commands;
-  std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+  std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
     {
     std::vector<cmLocalGenerator*>& gen = it->second;
@@ -118,51 +119,12 @@
 }
 
 //----------------------------------------------------------------------------
-void
-cmGlobalVisualStudioGenerator
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
+void cmGlobalVisualStudioGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
 {
-  cmLocalVisualStudioGenerator* lg =
-    static_cast<cmLocalVisualStudioGenerator*>(gt->LocalGenerator);
-  std::string dir_max = lg->ComputeLongestObjectDirectory(*gt->Target);
-
-  // Count the number of object files with each name.  Note that
-  // windows file names are not case sensitive.
-  std::map<cmStdString, int> counts;
-  std::vector<cmSourceFile*> objectSources;
-  gt->GetObjectSources(objectSources);
-  for(std::vector<cmSourceFile*>::const_iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    std::string objectNameLower = cmSystemTools::LowerCase(
-      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
-    objectNameLower += ".obj";
-    counts[objectNameLower] += 1;
-    }
-
-  // For all source files producing duplicate names we need unique
-  // object name computation.
-  for(std::vector<cmSourceFile*>::const_iterator
-        si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    std::string objectName =
-      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
-    objectName += ".obj";
-    if(counts[cmSystemTools::LowerCase(objectName)] > 1)
-      {
-      gt->AddExplicitObjectName(sf);
-      objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max);
-      }
-    gt->AddObject(sf, objectName);
-    }
-
   std::string dir = gt->Makefile->GetCurrentOutputDirectory();
   dir += "/";
-  std::string tgtDir = lg->GetTargetDirectory(*gt->Target);
+  std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target);
   if(!tgtDir.empty())
     {
     dir += tgtDir;
@@ -380,7 +342,7 @@
     {
     return false;
     }
-  std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+  std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
     {
     std::vector<cmLocalGenerator*>& gen = it->second;
@@ -518,7 +480,7 @@
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf)
 {
-  if(this->AdditionalPlatformDefinition)
+  if(!this->AdditionalPlatformDefinition.empty())
     {
     mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE");
     }
@@ -852,8 +814,16 @@
 cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
 {
   // check to see if this is a fortran build
-  std::set<cmStdString> languages;
-  target.GetLanguages(languages);
+  std::set<std::string> languages;
+  {
+  // Issue diagnostic if the source files depend on the config.
+  std::vector<cmSourceFile*> sources;
+  if (!target.GetConfigCommonSourceFiles(sources))
+    {
+    return false;
+    }
+  }
+  target.GetLanguages(languages, "");
   if(languages.size() == 1)
     {
     if(*languages.begin() == "Fortran")
@@ -870,15 +840,15 @@
 ::operator()(cmTarget const* l, cmTarget const* r) const
 {
   // Make sure ALL_BUILD is first so it is the default active project.
-  if(strcmp(r->GetName(), "ALL_BUILD") == 0)
+  if(r->GetName() == "ALL_BUILD")
     {
     return false;
     }
-  if(strcmp(l->GetName(), "ALL_BUILD") == 0)
+  if(l->GetName() == "ALL_BUILD")
     {
     return true;
     }
-  return strcmp(l->GetName(), r->GetName()) < 0;
+  return strcmp(l->GetName().c_str(), r->GetName().c_str()) < 0;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 9186d65..1ab8990 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -88,6 +88,7 @@
   virtual std::string ExpandCFGIntDir(const std::string& str,
                                       const std::string& config) const;
 
+  void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
   // Does this VS version link targets to each other if there are
   // dependencies in the SLN file?  This was done for VS versions
@@ -99,23 +100,23 @@
   virtual void AddPlatformDefinitions(cmMakefile* mf);
 
   virtual bool ComputeTargetDepends();
-  class VSDependSet: public std::set<cmStdString> {};
+  class VSDependSet: public std::set<std::string> {};
   class VSDependMap: public std::map<cmTarget const*, VSDependSet> {};
   VSDependMap VSTargetDepends;
   void ComputeVSTargetDepends(cmTarget&);
 
-  bool CheckTargetLinks(cmTarget& target, const char* name);
-  std::string GetUtilityForTarget(cmTarget& target, const char*);
+  bool CheckTargetLinks(cmTarget& target, const std::string& name);
+  std::string GetUtilityForTarget(cmTarget& target, const std::string&);
   virtual std::string WriteUtilityDepend(cmTarget const*) = 0;
   std::string GetUtilityDepend(cmTarget const* target);
-  typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap;
+  typedef std::map<cmTarget const*, std::string> UtilityDependsMap;
   UtilityDependsMap UtilityDepends;
-  const char* AdditionalPlatformDefinition;
+  std::string AdditionalPlatformDefinition;
 
 private:
   virtual std::string GetVSMakeProgram() = 0;
-  void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {}
-  void ComputeTargetObjects(cmGeneratorTarget* gt) const;
+  void PrintCompilerAdvice(std::ostream&, std::string const&,
+                           const char*) const {}
 
   void FollowLinkDepends(cmTarget const* target,
                          std::set<cmTarget const*>& linked);
diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx
index 98ce685..e44ed79 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.cxx
+++ b/Source/cmGlobalWatcomWMakeGenerator.cxx
@@ -16,7 +16,9 @@
 cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator()
 {
   this->FindMakeProgramFile = "CMakeFindWMake.cmake";
+#ifdef _WIN32
   this->ForceUnixPaths = false;
+#endif
   this->ToolSupportsColor = true;
   this->NeedSymbolicMark = true;
   this->EmptyRuleHackCommand = "@cd .";
@@ -33,7 +35,6 @@
   mf->AddDefinition("CMAKE_MANGLE_OBJECT_FILE_NAMES", "1");
   mf->AddDefinition("CMAKE_MAKE_LINE_CONTINUE", "&");
   mf->AddDefinition("CMAKE_MAKE_SYMBOLIC_RULE", ".SYMBOLIC");
-  mf->AddDefinition("CMAKE_NO_QUOTED_OBJECTS", "1");
   mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl386");
   mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl386");
   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
@@ -43,11 +44,12 @@
 cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator()
 {
   cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
-  lg->SetSilentNoColon(true);
   lg->SetDefineWindowsNULL(true);
+#ifdef _WIN32
   lg->SetWindowsShell(true);
+#endif
   lg->SetWatcomWMake(true);
-  lg->SetMakeSilentFlag("-s -h -e");
+  lg->SetMakeSilentFlag("-h");
   lg->SetGlobalGenerator(this);
   lg->SetIgnoreLibPrefix(true);
   lg->SetPassMakeflags(false);
diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h
index d5350ef..2057a42 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.h
+++ b/Source/cmGlobalWatcomWMakeGenerator.h
@@ -27,9 +27,9 @@
     return new cmGlobalGeneratorSimpleFactory
       <cmGlobalWatcomWMakeGenerator>(); }
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalWatcomWMakeGenerator::GetActualName();}
-  static const char* GetActualName() {return "Watcom WMake";}
+  static std::string GetActualName() {return "Watcom WMake";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 484b28f..29a5955 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -34,17 +34,17 @@
 {
 public:
   cmXcodeVersionParser(): Version("1.5") {}
-  void StartElement(const char* , const char** )
+  void StartElement(const std::string&, const char**)
     {
       this->Data = "";
     }
-  void EndElement(const char* name)
+  void EndElement(const std::string& name)
     {
-      if(strcmp(name, "key") == 0)
+      if(name == "key")
         {
         this->Key = this->Data;
         }
-      else if(strcmp(name, "string") == 0)
+      else if(name == "string")
         {
         if(this->Key == "CFBundleShortVersionString")
           {
@@ -116,7 +116,8 @@
 class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
 {
 public:
-  virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const;
+  virtual cmGlobalGenerator* CreateGlobalGenerator(
+                                              const std::string& name) const;
 
   virtual void GetDocumentation(cmDocumentationEntry& entry) const {
     cmGlobalXCodeGenerator::GetDocumentation(entry); }
@@ -152,9 +153,9 @@
 
 //----------------------------------------------------------------------------
 cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
-::CreateGlobalGenerator(const char* name) const
+::CreateGlobalGenerator(const std::string& name) const
 {
-  if (strcmp(name, GetActualName()))
+  if (name != GetActualName())
     return 0;
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   cmXcodeVersionParser parser;
@@ -201,16 +202,19 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts)
+bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
+                                                 cmMakefile* mf)
 {
   if(this->XcodeVersion >= 30)
     {
-    this->PlatformToolset = ts;
+    this->GeneratorToolset = ts;
+    mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
+                      this->GeneratorToolset.c_str());
     return true;
     }
   else
     {
-    return cmGlobalGenerator::SetGeneratorToolset(ts);
+    return cmGlobalGenerator::SetGeneratorToolset(ts, mf);
     }
 }
 
@@ -238,11 +242,6 @@
       }
     }
   mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1");
-  if(!this->PlatformToolset.empty())
-    {
-    mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
-                      this->PlatformToolset.c_str());
-    }
   this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
     const char* osxArch =
       mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
@@ -260,11 +259,11 @@
 void
 cmGlobalXCodeGenerator::GenerateBuildCommand(
   std::vector<std::string>& makeCommand,
-  const char* makeProgram,
-  const char* projectName,
-  const char* /*projectDir*/,
-  const char* targetName,
-  const char* config,
+  const std::string& makeProgram,
+  const std::string& projectName,
+  const std::string& /*projectDir*/,
+  const std::string& targetName,
+  const std::string& config,
   bool /*fast*/,
   std::vector<std::string> const& makeOptions)
 {
@@ -283,10 +282,11 @@
   makeCommand.push_back(projectArg);
 
   bool clean = false;
-  if ( targetName && strcmp(targetName, "clean") == 0 )
+  std::string realTarget = targetName;
+  if ( realTarget == "clean" )
     {
     clean = true;
-    targetName = "ALL_BUILD";
+    realTarget = "ALL_BUILD";
     }
   if(clean)
     {
@@ -297,14 +297,9 @@
     makeCommand.push_back("build");
     }
   makeCommand.push_back("-target");
-  // if it is a null string for config don't use it
-  if(config && *config == 0)
+  if (!realTarget.empty())
     {
-    config = 0;
-    }
-  if (targetName && strlen(targetName))
-    {
-    makeCommand.push_back(targetName);
+    makeCommand.push_back(realTarget);
     }
   else
     {
@@ -318,7 +313,7 @@
   else
     {
     makeCommand.push_back("-configuration");
-    makeCommand.push_back(config?config:"Debug");
+    makeCommand.push_back(!config.empty()?config:"Debug");
     }
   makeCommand.insert(makeCommand.end(),
                      makeOptions.begin(), makeOptions.end());
@@ -336,7 +331,7 @@
 //----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::Generate()
 {
-  std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+  std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
   // make sure extra targets are added before calling
   // the parent generate which will call trace depends
   for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
@@ -346,7 +341,6 @@
     // add ALL_BUILD, INSTALL, etc
     this->AddExtraTargets(root, it->second);
     }
-  this->ForceLinkerLanguages();
   this->cmGlobalGenerator::Generate();
   if(cmSystemTools::GetErrorOccuredFlag())
     {
@@ -415,7 +409,7 @@
   std::string listfile = mf->GetStartDirectory();
   listfile += "/";
   listfile += "CMakeLists.txt";
-  allbuild->AddSource(listfile.c_str());
+  allbuild->AddSourceCMP0049(listfile.c_str());
 
   // Add XCODE depend helper
   std::string dir = mf->GetCurrentOutputDirectory();
@@ -498,7 +492,7 @@
       listfile = lg->GetMakefile()->GetStartDirectory();
       listfile += "/";
       listfile += "CMakeLists.txt";
-      target.AddSource(listfile.c_str());
+      target.AddSourceCMP0049(listfile.c_str());
       }
     }
 }
@@ -569,7 +563,7 @@
 {
   if(obj->GetType() == cmXCodeObject::OBJECT)
     {
-    cmStdString id = obj->GetId();
+    std::string id = obj->GetId();
 
     // If this is a duplicate id, it's an error:
     //
@@ -613,7 +607,7 @@
 
 //----------------------------------------------------------------------------
 cmXCodeObject*
-cmGlobalXCodeGenerator::CreateString(const char* s)
+cmGlobalXCodeGenerator::CreateString(const std::string& s)
 {
   cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING);
   obj->SetString(s);
@@ -630,17 +624,17 @@
 }
 
 //----------------------------------------------------------------------------
-cmStdString
+std::string
 GetGroupMapKeyFromPath(cmTarget& cmtarget, const std::string& fullpath)
 {
-  cmStdString key(cmtarget.GetName());
+  std::string key(cmtarget.GetName());
   key += "-";
   key += fullpath;
   return key;
 }
 
 //----------------------------------------------------------------------------
-cmStdString
+std::string
 GetGroupMapKey(cmTarget& cmtarget, cmSourceFile* sf)
 {
   return GetGroupMapKeyFromPath(cmtarget, sf->GetFullPath());
@@ -651,13 +645,14 @@
 cmGlobalXCodeGenerator::CreateXCodeSourceFileFromPath(
   const std::string &fullpath,
   cmTarget& cmtarget,
-  const std::string &lang)
+  const std::string &lang,
+  cmSourceFile* sf)
 {
   // Using a map and the full path guarantees that we will always get the same
   // fileRef object for any given full path.
   //
   cmXCodeObject* fileRef =
-    this->CreateXCodeFileReferenceFromPath(fullpath, cmtarget, lang);
+    this->CreateXCodeFileReferenceFromPath(fullpath, cmtarget, lang, sf);
 
   cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile);
   buildFile->SetComment(fileRef->GetComment());
@@ -696,15 +691,11 @@
     flags += flagsBuild.GetString();
     }
 
-  const char* lang =
+  std::string lang =
     this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
-  if (!lang)
-    {
-    lang = "";
-    }
 
   cmXCodeObject* buildFile =
-    this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), cmtarget, lang);
+    this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), cmtarget, lang, sf);
   cmXCodeObject* fileRef = buildFile->GetObject("fileRef")->GetObject();
 
   cmXCodeObject* settings =
@@ -713,22 +704,23 @@
 
   // Is this a resource file in this target? Add it to the resources group...
   //
-  cmTarget::SourceFileFlags tsFlags = cmtarget.GetTargetSourceFileFlags(sf);
-  bool isResource = (tsFlags.Type == cmTarget::SourceFileTypeResource);
+  cmGeneratorTarget::SourceFileFlags tsFlags =
+            this->GetGeneratorTarget(&cmtarget)->GetTargetSourceFileFlags(sf);
+  bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource;
 
   // Is this a "private" or "public" framework header file?
   // Set the ATTRIBUTES attribute appropriately...
   //
   if(cmtarget.IsFrameworkOnApple())
     {
-    if(tsFlags.Type == cmTarget::SourceFileTypePrivateHeader)
+    if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader)
       {
       cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
       attrs->AddObject(this->CreateString("Private"));
       settings->AddAttribute("ATTRIBUTES", attrs);
       isResource = true;
       }
-    else if(tsFlags.Type == cmTarget::SourceFileTypePublicHeader)
+    else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader)
       {
       cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
       attrs->AddObject(this->CreateString("Public"));
@@ -835,7 +827,8 @@
 cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
   const std::string &fullpath,
   cmTarget& cmtarget,
-  const std::string &lang)
+  const std::string &lang,
+  cmSourceFile* sf)
 {
   std::string fname = fullpath;
   cmXCodeObject* fileRef = this->FileRefs[fname];
@@ -846,7 +839,7 @@
     fileRef->SetComment(fname.c_str());
     this->FileRefs[fname] = fileRef;
     }
-  cmStdString key = GetGroupMapKeyFromPath(cmtarget, fullpath);
+  std::string key = GetGroupMapKeyFromPath(cmtarget, fullpath);
   cmXCodeObject* group = this->GroupMap[key];
   cmXCodeObject* children = group->GetObject("children");
   if (!children->HasObject(fileRef))
@@ -855,35 +848,48 @@
     }
   fileRef->AddAttribute("fileEncoding", this->CreateString("4"));
 
-  // Compute the extension.
-  std::string ext;
-  std::string realExt =
-    cmSystemTools::GetFilenameLastExtension(fullpath);
-  if(!realExt.empty())
+  bool useLastKnownFileType = false;
+  std::string fileType;
+  if(sf)
     {
-    // Extension without the leading '.'.
-    ext = realExt.substr(1);
+    if(const char* e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE"))
+      {
+      fileType = e;
+      }
+    else if(const char* l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE"))
+      {
+      useLastKnownFileType = true;
+      fileType = l;
+      }
+    }
+  if(fileType.empty())
+    {
+    // If fullpath references a directory, then we need to specify
+    // lastKnownFileType as folder in order for Xcode to be able to
+    // open the contents of the folder.
+    // (Xcode 4.6 does not like explicitFileType=folder).
+    if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
+      {
+      fileType = "folder";
+      useLastKnownFileType = true;
+      }
+    else
+      {
+      // Compute the extension without leading '.'.
+      std::string ext = cmSystemTools::GetFilenameLastExtension(fullpath);
+      if(!ext.empty())
+        {
+        ext = ext.substr(1);
+        }
+
+      fileType = GetSourcecodeValueFromFileExtension(
+        ext, lang, useLastKnownFileType);
+      }
     }
 
-  // If fullpath references a directory, then we need to specify
-  // lastKnownFileType as folder in order for Xcode to be able to open the
-  // contents of the folder (Xcode 4.6 does not like explicitFileType=folder).
-  if(cmSystemTools::FileIsDirectory(fullpath.c_str()))
-    {
-    fileRef->AddAttribute("lastKnownFileType",
-                          this->CreateString("folder"));
-    }
-  else
-    {
-    bool keepLastKnownFileType = false;
-    std::string sourcecode = GetSourcecodeValueFromFileExtension(ext,
-                             lang, keepLastKnownFileType);
-    const char* attribute = keepLastKnownFileType ?
-                             "lastKnownFileType" :
-                             "explicitFileType";
-    fileRef->AddAttribute(attribute,
-                          this->CreateString(sourcecode.c_str()));
-    }
+  fileRef->AddAttribute(useLastKnownFileType? "lastKnownFileType"
+                                            : "explicitFileType",
+                        this->CreateString(fileType));
 
   // Store the file path relative to the top of the source tree.
   std::string path = this->RelativeToSource(fullpath.c_str());
@@ -905,15 +911,11 @@
 cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf,
                                                  cmTarget& cmtarget)
 {
-  const char* lang =
+  std::string lang =
     this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
-  if (!lang)
-    {
-    lang = "";
-    }
 
   return this->CreateXCodeFileReferenceFromPath(
-    sf->GetFullPath(), cmtarget, lang);
+    sf->GetFullPath(), cmtarget, lang, sf);
 }
 
 //----------------------------------------------------------------------------
@@ -973,6 +975,7 @@
   for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
     {
     cmTarget& cmtarget = l->second;
+    cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
 
     // make sure ALL_BUILD, INSTALL, etc are only done once
     if(this->SpecialTargetEmitted(l->first.c_str()))
@@ -994,9 +997,14 @@
 
     // organize the sources
     std::vector<cmSourceFile*> classes;
-    cmtarget.GetSourceFiles(classes);
+    if (!cmtarget.GetConfigCommonSourceFiles(classes))
+      {
+      return;
+      }
     std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
 
+    gtgt->ComputeObjectMapping();
+
     std::vector<cmXCodeObject*> externalObjFiles;
     std::vector<cmXCodeObject*> headerFiles;
     std::vector<cmXCodeObject*> resourceFiles;
@@ -1011,21 +1019,24 @@
       cmXCodeObject* filetype =
         fr->GetObject()->GetObject("explicitFileType");
 
-      cmTarget::SourceFileFlags tsFlags =
-        cmtarget.GetTargetSourceFileFlags(*i);
+      cmGeneratorTarget::SourceFileFlags tsFlags =
+        gtgt->GetTargetSourceFileFlags(*i);
 
       if(filetype &&
-         strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0)
+         filetype->GetString() == "compiled.mach-o.objfile")
         {
-        externalObjFiles.push_back(xsf);
+        if ((*i)->GetObjectLibrary().empty())
+          {
+          externalObjFiles.push_back(xsf);
+          }
         }
       else if(this->IsHeaderFile(*i) ||
-        (tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) ||
-        (tsFlags.Type == cmTarget::SourceFileTypePublicHeader))
+        (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) ||
+        (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader))
         {
         headerFiles.push_back(xsf);
         }
-      else if(tsFlags.Type == cmTarget::SourceFileTypeResource)
+      else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource)
         {
         resourceFiles.push_back(xsf);
         }
@@ -1034,7 +1045,7 @@
         // Include this file in the build if it has a known language
         // and has not been listed as an ignored extension for this
         // generator.
-        if(this->CurrentLocalGenerator->GetSourceFileLanguage(**i) &&
+        if(!this->CurrentLocalGenerator->GetSourceFileLanguage(**i).empty() &&
            !this->IgnoreFile((*i)->GetExtension().c_str()))
           {
           sourceFiles.push_back(xsf);
@@ -1048,13 +1059,13 @@
       // the externalObjFiles above, except each one is not a cmSourceFile
       // within the target.)
       std::vector<std::string> objs;
-      this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs);
+      gtgt->UseObjectLibraries(objs, "");
       for(std::vector<std::string>::const_iterator
             oi = objs.begin(); oi != objs.end(); ++oi)
         {
         std::string obj = *oi;
         cmXCodeObject* xsf =
-          this->CreateXCodeSourceFileFromPath(obj, cmtarget, "");
+          this->CreateXCodeSourceFileFromPath(obj, cmtarget, "", 0);
         externalObjFiles.push_back(xsf);
         }
       }
@@ -1132,15 +1143,15 @@
     std::vector<cmXCodeObject*> contentBuildPhases;
     if (isFrameworkTarget || isBundleTarget || isCFBundleTarget)
       {
-      typedef std::map<cmStdString, std::vector<cmSourceFile*> >
+      typedef std::map<std::string, std::vector<cmSourceFile*> >
         mapOfVectorOfSourceFiles;
       mapOfVectorOfSourceFiles bundleFiles;
       for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
           i != classes.end(); ++i)
         {
-        cmTarget::SourceFileFlags tsFlags =
-          cmtarget.GetTargetSourceFileFlags(*i);
-        if(tsFlags.Type == cmTarget::SourceFileTypeMacContent)
+        cmGeneratorTarget::SourceFileFlags tsFlags =
+          gtgt->GetTargetSourceFileFlags(*i);
+        if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent)
           {
           bundleFiles[tsFlags.MacFolder].push_back(*i);
           }
@@ -1221,7 +1232,7 @@
 void cmGlobalXCodeGenerator::ForceLinkerLanguages()
 {
   // This makes sure all targets link using the proper language.
-  for(std::map<cmStdString, cmTarget*>::const_iterator
+  for(TargetMap::const_iterator
         ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
     {
     this->ForceLinkerLanguage(*ti->second);
@@ -1239,8 +1250,8 @@
     return;
     }
 
-  const char* llang = cmtarget.GetLinkerLanguage("NOCONFIG");
-  if(!llang) { return; }
+  std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG");
+  if(llang.empty()) { return; }
 
   // If the language is compiled as a source trust Xcode to link with it.
   cmTarget::LinkImplementation const* impl =
@@ -1268,8 +1279,8 @@
   }
   if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str()))
     {
-    sf->SetProperty("LANGUAGE", llang);
-    cmtarget.AddSourceFile(sf);
+    sf->SetProperty("LANGUAGE", llang.c_str());
+    cmtarget.AddSource(fname);
     }
 }
 
@@ -1364,7 +1375,10 @@
     }
 
   std::vector<cmSourceFile*> classes;
-  cmtarget.GetSourceFiles(classes);
+  if (!cmtarget.GetConfigCommonSourceFiles(classes))
+    {
+    return;
+    }
   // add all the sources
   std::vector<cmCustomCommand> commands;
   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
@@ -1479,32 +1493,7 @@
                                                 const & commands,
                                                 const char* name)
 {
-
-  // collect multiple outputs of custom commands into a set
-  // which will be used for every configuration
-  std::map<cmStdString, cmStdString> multipleOutputPairs;
-  for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
-      i != commands.end(); ++i)
-    {
-    cmCustomCommand const& cc = *i;
-    if(!cc.GetCommandLines().empty())
-      {
-      const std::vector<std::string>& outputs = cc.GetOutputs();
-      if(!outputs.empty())
-        {
-        // If there are more than one outputs treat the
-        // first as the primary output and make the rest depend on it.
-        std::vector<std::string>::const_iterator o = outputs.begin();
-        std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str());
-        for(++o; o != outputs.end(); ++o)
-          {
-          std::string currentOutput=this->ConvertToRelativeForMake(o->c_str());
-          multipleOutputPairs[currentOutput] = primaryOutput;
-          }
-        }
-      }
-    }
-
+  bool haveMultipleOutputPairs = false;
   std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory();
   dir += "/CMakeScripts";
   cmSystemTools::MakeDirectory(dir.c_str());
@@ -1524,7 +1513,7 @@
                                     target,
                                     commands,
                                     currentConfig->c_str(),
-                                    multipleOutputPairs);
+                                    haveMultipleOutputPairs);
     }
 
   std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory();
@@ -1534,7 +1523,7 @@
   makecmd += " -f ";
   makecmd += this->ConvertToRelativeForMake(
                                           (makefile+"$CONFIGURATION").c_str());
-  if(!multipleOutputPairs.empty())
+  if(haveMultipleOutputPairs)
     {
     makecmd += " cmake_check_multiple_outputs";
     }
@@ -1552,10 +1541,8 @@
                             cmTarget& target,
                             std::vector<cmCustomCommand>
                             const & commands,
-                            const char* configName,
-                            const std::map<cmStdString,
-                            cmStdString>& multipleOutputPairs
-                           )
+                            const std::string& configName,
+                            bool& haveMultipleOutputPairs)
 {
   std::string makefileName=makefileBasename;
   if(this->XcodeVersion > 20)
@@ -1576,15 +1563,16 @@
 
   // have all depend on all outputs
   makefileStream << "all: ";
-  std::map<const cmCustomCommand*, cmStdString> tname;
+  std::map<const cmCustomCommand*, std::string> tname;
   int count = 0;
+  std::map<std::string, std::string> multipleOutputPairs;
   for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
       i != commands.end(); ++i)
     {
-    cmCustomCommand const& cc = *i;
-    if(!cc.GetCommandLines().empty())
+    cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile);
+    if(ccg.GetNumberOfCommands() > 0)
       {
-      const std::vector<std::string>& outputs = cc.GetOutputs();
+      const std::vector<std::string>& outputs = ccg.GetOutputs();
       if(!outputs.empty())
         {
         for(std::vector<std::string>::const_iterator o = outputs.begin();
@@ -1593,13 +1581,23 @@
           makefileStream
               << "\\\n\t" << this->ConvertToRelativeForMake(o->c_str());
           }
+
+        // If there is more than one output treat the first as the
+        // primary output and make the rest depend on it.
+        std::vector<std::string>::const_iterator o = outputs.begin();
+        std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str());
+        for(++o; o != outputs.end(); ++o)
+          {
+          std::string currentOutput=this->ConvertToRelativeForMake(o->c_str());
+          multipleOutputPairs[currentOutput] = primaryOutput;
+          }
         }
       else
         {
         cmOStringStream str;
         str << "_buildpart_" << count++ ;
-        tname[&cc] = std::string(target.GetName()) + str.str();
-        makefileStream << "\\\n\t" << tname[&cc];
+        tname[&ccg.GetCC()] = std::string(target.GetName()) + str.str();
+        makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
         }
       }
     }
@@ -1607,12 +1605,11 @@
   for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
       i != commands.end(); ++i)
     {
-    cmCustomCommand const& cc = *i;
-    if(!cc.GetCommandLines().empty())
+    cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile);
+    if(ccg.GetNumberOfCommands() > 0)
       {
-      cmCustomCommandGenerator ccg(cc, configName, this->CurrentMakefile);
       makefileStream << "\n";
-      const std::vector<std::string>& outputs = cc.GetOutputs();
+      const std::vector<std::string>& outputs = ccg.GetOutputs();
       if(!outputs.empty())
         {
         // There is at least one output, start the rule for it
@@ -1623,11 +1620,11 @@
       else
         {
         // There are no outputs.  Use the generated force rule name.
-        makefileStream << tname[&cc] << ": ";
+        makefileStream << tname[&ccg.GetCC()] << ": ";
         }
       for(std::vector<std::string>::const_iterator d =
-          cc.GetDepends().begin();
-          d != cc.GetDepends().end(); ++d)
+          ccg.GetDepends().begin();
+          d != ccg.GetDepends().end(); ++d)
         {
         std::string dep;
         if(this->CurrentLocalGenerator
@@ -1639,11 +1636,11 @@
         }
       makefileStream << "\n";
 
-      if(const char* comment = cc.GetComment())
+      if(const char* comment = ccg.GetComment())
         {
         std::string echo_cmd = "echo ";
         echo_cmd += (this->CurrentLocalGenerator->
-                     EscapeForShell(comment, cc.GetEscapeAllowMakeVars()));
+          EscapeForShell(comment, ccg.GetCC().GetEscapeAllowMakeVars()));
         makefileStream << "\t" << echo_cmd.c_str() << "\n";
         }
 
@@ -1655,10 +1652,11 @@
         cmSystemTools::ReplaceString(cmd2, "/./", "/");
         cmd2 = this->ConvertToRelativeForMake(cmd2.c_str());
         std::string cmd;
-        if(cc.GetWorkingDirectory())
+        std::string wd = ccg.GetWorkingDirectory();
+        if(!wd.empty())
           {
           cmd += "cd ";
-          cmd += this->ConvertToRelativeForMake(cc.GetWorkingDirectory());
+          cmd += this->ConvertToRelativeForMake(wd.c_str());
           cmd += " && ";
           }
         cmd += cmd2;
@@ -1674,7 +1672,7 @@
     makefileStream <<
         "\n# Dependencies of multiple outputs to their primary outputs \n";
 
-    for(std::map<cmStdString, cmStdString>::const_iterator o =
+    for(std::map<std::string, std::string>::const_iterator o =
         multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o)
       {
       makefileStream << o->first << ": " << o->second << "\n";
@@ -1683,7 +1681,7 @@
     makefileStream <<
         "\n"
         "cmake_check_multiple_outputs:\n";
-    for(std::map<cmStdString, cmStdString>::const_iterator o =
+    for(std::map<std::string, std::string>::const_iterator o =
         multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o)
       {
       makefileStream << "\t@if [ ! -f "
@@ -1691,12 +1689,15 @@
           << o->second << "; fi\n";
       }
     }
+
+  haveMultipleOutputPairs =
+    haveMultipleOutputPairs || !multipleOutputPairs.empty();
 }
 
 //----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
-                                                 cmXCodeObject* buildSettings,
-                                                 const char* configName)
+                                                cmXCodeObject* buildSettings,
+                                                const std::string& configName)
 {
   if(target.GetType() == cmTarget::INTERFACE_LIBRARY)
     {
@@ -1712,12 +1713,12 @@
                  (target.GetType() == cmTarget::EXECUTABLE) ||
                  shared);
 
-  const char* lang = target.GetLinkerLanguage(configName);
+  std::string lang = target.GetLinkerLanguage(configName);
   std::string cflags;
-  if(lang)
+  if(!lang.empty())
     {
     // for c++ projects get the c flags as well
-    if(strcmp(lang, "CXX") == 0)
+    if(lang == "CXX")
       {
       this->CurrentLocalGenerator->AddLanguageFlags(cflags, "C", configName);
       this->CurrentLocalGenerator->AddCMP0018Flags(cflags, &target,
@@ -1743,7 +1744,7 @@
   {
     cmSystemTools::Error
       ("CMake can not determine linker language for target: ",
-       target.GetName());
+       target.GetName().c_str());
     return;
   }
 
@@ -1809,7 +1810,7 @@
       this->CurrentLocalGenerator->
         AppendFlags(extraLinkOptions, targetLinkFlags);
       }
-    if(configName && *configName)
+    if(!configName.empty())
       {
       std::string linkFlagsVar = "LINK_FLAGS_";
       linkFlagsVar += cmSystemTools::UpperCase(configName);
@@ -2093,7 +2094,7 @@
   std::vector<std::string> includes;
   this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt,
                                                      "C", configName);
-  std::set<cmStdString> emitted;
+  std::set<std::string> emitted;
   emitted.insert("/System/Library/Frameworks");
   for(std::vector<std::string>::iterator i = includes.begin();
       i != includes.end(); ++i)
@@ -2176,7 +2177,7 @@
   const char* debugStr = "YES";
   // We can't set the Xcode flag differently depending on the language,
   // so put them back in this case.
-  if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc )
+  if( (lang == "CXX") && gflag != gflagc )
     {
     cflags += " ";
     cflags += gflagc;
@@ -2199,7 +2200,7 @@
                               this->CreateString("NO"));
   buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN",
                               this->CreateString("NO"));
-  if(lang && strcmp(lang, "CXX") == 0)
+  if(lang == "CXX")
     {
     flags += " ";
     flags += defFlags;
@@ -2362,18 +2363,18 @@
     {
     if(i->first.find("XCODE_ATTRIBUTE_") == 0)
       {
-      cmStdString attribute = i->first.substr(16);
+      std::string attribute = i->first.substr(16);
       // Handle [variant=<config>] condition explicitly here.
-      cmStdString::size_type beginVariant =
+      std::string::size_type beginVariant =
         attribute.find("[variant=");
-      if (beginVariant != cmStdString::npos)
+      if (beginVariant != std::string::npos)
         {
-        cmStdString::size_type endVariant =
+        std::string::size_type endVariant =
           attribute.find("]", beginVariant+9);
-        if (endVariant != cmStdString::npos)
+        if (endVariant != std::string::npos)
           {
           // Compare the variant to the configuration.
-          cmStdString variant =
+          std::string variant =
             attribute.substr(beginVariant+9, endVariant-beginVariant-9);
           if (variant == configName)
             {
@@ -2426,7 +2427,7 @@
 
   cmXCodeObject* target =
     this->CreateObject(cmXCodeObject::PBXAggregateTarget);
-  target->SetComment(cmtarget.GetName());
+  target->SetComment(cmtarget.GetName().c_str());
   cmXCodeObject* buildPhases =
     this->CreateObject(cmXCodeObject::OBJECT_LIST);
   std::vector<cmXCodeObject*> emptyContentVector;
@@ -2439,8 +2440,8 @@
     }
   else
     {
-    const char* theConfig =
-      this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE");
+    std::string theConfig =
+      this->CurrentMakefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
     cmXCodeObject* buildSettings =
       this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
     this->CreateBuildSettings(cmtarget, buildSettings, theConfig);
@@ -2457,7 +2458,11 @@
   if(cmtarget.GetType() == cmTarget::UTILITY)
     {
     std::vector<cmSourceFile*> sources;
-    cmtarget.GetSourceFiles(sources);
+    if (!cmtarget.GetConfigCommonSourceFiles(sources))
+      {
+      return 0;
+      }
+
     for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
         i != sources.end(); ++i)
       {
@@ -2627,7 +2632,7 @@
   fileRef->AddAttribute("refType", this->CreateString("0"));
   fileRef->AddAttribute("sourceTree",
                         this->CreateString("BUILT_PRODUCTS_DIR"));
-  fileRef->SetComment(cmtarget.GetName());
+  fileRef->SetComment(cmtarget.GetName().c_str());
   target->AddAttribute("productReference",
                        this->CreateObjectReference(fileRef));
   if(const char* productType = this->GetTargetProductType(cmtarget))
@@ -2660,8 +2665,8 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name,
-                                                  const char* id)
+std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
+                                                  const std::string& id)
 {
   std::string guidStoreName = name;
   guidStoreName += "_GUID_CMAKE";
@@ -2674,7 +2679,7 @@
     }
 
   this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
-    id, "Stored Xcode object GUID", cmCacheManager::INTERNAL);
+    id.c_str(), "Stored Xcode object GUID", cmCacheManager::INTERNAL);
 
   return id;
 }
@@ -2743,7 +2748,7 @@
 ::AppendBuildSettingAttribute(cmXCodeObject* target,
                               const char* attribute,
                               const char* value,
-                              const char* configName)
+                              const std::string& configName)
 {
   if(this->XcodeVersion < 21)
     {
@@ -2766,9 +2771,9 @@
     for(std::vector<cmXCodeObject*>::iterator i = list.begin();
         i != list.end(); ++i)
       {
-      if(configName)
+      if(!configName.empty())
         {
-        if(strcmp((*i)->GetObject("name")->GetString(), configName) == 0)
+        if((*i)->GetObject("name")->GetString() == configName)
           {
           cmXCodeObject* settings = (*i)->GetObject("buildSettings");
           this->AppendOrAddBuildSetting(settings, attribute, value);
@@ -2814,11 +2819,7 @@
       i != this->CurrentConfigurationTypes.end(); ++i)
     {
     // Get the current configuration name.
-    const char* configName = i->c_str();
-    if(!*configName)
-      {
-      configName = 0;
-      }
+    std::string configName = *i;
 
     if(this->XcodeVersion >= 50)
       {
@@ -2826,7 +2827,7 @@
       std::string linkObjs;
       const char* sep = "";
       std::vector<std::string> objs;
-      this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs);
+      this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs, "");
       for(std::vector<std::string>::const_iterator
             oi = objs.begin(); oi != objs.end(); ++oi)
         {
@@ -2956,13 +2957,15 @@
       if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"))
         {
         std::string plist = this->ComputeInfoPListLocation(cmtarget);
-        cmSourceFile* sf = mf->GetOrCreateSource(plist.c_str(), true);
-        cmtarget.AddSourceFile(sf);
+        mf->GetOrCreateSource(plist, true);
+        cmtarget.AddSource(plist);
         }
 
       std::vector<cmSourceFile*> classes;
-      cmtarget.GetSourceFiles(classes);
-
+      if (!cmtarget.GetConfigCommonSourceFiles(classes))
+        {
+        return;
+        }
       // Put cmSourceFile instances in proper groups:
       for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
           s != classes.end(); s++)
@@ -2974,13 +2977,13 @@
           mf->FindSourceGroup(source.c_str(), sourceGroups);
         cmXCodeObject* pbxgroup =
           this->CreateOrGetPBXGroup(cmtarget, sourceGroup);
-        cmStdString key = GetGroupMapKey(cmtarget, sf);
+        std::string key = GetGroupMapKey(cmtarget, sf);
         this->GroupMap[key] = pbxgroup;
         }
 
       // Put OBJECT_LIBRARY objects in proper groups:
       std::vector<std::string> objs;
-      this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs);
+      this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs, "");
       for(std::vector<std::string>::const_iterator
             oi = objs.begin(); oi != objs.end(); ++oi)
         {
@@ -2989,7 +2992,7 @@
           mf->FindSourceGroup(source.c_str(), sourceGroups);
         cmXCodeObject* pbxgroup =
           this->CreateOrGetPBXGroup(cmtarget, sourceGroup);
-        cmStdString key = GetGroupMapKeyFromPath(cmtarget, source);
+        std::string key = GetGroupMapKeyFromPath(cmtarget, source);
         this->GroupMap[key] = pbxgroup;
         }
       }
@@ -2997,7 +3000,7 @@
 }
 
 cmXCodeObject *cmGlobalXCodeGenerator
-::CreatePBXGroup(cmXCodeObject *parent, cmStdString name)
+::CreatePBXGroup(cmXCodeObject *parent, std::string name)
 {
   cmXCodeObject* parentChildren = NULL;
   if(parent)
@@ -3021,8 +3024,8 @@
 cmXCodeObject* cmGlobalXCodeGenerator
 ::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg)
 {
-  cmStdString s;
-  cmStdString target;
+  std::string s;
+  std::string target;
   const char *targetFolder= cmtarget.GetProperty("FOLDER");
   if(targetFolder) {
     target = targetFolder;
@@ -3031,7 +3034,7 @@
   target += cmtarget.GetName();
   s = target + "/";
   s += sg->GetFullName();
-  std::map<cmStdString, cmXCodeObject* >::iterator it =
+  std::map<std::string, cmXCodeObject* >::iterator it =
     this->GroupNameMap.find(s);
   if(it != this->GroupNameMap.end())
     {
@@ -3048,7 +3051,7 @@
     {
     std::vector<std::string> tgt_folders =
       cmSystemTools::tokenize(target, "/");
-    cmStdString curr_tgt_folder;
+    std::string curr_tgt_folder;
     for(std::vector<std::string>::size_type i = 0; i < tgt_folders.size();i++)
       {
       if (i != 0)
@@ -3075,7 +3078,7 @@
   // If it's the default source group (empty name) then put the source file
   // directly in the tgroup...
   //
-  if (cmStdString(sg->GetFullName()) == "")
+  if (std::string(sg->GetFullName()) == "")
     {
     this->GroupNameMap[s] = tgroup;
     return tgroup;
@@ -3086,12 +3089,12 @@
     {
     std::vector<std::string> folders =
       cmSystemTools::tokenize(sg->GetFullName(), "\\");
-    cmStdString curr_folder = target;
+    std::string curr_folder = target;
     curr_folder += "/";
     for(std::vector<std::string>::size_type i = 0; i < folders.size();i++)
       {
       curr_folder += folders[i];
-      std::map<cmStdString, cmXCodeObject* >::iterator i_folder =
+      std::map<std::string, cmXCodeObject* >::iterator i_folder =
         this->GroupNameMap.find(curr_folder);
       //Create new folder
       if(i_folder == this->GroupNameMap.end())
@@ -3354,10 +3357,10 @@
     buildSettings->AddAttribute("MACOSX_DEPLOYMENT_TARGET",
                                 this->CreateString(deploymentTarget));
     }
-  if(!this->PlatformToolset.empty())
+  if(!this->GeneratorToolset.empty())
     {
     buildSettings->AddAttribute("GCC_VERSION",
-      this->CreateString(this->PlatformToolset.c_str()));
+      this->CreateString(this->GeneratorToolset.c_str()));
     }
 
   // Put this last so it can override existing settings
@@ -3471,14 +3474,14 @@
   makefileStream
     << "# For each target create a dummy rule "
     "so the target does not have to exist\n";
-  std::set<cmStdString> emitted;
+  std::set<std::string> emitted;
   for(std::vector<cmXCodeObject*>::iterator i = targets.begin();
       i != targets.end(); ++i)
     {
     cmXCodeObject* target = *i;
-    std::map<cmStdString, cmXCodeObject::StringVec> const& deplibs =
+    std::map<std::string, cmXCodeObject::StringVec> const& deplibs =
       target->GetDependLibraries();
-    for(std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator ci
+    for(std::map<std::string, cmXCodeObject::StringVec>::const_iterator ci
           = deplibs.begin(); ci != deplibs.end(); ++ci)
       {
       for(cmXCodeObject::StringVec::const_iterator d = ci->second.begin();
@@ -3503,11 +3506,7 @@
         ct = this->CurrentConfigurationTypes.begin();
       ct != this->CurrentConfigurationTypes.end(); ++ct)
     {
-    const char* configName = 0;
-    if(!ct->empty())
-      {
-      configName = ct->c_str();
-      }
+    std::string configName = *ct;
     for(std::vector<cmXCodeObject*>::iterator i = targets.begin();
         i != targets.end(); ++i)
       {
@@ -3534,12 +3533,12 @@
         std::string trel = this->ConvertToRelativeForMake(tfull.c_str());
 
         // Add this target to the post-build phases of its dependencies.
-        std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator
+        std::map<std::string, cmXCodeObject::StringVec>::const_iterator
           y = target->GetDependTargets().find(*ct);
         if(y != target->GetDependTargets().end())
           {
-          std::vector<cmStdString> const& deptgts = y->second;
-          for(std::vector<cmStdString>::const_iterator d = deptgts.begin();
+          std::vector<std::string> const& deptgts = y->second;
+          for(std::vector<std::string>::const_iterator d = deptgts.begin();
               d != deptgts.end(); ++d)
             {
             makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": "
@@ -3551,12 +3550,12 @@
         makefileStream << trel << ":";
 
         // List dependencies if any exist.
-        std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator
+        std::map<std::string, cmXCodeObject::StringVec>::const_iterator
           x = target->GetDependLibraries().find(*ct);
         if(x != target->GetDependLibraries().end())
           {
-          std::vector<cmStdString> const& deplibs = x->second;
-          for(std::vector<cmStdString>::const_iterator d = deplibs.begin();
+          std::vector<std::string> const& deplibs = x->second;
+          for(std::vector<std::string>::const_iterator d = deplibs.begin();
               d != deplibs.end(); ++d)
             {
             makefileStream << "\\\n\t" <<
@@ -3781,14 +3780,14 @@
 //----------------------------------------------------------------------------
 void
 cmGlobalXCodeGenerator
-::AppendDirectoryForConfig(const char* prefix,
-                           const char* config,
-                           const char* suffix,
+::AppendDirectoryForConfig(const std::string& prefix,
+                           const std::string& config,
+                           const std::string& suffix,
                            std::string& dir)
 {
   if(this->XcodeVersion > 20)
     {
-    if(config)
+    if(!config.empty())
       {
       dir += prefix;
       dir += config;
@@ -3798,12 +3797,13 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmGlobalXCodeGenerator::LookupFlags(const char* varNamePrefix,
-                                                const char* varNameLang,
-                                                const char* varNameSuffix,
-                                                const char* default_flags)
+std::string cmGlobalXCodeGenerator::LookupFlags(
+                                              const std::string& varNamePrefix,
+                                              const std::string& varNameLang,
+                                              const std::string& varNameSuffix,
+                                              const std::string& default_flags)
 {
-  if(varNameLang)
+  if(!varNameLang.empty())
     {
     std::string varName = varNamePrefix;
     varName += varNameLang;
@@ -3955,38 +3955,11 @@
   return true;
 }
 
- //----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
+//----------------------------------------------------------------------------
+void cmGlobalXCodeGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
 {
-  // Count the number of object files with each name. Warn about duplicate
-  // names since Xcode names them uniquely automatically with a numeric suffix
-  // to avoid exact duplicate file names. Note that Mac file names are not
-  // typically case sensitive, hence the LowerCase.
-  std::map<cmStdString, int> counts;
-  std::vector<cmSourceFile*> objectSources;
-  gt->GetObjectSources(objectSources);
-  for(std::vector<cmSourceFile*>::const_iterator
-      si = objectSources.begin();
-      si != objectSources.end(); ++si)
-    {
-    cmSourceFile* sf = *si;
-    std::string objectName =
-      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
-    objectName += ".o";
-
-    std::string objectNameLower = cmSystemTools::LowerCase(objectName);
-    counts[objectNameLower] += 1;
-    if (2 == counts[objectNameLower])
-      {
-      // TODO: emit warning about duplicate name?
-      }
-
-    gt->AddObject(sf, objectName);
-    }
-
-  const char* configName = this->GetCMakeCFGIntDir();
+  std::string configName = this->GetCMakeCFGIntDir();
   std::string dir = this->GetObjectsNormalDirectory(
     "$(PROJECT_NAME)", configName, gt->Target);
   if(this->XcodeVersion >= 21)
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index c9d20c2..ae23e3b 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -33,9 +33,9 @@
   static cmGlobalGeneratorFactory* NewFactory();
 
   ///! Get the name for the generator.
-  virtual const char* GetName() const {
+  virtual std::string GetName() const {
     return cmGlobalXCodeGenerator::GetActualName();}
-  static const char* GetActualName() {return "Xcode";}
+  static std::string GetActualName() {return "Xcode";}
 
   /** Get the documentation entry for this generator.  */
   static void GetDocumentation(cmDocumentationEntry& entry);
@@ -55,11 +55,11 @@
    */
   virtual void GenerateBuildCommand(
     std::vector<std::string>& makeCommand,
-    const char* makeProgram,
-    const char* projectName,
-    const char* projectDir,
-    const char* targetName,
-    const char* config,
+    const std::string& makeProgram,
+    const std::string& projectName,
+    const std::string& projectDir,
+    const std::string& targetName,
+    const std::string& config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
@@ -72,9 +72,9 @@
   virtual void Generate();
 
   /** Append the subdirectory for the given configuration.  */
-  virtual void AppendDirectoryForConfig(const char* prefix,
-                                        const char* config,
-                                        const char* suffix,
+  virtual void AppendDirectoryForConfig(const std::string& prefix,
+                                        const std::string& config,
+                                        const std::string& suffix,
                                         std::string& dir);
 
   ///! What is the configurations directory variable called?
@@ -89,13 +89,13 @@
       i.e. "Can I build Debug and Release in the same tree?" */
   virtual bool IsMultiConfig();
 
-  virtual bool SetGeneratorToolset(std::string const& ts);
+  virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
   void AppendFlag(std::string& flags, std::string const& flag);
 private:
   cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
                                      cmSourceGroup* sg);
   cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent,
-                                cmStdString name);
+                                std::string name);
   void CreateGroups(cmLocalGenerator* root,
                     std::vector<cmLocalGenerator*>&
                     generators);
@@ -123,19 +123,17 @@
   void CreateCustomRulesMakefile(const char* makefileBasename,
                                  cmTarget& target,
                                  std::vector<cmCustomCommand> const & commands,
-                                 const char* configName,
-                                 const std::map<cmStdString, cmStdString>&
-                                     multipleOutputPairs
-                                );
+                                 const std::string& configName,
+                                 bool& haveMultipleOutputPairs);
 
   cmXCodeObject* FindXCodeTarget(cmTarget const*);
-  std::string GetOrCreateId(const char* name, const char* id);
+  std::string GetOrCreateId(const std::string& name, const std::string& id);
 
   // create cmXCodeObject from these functions so that memory can be managed
   // correctly.  All objects created are stored in this->XCodeObjects.
   cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype);
   cmXCodeObject* CreateObject(cmXCodeObject::Type type);
-  cmXCodeObject* CreateString(const char* s);
+  cmXCodeObject* CreateString(const std::string& s);
   cmXCodeObject* CreateObjectReference(cmXCodeObject*);
   cmXCodeObject* CreateXCodeTarget(cmTarget& target,
                                    cmXCodeObject* buildPhases);
@@ -147,12 +145,13 @@
   void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr,
                                const char* value);
   void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr,
-                                   const char* value, const char* configName);
+                                   const char* value,
+                                   const std::string& configName);
   cmXCodeObject* CreateUtilityTarget(cmTarget& target);
   void AddDependAndLinkInformation(cmXCodeObject* target);
   void CreateBuildSettings(cmTarget& target,
                            cmXCodeObject* buildSettings,
-                           const char* buildType);
+                           const std::string& buildType);
   std::string ExtractFlag(const char* flag, std::string& flags);
   // delete all objects in the this->XCodeObjects vector.
   void ClearXCodeObjects();
@@ -164,10 +163,12 @@
                          std::vector<cmLocalGenerator*>& generators);
   cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string &fullpath,
                                                   cmTarget& cmtarget,
-                                                  const std::string &lang);
+                                                  const std::string &lang,
+                                                  cmSourceFile* sf);
   cmXCodeObject* CreateXCodeSourceFileFromPath(const std::string &fullpath,
                                                cmTarget& cmtarget,
-                                               const std::string &lang);
+                                               const std::string &lang,
+                                               cmSourceFile* sf);
   cmXCodeObject* CreateXCodeFileReference(cmSourceFile* sf,
                                           cmTarget& cmtarget);
   cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
@@ -190,10 +191,10 @@
   void CreateReRunCMakeFile(cmLocalGenerator* root,
                             std::vector<cmLocalGenerator*> const& gens);
 
-  std::string LookupFlags(const char* varNamePrefix,
-                          const char* varNameLang,
-                          const char* varNameSuffix,
-                          const char* default_flags);
+  std::string LookupFlags(const std::string& varNamePrefix,
+                          const std::string& varNameLang,
+                          const std::string& varNameSuffix,
+                          const std::string& default_flags);
 
   class Factory;
   class BuildObjectListOrString;
@@ -205,18 +206,19 @@
                      std::vector<std::string> const& defines,
                      bool dflag = false);
 
+  void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
 protected:
   virtual const char* GetInstallTargetName() const { return "install"; }
   virtual const char* GetPackageTargetName() const { return "package"; }
 
   unsigned int XcodeVersion;
   std::string VersionString;
-  std::set<cmStdString> XCodeObjectIDs;
+  std::set<std::string> XCodeObjectIDs;
   std::vector<cmXCodeObject*> XCodeObjects;
   cmXCodeObject* RootObject;
 private:
-  void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {}
-  void ComputeTargetObjects(cmGeneratorTarget* gt) const;
+  void PrintCompilerAdvice(std::ostream&, std::string const&,
+                           const char*) const {}
 
   std::string GetObjectsNormalDirectory(
     const std::string &projName,
@@ -235,16 +237,16 @@
   std::string CurrentReRunCMakeMakefile;
   std::string CurrentXCodeHackMakefile;
   std::string CurrentProject;
-  std::set<cmStdString> TargetDoneSet;
+  std::set<std::string> TargetDoneSet;
   std::vector<std::string> CurrentOutputDirectoryComponents;
   std::vector<std::string> ProjectSourceDirectoryComponents;
   std::vector<std::string> ProjectOutputDirectoryComponents;
-  std::map<cmStdString, cmXCodeObject* > GroupMap;
-  std::map<cmStdString, cmXCodeObject* > GroupNameMap;
-  std::map<cmStdString, cmXCodeObject* > TargetGroup;
-  std::map<cmStdString, cmXCodeObject* > FileRefs;
+  std::map<std::string, cmXCodeObject* > GroupMap;
+  std::map<std::string, cmXCodeObject* > GroupNameMap;
+  std::map<std::string, cmXCodeObject* > TargetGroup;
+  std::map<std::string, cmXCodeObject* > FileRefs;
   std::vector<std::string> Architectures;
-  std::string PlatformToolset;
+  std::string GeneratorToolset;
 };
 
 #endif
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index db964a9..601993f 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -121,7 +121,7 @@
   __set_bool_if_set(this->GeneratePerTarget, "GRAPHVIZ_GENERATE_PER_TARGET");
   __set_bool_if_set(this->GenerateDependers, "GRAPHVIZ_GENERATE_DEPENDERS");
 
-  cmStdString ignoreTargetsRegexes;
+  std::string ignoreTargetsRegexes;
   __set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS");
 
   this->TargetsToIgnoreRegex.clear();
@@ -135,7 +135,7 @@
         itvIt != ignoreTargetsRegExVector.end();
         ++ itvIt )
       {
-      cmStdString currentRegexString(*itvIt);
+      std::string currentRegexString(*itvIt);
       cmsys::RegularExpression currentRegex;
       if (!currentRegex.compile(currentRegexString.c_str()))
         {
@@ -160,7 +160,7 @@
 
   this->CollectTargetsAndLibs();
 
-  for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
+  for(std::map<std::string, const cmTarget*>::const_iterator ptrIt =
                                                       this->TargetPtrs.begin();
       ptrIt != this->TargetPtrs.end();
       ++ptrIt)
@@ -192,7 +192,7 @@
     std::cout << "Writing " << currentFilename << "..." << std::endl;
     this->WriteHeader(str);
 
-    this->WriteDependerConnections(ptrIt->first.c_str(),
+    this->WriteDependerConnections(ptrIt->first,
                                    insertedNodes, insertedConnections, str);
 
     this->WriteFooter(str);
@@ -211,7 +211,7 @@
 
   this->CollectTargetsAndLibs();
 
-  for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
+  for(std::map<std::string, const cmTarget*>::const_iterator ptrIt =
                                                       this->TargetPtrs.begin();
       ptrIt != this->TargetPtrs.end();
       ++ptrIt)
@@ -241,7 +241,7 @@
     std::cout << "Writing " << currentFilename << "..." << std::endl;
     this->WriteHeader(str);
 
-    this->WriteConnections(ptrIt->first.c_str(),
+    this->WriteConnections(ptrIt->first,
                               insertedNodes, insertedConnections, str);
     this->WriteFooter(str);
     }
@@ -265,7 +265,7 @@
   std::set<std::string> insertedConnections;
   std::set<std::string> insertedNodes;
 
-  for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
+  for(std::map<std::string, const cmTarget*>::const_iterator ptrIt =
                                                       this->TargetPtrs.begin();
       ptrIt != this->TargetPtrs.end();
       ++ptrIt)
@@ -280,7 +280,7 @@
       continue;
       }
 
-    this->WriteConnections(ptrIt->first.c_str(),
+    this->WriteConnections(ptrIt->first,
                               insertedNodes, insertedConnections, str);
     }
   this->WriteFooter(str);
@@ -300,12 +300,12 @@
 }
 
 
-void cmGraphVizWriter::WriteConnections(const char* targetName,
+void cmGraphVizWriter::WriteConnections(const std::string& targetName,
                                     std::set<std::string>& insertedNodes,
                                     std::set<std::string>& insertedConnections,
                                     cmGeneratedFileStream& str) const
 {
-  std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt =
+  std::map<std::string, const cmTarget* >::const_iterator targetPtrIt =
                                              this->TargetPtrs.find(targetName);
 
   if (targetPtrIt == this->TargetPtrs.end())  // not found at all
@@ -331,7 +331,7 @@
        ++ llit )
     {
     const char* libName = llit->first.c_str();
-    std::map<cmStdString, cmStdString>::const_iterator libNameIt =
+    std::map<std::string, std::string>::const_iterator libNameIt =
                                           this->TargetNamesNodes.find(libName);
 
     // can happen e.g. if GRAPHVIZ_TARGET_IGNORE_REGEX is used
@@ -349,8 +349,8 @@
       this->WriteNode(libName, this->TargetPtrs.find(libName)->second,
                       insertedNodes, str);
 
-      str << "    \"" << myNodeName.c_str() << "\" -> \""
-          << libNameIt->second.c_str() << "\"";
+      str << "    \"" << myNodeName << "\" -> \""
+          << libNameIt->second << "\"";
       str << " // " << targetName << " -> " << libName << std::endl;
       this->WriteConnections(libName, insertedNodes, insertedConnections, str);
       }
@@ -359,12 +359,12 @@
 }
 
 
-void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
+void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
                                     std::set<std::string>& insertedNodes,
                                     std::set<std::string>& insertedConnections,
                                     cmGeneratedFileStream& str) const
 {
-  std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt =
+  std::map<std::string, const cmTarget* >::const_iterator targetPtrIt =
                                              this->TargetPtrs.find(targetName);
 
   if (targetPtrIt == this->TargetPtrs.end())  // not found at all
@@ -383,7 +383,7 @@
   std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
 
   // now search who links against me
-  for(std::map<cmStdString, const cmTarget*>::const_iterator dependerIt =
+  for(std::map<std::string, const cmTarget*>::const_iterator dependerIt =
                                                       this->TargetPtrs.begin();
       dependerIt != this->TargetPtrs.end();
       ++dependerIt)
@@ -407,11 +407,11 @@
          llit != ll->end();
          ++ llit )
       {
-      std::string libName = llit->first.c_str();
+      std::string libName = llit->first;
       if (libName == targetName)
         {
         // So this target links against targetName.
-        std::map<cmStdString, cmStdString>::const_iterator dependerNodeNameIt =
+        std::map<std::string, std::string>::const_iterator dependerNodeNameIt =
                                 this->TargetNamesNodes.find(dependerIt->first);
 
         if(dependerNodeNameIt != this->TargetNamesNodes.end())
@@ -424,13 +424,13 @@
                                                      insertedConnections.end())
             {
             insertedConnections.insert(connectionName);
-            this->WriteNode(dependerIt->first.c_str(), dependerIt->second,
+            this->WriteNode(dependerIt->first, dependerIt->second,
                             insertedNodes, str);
 
             str << "    \"" << dependerNodeNameIt->second << "\" -> \""
                 << myNodeName << "\"";
             str << " // " <<targetName<< " -> " <<dependerIt->first<<std::endl;
-            this->WriteDependerConnections(dependerIt->first.c_str(),
+            this->WriteDependerConnections(dependerIt->first,
                                       insertedNodes, insertedConnections, str);
             }
 
@@ -444,7 +444,7 @@
 }
 
 
-void cmGraphVizWriter::WriteNode(const char* targetName,
+void cmGraphVizWriter::WriteNode(const std::string& targetName,
                                  const cmTarget* target,
                                  std::set<std::string>& insertedNodes,
                                  cmGeneratedFileStream& str) const
@@ -452,10 +452,10 @@
   if (insertedNodes.find(targetName) == insertedNodes.end())
   {
     insertedNodes.insert(targetName);
-    std::map<cmStdString, cmStdString>::const_iterator nameIt =
+    std::map<std::string, std::string>::const_iterator nameIt =
                                        this->TargetNamesNodes.find(targetName);
 
-    str << "    \"" << nameIt->second.c_str() << "\" [ label=\""
+    str << "    \"" << nameIt->second << "\" [ label=\""
         << targetName <<  "\" shape=\"" << getShapeForTarget(target)
         << "\"];" << std::endl;
   }
@@ -540,7 +540,7 @@
           continue;
           }
 
-        std::map<cmStdString, const cmTarget*>::const_iterator tarIt =
+        std::map<std::string, const cmTarget*>::const_iterator tarIt =
                                                 this->TargetPtrs.find(libName);
         if ( tarIt == this->TargetPtrs.end() )
           {
@@ -558,7 +558,7 @@
 }
 
 
-bool cmGraphVizWriter::IgnoreThisTarget(const char* name)
+bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name)
 {
   for(std::vector<cmsys::RegularExpression>::iterator itvIt
                                           = this->TargetsToIgnoreRegex.begin();
diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h
index 17b97f8..a7acd0e 100644
--- a/Source/cmGraphVizWriter.h
+++ b/Source/cmGraphVizWriter.h
@@ -44,30 +44,30 @@
 
   void WriteHeader(cmGeneratedFileStream& str) const;
 
-  void WriteConnections(const char* targetName,
+  void WriteConnections(const std::string& targetName,
                         std::set<std::string>& insertedNodes,
                         std::set<std::string>& insertedConnections,
                         cmGeneratedFileStream& str) const;
 
-  void WriteDependerConnections(const char* targetName,
+  void WriteDependerConnections(const std::string& targetName,
                                 std::set<std::string>& insertedNodes,
                                 std::set<std::string>& insertedConnections,
                                 cmGeneratedFileStream& str) const;
 
-  void WriteNode(const char* targetName, const cmTarget* target,
+  void WriteNode(const std::string& targetName, const cmTarget* target,
                  std::set<std::string>& insertedNodes,
                  cmGeneratedFileStream& str) const;
 
   void WriteFooter(cmGeneratedFileStream& str) const;
 
-  bool IgnoreThisTarget(const char* name);
+  bool IgnoreThisTarget(const std::string& name);
 
   bool GenerateForTargetType(cmTarget::TargetType targetType) const;
 
-  cmStdString GraphType;
-  cmStdString GraphName;
-  cmStdString GraphHeader;
-  cmStdString GraphNodePrefix;
+  std::string GraphType;
+  std::string GraphName;
+  std::string GraphHeader;
+  std::string GraphNodePrefix;
 
   bool GenerateForExecutables;
   bool GenerateForStaticLibs;
@@ -81,9 +81,9 @@
 
   const std::vector<cmLocalGenerator*>& LocalGenerators;
 
-  std::map<cmStdString, const cmTarget*> TargetPtrs;
+  std::map<std::string, const cmTarget*> TargetPtrs;
   // maps from the actual target names to node names in dot:
-  std::map<cmStdString, cmStdString> TargetNamesNodes;
+  std::map<std::string, std::string> TargetNamesNodes;
 
   bool HaveTargetsAndLibs;
 };
diff --git a/Source/cmIDEFlagTable.h b/Source/cmIDEFlagTable.h
index e372c0a..d9a045d 100644
--- a/Source/cmIDEFlagTable.h
+++ b/Source/cmIDEFlagTable.h
@@ -31,6 +31,7 @@
                                   // old value with semicolons (e.g.
                                   // /NODEFAULTLIB: =>
                                   // IgnoreDefaultLibraryNames)
+    UserFollowing = (1<<5), // expect value in following argument
 
     UserValueIgnored  = UserValue | UserIgnored,
     UserValueRequired = UserValue | UserRequired
diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx
index 34a9c7c..1f3c066 100644
--- a/Source/cmIDEOptions.cxx
+++ b/Source/cmIDEOptions.cxx
@@ -19,6 +19,7 @@
   this->DoingDefine = false;
   this->AllowDefine = true;
   this->AllowSlash = false;
+  this->DoingFollowing = 0;
   for(int i=0; i < FlagTableCount; ++i)
     {
     this->FlagTable[i] = 0;
@@ -41,6 +42,14 @@
     return;
     }
 
+  // If the last option expected a following value, this is it.
+  if(this->DoingFollowing)
+    {
+    this->FlagMapUpdate(this->DoingFollowing, flag);
+    this->DoingFollowing = 0;
+    return;
+    }
+
   // Look for known arguments.
   if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))
     {
@@ -99,40 +108,22 @@
          (!(entry->special & cmIDEFlagTable::UserRequired) ||
           static_cast<int>(strlen(flag+1)) > n))
         {
-        if(entry->special & cmIDEFlagTable::UserIgnored)
-          {
-          // Ignore the user-specified value.
-          this->FlagMap[entry->IDEName] = entry->value;
-          }
-        else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
-          {
-          const char *new_value = flag+1+n;
-
-          std::map<cmStdString,cmStdString>::iterator itr;
-          itr = this->FlagMap.find(entry->IDEName);
-          if(itr != this->FlagMap.end())
-            {
-            // Append to old value (if present) with semicolons;
-            itr->second += ";";
-            itr->second += new_value;
-            }
-          else
-            {
-            this->FlagMap[entry->IDEName] = new_value;
-            }
-          }
-        else
-          {
-          // Use the user-specified value.
-          this->FlagMap[entry->IDEName] = flag+1+n;
-          }
+        this->FlagMapUpdate(entry, flag+n+1);
         entry_found = true;
         }
       }
     else if(strcmp(flag+1, entry->commandFlag) == 0)
       {
-      // This flag table entry provides a fixed value.
-      this->FlagMap[entry->IDEName] = entry->value;
+      if(entry->special & cmIDEFlagTable::UserFollowing)
+        {
+        // This flag expects a value in the following argument.
+        this->DoingFollowing = entry;
+        }
+      else
+        {
+        // This flag table entry provides a fixed value.
+        this->FlagMap[entry->IDEName] = entry->value;
+        }
       entry_found = true;
       }
 
@@ -151,6 +142,37 @@
 }
 
 //----------------------------------------------------------------------------
+void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
+                                 const char* new_value)
+{
+  if(entry->special & cmIDEFlagTable::UserIgnored)
+    {
+    // Ignore the user-specified value.
+    this->FlagMap[entry->IDEName] = entry->value;
+    }
+  else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
+    {
+    std::map<std::string,std::string>::iterator itr;
+    itr = this->FlagMap.find(entry->IDEName);
+    if(itr != this->FlagMap.end())
+      {
+      // Append to old value (if present) with semicolons;
+      itr->second += ";";
+      itr->second += new_value;
+      }
+    else
+      {
+      this->FlagMap[entry->IDEName] = new_value;
+      }
+    }
+  else
+    {
+    // Use the user-specified value.
+    this->FlagMap[entry->IDEName] = new_value;
+    }
+}
+
+//----------------------------------------------------------------------------
 void cmIDEOptions::AddDefine(const std::string& def)
 {
   this->Defines.push_back(def);
@@ -186,7 +208,7 @@
 //----------------------------------------------------------------------------
 const char* cmIDEOptions::GetFlag(const char* flag)
 {
-  std::map<cmStdString, cmStdString>::iterator i = this->FlagMap.find(flag);
+  std::map<std::string, std::string>::iterator i = this->FlagMap.find(flag);
   if(i != this->FlagMap.end())
     {
     return i->second.c_str();
diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h
index e78af3e..e7749ec 100644
--- a/Source/cmIDEOptions.h
+++ b/Source/cmIDEOptions.h
@@ -40,22 +40,24 @@
   // Then parse the command line flags specified in CMAKE_CXX_FLAGS
   // and CMAKE_C_FLAGS
   // and overwrite or add new values to this map
-  std::map<cmStdString, cmStdString> FlagMap;
+  std::map<std::string, std::string> FlagMap;
 
   // Preprocessor definitions.
   std::vector<std::string> Defines;
 
   // Unrecognized flags that get no special handling.
-  cmStdString FlagString;
+  std::string FlagString;
 
   bool DoingDefine;
   bool AllowDefine;
   bool AllowSlash;
+  cmIDEFlagTable const* DoingFollowing;
   enum { FlagTableCount = 16 };
   cmIDEFlagTable const* FlagTable[FlagTableCount];
   void HandleFlag(const char* flag);
   bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
                       bool& flag_handled);
+  void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value);
   virtual void StoreUnknownFlag(const char* flag) = 0;
 };
 
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index ee95c05..1141b01 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -26,7 +26,7 @@
       i != args.end(); ++i)
     {
     err += " ";
-    err += lg->EscapeForCMake(i->c_str());
+    err += lg->EscapeForCMake(*i);
     }
   err += "\n";
   return err;
@@ -199,7 +199,7 @@
     err += errorString;
     if (status == cmake::FATAL_ERROR)
       {
-      this->SetError(err.c_str());
+      this->SetError(err);
       cmSystemTools::SetFatalErrorOccured();
       return false;
       }
@@ -261,7 +261,7 @@
     }
 
   // Check definition.
-  const char* def = mf->GetDefinition(arg.c_str());
+  const char* def = mf->GetDefinition(arg);
   return !cmSystemTools::IsOff(def);
   }
 
@@ -277,12 +277,12 @@
     else if(arg == "1")
       { return true; }
     else
-      { return !cmSystemTools::IsOff(mf->GetDefinition(arg.c_str())); }
+      { return !cmSystemTools::IsOff(mf->GetDefinition(arg)); }
     }
   else
     {
     // Old GetVariableOrNumber behavior.
-    const char* def = mf->GetDefinition(arg.c_str());
+    const char* def = mf->GetDefinition(arg);
     if(!def && atoi(arg.c_str()))
       {
       def = arg.c_str();
@@ -559,7 +559,7 @@
           }
         else
           {
-          bdef = makefile->IsDefinitionSet((argP1)->c_str());
+          bdef = makefile->IsDefinitionSet(*(argP1));
           }
         HandlePredicate(bdef, reducible, arg, newArgs, argP1, argP2);
         }
@@ -593,9 +593,9 @@
       if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
         *(argP1) == "MATCHES")
         {
-        def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
+        def = cmIfCommand::GetVariableOrString(*arg, makefile);
         const char* rex = (argP2)->c_str();
-        cmStringCommand::ClearMatches(makefile);
+        makefile->ClearMatches();
         cmsys::RegularExpression regEntry;
         if ( !regEntry.compile(rex) )
           {
@@ -607,7 +607,7 @@
           }
         if (regEntry.find(def))
           {
-          cmStringCommand::StoreMatches(makefile, regEntry);
+          makefile->StoreMatches(regEntry);
           *arg = "1";
           }
         else
@@ -634,8 +634,8 @@
         (*(argP1) == "LESS" || *(argP1) == "GREATER" ||
          *(argP1) == "EQUAL"))
         {
-        def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
-        def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
+        def = cmIfCommand::GetVariableOrString(*arg, makefile);
+        def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
         double lhs;
         double rhs;
         bool result;
@@ -665,8 +665,8 @@
          *(argP1) == "STREQUAL" ||
          *(argP1) == "STRGREATER"))
         {
-        def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
-        def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
+        def = cmIfCommand::GetVariableOrString(*arg, makefile);
+        def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
         int val = strcmp(def,def2);
         bool result;
         if (*(argP1) == "STRLESS")
@@ -689,8 +689,8 @@
         (*(argP1) == "VERSION_LESS" || *(argP1) == "VERSION_GREATER" ||
          *(argP1) == "VERSION_EQUAL"))
         {
-        def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
-        def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
+        def = cmIfCommand::GetVariableOrString(*arg, makefile);
+        def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
         cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL;
         if(*argP1 == "VERSION_LESS")
           {
@@ -907,13 +907,13 @@
 }
 
 //=========================================================================
-const char* cmIfCommand::GetVariableOrString(const char* str,
+const char* cmIfCommand::GetVariableOrString(const std::string& str,
                                              const cmMakefile* mf)
 {
   const char* def = mf->GetDefinition(str);
   if(!def)
     {
-    def = str;
+    def = str.c_str();
     }
   return def;
 }
diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h
index f2633ad..814c052 100644
--- a/Source/cmIfCommand.h
+++ b/Source/cmIfCommand.h
@@ -58,12 +58,12 @@
    * the CMakeLists.txt file.
    */
   virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) { return false;};
+                           cmExecutionStatus &) { return false;}
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "if";}
+  virtual std::string GetName() const { return "if";}
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -79,7 +79,7 @@
 
   // Get a definition from the makefile.  If it doesn't exist,
   // return the original string.
-  static const char* GetVariableOrString(const char* str,
+  static const char* GetVariableOrString(const std::string& str,
                                          const cmMakefile* mf);
 
   cmTypeMacro(cmIfCommand, cmCommand);
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index fbcbc75..0a4f5c9 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -65,7 +65,7 @@
         {
         std::string errorText = "called with invalid argument: ";
         errorText += args[i];
-        this->SetError(errorText.c_str());
+        this->SetError(errorText);
         return false;
         }
     }
@@ -121,7 +121,7 @@
         "command.  It " << modal << " not be used as the argument to the "
         "include() command.  Use ALIAS targets instead to refer to targets "
         "by alternative names.\n";
-      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      this->Makefile->IssueMessage(messageType, e.str());
       if (messageType == cmake::FATAL_ERROR)
         {
         return false;
@@ -139,7 +139,7 @@
   // add the location of the included file if a result variable was given
   if (resultVarName.size())
     {
-      this->Makefile->AddDefinition(resultVarName.c_str(),
+      this->Makefile->AddDefinition(resultVarName,
                                     readit?fullFilePath.c_str():"NOTFOUND");
     }
 
@@ -149,7 +149,7 @@
       "could not find load file:\n"
       "  ";
     m += fname;
-    this->SetError(m.c_str());
+    this->SetError(m);
     return false;
     }
   return true;
diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h
index 267723d..0dcd7de 100644
--- a/Source/cmIncludeCommand.h
+++ b/Source/cmIncludeCommand.h
@@ -46,7 +46,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "include";}
+  virtual std::string GetName() const {return "include";}
 
   cmTypeMacro(cmIncludeCommand, cmCommand);
 };
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index e20fe02..df5508e 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -38,7 +38,7 @@
 
   std::vector<std::string> beforeIncludes;
   std::vector<std::string> afterIncludes;
-  std::set<cmStdString> systemIncludes;
+  std::set<std::string> systemIncludes;
 
   for(; i != args.end(); ++i)
     {
diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h
index c621dcb..6cc2c83 100644
--- a/Source/cmIncludeDirectoryCommand.h
+++ b/Source/cmIncludeDirectoryCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "include_directories";}
+  virtual std::string GetName() const { return "include_directories";}
 
   cmTypeMacro(cmIncludeDirectoryCommand, cmCommand);
 
diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h
index 8ca674f..081f77a 100644
--- a/Source/cmIncludeExternalMSProjectCommand.h
+++ b/Source/cmIncludeExternalMSProjectCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "include_external_msproject";}
+  virtual std::string GetName() const {return "include_external_msproject";}
 
   cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand);
 };
diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx
index ef6e8c6..d6dfdd2 100644
--- a/Source/cmIncludeRegularExpressionCommand.cxx
+++ b/Source/cmIncludeRegularExpressionCommand.cxx
@@ -24,7 +24,7 @@
 
   if(args.size() > 1)
     {
-    this->Makefile->SetComplainRegularExpression(args[1].c_str());
+    this->Makefile->SetComplainRegularExpression(args[1]);
     }
 
   return true;
diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h
index 0c5fa6f..c58f018 100644
--- a/Source/cmIncludeRegularExpressionCommand.h
+++ b/Source/cmIncludeRegularExpressionCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "include_regular_expression";}
+  virtual std::string GetName() const {return "include_regular_expression";}
 
   cmTypeMacro(cmIncludeRegularExpressionCommand, cmCommand);
 };
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 0878aae..0041122 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -97,9 +97,9 @@
     }
 
   // Unknown mode.
-  cmStdString e = "called with unknown mode ";
+  std::string e = "called with unknown mode ";
   e += args[0];
-  this->SetError(e.c_str());
+  this->SetError(e);
   return false;
 }
 
@@ -269,7 +269,7 @@
     // Unknown argument.
     cmOStringStream e;
     e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -370,7 +370,7 @@
       cmOStringStream e;
       e << "TARGETS given target \"" << (*targetIt)
         << "\" which is an alias.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     // Lookup this target in the current directory.
@@ -387,7 +387,7 @@
         cmOStringStream e;
         e << "TARGETS given target \"" << (*targetIt)
           << "\" which is not an executable, library, or module.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       else if(target->GetType() == cmTarget::OBJECT_LIBRARY)
@@ -395,7 +395,7 @@
         cmOStringStream e;
         e << "TARGETS given OBJECT library \"" << (*targetIt)
           << "\" which may not be installed.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       // Store the target in the list to be installed.
@@ -407,7 +407,7 @@
       cmOStringStream e;
       e << "TARGETS given target \"" << (*targetIt)
         << "\" which does not exist in this directory.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -499,7 +499,7 @@
               cmOStringStream e;
               e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
                 "FRAMEWORK target \"" << target.GetName() << "\".";
-              this->SetError(e.str().c_str());
+              this->SetError(e.str());
               return false;
               }
             }
@@ -519,7 +519,7 @@
               cmOStringStream e;
               e << "TARGETS given no LIBRARY DESTINATION for shared library "
                 "target \"" << target.GetName() << "\".";
-              this->SetError(e.str().c_str());
+              this->SetError(e.str());
               return false;
               }
             }
@@ -539,7 +539,7 @@
           cmOStringStream e;
           e << "TARGETS given no ARCHIVE DESTINATION for static library "
             "target \"" << target.GetName() << "\".";
-          this->SetError(e.str().c_str());
+          this->SetError(e.str());
           return false;
           }
         }
@@ -560,7 +560,7 @@
           cmOStringStream e;
           e << "TARGETS given no LIBRARY DESTINATION for module target \""
             << target.GetName() << "\".";
-          this->SetError(e.str().c_str());
+          this->SetError(e.str());
           return false;
           }
         }
@@ -595,7 +595,7 @@
             cmOStringStream e;
             e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
                  "executable target \"" << target.GetName() << "\".";
-            this->SetError(e.str().c_str());
+            this->SetError(e.str());
             return false;
             }
           }
@@ -612,7 +612,7 @@
             cmOStringStream e;
             e << "TARGETS given no RUNTIME DESTINATION for executable "
                  "target \"" << target.GetName() << "\".";
-            this->SetError(e.str().c_str());
+            this->SetError(e.str());
             return false;
             }
           }
@@ -851,7 +851,7 @@
     // Unknown argument.
     cmOStringStream e;
     e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -866,7 +866,7 @@
     // The rename option works only with one file.
     cmOStringStream e;
     e << args[0] << " given RENAME option with more than one file.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -886,7 +886,7 @@
     // A destination is required.
     cmOStringStream e;
     e << args[0] << " given no DESTINATION!";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -927,7 +927,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" after PATTERN or REGEX.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -941,7 +941,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" after PATTERN or REGEX.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -969,7 +969,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" before a PATTERN or REGEX is given.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       literal_args += " EXCLUDE";
@@ -982,7 +982,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" before a PATTERN or REGEX is given.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -997,7 +997,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" after PATTERN or REGEX.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -1011,7 +1011,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" after PATTERN or REGEX.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -1025,7 +1025,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" after PATTERN or REGEX.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -1040,7 +1040,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" after PATTERN or REGEX.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -1055,7 +1055,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" after PATTERN or REGEX.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -1069,7 +1069,7 @@
         cmOStringStream e;
         e << args[0] << " does not allow \""
           << args[i] << "\" after PATTERN or REGEX.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -1094,7 +1094,7 @@
         cmOStringStream e;
         e << args[0] << " given non-directory \""
           << args[i] << "\" to install.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
 
@@ -1150,7 +1150,7 @@
         cmOStringStream e;
         e << args[0] << " given invalid file permission \""
           << args[i] << "\".";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       }
@@ -1162,7 +1162,7 @@
         cmOStringStream e;
         e << args[0] << " given invalid directory permission \""
           << args[i] << "\".";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       }
@@ -1174,7 +1174,7 @@
         cmOStringStream e;
         e << args[0] << " given invalid permission \""
           << args[i] << "\".";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       }
@@ -1183,7 +1183,7 @@
       // Unknown argument.
       cmOStringStream e;
       e << args[0] << " given unknown argument \"" << args[i] << "\".";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -1204,7 +1204,7 @@
     // A destination is required.
     cmOStringStream e;
     e << args[0] << " given no DESTINATION!";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -1247,7 +1247,7 @@
     // Unknown argument.
     cmOStringStream e;
     e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -1262,7 +1262,7 @@
     // A destination is required.
     cmOStringStream e;
     e << args[0] << " given no DESTINATION!";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -1274,7 +1274,7 @@
     e << args[0] << " given invalid export file name \"" << fname << "\".  "
       << "The FILE argument may not contain a path.  "
       << "Specify the path in the DESTINATION argument.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -1285,7 +1285,7 @@
     cmOStringStream e;
     e << args[0] << " given invalid export file name \"" << fname << "\".  "
       << "The FILE argument must specify a name ending in \".cmake\".";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -1302,7 +1302,7 @@
         << "This name cannot be safely converted to a file name.  "
         << "Specify a different export name or use the FILE option to set "
         << "a file name explicitly.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -1327,7 +1327,7 @@
           << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \""
           << te->Target->GetName()
           << "\" does not have policy CMP0022 set to NEW.";
-        this->SetError(e.str().c_str());
+        this->SetError(e.str());
         return false;
         }
       }
@@ -1368,7 +1368,7 @@
       {
       cmOStringStream e;
       e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     // Store the file for installation.
diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h
index 9db2490..8e14a08 100644
--- a/Source/cmInstallCommand.h
+++ b/Source/cmInstallCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "install";}
+  virtual std::string GetName() const { return "install";}
 
   cmTypeMacro(cmInstallCommand, cmCommand);
 
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 1287ea6..9a17052 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -94,7 +94,7 @@
     {
     // Replace the destination path with a hash to keep it short.
     this->TempDir +=
-      cmSystemTools::ComputeStringMD5(this->Destination.c_str());
+      cmSystemTools::ComputeStringMD5(this->Destination);
     }
   else
     {
@@ -138,11 +138,11 @@
 
   // Generate the import file for this export set.
   this->EFGen->SetExportFile(this->MainImportFile.c_str());
-  this->EFGen->SetNamespace(this->Namespace.c_str());
+  this->EFGen->SetNamespace(this->Namespace);
   this->EFGen->SetExportOld(this->ExportOld);
   if(this->ConfigurationTypes->empty())
     {
-    if(this->ConfigurationName && *this->ConfigurationName)
+    if(!this->ConfigurationName.empty())
       {
       this->EFGen->AddConfiguration(this->ConfigurationName);
       }
@@ -157,7 +157,7 @@
           ci = this->ConfigurationTypes->begin();
         ci != this->ConfigurationTypes->end(); ++ci)
       {
-      this->EFGen->AddConfiguration(ci->c_str());
+      this->EFGen->AddConfiguration(*ci);
       }
     }
   this->EFGen->GenerateImportFile();
@@ -177,12 +177,12 @@
   // Now create a configuration-specific install rule for the import
   // file of each configuration.
   std::vector<std::string> files;
-  for(std::map<cmStdString, cmStdString>::const_iterator
+  for(std::map<std::string, std::string>::const_iterator
         i = this->EFGen->GetConfigImportFiles().begin();
       i != this->EFGen->GetConfigImportFiles().end(); ++i)
     {
     files.push_back(i->second);
-    std::string config_test = this->CreateConfigTest(i->first.c_str());
+    std::string config_test = this->CreateConfigTest(i->first);
     os << indent << "if(" << config_test << ")\n";
     this->AddInstallRule(os, cmInstallType_FILES, files, false,
                          this->FilePermissions.c_str(), 0, 0, 0,
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index 488d486..7eabbef 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -100,9 +100,9 @@
   else     // reg exp list
     {
     std::vector<std::string> files;
-    std::string regex = this->FinalArgs[0].c_str();
+    std::string regex = this->FinalArgs[0];
     cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(),
-                        regex.c_str(), files);
+                        regex, files);
 
     std::vector<std::string>::iterator s = files.begin();
     // for each argument, get the files
diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h
index 5583fe4..4551ab1 100644
--- a/Source/cmInstallFilesCommand.h
+++ b/Source/cmInstallFilesCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "install_files";}
+  virtual std::string GetName() const { return "install_files";}
 
   /**
    * This is called at the end after all the information
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index ec15044..b2be82e 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -12,6 +12,7 @@
 #include "cmInstallFilesGenerator.h"
 
 #include "cmGeneratorExpression.h"
+#include "cmMakefile.h"
 #include "cmSystemTools.h"
 
 //----------------------------------------------------------------------------
@@ -80,12 +81,11 @@
 
 //----------------------------------------------------------------------------
 void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os,
-                                                      const char* config,
-                                                      Indent const& indent)
+                                                    const std::string& config,
+                                                    Indent const& indent)
 {
   std::vector<std::string> files;
-  cmListFileBacktrace lfbt;
-  cmGeneratorExpression ge(lfbt);
+  cmGeneratorExpression ge;
   for(std::vector<std::string>::const_iterator i = this->Files.begin();
       i != this->Files.end(); ++i)
     {
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index 9dea296..23bf935 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -35,7 +35,7 @@
 protected:
   virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
   virtual void GenerateScriptForConfig(std::ostream& os,
-                                       const char* config,
+                                       const std::string& config,
                                        Indent const& indent);
   void AddFilesInstallRule(std::ostream& os, Indent const& indent,
                            std::vector<std::string> const& files);
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index d105a0c..9370e48 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -91,7 +91,7 @@
         << "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n";
      os << indent << "endif()\n";
      }
-  os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str();
+  os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype;
   if(optional)
     {
     os << " OPTIONAL";
@@ -163,7 +163,7 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmInstallGenerator::InstallsForConfig(const char* config)
+bool cmInstallGenerator::InstallsForConfig(const std::string& config)
 {
   return this->GeneratesForConfig(config);
 }
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index c89ab8a..c72e9e9 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -48,7 +48,7 @@
   std::string GetInstallDestination() const;
 
   /** Test if this generator installs something for a given configuration.  */
-  bool InstallsForConfig(const char*);
+  bool InstallsForConfig(const std::string& config);
 
 protected:
   virtual void GenerateScript(std::ostream& os);
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 54d903a..597f7ee 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -68,7 +68,7 @@
     {
     std::vector<std::string> programs;
     cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(),
-                        this->FinalArgs[0].c_str(), programs);
+                        this->FinalArgs[0], programs);
 
     std::vector<std::string>::iterator s = programs.begin();
     // for each argument, get the programs
diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h
index 95acfa2..90c7ba3 100644
--- a/Source/cmInstallProgramsCommand.h
+++ b/Source/cmInstallProgramsCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "install_programs";}
+  virtual std::string GetName() const { return "install_programs";}
 
   /**
    * This is called at the end after all the information
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 7a39f45..ec2b518 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -59,8 +59,8 @@
 
 //----------------------------------------------------------------------------
 void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
-                                                       const char* config,
-                                                       Indent const& indent)
+                                                    const std::string& config,
+                                                    Indent const& indent)
 {
   // Compute the build tree directory from which to copy the target.
   std::string fromDirConfig;
@@ -319,7 +319,7 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmInstallTargetGenerator::GetInstallFilename(const char* config) const
+cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const
 {
   NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
   return
@@ -330,7 +330,7 @@
 //----------------------------------------------------------------------------
 std::string
 cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
-                                             const char* config,
+                                             const std::string& config,
                                              NameType nameType)
 {
   std::string fname;
@@ -405,7 +405,7 @@
 //----------------------------------------------------------------------------
 void
 cmInstallTargetGenerator
-::AddTweak(std::ostream& os, Indent const& indent, const char* config,
+::AddTweak(std::ostream& os, Indent const& indent, const std::string& config,
            std::string const& file, TweakMethod tweak)
 {
   cmOStringStream tw;
@@ -423,7 +423,7 @@
 //----------------------------------------------------------------------------
 void
 cmInstallTargetGenerator
-::AddTweak(std::ostream& os, Indent const& indent, const char* config,
+::AddTweak(std::ostream& os, Indent const& indent, const std::string& config,
            std::vector<std::string> const& files, TweakMethod tweak)
 {
   if(files.size() == 1)
@@ -470,7 +470,7 @@
 //----------------------------------------------------------------------------
 void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os,
                                                     Indent const& indent,
-                                                    const char* config,
+                                                    const std::string& config,
                                                     std::string const& file)
 {
   this->AddRPathCheckRule(os, indent, config, file);
@@ -478,9 +478,9 @@
 
 //----------------------------------------------------------------------------
 void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os,
-                                                     Indent const& indent,
-                                                     const char* config,
-                                                     std::string const& file)
+                                                    Indent const& indent,
+                                                    const std::string& config,
+                                                    std::string const& file)
 {
   this->AddInstallNamePatchRule(os, indent, config, file);
   this->AddChrpathPatchRule(os, indent, config, file);
@@ -492,7 +492,8 @@
 void
 cmInstallTargetGenerator
 ::AddInstallNamePatchRule(std::ostream& os, Indent const& indent,
-                          const char* config, std::string const& toDestDirPath)
+                          const std::string& config,
+                          std::string const& toDestDirPath)
 {
   if(this->ImportLibrary ||
      !(this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -513,7 +514,7 @@
 
   // Build a map of build-tree install_name to install-tree install_name for
   // shared libraries linked to this target.
-  std::map<cmStdString, cmStdString> install_name_remap;
+  std::map<std::string, std::string> install_name_remap;
   if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
     {
     std::set<cmTarget const*> const& sharedLibs
@@ -590,7 +591,7 @@
       {
       os << "\n" << indent << "  -id \"" << new_id << "\"";
       }
-    for(std::map<cmStdString, cmStdString>::const_iterator
+    for(std::map<std::string, std::string>::const_iterator
           i = install_name_remap.begin();
         i != install_name_remap.end(); ++i)
       {
@@ -605,7 +606,8 @@
 void
 cmInstallTargetGenerator
 ::AddRPathCheckRule(std::ostream& os, Indent const& indent,
-                    const char* config, std::string const& toDestDirPath)
+                    const std::string& config,
+                    std::string const& toDestDirPath)
 {
   // Skip the chrpath if the target does not need it.
   if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
@@ -642,7 +644,8 @@
 void
 cmInstallTargetGenerator
 ::AddChrpathPatchRule(std::ostream& os, Indent const& indent,
-                      const char* config, std::string const& toDestDirPath)
+                      const std::string& config,
+                      std::string const& toDestDirPath)
 {
   // Skip the chrpath if the target does not need it.
   if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index 18c3957..0f21da7 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -43,7 +43,7 @@
   void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; }
   NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; }
 
-  std::string GetInstallFilename(const char* config) const;
+  std::string GetInstallFilename(const std::string& config) const;
 
   enum NameType
   {
@@ -54,7 +54,7 @@
   };
 
   static std::string GetInstallFilename(cmTarget const* target,
-                                        const char* config,
+                                        const std::string& config,
                                         NameType nameType = NameNormal);
 
   cmTarget* GetTarget() const { return this->Target; }
@@ -63,30 +63,33 @@
 protected:
   virtual void GenerateScript(std::ostream& os);
   virtual void GenerateScriptForConfig(std::ostream& os,
-                                       const char* config,
+                                       const std::string& config,
                                        Indent const& indent);
   typedef void (cmInstallTargetGenerator::*TweakMethod)(
-    std::ostream&, Indent const&, const char*, std::string const&
+    std::ostream&, Indent const&, const std::string&, std::string const&
     );
   void AddTweak(std::ostream& os, Indent const& indent,
-                const char* config, std::string const& file,
+                const std::string& config, std::string const& file,
                 TweakMethod tweak);
   void AddTweak(std::ostream& os, Indent const& indent,
-                const char* config, std::vector<std::string> const& files,
+                const std::string& config,
+                std::vector<std::string> const& files,
                 TweakMethod tweak);
   std::string GetDestDirPath(std::string const& file);
   void PreReplacementTweaks(std::ostream& os, Indent const& indent,
-                            const char* config, std::string const& file);
+                            const std::string& config,
+                            std::string const& file);
   void PostReplacementTweaks(std::ostream& os, Indent const& indent,
-                             const char* config, std::string const& file);
+                             const std::string& config,
+                             std::string const& file);
   void AddInstallNamePatchRule(std::ostream& os, Indent const& indent,
-                               const char* config,
+                               const std::string& config,
                                const std::string& toDestDirPath);
   void AddChrpathPatchRule(std::ostream& os, Indent const& indent,
-                           const char* config,
+                           const std::string& config,
                            std::string const& toDestDirPath);
   void AddRPathCheckRule(std::ostream& os, Indent const& indent,
-                         const char* config,
+                         const std::string& config,
                          std::string const& toDestDirPath);
 
   void AddStripRule(std::ostream& os, Indent const& indent,
diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx
index 277ccea..b738844 100644
--- a/Source/cmInstallTargetsCommand.cxx
+++ b/Source/cmInstallTargetsCommand.cxx
@@ -52,7 +52,7 @@
     else
       {
       std::string str = "Cannot find target: \"" + *s + "\" to install.";
-      this->SetError(str.c_str());
+      this->SetError(str);
       return false;
       }
     }
diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h
index 2aa34db..e6cbe6e 100644
--- a/Source/cmInstallTargetsCommand.h
+++ b/Source/cmInstallTargetsCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "install_targets";}
+  virtual std::string GetName() const { return "install_targets";}
 
   /** This command is kept for compatibility with older CMake versions. */
   virtual bool IsDiscouraged() const
diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx
new file mode 100644
index 0000000..7813fcc
--- /dev/null
+++ b/Source/cmInstalledFile.cxx
@@ -0,0 +1,113 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 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 "cmInstalledFile.h"
+#include "cmSystemTools.h"
+#include "cmMakefile.h"
+
+//----------------------------------------------------------------------------
+cmInstalledFile::cmInstalledFile():
+  NameExpression(0)
+{
+
+}
+
+//----------------------------------------------------------------------------
+cmInstalledFile::~cmInstalledFile()
+{
+  if(NameExpression)
+    {
+    delete NameExpression;
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name)
+{
+  cmListFileBacktrace backtrace = mf->GetBacktrace();
+  cmGeneratorExpression ge(&backtrace);
+
+  this->Name = name;
+  this->NameExpression = ge.Parse(name).release();
+}
+
+//----------------------------------------------------------------------------
+std::string const& cmInstalledFile::GetName() const
+{
+  return this->Name;
+}
+
+//----------------------------------------------------------------------------
+cmCompiledGeneratorExpression const& cmInstalledFile::GetNameExpression() const
+{
+  return *(this->NameExpression);
+}
+
+//----------------------------------------------------------------------------
+void cmInstalledFile::RemoveProperty(const std::string& prop)
+{
+  this->Properties.erase(prop);
+}
+
+//----------------------------------------------------------------------------
+void cmInstalledFile::SetProperty(cmMakefile const* mf,
+  const std::string& prop, const char* value)
+{
+  this->RemoveProperty(prop);
+  this->AppendProperty(mf, prop, value);
+}
+
+//----------------------------------------------------------------------------
+void cmInstalledFile::AppendProperty(cmMakefile const* mf,
+  const std::string& prop, const char* value, bool /*asString*/)
+{
+  cmListFileBacktrace backtrace = mf->GetBacktrace();
+  cmGeneratorExpression ge(&backtrace);
+
+  Property& property = this->Properties[prop];
+  property.ValueExpressions.push_back(ge.Parse(value).release());
+}
+
+//----------------------------------------------------------------------------
+bool cmInstalledFile::GetProperty(
+  const std::string& prop, std::string& value) const
+{
+  PropertyMapType::const_iterator i = this->Properties.find(prop);
+  if(i == this->Properties.end())
+    {
+    return false;
+    }
+
+  Property const& property = i->second;
+
+  std::string output;
+  std::string separator;
+
+  for(ExpressionVectorType::const_iterator
+    j = property.ValueExpressions.begin();
+    j != property.ValueExpressions.end(); ++j)
+    {
+    output += separator;
+    output += (*j)->GetInput();
+    separator = ";";
+    }
+
+  value = output;
+  return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const
+{
+  std::string value;
+  bool isSet = this->GetProperty(prop, value);
+  return isSet && cmSystemTools::IsOn(value.c_str());
+}
diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h
new file mode 100644
index 0000000..df28221
--- /dev/null
+++ b/Source/cmInstalledFile.h
@@ -0,0 +1,83 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 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 cmInstalledFile_h
+#define cmInstalledFile_h
+
+#include "cmGeneratorExpression.h"
+
+/** \class cmInstalledFile
+ * \brief Represents a file intended for installation.
+ *
+ * cmInstalledFile represents a file intended for installation.
+ */
+class cmInstalledFile
+{
+public:
+
+  typedef cmsys::auto_ptr<cmCompiledGeneratorExpression>
+    CompiledGeneratorExpressionPtrType;
+
+  typedef std::vector<cmCompiledGeneratorExpression*>
+    ExpressionVectorType;
+
+  struct Property
+  {
+    Property()
+    {
+
+    }
+
+    ~Property()
+    {
+      for(ExpressionVectorType::iterator i = ValueExpressions.begin();
+        i != ValueExpressions.end(); ++i)
+        {
+        delete *i;
+        }
+    }
+
+    ExpressionVectorType ValueExpressions;
+  };
+
+  typedef std::map<std::string, Property> PropertyMapType;
+
+  cmInstalledFile();
+
+  ~cmInstalledFile();
+
+  void RemoveProperty(const std::string& prop);
+
+  void SetProperty(cmMakefile const* mf,
+    const std::string& prop, const char *value);
+
+  void AppendProperty(cmMakefile const* mf,
+    const std::string& prop, const char* value,bool asString=false);
+
+  bool GetProperty(const std::string& prop, std::string& value) const;
+
+  bool GetPropertyAsBool(const std::string& prop) const;
+
+  void SetName(cmMakefile* mf, const std::string& name);
+
+  std::string const& GetName() const;
+
+  cmCompiledGeneratorExpression const& GetNameExpression() const;
+
+  PropertyMapType const& GetProperties() const { return this->Properties; }
+
+private:
+  std::string Name;
+  cmCompiledGeneratorExpression* NameExpression;
+  PropertyMapType Properties;
+};
+
+#endif
diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx
index 4412414..3644d93 100644
--- a/Source/cmLinkDirectoriesCommand.cxx
+++ b/Source/cmLinkDirectoriesCommand.cxx
@@ -66,5 +66,5 @@
       unixPath = tmp;
       }
     }
-  this->Makefile->AddLinkDirectory(unixPath.c_str());
+  this->Makefile->AddLinkDirectory(unixPath);
 }
diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h
index c6eb40c..8e04baf 100644
--- a/Source/cmLinkDirectoriesCommand.h
+++ b/Source/cmLinkDirectoriesCommand.h
@@ -43,7 +43,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "link_directories";}
+  virtual std::string GetName() const { return "link_directories";}
 
   cmTypeMacro(cmLinkDirectoriesCommand, cmCommand);
 private:
diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx
index 2f1db2a..996b538 100644
--- a/Source/cmLinkLibrariesCommand.cxx
+++ b/Source/cmLinkLibrariesCommand.cxx
@@ -33,7 +33,7 @@
                        "a library");
         return false;
         }
-      this->Makefile->AddLinkLibrary(i->c_str(),
+      this->Makefile->AddLinkLibrary(*i,
                                  cmTarget::DEBUG);
       }
     else if (*i == "optimized")
@@ -45,12 +45,12 @@
                        "a library");
         return false;
         }
-      this->Makefile->AddLinkLibrary(i->c_str(),
+      this->Makefile->AddLinkLibrary(*i,
                                  cmTarget::OPTIMIZED);
       }
     else
       {
-      this->Makefile->AddLinkLibrary(i->c_str());
+      this->Makefile->AddLinkLibrary(*i);
       }
     }
 
diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h
index 74de23c..c572439 100644
--- a/Source/cmLinkLibrariesCommand.h
+++ b/Source/cmLinkLibrariesCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "link_libraries";}
+  virtual std::string GetName() const { return "link_libraries";}
 
   /** This command is kept for compatibility with older CMake versions. */
   virtual bool IsDiscouraged() const
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index df64695..f1ea088 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -69,17 +69,14 @@
     }
 
   std::string e = "does not recognize sub-command "+subCommand;
-  this->SetError(e.c_str());
+  this->SetError(e);
   return false;
 }
 
 //----------------------------------------------------------------------------
-bool cmListCommand::GetListString(std::string& listString, const char* var)
+bool cmListCommand::GetListString(std::string& listString,
+                                  const std::string& var)
 {
-  if ( !var )
-    {
-    return false;
-    }
   // get the old value
   const char* cacheValue
     = this->Makefile->GetDefinition(var);
@@ -92,7 +89,8 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmListCommand::GetList(std::vector<std::string>& list, const char* var)
+bool cmListCommand::GetList(std::vector<std::string>& list,
+                            const std::string& var)
 {
   std::string listString;
   if ( !this->GetListString(listString, var) )
@@ -178,12 +176,12 @@
   // do not check the return value here
   // if the list var is not found varArgsExpanded will have size 0
   // and we will return 0
-  this->GetList(varArgsExpanded, listName.c_str());
+  this->GetList(varArgsExpanded, listName);
   size_t length = varArgsExpanded.size();
   char buffer[1024];
   sprintf(buffer, "%d", static_cast<int>(length));
 
-  this->Makefile->AddDefinition(variableName.c_str(), buffer);
+  this->Makefile->AddDefinition(variableName, buffer);
   return true;
 }
 
@@ -200,9 +198,9 @@
   const std::string& variableName = args[args.size() - 1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+  if ( !this->GetList(varArgsExpanded, listName) )
     {
-    this->Makefile->AddDefinition(variableName.c_str(), "NOTFOUND");
+    this->Makefile->AddDefinition(variableName, "NOTFOUND");
     return true;
     }
   // FIXME: Add policy to make non-existing lists an error like empty lists.
@@ -231,13 +229,13 @@
       str << "index: " << item << " out of range (-"
           << varArgsExpanded.size() << ", "
           << varArgsExpanded.size()-1 << ")";
-      this->SetError(str.str().c_str());
+      this->SetError(str.str());
       return false;
       }
     value += varArgsExpanded[item];
     }
 
-  this->Makefile->AddDefinition(variableName.c_str(), value.c_str());
+  this->Makefile->AddDefinition(variableName, value.c_str());
   return true;
 }
 
@@ -255,7 +253,7 @@
   const std::string& listName = args[1];
   // expand the variable
   std::string listString;
-  this->GetListString(listString, listName.c_str());
+  this->GetListString(listString, listName);
   size_t cc;
   for ( cc = 2; cc < args.size(); ++ cc )
     {
@@ -266,7 +264,7 @@
     listString += args[cc];
     }
 
-  this->Makefile->AddDefinition(listName.c_str(), listString.c_str());
+  this->Makefile->AddDefinition(listName, listString.c_str());
   return true;
 }
 
@@ -283,9 +281,9 @@
   const std::string& variableName = args[args.size() - 1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+  if ( !this->GetList(varArgsExpanded, listName) )
     {
-    this->Makefile->AddDefinition(variableName.c_str(), "-1");
+    this->Makefile->AddDefinition(variableName, "-1");
     return true;
     }
 
@@ -297,13 +295,13 @@
       {
       char indexString[32];
       sprintf(indexString, "%d", index);
-      this->Makefile->AddDefinition(variableName.c_str(), indexString);
+      this->Makefile->AddDefinition(variableName, indexString);
       return true;
       }
     index++;
     }
 
-  this->Makefile->AddDefinition(variableName.c_str(), "-1");
+  this->Makefile->AddDefinition(variableName, "-1");
   return true;
 }
 
@@ -321,12 +319,12 @@
   // expand the variable
   int item = atoi(args[2].c_str());
   std::vector<std::string> varArgsExpanded;
-  if((!this->GetList(varArgsExpanded, listName.c_str())
+  if((!this->GetList(varArgsExpanded, listName)
       || varArgsExpanded.empty()) && item != 0)
     {
     cmOStringStream str;
     str << "index: " << item << " out of range (0, 0)";
-    this->SetError(str.str().c_str());
+    this->SetError(str.str());
     return false;
     }
 
@@ -343,7 +341,7 @@
       str << "index: " << item << " out of range (-"
         << varArgsExpanded.size() << ", "
         << (varArgsExpanded.size() == 0?0:(varArgsExpanded.size()-1)) << ")";
-      this->SetError(str.str().c_str());
+      this->SetError(str.str());
       return false;
       }
     }
@@ -364,7 +362,7 @@
     sep = ";";
     }
 
-  this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+  this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
@@ -381,7 +379,7 @@
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+  if ( !this->GetList(varArgsExpanded, listName) )
     {
     this->SetError("sub-command REMOVE_ITEM requires list to be present.");
     return false;
@@ -413,7 +411,7 @@
     sep = ";";
     }
 
-  this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+  this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
@@ -432,7 +430,7 @@
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+  if ( !this->GetList(varArgsExpanded, listName) )
     {
     this->SetError("sub-command REVERSE requires list to be present.");
     return false;
@@ -448,7 +446,7 @@
     sep = ";";
     }
 
-  this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+  this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
@@ -467,7 +465,7 @@
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+  if ( !this->GetList(varArgsExpanded, listName) )
     {
     this->SetError(
       "sub-command REMOVE_DUPLICATES requires list to be present.");
@@ -493,7 +491,7 @@
     }
 
 
-  this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+  this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
@@ -512,7 +510,7 @@
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+  if ( !this->GetList(varArgsExpanded, listName) )
     {
     this->SetError("sub-command SORT requires list to be present.");
     return false;
@@ -530,7 +528,7 @@
     sep = ";";
     }
 
-  this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+  this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
@@ -548,7 +546,7 @@
   const std::string& listName = args[1];
   // expand the variable
   std::vector<std::string> varArgsExpanded;
-  if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+  if ( !this->GetList(varArgsExpanded, listName) )
     {
     this->SetError("sub-command REMOVE_AT requires list to be present.");
     return false;
@@ -576,7 +574,7 @@
       str << "index: " << item << " out of range (-"
           << varArgsExpanded.size() << ", "
           << varArgsExpanded.size()-1 << ")";
-      this->SetError(str.str().c_str());
+      this->SetError(str.str());
       return false;
       }
     removed.push_back(static_cast<size_t>(item));
@@ -604,7 +602,7 @@
       }
     }
 
-  this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+  this->Makefile->AddDefinition(listName, value.c_str());
   return true;
 }
 
diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h
index 0cb5da2..5ea1d9f 100644
--- a/Source/cmListCommand.h
+++ b/Source/cmListCommand.h
@@ -44,7 +44,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "list";}
+  virtual std::string GetName() const { return "list";}
 
   cmTypeMacro(cmListCommand, cmCommand);
 protected:
@@ -60,8 +60,8 @@
   bool HandleReverseCommand(std::vector<std::string> const& args);
 
 
-  bool GetList(std::vector<std::string>& list, const char* var);
-  bool GetListString(std::string& listString, const char* var);
+  bool GetList(std::vector<std::string>& list, const std::string& var);
+  bool GetListString(std::string& listString, const std::string& var);
 };
 
 
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 7461d37..705666d 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -12,6 +12,7 @@
 #include "cmListFileCache.h"
 
 #include "cmListFileLexer.h"
+#include "cmLocalGenerator.h"
 #include "cmSystemTools.h"
 #include "cmMakefile.h"
 #include "cmVersion.h"
@@ -397,17 +398,34 @@
     << "Argument not separated from preceding token by whitespace.";
   if(isError)
     {
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str().c_str());
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
     return false;
     }
   else
     {
-    this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str());
+    this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
     return true;
     }
 }
 
 //----------------------------------------------------------------------------
+void cmListFileBacktrace::MakeRelative()
+{
+  if (this->Relative)
+    {
+    return;
+    }
+  for (cmListFileBacktrace::iterator i = this->begin();
+       i != this->end(); ++i)
+    {
+    i->FilePath = this->LocalGenerator->Convert(i->FilePath,
+                                                cmLocalGenerator::HOME);
+    }
+  this->Relative = true;
+}
+
+
+//----------------------------------------------------------------------------
 std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
 {
   os << lfc.FilePath;
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index bede25e..2ca9b8e 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -14,6 +14,8 @@
 
 #include "cmStandardIncludes.h"
 
+class cmLocalGenerator;
+
 /** \class cmListFileCache
  * \brief A class to cache list file contents.
  *
@@ -66,7 +68,20 @@
   std::vector<cmListFileArgument> Arguments;
 };
 
-class cmListFileBacktrace: public std::vector<cmListFileContext> {};
+class cmListFileBacktrace: public std::vector<cmListFileContext>
+{
+  public:
+    cmListFileBacktrace(cmLocalGenerator* localGen)
+      : LocalGenerator(localGen)
+      , Relative(localGen ? false : true)
+    {
+    }
+
+    void MakeRelative();
+  private:
+    cmLocalGenerator* LocalGenerator;
+    bool Relative;
+};
 
 struct cmListFile
 {
diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx
index dfd98fa..427e29d 100644
--- a/Source/cmLoadCacheCommand.cxx
+++ b/Source/cmLoadCacheCommand.cxx
@@ -33,7 +33,7 @@
   // and they can not be overridden.
   bool excludeFiles=false;
   unsigned int i;
-  std::set<cmStdString> excludes;
+  std::set<std::string> excludes;
 
   for(i=0; i<args.size(); i++)
     {
@@ -55,7 +55,7 @@
   // If this set is empty, no internal cache entries are
   // brought in.
   bool includeFiles=false;
-  std::set<cmStdString> includes;
+  std::set<std::string> includes;
 
   for(i=0; i<args.size(); i++)
     {
@@ -81,7 +81,7 @@
       {
       break;
       }
-    this->Makefile->GetCacheManager()->LoadCache(args[i].c_str(), false,
+    this->Makefile->GetCacheManager()->LoadCache(args[i], false,
                                              excludes, includes);
     }
 
@@ -104,7 +104,7 @@
   if(!cmSystemTools::FileExists(cacheFile.c_str()))
     {
     std::string e = "Cannot load cache file from " + cacheFile;
-    this->SetError(e.c_str());
+    this->SetError(e);
     return false;
     }
 
@@ -186,11 +186,11 @@
       var = this->Prefix + var;
       if(value.length())
         {
-        this->Makefile->AddDefinition(var.c_str(), value.c_str());
+        this->Makefile->AddDefinition(var, value.c_str());
         }
       else
         {
-        this->Makefile->RemoveDefinition(var.c_str());
+        this->Makefile->RemoveDefinition(var);
         }
       }
     }
diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h
index c8f7236..04207d0 100644
--- a/Source/cmLoadCacheCommand.h
+++ b/Source/cmLoadCacheCommand.h
@@ -40,12 +40,12 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "load_cache";}
+  virtual std::string GetName() const { return "load_cache";}
 
   cmTypeMacro(cmLoadCacheCommand, cmCommand);
 protected:
 
-  std::set<cmStdString> VariablesToRead;
+  std::set<std::string> VariablesToRead;
   std::string Prefix;
 
   bool ReadWithPrefix(std::vector<std::string> const& args);
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 21ee0fe..a4063a6 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -69,7 +69,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return info.Name; }
+  virtual std::string GetName() const { return info.Name; }
 
   static const char* LastName;
   static void TrapsForSignals(int sig)
@@ -201,7 +201,7 @@
   // Start by removing the definition in case of failure.
   std::string reportVar = "CMAKE_LOADED_COMMAND_";
   reportVar += args[0];
-  this->Makefile->RemoveDefinition(reportVar.c_str());
+  this->Makefile->RemoveDefinition(reportVar);
 
   // the file must exist
   std::string moduleName =
@@ -219,7 +219,7 @@
     cmSystemTools::ExpandRegistryValues(exp);
 
     // Glob the entry in case of wildcards.
-    cmSystemTools::GlobDirs(exp.c_str(), path);
+    cmSystemTools::GlobDirs(exp, path);
     }
 
   // Try to find the program.
@@ -229,7 +229,7 @@
     cmOStringStream e;
     e << "Attempt to load command failed from file \""
       << moduleName << "\"";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
@@ -246,12 +246,12 @@
       err += " Additional error info is:\n";
       err += error;
       }
-    this->SetError(err.c_str());
+    this->SetError(err);
     return false;
     }
 
   // Report what file was loaded for this command.
-  this->Makefile->AddDefinition(reportVar.c_str(), fullPath.c_str());
+  this->Makefile->AddDefinition(reportVar, fullPath.c_str());
 
   // find the init function
   std::string initFuncName = args[0] + "Init";
diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h
index 11bcf09..4581269 100644
--- a/Source/cmLoadCommandCommand.h
+++ b/Source/cmLoadCommandCommand.h
@@ -20,7 +20,7 @@
   virtual cmCommand* Clone() { return new cmLoadCommandCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
-  virtual const char* GetName() const {return "load_command";}
+  virtual std::string GetName() const {return "load_command";}
   virtual bool IsDiscouraged() const { return true; }
   cmTypeMacro(cmLoadCommandCommand, cmCommand);
 };
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 7890379..c8c8c79 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -22,6 +22,7 @@
 #include "cmSourceFile.h"
 #include "cmTest.h"
 #include "cmTestGenerator.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmVersion.h"
 #include "cmake.h"
 
@@ -281,7 +282,7 @@
 
   // Compute the set of configurations.
   std::vector<std::string> configurationTypes;
-  const char* config =
+  const std::string& config =
     this->Makefile->GetConfigurations(configurationTypes, false);
 
   std::string file = this->Makefile->GetStartOutputDirectory();
@@ -326,7 +327,7 @@
       fout << "subdirs(";
       std::string outP =
         this->Children[i]->GetMakefile()->GetStartOutputDirectory();
-      fout << this->Convert(outP.c_str(),START_OUTPUT);
+      fout << this->Convert(outP,START_OUTPUT);
       fout << ")" << std::endl;
       }
     }
@@ -385,11 +386,11 @@
 
   // Compute the set of configurations.
   std::vector<std::string> configurationTypes;
-  const char* config =
+  const std::string& config =
     this->Makefile->GetConfigurations(configurationTypes, false);
 
   // Choose a default install configuration.
-  const char* default_config = config;
+  const char* default_config = config.c_str();
   const char* default_order[] = {"RELEASE", "MINSIZEREL",
                                  "RELWITHDEBINFO", "DEBUG", 0};
   for(const char** c = default_order; *c && !default_config; ++c)
@@ -504,7 +505,7 @@
         {
         std::string odir = (*ci)->GetMakefile()->GetStartOutputDirectory();
         cmSystemTools::ConvertToUnixSlashes(odir);
-        fout << "  include(\"" <<  odir.c_str()
+        fout << "  include(\"" <<  odir
              << "/cmake_install.cmake\")" << std::endl;
         }
       }
@@ -524,12 +525,12 @@
       "endif()\n\n";
     fout
       << "file(WRITE \""
-      << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" "
+      << homedir << "/${CMAKE_INSTALL_MANIFEST}\" "
       << "\"\")" << std::endl;
     fout
       << "foreach(file ${CMAKE_INSTALL_MANIFEST_FILES})" << std::endl
       << "  file(APPEND \""
-      << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" "
+      << homedir << "/${CMAKE_INSTALL_MANIFEST}\" "
       << "\"${file}\\n\")" << std::endl
       << "endforeach()" << std::endl;
     }
@@ -541,6 +542,10 @@
   // Collect the set of configuration types.
   std::vector<std::string> configNames;
   this->Makefile->GetConfigurations(configNames);
+  if(configNames.empty())
+    {
+    configNames.push_back("");
+    }
 
   // Add our targets to the manifest for each configuration.
   cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
@@ -556,42 +561,35 @@
       {
       continue;
       }
-    if(configNames.empty())
+    for(std::vector<std::string>::iterator ci = configNames.begin();
+        ci != configNames.end(); ++ci)
       {
-      target.GenerateTargetManifest(0);
-      }
-    else
-      {
-      for(std::vector<std::string>::iterator ci = configNames.begin();
-          ci != configNames.end(); ++ci)
-        {
-        const char* config = ci->c_str();
-        target.GenerateTargetManifest(config);
-        }
+      const char* config = ci->c_str();
+      target.GenerateTargetManifest(config);
       }
     }
 }
 
 void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
-                                                    const char* lang,
+                                                    const std::string& lang,
                                                     cmSourceFile& source,
                                                     cmGeneratorTarget& target)
 {
   std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
-  objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
+  objectDir = this->Convert(objectDir,START_OUTPUT,SHELL);
   std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
   std::string sourceFile =
-    this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true);
+    this->Convert(source.GetFullPath(),START_OUTPUT,SHELL,true);
   std::string varString = "CMAKE_";
   varString += lang;
   varString += "_COMPILE_OBJECT";
   std::vector<std::string> rules;
-  rules.push_back(this->Makefile->GetRequiredDefinition(varString.c_str()));
+  rules.push_back(this->Makefile->GetRequiredDefinition(varString));
   varString = "CMAKE_";
   varString += lang;
   varString += "_FLAGS";
   std::string flags;
-  flags += this->Makefile->GetSafeDefinition(varString.c_str());
+  flags += this->Makefile->GetSafeDefinition(varString);
   flags += " ";
     {
     std::vector<std::string> includes;
@@ -605,7 +603,7 @@
   std::vector<std::string> commands;
   cmSystemTools::ExpandList(rules, commands);
   cmLocalGenerator::RuleVariables vars;
-  vars.Language = lang;
+  vars.Language = lang.c_str();
   vars.Source = sourceFile.c_str();
   vars.Object = objectFile.c_str();
   vars.ObjectDir = objectDir.c_str();
@@ -618,8 +616,8 @@
 
     // Parse the string to get the custom command line.
     cmCustomCommandLine commandLine;
-    std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
-    for(std::vector<cmStdString>::iterator a = cmd.begin();
+    std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str());
+    for(std::vector<std::string>::iterator a = cmd.begin();
         a != cmd.end(); ++a)
       {
       commandLine.push_back(*a);
@@ -647,21 +645,22 @@
   this->Makefile->AddCustomCommandToOutput(
     ofname,
     depends,
-    source.GetFullPath().c_str(),
+    source.GetFullPath(),
     commandLines,
     comment.c_str(),
     this->Makefile->GetStartOutputDirectory()
     );
 }
 
-void cmLocalGenerator::AddBuildTargetRule(const char* llang,
+void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
                                           cmGeneratorTarget& target)
 {
-  cmStdString objs;
+  std::string objs;
   std::vector<std::string> objVector;
+  std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
   // Add all the sources outputs to the depends of the target
   std::vector<cmSourceFile*> classes;
-  target.GetSourceFiles(classes);
+  target.GetSourceFiles(classes, config);
   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
       i != classes.end(); ++i)
     {
@@ -682,14 +681,13 @@
         objVector.push_back(ofname);
         this->AddCustomCommandToCreateObject(ofname.c_str(),
                                              llang, *(*i), target);
-        objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE);
+        objs += this->Convert(ofname,START_OUTPUT,MAKEFILE);
         objs += " ";
         }
       }
     }
-  std::string createRule = "CMAKE_";
-  createRule += llang;
-  createRule += target.GetCreateRuleVariable();
+  std::string createRule = target.GetCreateRuleVariable(llang, config);
+  bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE");
   std::string targetName = target.Target->GetFullName();
   // Executable :
   // Shared Library:
@@ -701,10 +699,10 @@
   std::string flags; // should be set
   std::string linkFlags; // should be set
   this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
-                       &target);
+                       &target, useWatcomQuote);
   linkLibs = frameworkPath + linkPath + linkLibs;
   cmLocalGenerator::RuleVariables vars;
-  vars.Language = llang;
+  vars.Language = llang.c_str();
   vars.Objects = objs.c_str();
   vars.ObjectDir = ".";
   vars.Target = targetName.c_str();
@@ -713,13 +711,13 @@
   vars.LinkFlags = linkFlags.c_str();
 
   std::string langFlags;
-  this->AddLanguageFlags(langFlags, llang, 0);
-  this->AddArchitectureFlags(langFlags, &target, llang, 0);
+  this->AddLanguageFlags(langFlags, llang, "");
+  this->AddArchitectureFlags(langFlags, &target, llang, "");
   vars.LanguageCompileFlags = langFlags.c_str();
 
   cmCustomCommandLines commandLines;
   std::vector<std::string> rules;
-  rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str()));
+  rules.push_back(this->Makefile->GetRequiredDefinition(createRule));
   std::vector<std::string> commands;
   cmSystemTools::ExpandList(rules, commands);
   for(std::vector<std::string>::iterator i = commands.begin();
@@ -729,8 +727,8 @@
     this->ExpandRuleVariables(*i, vars);
     // Parse the string to get the custom command line.
     cmCustomCommandLine commandLine;
-    std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
-    for(std::vector<cmStdString>::iterator a = cmd.begin();
+    std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str());
+    for(std::vector<std::string>::iterator a = cmd.begin();
         a != cmd.end(); ++a)
       {
       commandLine.push_back(*a);
@@ -744,22 +742,22 @@
   std::string comment = "Linking ";
   comment += llang;
   comment += " target ";
-  comment += this->Convert(targetFullPath.c_str(), START_OUTPUT);
+  comment += this->Convert(targetFullPath, START_OUTPUT);
   this->Makefile->AddCustomCommandToOutput(
-    targetFullPath.c_str(),
+    targetFullPath,
     objVector,
-    0,
+    "",
     commandLines,
     comment.c_str(),
     this->Makefile->GetStartOutputDirectory()
     );
-  target.Target->AddSourceFile
-    (this->Makefile->GetSource(targetFullPath.c_str()));
+  this->Makefile->GetSource(targetFullPath);
+  target.Target->AddSource(targetFullPath);
 }
 
 
 void cmLocalGenerator
-::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang)
+::CreateCustomTargetsAndCommands(std::set<std::string> const& lang)
 {
   cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets();
   for(cmGeneratorTargetsType::iterator l = tgts.begin();
@@ -777,12 +775,12 @@
       case cmTarget::MODULE_LIBRARY:
       case cmTarget::EXECUTABLE:
         {
-        const char* llang = target.Target->GetLinkerLanguage();
-        if(!llang)
+        std::string llang = target.Target->GetLinkerLanguage();
+        if(llang.empty())
           {
           cmSystemTools::Error
             ("CMake can not determine linker language for target: ",
-             target.Target->GetName());
+             target.Target->GetName().c_str());
           return;
           }
         // if the language is not in the set lang then create custom
@@ -877,6 +875,13 @@
       return replaceValues.ObjectDir;
       }
     }
+  if(replaceValues.ObjectFileDir)
+    {
+    if(variable == "OBJECT_FILE_DIR")
+      {
+      return replaceValues.ObjectFileDir;
+      }
+    }
   if(replaceValues.Objects)
     {
     if(variable == "OBJECTS")
@@ -902,6 +907,13 @@
       return replaceValues.TargetPDB;
       }
     }
+  if(replaceValues.TargetCompilePDB)
+    {
+    if(variable == "TARGET_COMPILE_PDB")
+      {
+      return replaceValues.TargetCompilePDB;
+      }
+    }
   if(replaceValues.DependencyFile )
     {
     if(variable == "DEP_FILE")
@@ -1075,28 +1087,28 @@
         {
         std::string arg1 = actualReplace + "_ARG1";
         cmSystemTools::ReplaceString(arg1, "${LANG}", lang);
-        compilerArg1 = this->Makefile->GetDefinition(arg1.c_str());
+        compilerArg1 = this->Makefile->GetDefinition(arg1);
         compilerTarget
               = this->Makefile->GetDefinition(
-                (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str());
+                std::string("CMAKE_") + lang + "_COMPILER_TARGET");
         compilerOptionTarget
               = this->Makefile->GetDefinition(
-                (std::string("CMAKE_") + lang +
-                                          "_COMPILE_OPTIONS_TARGET").c_str());
+                std::string("CMAKE_") + lang +
+                                          "_COMPILE_OPTIONS_TARGET");
         compilerExternalToolchain
               = this->Makefile->GetDefinition(
-                (std::string("CMAKE_") + lang +
-                                    "_COMPILER_EXTERNAL_TOOLCHAIN").c_str());
+                std::string("CMAKE_") + lang +
+                                    "_COMPILER_EXTERNAL_TOOLCHAIN");
         compilerOptionExternalToolchain
               = this->Makefile->GetDefinition(
-                (std::string("CMAKE_") + lang +
-                              "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str());
+                std::string("CMAKE_") + lang +
+                              "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN");
         compilerSysroot
               = this->Makefile->GetDefinition("CMAKE_SYSROOT");
         compilerOptionSysroot
               = this->Makefile->GetDefinition(
-                (std::string("CMAKE_") + lang +
-                              "_COMPILE_OPTIONS_SYSROOT").c_str());
+                std::string("CMAKE_") + lang +
+                              "_COMPILE_OPTIONS_SYSROOT");
         }
       if(actualReplace.find("${LANG}") != actualReplace.npos)
         {
@@ -1105,11 +1117,11 @@
       if(actualReplace == variable)
         {
         std::string replace =
-          this->Makefile->GetSafeDefinition(variable.c_str());
+          this->Makefile->GetSafeDefinition(variable);
         // if the variable is not a FLAG then treat it like a path
         if(variable.find("_FLAG") == variable.npos)
           {
-          std::string ret = this->ConvertToOutputForExisting(replace.c_str());
+          std::string ret = this->ConvertToOutputForExisting(replace);
           // if there is a required first argument to the compiler add it
           // to the compiler string
           if(compilerArg1)
@@ -1150,8 +1162,11 @@
 cmLocalGenerator::ExpandRuleVariables(std::string& s,
                                       const RuleVariables& replaceValues)
 {
-  this->InsertRuleLauncher(s, replaceValues.CMTarget,
-                           replaceValues.RuleLauncher);
+  if(replaceValues.RuleLauncher)
+    {
+    this->InsertRuleLauncher(s, replaceValues.CMTarget,
+                             replaceValues.RuleLauncher);
+    }
   std::string::size_type start = s.find('<');
   // no variables to expand
   if(start == s.npos)
@@ -1195,7 +1210,7 @@
 
 //----------------------------------------------------------------------------
 const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target,
-                                              const char* prop)
+                                              const std::string& prop)
 {
   if(target)
     {
@@ -1209,7 +1224,7 @@
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
-                                          const char* prop)
+                                          const std::string& prop)
 {
   if(const char* val = this->GetRuleLauncher(target, prop))
     {
@@ -1221,19 +1236,20 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
-                                                   std::string const& result)
+cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote,
+                                                   std::string const& result,
+                                                   OutputFormat format)
 {
   // If this is a windows shell, the result has a space, and the path
   // already exists, we can use a short-path to reference it without a
   // space.
   if(this->WindowsShell && result.find(' ') != result.npos &&
-     cmSystemTools::FileExists(remote))
+     cmSystemTools::FileExists(remote.c_str()))
     {
     std::string tmp;
-    if(cmSystemTools::GetShortPath(remote, tmp))
+    if(cmSystemTools::GetShortPath(remote.c_str(), tmp))
       {
-      return this->Convert(tmp.c_str(), NONE, SHELL, true);
+      return this->Convert(tmp, NONE, format, true);
       }
     }
 
@@ -1243,57 +1259,62 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmLocalGenerator::ConvertToOutputForExisting(const char* remote,
-                                             RelativeRoot local)
+cmLocalGenerator::ConvertToOutputForExisting(const std::string& remote,
+                                             RelativeRoot local,
+                                             OutputFormat format)
 {
   // Perform standard conversion.
-  std::string result = this->Convert(remote, local, SHELL, true);
+  std::string result = this->Convert(remote, local, format, true);
 
   // Consider short-path.
-  return this->ConvertToOutputForExistingCommon(remote, result);
+  return this->ConvertToOutputForExistingCommon(remote, result, format);
 }
 
 //----------------------------------------------------------------------------
 std::string
 cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote,
-                                             const char* local)
+                                             const std::string& local,
+                                             OutputFormat format)
 {
   // Perform standard conversion.
-  std::string result = this->Convert(remote, local, SHELL, true);
+  std::string result = this->Convert(remote, local, format, true);
 
   // Consider short-path.
   const char* remotePath = this->GetRelativeRootPath(remote);
-  return this->ConvertToOutputForExistingCommon(remotePath, result);
+  return this->ConvertToOutputForExistingCommon(remotePath, result, format);
 }
 
 //----------------------------------------------------------------------------
 std::string
-cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
+cmLocalGenerator::ConvertToIncludeReference(std::string const& path,
+                                            OutputFormat format)
 {
-  return this->ConvertToOutputForExisting(path.c_str());
+  return this->ConvertToOutputForExisting(path, START_OUTPUT, format);
 }
 
 //----------------------------------------------------------------------------
 std::string cmLocalGenerator::GetIncludeFlags(
                                      const std::vector<std::string> &includes,
                                      cmGeneratorTarget* target,
-                                     const char* lang, bool forResponseFile,
-                                     const char *config)
+                                     const std::string& lang,
+                                     bool forResponseFile,
+                                     const std::string& config)
 {
-  if(!lang)
+  if(lang.empty())
     {
     return "";
     }
 
+  OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
   cmOStringStream includeFlags;
 
   std::string flagVar = "CMAKE_INCLUDE_FLAG_";
   flagVar += lang;
   const char* includeFlag =
-    this->Makefile->GetSafeDefinition(flagVar.c_str());
+    this->Makefile->GetSafeDefinition(flagVar);
   flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
   flagVar += lang;
-  const char* sep = this->Makefile->GetDefinition(flagVar.c_str());
+  const char* sep = this->Makefile->GetDefinition(flagVar);
   bool quotePaths = false;
   if(this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS"))
     {
@@ -1319,17 +1340,23 @@
   const char* sysIncludeFlag = 0;
   if(repeatFlag)
     {
-    sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar.c_str());
+    sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar);
     }
 
   std::string fwSearchFlagVar = "CMAKE_";
   fwSearchFlagVar += lang;
   fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
   const char* fwSearchFlag =
-    this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
+    this->Makefile->GetDefinition(fwSearchFlagVar);
+
+  std::string sysFwSearchFlagVar = "CMAKE_";
+  sysFwSearchFlagVar += lang;
+  sysFwSearchFlagVar += "_SYSTEM_FRAMEWORK_SEARCH_FLAG";
+  const char* sysFwSearchFlag =
+    this->Makefile->GetDefinition(sysFwSearchFlagVar);
 
   bool flagUsed = false;
-  std::set<cmStdString> emitted;
+  std::set<std::string> emitted;
 #ifdef __APPLE__
   emitted.insert("/System/Library/Frameworks");
 #endif
@@ -1344,10 +1371,17 @@
       frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
       if(emitted.insert(frameworkDir).second)
         {
-        OutputFormat format = forResponseFile? RESPONSE : SHELL;
-        includeFlags
-          << fwSearchFlag << this->Convert(frameworkDir.c_str(),
-                                           START_OUTPUT, format, true)
+        if (sysFwSearchFlag && target &&
+            target->IsSystemIncludeDirectory(*i, config))
+          {
+          includeFlags << sysFwSearchFlag;
+          }
+        else
+          {
+          includeFlags << fwSearchFlag;
+          }
+        includeFlags << this->Convert(frameworkDir, START_OUTPUT,
+                                      shellFormat, true)
           << " ";
         }
       continue;
@@ -1356,7 +1390,7 @@
     if(!flagUsed || repeatFlag)
       {
       if(sysIncludeFlag && target &&
-         target->IsSystemIncludeDirectory(i->c_str(), config))
+         target->IsSystemIncludeDirectory(*i, config))
         {
         includeFlags << sysIncludeFlag;
         }
@@ -1366,16 +1400,8 @@
         }
       flagUsed = true;
       }
-    std::string includePath;
-    if(forResponseFile)
-      {
-      includePath = this->Convert(i->c_str(), START_OUTPUT,
-                                  RESPONSE, true);
-      }
-    else
-      {
-      includePath = this->ConvertToIncludeReference(*i);
-      }
+    std::string includePath =
+      this->ConvertToIncludeReference(*i, shellFormat);
     if(quotePaths && includePath.size() && includePath[0] != '\"')
       {
       includeFlags << "\"";
@@ -1399,7 +1425,7 @@
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
                                              cmTarget const* target,
-                                             const char* config)
+                                             const std::string& config)
 {
   std::vector<std::string> targetDefines;
   target->GetCompileDefinitions(targetDefines,
@@ -1410,12 +1436,12 @@
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AddCompileOptions(
   std::string& flags, cmTarget* target,
-  const char* lang, const char* config
+  const std::string& lang, const std::string& config
   )
 {
   std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX";
   if(const char* langFlagRegexStr =
-     this->Makefile->GetDefinition(langFlagRegexVar.c_str()))
+     this->Makefile->GetDefinition(langFlagRegexVar))
     {
     // Filter flags acceptable to this language.
     cmsys::RegularExpression r(langFlagRegexStr);
@@ -1432,7 +1458,7 @@
         {
         // (Re-)Escape this flag.  COMPILE_FLAGS were already parsed
         // as a command line above, and COMPILE_OPTIONS are escaped.
-        this->AppendFlagEscape(flags, i->c_str());
+        this->AppendFlagEscape(flags, *i);
         }
       }
     }
@@ -1450,16 +1476,52 @@
         i != opts.end(); ++i)
       {
       // COMPILE_OPTIONS are escaped.
-      this->AppendFlagEscape(flags, i->c_str());
+      this->AppendFlagEscape(flags, *i);
       }
     }
+  std::vector<std::string> features;
+  target->GetCompileFeatures(features, config);
+  for(std::vector<std::string>::const_iterator it = features.begin();
+      it != features.end(); ++it)
+    {
+     if (!this->Makefile->AddRequiredTargetFeature(target, *it))
+      {
+      return;
+      }
+    }
+
+  for(std::map<std::string, std::string>::const_iterator it
+      = target->GetMaxLanguageStandards().begin();
+      it != target->GetMaxLanguageStandards().end(); ++it)
+    {
+    const char* standard = target->GetProperty(it->first + "_STANDARD");
+    if(!standard)
+      {
+      continue;
+      }
+    if (this->Makefile->IsLaterStandard(it->first, standard, it->second))
+      {
+      cmOStringStream e;
+      e << "The COMPILE_FEATURES property of target \""
+        << target->GetName() << "\" was evaluated when computing the link "
+        "implementation, and the \"" << it->first << "_STANDARD\" was \""
+        << it->second << "\" for that computation.  Computing the "
+        "COMPILE_FEATURES based on the link implementation resulted in a "
+        "higher \"" << it->first << "_STANDARD\" \"" << standard << "\".  "
+        "This is not permitted. The COMPILE_FEATURES may not both depend on "
+        "and be depended on by the link implementation." << std::endl;
+      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+      return;
+      }
+    }
+  this->AddCompilerRequirementFlag(flags, target, lang);
 }
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
                                              cmGeneratorTarget* target,
-                                             const char* lang,
-                                             const char *config,
+                                             const std::string& lang,
+                                             const std::string& config,
                                              bool stripImplicitInclDirs
                                             )
 {
@@ -1482,7 +1544,7 @@
     }
 
   // Do not repeat an include path.
-  std::set<cmStdString> emitted;
+  std::set<std::string> emitted;
 
   // Store the automatic include paths.
   if(includeBinaryDir)
@@ -1515,7 +1577,7 @@
   std::string impDirVar = "CMAKE_";
   impDirVar += lang;
   impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES";
-  if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str()))
+  if(const char* value = this->Makefile->GetDefinition(impDirVar))
     {
     std::vector<std::string> impDirVec;
     cmSystemTools::ExpandListArgument(value, impDirVec);
@@ -1590,13 +1652,13 @@
   if(!config.empty())
     {
     std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config;
-    this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name.c_str()));
+    this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name));
     }
   this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS"));
   if(!config.empty())
     {
     std::string name = "STATIC_LIBRARY_FLAGS_" + config;
-    this->AppendFlags(flags, target->GetProperty(name.c_str()));
+    this->AppendFlags(flags, target->GetProperty(name));
     }
 }
 
@@ -1605,7 +1667,8 @@
                                  std::string& linkFlags,
                                  std::string& frameworkPath,
                                  std::string& linkPath,
-                                 cmGeneratorTarget* target)
+                                 cmGeneratorTarget* target,
+                                 bool useWatcomQuote)
 {
   std::string buildType =
     this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
@@ -1629,14 +1692,14 @@
         std::string build = libraryLinkVariable;
         build += "_";
         build += buildType;
-        linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
+        linkFlags += this->Makefile->GetSafeDefinition(build);
         linkFlags += " ";
         }
       if(this->Makefile->IsOn("WIN32") &&
          !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
         {
         std::vector<cmSourceFile*> sources;
-        target->GetSourceFiles(sources);
+        target->GetSourceFiles(sources, buildType);
         for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
             i != sources.end(); ++i)
           {
@@ -1645,7 +1708,7 @@
             {
             linkFlags +=
               this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
-            linkFlags += this->Convert(sf->GetFullPath().c_str(),
+            linkFlags += this->Convert(sf->GetFullPath(),
                                        FULL, SHELL);
             linkFlags += " ";
             }
@@ -1661,7 +1724,7 @@
         {
         std::string configLinkFlags = "LINK_FLAGS_";
         configLinkFlags += buildType;
-        targetLinkFlags = target->GetProperty(configLinkFlags.c_str());
+        targetLinkFlags = target->GetProperty(configLinkFlags);
         if(targetLinkFlags)
           {
           linkFlags += targetLinkFlags;
@@ -1669,7 +1732,7 @@
           }
         }
       this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                *target, false);
+                                *target, false, false, useWatcomQuote);
       }
       break;
     case cmTarget::EXECUTABLE:
@@ -1681,26 +1744,26 @@
         {
         std::string build = "CMAKE_EXE_LINKER_FLAGS_";
         build += buildType;
-        linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
+        linkFlags += this->Makefile->GetSafeDefinition(build);
         linkFlags += " ";
         }
-      const char* linkLanguage = target->Target->GetLinkerLanguage();
-      if(!linkLanguage)
+      std::string linkLanguage = target->Target->GetLinkerLanguage(buildType);
+      if(linkLanguage.empty())
         {
         cmSystemTools::Error
           ("CMake can not determine linker language for target: ",
-           target->Target->GetName());
+           target->Target->GetName().c_str());
         return;
         }
-      this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
+      this->AddLanguageFlags(flags, linkLanguage, buildType);
       this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                *target, false);
+                                *target, false, false, useWatcomQuote);
       if(cmSystemTools::IsOn
          (this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
         {
         std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_")
           + linkLanguage + std::string("_FLAGS");
-        linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str());
+        linkFlags += this->Makefile->GetSafeDefinition(sFlagVar);
         linkFlags += " ";
         }
       if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") )
@@ -1722,7 +1785,7 @@
         exportFlagVar += "_FLAG";
 
         linkFlags +=
-          this->Makefile->GetSafeDefinition(exportFlagVar.c_str());
+          this->Makefile->GetSafeDefinition(exportFlagVar);
         linkFlags += " ";
         }
       const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
@@ -1735,7 +1798,7 @@
         {
         std::string configLinkFlags = "LINK_FLAGS_";
         configLinkFlags += buildType;
-        targetLinkFlags = target->GetProperty(configLinkFlags.c_str());
+        targetLinkFlags = target->GetProperty(configLinkFlags);
         if(targetLinkFlags)
           {
           linkFlags += targetLinkFlags;
@@ -1749,12 +1812,12 @@
     }
 }
 
-std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
+std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
+                                                     OutputFormat format)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-  // Work-ardound command line parsing limitations in MSVC 6.0 and
-  // Watcom.
-  if(this->Makefile->IsOn("MSVC60") || this->Makefile->IsOn("WATCOM"))
+  // Work-ardound command line parsing limitations in MSVC 6.0
+  if(this->Makefile->IsOn("MSVC60"))
     {
     // Search for the last space.
     std::string::size_type pos = lib.rfind(' ');
@@ -1771,14 +1834,14 @@
         sp += lib.substr(pos);
 
         // Convert to an output path.
-        return this->Convert(sp.c_str(), NONE, SHELL);
+        return this->Convert(sp.c_str(), NONE, format);
         }
       }
     }
 #endif
 
   // Normal behavior.
-  return this->Convert(lib.c_str(), START_OUTPUT, SHELL);
+  return this->Convert(lib, START_OUTPUT, format);
 }
 
 /**
@@ -1790,8 +1853,13 @@
                                            std::string& frameworkPath,
                                            std::string& linkPath,
                                            cmGeneratorTarget &tgt,
-                                           bool relink)
+                                           bool relink,
+                                           bool forResponseFile,
+                                           bool useWatcomQuote)
 {
+  OutputFormat shellFormat = (forResponseFile) ? RESPONSE :
+                             ((useWatcomQuote) ? WATCOMQUOTE : SHELL);
+  bool escapeAllowMakeVars = !forResponseFile;
   cmOStringStream fout;
   const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
   cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config);
@@ -1804,7 +1872,7 @@
   // Collect library linking flags command line options.
   std::string linkLibs;
 
-  const char* linkLanguage = cli.GetLinkLanguage();
+  std::string linkLanguage = cli.GetLinkLanguage();
 
   std::string libPathFlag =
     this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
@@ -1817,7 +1885,7 @@
   linkFlagsVar += "_FLAGS";
   if( tgt.GetType() == cmTarget::EXECUTABLE )
     {
-    linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str());
+    linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar);
     linkLibs += " ";
     }
 
@@ -1826,7 +1894,7 @@
   fwSearchFlagVar += linkLanguage;
   fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
   const char* fwSearchFlag =
-    this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
+    this->Makefile->GetDefinition(fwSearchFlagVar);
   if(fwSearchFlag && *fwSearchFlag)
     {
     std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
@@ -1834,7 +1902,7 @@
         fdi != fwDirs.end(); ++fdi)
       {
       frameworkPath += fwSearchFlag;
-      frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false);
+      frameworkPath += this->Convert(*fdi, NONE, shellFormat, false);
       frameworkPath += " ";
       }
     }
@@ -1844,7 +1912,9 @@
   for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
       libDir != libDirs.end(); ++libDir)
     {
-    std::string libpath = this->ConvertToOutputForExisting(libDir->c_str());
+    std::string libpath = this->ConvertToOutputForExisting(*libDir,
+                                                           START_OUTPUT,
+                                                           shellFormat);
     linkPath += " " + libPathFlag;
     linkPath += libpath;
     linkPath += libPathTerminator;
@@ -1862,7 +1932,7 @@
       }
     if(li->IsPath)
       {
-      linkLibs += this->ConvertToLinkReference(li->Value);
+      linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
       }
     else
       {
@@ -1887,7 +1957,7 @@
         ri != runtimeDirs.end(); ++ri)
       {
       rpath += cli.GetRuntimeFlag();
-      rpath += this->Convert(ri->c_str(), NONE, SHELL, false);
+      rpath += this->Convert(*ri, NONE, shellFormat, false);
       rpath += " ";
       }
     fout << rpath;
@@ -1901,7 +1971,7 @@
     if(!rpath.empty())
       {
       fout << cli.GetRuntimeFlag();
-      fout << this->EscapeForShell(rpath.c_str(), true);
+      fout << this->EscapeForShell(rpath, escapeAllowMakeVars);
       fout << " ";
       }
     }
@@ -1911,7 +1981,7 @@
   if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty())
     {
     fout << cli.GetRPathLinkFlag();
-    fout << this->EscapeForShell(rpath_link.c_str(), true);
+    fout << this->EscapeForShell(rpath_link, escapeAllowMakeVars);
     fout << " ";
     }
 
@@ -1920,7 +1990,7 @@
   standardLibsVar += cli.GetLinkLanguage();
   standardLibsVar += "_STANDARD_LIBRARIES";
   if(const char* stdLibs =
-     this->Makefile->GetDefinition(standardLibsVar.c_str()))
+     this->Makefile->GetDefinition(standardLibsVar))
     {
     fout << stdLibs << " ";
     }
@@ -1932,8 +2002,8 @@
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
                                             cmGeneratorTarget* target,
-                                            const char *lang,
-                                            const char* config)
+                                            const std::string& lang,
+                                            const std::string& config)
 {
   // Only add Mac OS X specific flags on Darwin platforms (OSX and iphone):
   if(!this->Makefile->IsOn("APPLE"))
@@ -1951,14 +2021,14 @@
     std::string sysrootFlagVar =
       std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
     const char* sysrootFlag =
-      this->Makefile->GetDefinition(sysrootFlagVar.c_str());
+      this->Makefile->GetDefinition(sysrootFlagVar);
     const char* deploymentTarget =
       this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
     std::string deploymentTargetFlagVar =
       std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
     const char* deploymentTargetFlag =
-      this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str());
-    if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F'))
+      this->Makefile->GetDefinition(deploymentTargetFlagVar);
+    if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F'))
       {
       for(std::vector<std::string>::iterator i = archs.begin();
           i != archs.end(); ++i)
@@ -1989,19 +2059,19 @@
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AddLanguageFlags(std::string& flags,
-                                        const char* lang,
-                                        const char* config)
+                                        const std::string& lang,
+                                        const std::string& config)
 {
   // Add language-specific flags.
   std::string flagsVar = "CMAKE_";
   flagsVar += lang;
   flagsVar += "_FLAGS";
-  this->AddConfigVariableFlags(flags, flagsVar.c_str(), config);
+  this->AddConfigVariableFlags(flags, flagsVar, config);
 }
 
 //----------------------------------------------------------------------------
-bool cmLocalGenerator::GetRealDependency(const char* inName,
-                                         const char* config,
+bool cmLocalGenerator::GetRealDependency(const std::string& inName,
+                                         const std::string& config,
                                          std::string& dep)
 {
   // Older CMake code may specify the dependency using the target
@@ -2028,7 +2098,7 @@
     {
     // make sure it is not just a coincidence that the target name
     // found is part of the inName
-    if(cmSystemTools::FileIsFullPath(inName))
+    if(cmSystemTools::FileIsFullPath(inName.c_str()))
       {
       std::string tLocation;
       if(target->GetType() >= cmTarget::EXECUTABLE &&
@@ -2076,7 +2146,7 @@
     }
 
   // The name was not that of a CMake target.  It must name a file.
-  if(cmSystemTools::FileIsFullPath(inName))
+  if(cmSystemTools::FileIsFullPath(inName.c_str()))
     {
     // This is a full path.  Return it as given.
     dep = inName;
@@ -2101,7 +2171,7 @@
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AddSharedFlags(std::string& flags,
-                                      const char* lang,
+                                      const std::string& lang,
                                       bool shared)
 {
   std::string flagsVar;
@@ -2112,23 +2182,119 @@
     flagsVar = "CMAKE_SHARED_LIBRARY_";
     flagsVar += lang;
     flagsVar += "_FLAGS";
-    this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
+    this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmLocalGenerator::
+AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
+                           const std::string& lang)
+{
+  if (lang.empty())
+    {
+    return;
+    }
+  std::string stdProp = lang + "_STANDARD";
+  const char *standardProp = target->GetProperty(stdProp);
+  if (!standardProp)
+    {
+    return;
+    }
+  std::string extProp = lang + "_EXTENSIONS";
+  std::string type = "EXTENSION";
+  bool ext = true;
+  if (const char* extPropValue = target->GetProperty(extProp))
+    {
+    if (cmSystemTools::IsOff(extPropValue))
+      {
+      ext = false;
+      type = "STANDARD";
+      }
+    }
+
+  if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED"))
+    {
+    std::string option_flag =
+              "CMAKE_" + lang + standardProp
+                      + "_" + type + "_COMPILE_OPTION";
+
+    const char *opt = target->GetMakefile()->GetDefinition(option_flag);
+    if (!opt)
+      {
+      cmOStringStream e;
+      e << "Target \"" << target->GetName() << "\" requires the language "
+           "dialect \"" << lang << standardProp << "\" "
+        << (ext ? "(with compiler extensions)" : "") << ", but CMake "
+           "does not know the compile flags to use to enable it.";
+      this->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str());
+      }
+    this->AppendFlags(flags, opt);
+    return;
+    }
+
+  static std::map<std::string, std::vector<std::string> > langStdMap;
+  if (langStdMap.empty())
+    {
+    // Maintain sorted order, most recent first.
+    langStdMap["CXX"].push_back("14");
+    langStdMap["CXX"].push_back("11");
+    langStdMap["CXX"].push_back("98");
+
+    langStdMap["C"].push_back("11");
+    langStdMap["C"].push_back("99");
+    langStdMap["C"].push_back("90");
+    }
+
+  std::string standard(standardProp);
+
+  std::vector<std::string>& stds = langStdMap[lang];
+
+  std::vector<std::string>::const_iterator stdIt =
+                                std::find(stds.begin(), stds.end(), standard);
+  assert(stdIt != stds.end());
+
+  const char* defaultStd
+      = this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
+  std::vector<std::string>::const_iterator defaultStdIt;
+  if (defaultStd)
+    {
+    defaultStdIt = std::find(stds.begin(), stds.end(), defaultStd);
+    assert(defaultStdIt != stds.end());
+    }
+  else
+    {
+    defaultStdIt = stds.end() - 1;
+    }
+
+  for ( ; stdIt <= defaultStdIt; ++stdIt)
+    {
+    std::string option_flag =
+              "CMAKE_" + lang + *stdIt
+                      + "_" + type + "_COMPILE_OPTION";
+
+    if (const char *opt = target->GetMakefile()->GetDefinition(option_flag))
+      {
+      this->AppendFlags(flags, opt);
+      return;
+      }
     }
 }
 
 static void AddVisibilityCompileOption(std::string &flags, cmTarget* target,
-                                       cmLocalGenerator *lg, const char *lang)
+                                       cmLocalGenerator *lg,
+                                       const std::string& lang)
 {
   std::string l(lang);
   std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
-  const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str());
+  const char *opt = lg->GetMakefile()->GetDefinition(compileOption);
   if (!opt)
     {
     return;
     }
   std::string flagDefine = l + "_VISIBILITY_PRESET";
 
-  const char *prop = target->GetProperty(flagDefine.c_str());
+  const char *prop = target->GetProperty(flagDefine);
   if (!prop)
     {
     return;
@@ -2145,7 +2311,7 @@
     return;
     }
   std::string option = std::string(opt) + prop;
-  lg->AppendFlags(flags, option.c_str());
+  lg->AppendFlags(flags, option);
 }
 
 static void AddInlineVisibilityCompileOption(std::string &flags,
@@ -2154,7 +2320,7 @@
 {
   std::string compileOption
                 = "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
-  const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str());
+  const char *opt = lg->GetMakefile()->GetDefinition(compileOption);
   if (!opt)
     {
     return;
@@ -2171,7 +2337,7 @@
 //----------------------------------------------------------------------------
 void cmLocalGenerator
 ::AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
-                            const char *lang)
+                            const std::string& lang)
 {
   int targetType = target->GetType();
   bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY)
@@ -2183,13 +2349,13 @@
     return;
     }
 
-  if (!lang)
+  if (lang.empty())
     {
     return;
     }
   AddVisibilityCompileOption(flags, target, this, lang);
 
-  if(strcmp(lang, "CXX") == 0)
+  if(lang == "CXX")
     {
     AddInlineVisibilityCompileOption(flags, target, this);
     }
@@ -2198,7 +2364,7 @@
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target,
                                        std::string const& lang,
-                                       const char *config)
+                                       const std::string& config)
 {
   int targetType = target->GetType();
 
@@ -2207,7 +2373,7 @@
 
   if (this->GetShouldUseOldFlags(shared, lang))
     {
-    this->AddSharedFlags(flags, lang.c_str(), shared);
+    this->AddSharedFlags(flags, lang, shared);
     }
   else
     {
@@ -2228,7 +2394,7 @@
       }
     if (shared)
       {
-      this->AppendFeatureOptions(flags, lang.c_str(), "DLL");
+      this->AppendFeatureOptions(flags, lang, "DLL");
       }
     }
 }
@@ -2245,7 +2411,7 @@
     flagsVar += lang;
     flagsVar += "_FLAGS";
     const char* flags =
-        this->Makefile->GetSafeDefinition(flagsVar.c_str());
+        this->Makefile->GetSafeDefinition(flagsVar);
 
     if (flags && flags != originalFlags)
       {
@@ -2270,7 +2436,6 @@
         case cmPolicies::REQUIRED_IF_USED:
         case cmPolicies::REQUIRED_ALWAYS:
         case cmPolicies::NEW:
-        default:
           return false;
         }
       }
@@ -2290,14 +2455,14 @@
     std::string flagsVar = "CMAKE_";
     flagsVar += lang;
     flagsVar += "_COMPILE_OPTIONS_PIE";
-    picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str());
+    picFlags = this->Makefile->GetSafeDefinition(flagsVar);
     }
   if (!picFlags)
     {
     std::string flagsVar = "CMAKE_";
     flagsVar += lang;
     flagsVar += "_COMPILE_OPTIONS_PIC";
-    picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str());
+    picFlags = this->Makefile->GetSafeDefinition(flagsVar);
     }
   if (picFlags)
     {
@@ -2306,35 +2471,34 @@
     for(std::vector<std::string>::const_iterator oi = options.begin();
         oi != options.end(); ++oi)
       {
-      this->AppendFlagEscape(flags, oi->c_str());
+      this->AppendFlagEscape(flags, *oi);
       }
     }
 }
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
-                                              const char* var,
-                                              const char* config)
+                                              const std::string& var,
+                                              const std::string& config)
 {
   // Add the flags from the variable itself.
   std::string flagsVar = var;
-  this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
+  this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
   // Add the flags from the build-type specific variable.
-  if(config && *config)
+  if(!config.empty())
     {
     flagsVar += "_";
     flagsVar += cmSystemTools::UpperCase(config);
-    this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
+    this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
     }
 }
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AppendFlags(std::string& flags,
-                                                const char* newFlags)
+                                   const std::string& newFlags)
 {
-  if(newFlags && *newFlags)
+  if(!newFlags.empty())
     {
-    std::string newf = newFlags;
     if(flags.size())
       {
       flags += " ";
@@ -2344,10 +2508,20 @@
 }
 
 //----------------------------------------------------------------------------
-void cmLocalGenerator::AppendFlagEscape(std::string& flags,
-                                        const char* rawFlag)
+void cmLocalGenerator::AppendFlags(std::string& flags,
+                                   const char* newFlags)
 {
-  this->AppendFlags(flags, this->EscapeForShell(rawFlag).c_str());
+  if(newFlags && *newFlags)
+    {
+    this->AppendFlags(flags, std::string(newFlags));
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmLocalGenerator::AppendFlagEscape(std::string& flags,
+                                        const std::string& rawFlag)
+{
+  this->AppendFlags(flags, this->EscapeForShell(rawFlag));
 }
 
 //----------------------------------------------------------------------------
@@ -2385,16 +2559,16 @@
 //----------------------------------------------------------------------------
 void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
                                    std::string &definesString,
-                                   const char* lang)
+                                   const std::string& lang)
 {
   // Lookup the define flag for the current language.
   std::string dflag = "-D";
-  if(lang)
+  if(!lang.empty())
     {
     std::string defineFlagVar = "CMAKE_";
     defineFlagVar += lang;
     defineFlagVar += "_DEFINE_FLAG";
-    const char* df = this->Makefile->GetDefinition(defineFlagVar.c_str());
+    const char* df = this->Makefile->GetDefinition(defineFlagVar);
     if(df && *df)
       {
       dflag = df;
@@ -2449,46 +2623,46 @@
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::AppendFeatureOptions(
-  std::string& flags, const char* lang, const char* feature)
+  std::string& flags, const std::string& lang, const char* feature)
 {
   std::string optVar = "CMAKE_";
   optVar += lang;
   optVar += "_COMPILE_OPTIONS_";
   optVar += feature;
-  if(const char* optionList = this->Makefile->GetDefinition(optVar.c_str()))
+  if(const char* optionList = this->Makefile->GetDefinition(optVar))
     {
     std::vector<std::string> options;
     cmSystemTools::ExpandListArgument(optionList, options);
     for(std::vector<std::string>::const_iterator oi = options.begin();
         oi != options.end(); ++oi)
       {
-      this->AppendFlagEscape(flags, oi->c_str());
+      this->AppendFlagEscape(flags, *oi);
       }
     }
 }
 
 //----------------------------------------------------------------------------
 std::string
-cmLocalGenerator::ConstructComment(const cmCustomCommand& cc,
+cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg,
                                    const char* default_comment)
 {
   // Check for a comment provided with the command.
-  if(cc.GetComment())
+  if(ccg.GetComment())
     {
-    return cc.GetComment();
+    return ccg.GetComment();
     }
 
   // Construct a reasonable default comment if possible.
-  if(!cc.GetOutputs().empty())
+  if(!ccg.GetOutputs().empty())
     {
     std::string comment;
     comment = "Generating ";
     const char* sep = "";
-    for(std::vector<std::string>::const_iterator o = cc.GetOutputs().begin();
-        o != cc.GetOutputs().end(); ++o)
+    for(std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
+        o != ccg.GetOutputs().end(); ++o)
       {
       comment += sep;
-      comment += this->Convert(o->c_str(), cmLocalGenerator::START_OUTPUT);
+      comment += this->Convert(*o, cmLocalGenerator::START_OUTPUT);
       sep = ", ";
       }
     return comment;
@@ -2500,7 +2674,8 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(const char* remote)
+cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(
+                                                    const std::string& remote)
 {
   return this->Convert(remote, START_OUTPUT, SHELL, true);
 }
@@ -2520,7 +2695,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmLocalGenerator::Convert(const char* source,
+std::string cmLocalGenerator::Convert(const std::string& source,
                                       RelativeRoot relative,
                                       OutputFormat output,
                                       bool optional)
@@ -2542,24 +2717,24 @@
       case HOME:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
         result = this->ConvertToRelativePath(this->HomeDirectoryComponents,
-                                             result.c_str());
+                                             result);
         break;
       case START:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
         result = this->ConvertToRelativePath(this->StartDirectoryComponents,
-                                             result.c_str());
+                                             result);
         break;
       case HOME_OUTPUT:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
         result =
           this->ConvertToRelativePath(this->HomeOutputDirectoryComponents,
-                                      result.c_str());
+                                      result);
         break;
       case START_OUTPUT:
         //result = cmSystemTools::CollapseFullPath(result.c_str());
         result =
           this->ConvertToRelativePath(this->StartOutputDirectoryComponents,
-                                      result.c_str());
+                                      result);
         break;
       case FULL:
         result = cmSystemTools::CollapseFullPath(result.c_str());
@@ -2568,11 +2743,11 @@
         break;
       }
     }
-  return this->ConvertToOutputFormat(result.c_str(), output);
+  return this->ConvertToOutputFormat(result, output);
 }
 
 //----------------------------------------------------------------------------
-std::string cmLocalGenerator::ConvertToOutputFormat(const char* source,
+std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
                                                     OutputFormat output)
 {
   std::string result = source;
@@ -2581,7 +2756,7 @@
     {
     result = cmSystemTools::ConvertToOutputPath(result.c_str());
     }
-  else if( output == SHELL)
+  else if(output == SHELL || output == WATCOMQUOTE)
     {
         // For the MSYS shell convert drive letters to posix paths, so
     // that c:/some/path becomes /c/some/path.  This is needed to
@@ -2603,18 +2778,18 @@
         pos++;
         }
       }
-    result = this->EscapeForShell(result.c_str(), true, false);
+    result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE);
     }
   else if(output == RESPONSE)
     {
-    result = this->EscapeForShell(result.c_str(), false, false);
+    result = this->EscapeForShell(result, false, false, false);
     }
   return result;
 }
 
 //----------------------------------------------------------------------------
 std::string cmLocalGenerator::Convert(RelativeRoot remote,
-                                      const char* local,
+                                      const std::string& local,
                                       OutputFormat output,
                                       bool optional)
 {
@@ -2623,12 +2798,12 @@
   // The relative root must have a path (i.e. not FULL or NONE)
   assert(remotePath != 0);
 
-  if(local && (!optional || this->UseRelativePaths))
+  if(!local.empty() && (!optional || this->UseRelativePaths))
     {
     std::vector<std::string> components;
-    cmSystemTools::SplitPath(local, components);
+    cmSystemTools::SplitPath(local.c_str(), components);
     std::string result = this->ConvertToRelativePath(components, remotePath);
-    return this->ConvertToOutputFormat(result.c_str(), output);
+    return this->ConvertToOutputFormat(result, output);
     }
   else
     {
@@ -2709,7 +2884,8 @@
 //----------------------------------------------------------------------------
 std::string
 cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
-                                        const char* in_remote, bool force)
+                                        const std::string& in_remote,
+                                        bool force)
 {
   // The path should never be quoted.
   assert(in_remote[0] != '\"');
@@ -2718,7 +2894,7 @@
   assert(local.size() > 0 && !(local[local.size()-1] == ""));
 
   // If the path is already relative then just return the path.
-  if(!cmSystemTools::FileIsFullPath(in_remote))
+  if(!cmSystemTools::FileIsFullPath(in_remote.c_str()))
     {
     return in_remote;
     }
@@ -2737,11 +2913,11 @@
     std::string local_path = cmSystemTools::JoinPath(local);
     if(!((cmLocalGeneratorNotAbove(local_path.c_str(),
                                    this->RelativePathTopBinary.c_str()) &&
-          cmLocalGeneratorNotAbove(in_remote,
+          cmLocalGeneratorNotAbove(in_remote.c_str(),
                                    this->RelativePathTopBinary.c_str())) ||
          (cmLocalGeneratorNotAbove(local_path.c_str(),
                                    this->RelativePathTopSource.c_str()) &&
-          cmLocalGeneratorNotAbove(in_remote,
+          cmLocalGeneratorNotAbove(in_remote.c_str(),
                                    this->RelativePathTopSource.c_str()))))
       {
       return in_remote;
@@ -2751,7 +2927,7 @@
   // Identify the longest shared path component between the remote
   // path and the local path.
   std::vector<std::string> remote;
-  cmSystemTools::SplitPath(in_remote, remote);
+  cmSystemTools::SplitPath(in_remote.c_str(), remote);
   unsigned int common=0;
   while(common < remote.size() &&
         common < local.size() &&
@@ -2822,7 +2998,7 @@
 void
 cmLocalGenerator
 ::GenerateTargetInstallRules(
-  std::ostream& os, const char* config,
+  std::ostream& os, const std::string& config,
   std::vector<std::string> const& configurationTypes)
 {
   // Convert the old-style install specification from each target to
@@ -2969,11 +3145,11 @@
 //----------------------------------------------------------------------------
 std::string&
 cmLocalGenerator
-::CreateSafeUniqueObjectFileName(const char* sin,
+::CreateSafeUniqueObjectFileName(const std::string& sin,
                                  std::string const& dir_max)
 {
   // Look for an existing mapped name for this object file.
-  std::map<cmStdString,cmStdString>::iterator it =
+  std::map<std::string,std::string>::iterator it =
     this->UniqueObjectNamesMap.find(sin);
 
   // If no entry exists create one.
@@ -3056,7 +3232,7 @@
 #endif
 
     // Insert the newly mapped object file name.
-    std::map<cmStdString, cmStdString>::value_type e(sin, ssin);
+    std::map<std::string, std::string>::value_type e(sin, ssin);
     it = this->UniqueObjectNamesMap.insert(e).first;
     }
 
@@ -3065,6 +3241,14 @@
 }
 
 //----------------------------------------------------------------------------
+void cmLocalGenerator::ComputeObjectFilenames(
+                            std::map<cmSourceFile const*, std::string>&,
+                            cmGeneratorTarget const*)
+{
+
+}
+
+//----------------------------------------------------------------------------
 std::string
 cmLocalGenerator
 ::GetObjectFileNameWithoutTarget(const cmSourceFile& source,
@@ -3129,12 +3313,13 @@
     bool replaceExt = this->NeedBackwardsCompatibility_2_4();
     if(!replaceExt)
       {
-      if(const char* lang = source.GetLanguage())
+      std::string lang = source.GetLanguage();
+      if(!lang.empty())
         {
         std::string repVar = "CMAKE_";
         repVar += lang;
         repVar += "_OUTPUT_EXTENSION_REPLACE";
-        replaceExt = this->Makefile->IsOn(repVar.c_str());
+        replaceExt = this->Makefile->IsOn(repVar);
         }
       }
 
@@ -3159,11 +3344,11 @@
     }
 
   // Convert to a safe name.
-  return this->CreateSafeUniqueObjectFileName(objectName.c_str(), dir_max);
+  return this->CreateSafeUniqueObjectFileName(objectName, dir_max);
 }
 
 //----------------------------------------------------------------------------
-const char*
+std::string
 cmLocalGenerator
 ::GetSourceFileLanguage(const cmSourceFile& source)
 {
@@ -3171,7 +3356,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str)
+std::string cmLocalGenerator::EscapeForShellOldStyle(const std::string& str)
 {
   std::string result;
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -3187,7 +3372,7 @@
     }
   return str;
 #else
-  for(const char* ch = str; *ch != '\0'; ++ch)
+  for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
     {
     if(*ch == ' ')
       {
@@ -3200,29 +3385,32 @@
 }
 
 //----------------------------------------------------------------------------
-static bool cmLocalGeneratorIsShellOperator(const char* str)
+static bool cmLocalGeneratorIsShellOperator(const std::string& str)
 {
-  if(strcmp(str, "<") == 0 ||
-     strcmp(str, ">") == 0 ||
-     strcmp(str, "<<") == 0 ||
-     strcmp(str, ">>") == 0 ||
-     strcmp(str, "|") == 0 ||
-     strcmp(str, "||") == 0 ||
-     strcmp(str, "&&") == 0 ||
-     strcmp(str, "&>") == 0 ||
-     strcmp(str, "1>") == 0 ||
-     strcmp(str, "2>") == 0 ||
-     strcmp(str, "2>&1") == 0 ||
-     strcmp(str, "1>&2") == 0)
+  static std::set<std::string> shellOperators;
+  if(shellOperators.empty())
     {
-    return true;
+    shellOperators.insert("<");
+    shellOperators.insert(">");
+    shellOperators.insert("<<");
+    shellOperators.insert(">>");
+    shellOperators.insert("|");
+    shellOperators.insert("||");
+    shellOperators.insert("&&");
+    shellOperators.insert("&>");
+    shellOperators.insert("1>");
+    shellOperators.insert("2>");
+    shellOperators.insert("2>&1");
+    shellOperators.insert("1>&2");
     }
-  return false;
+  return shellOperators.count(str) > 0;
 }
 
 //----------------------------------------------------------------------------
-std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
-                                             bool forEcho)
+std::string cmLocalGenerator::EscapeForShell(const std::string& str,
+                                             bool makeVars,
+                                             bool forEcho,
+                                             bool useWatcomQuote)
 {
   // Do not escape shell operators.
   if(cmLocalGeneratorIsShellOperator(str))
@@ -3248,6 +3436,10 @@
     {
     flags |= cmsysSystem_Shell_Flag_EchoWindows;
     }
+  if(useWatcomQuote)
+    {
+    flags |= cmsysSystem_Shell_Flag_WatcomQuote;
+    }
   if(this->WatcomWMake)
     {
     flags |= cmsysSystem_Shell_Flag_WatcomWMake;
@@ -3263,28 +3455,28 @@
 
   // Compute the buffer size needed.
   int size = (this->WindowsShell ?
-              cmsysSystem_Shell_GetArgumentSizeForWindows(str, flags) :
-              cmsysSystem_Shell_GetArgumentSizeForUnix(str, flags));
+              cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) :
+              cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags));
 
   // Compute the shell argument itself.
   std::vector<char> arg(size);
   if(this->WindowsShell)
     {
-    cmsysSystem_Shell_GetArgumentForWindows(str, &arg[0], flags);
+    cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags);
     }
   else
     {
-    cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags);
+    cmsysSystem_Shell_GetArgumentForUnix(str.c_str(), &arg[0], flags);
     }
   return std::string(&arg[0]);
 }
 
 //----------------------------------------------------------------------------
-std::string cmLocalGenerator::EscapeForCMake(const char* str)
+std::string cmLocalGenerator::EscapeForCMake(const std::string& str)
 {
   // Always double-quote the argument to take care of most escapes.
   std::string result = "\"";
-  for(const char* c = str; *c; ++c)
+  for(const char* c = str.c_str(); *c; ++c)
     {
     if(*c == '"')
       {
@@ -3447,7 +3639,8 @@
 }
 
 //----------------------------------------------------------------------------
-static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop)
+static void cmLGInfoProp(cmMakefile* mf, cmTarget* target,
+    const std::string& prop)
 {
   if(const char* val = target->GetProperty(prop))
     {
@@ -3457,7 +3650,7 @@
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
-                                              const char* targetName,
+                                              const std::string& targetName,
                                               const char* fname)
 {
   // Find the Info.plist template.
@@ -3486,7 +3679,7 @@
   // back to the directory-level values set by the user.
   cmMakefile* mf = this->Makefile;
   mf->PushScope();
-  mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName);
+  mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName.c_str());
   cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING");
   cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE");
   cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER");
@@ -3501,8 +3694,8 @@
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
-                                                  const char* targetName,
-                                                  const char* fname)
+                                                const std::string& targetName,
+                                                const char* fname)
 {
   // Find the Info.plist template.
   const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
@@ -3530,7 +3723,7 @@
   // back to the directory-level values set by the user.
   cmMakefile* mf = this->Makefile;
   mf->PushScope();
-  mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName);
+  mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName.c_str());
   cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE");
   cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
   cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 9764813..ad73073 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -21,6 +21,7 @@
 class cmTargetManifest;
 class cmSourceFile;
 class cmCustomCommand;
+class cmCustomCommandGenerator;
 
 /** \class cmLocalGenerator
  * \brief Create required build files for a directory.
@@ -75,17 +76,17 @@
 
   ///! Get the makefile for this generator
   cmMakefile *GetMakefile() {
-    return this->Makefile; };
+    return this->Makefile; }
 
   ///! Get the makefile for this generator, const version
     const cmMakefile *GetMakefile() const {
-      return this->Makefile; };
+      return this->Makefile; }
 
   ///! Get the GlobalGenerator this is associated with
   cmGlobalGenerator *GetGlobalGenerator() {
-    return this->GlobalGenerator; };
+    return this->GlobalGenerator; }
   const cmGlobalGenerator *GetGlobalGenerator() const {
-    return this->GlobalGenerator; };
+    return this->GlobalGenerator; }
 
   ///! Set the Global Generator, done on creation by the GlobalGenerator
   void SetGlobalGenerator(cmGlobalGenerator *gg);
@@ -105,12 +106,13 @@
    * path setting
    */
   enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT };
-  enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, RESPONSE };
-  std::string ConvertToOutputFormat(const char* source, OutputFormat output);
-  std::string Convert(const char* remote, RelativeRoot local,
+  enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, WATCOMQUOTE, RESPONSE };
+  std::string ConvertToOutputFormat(const std::string& source,
+                                    OutputFormat output);
+  std::string Convert(const std::string& remote, RelativeRoot local,
                       OutputFormat output = UNCHANGED,
                       bool optional = false);
-  std::string Convert(RelativeRoot remote, const char* local,
+  std::string Convert(RelativeRoot remote, const std::string& local,
                       OutputFormat output = UNCHANGED,
                       bool optional = false);
 
@@ -125,7 +127,7 @@
    * remote path must use forward slashes and not already be escaped
    * or quoted.
    */
-  std::string ConvertToOptionallyRelativeOutputPath(const char* remote);
+  std::string ConvertToOptionallyRelativeOutputPath(const std::string& remote);
 
   ///! set/get the parent generator
   cmLocalGenerator* GetParent(){return this->Parent;}
@@ -133,28 +135,33 @@
 
   ///! set/get the children
   void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); }
-  std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; };
+  std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; }
 
 
   void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target,
-                            const char *lang, const char* config);
+                            const std::string&lang, const std::string& config);
 
-  void AddLanguageFlags(std::string& flags, const char* lang,
-                        const char* config);
+  void AddLanguageFlags(std::string& flags, const std::string& lang,
+                        const std::string& config);
   void AddCMP0018Flags(std::string &flags, cmTarget* target,
-                       std::string const& lang, const char *config);
+                       std::string const& lang, const std::string& config);
   void AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
-                                const char *lang);
-  void AddConfigVariableFlags(std::string& flags, const char* var,
-                              const char* config);
+                                const std::string& lang);
+  void AddConfigVariableFlags(std::string& flags, const std::string& var,
+                              const std::string& config);
+  void AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
+                                  const std::string& lang);
   ///! Append flags to a string.
+  virtual void AppendFlags(std::string& flags, const std::string& newFlags);
   virtual void AppendFlags(std::string& flags, const char* newFlags);
-  virtual void AppendFlagEscape(std::string& flags, const char* rawFlag);
+  virtual void AppendFlagEscape(std::string& flags,
+                                const std::string& rawFlag);
   ///! Get the include flags for the current makefile and language
   std::string GetIncludeFlags(const std::vector<std::string> &includes,
                               cmGeneratorTarget* target,
-                              const char* lang, bool forResponseFile = false,
-                              const char *config = 0);
+                              const std::string& lang,
+                              bool forResponseFile = false,
+                              const std::string& config = "");
 
   /**
    * Encode a list of preprocessor definitions for the compiler
@@ -175,10 +182,10 @@
    */
   void JoinDefines(const std::set<std::string>& defines,
                    std::string &definesString,
-                   const char* lang);
+                   const std::string& lang);
 
   /** Lookup and append options associated with a particular feature.  */
-  void AppendFeatureOptions(std::string& flags, const char* lang,
+  void AppendFeatureOptions(std::string& flags, const std::string& lang,
                             const char* feature);
 
   /** \brief Get absolute path to dependency \a name
@@ -193,19 +200,22 @@
    *   the source directory of this generator.  This should only be
    *   used for dependencies of custom commands.
    */
-  bool GetRealDependency(const char* name, const char* config,
+  bool GetRealDependency(const std::string& name, const std::string& config,
                          std::string& dep);
 
   ///! for existing files convert to output path and short path if spaces
-  std::string ConvertToOutputForExisting(const char* remote,
-                                         RelativeRoot local = START_OUTPUT);
+  std::string ConvertToOutputForExisting(const std::string& remote,
+                                         RelativeRoot local = START_OUTPUT,
+                                         OutputFormat format = SHELL);
 
   /** For existing path identified by RelativeRoot convert to output
       path and short path if spaces.  */
   std::string ConvertToOutputForExisting(RelativeRoot remote,
-                                         const char* local = 0);
+                                         const std::string& local = "",
+                                         OutputFormat format = SHELL);
 
-  virtual std::string ConvertToIncludeReference(std::string const& path);
+  virtual std::string ConvertToIncludeReference(std::string const& path,
+                                                OutputFormat format = SHELL);
 
   /** Called from command-line hook to clear dependencies.  */
   virtual void ClearDependencies(cmMakefile* /* mf */,
@@ -220,16 +230,17 @@
   /** Get the include flags for the current makefile and language.  */
   void GetIncludeDirectories(std::vector<std::string>& dirs,
                              cmGeneratorTarget* target,
-                             const char* lang = "C", const char *config = 0,
+                             const std::string& lang = "C",
+                             const std::string& config = "",
                              bool stripImplicitInclDirs = true);
   void AddCompileOptions(std::string& flags, cmTarget* target,
-                         const char* lang, const char* config);
+                         const std::string& lang, const std::string& config);
   void AddCompileDefinitions(std::set<std::string>& defines,
                              cmTarget const* target,
-                             const char* config);
+                             const std::string& config);
 
   /** Compute the language used to compile the given source file.  */
-  const char* GetSourceFileLanguage(const cmSourceFile& source);
+  std::string GetSourceFileLanguage(const cmSourceFile& source);
 
   // Fill the vector with the target names for the object files,
   // preprocessed files and assembly files.
@@ -245,6 +256,7 @@
       }
     cmTarget* CMTarget;
     const char* TargetPDB;
+    const char* TargetCompilePDB;
     const char* TargetVersionMajor;
     const char* TargetVersionMinor;
     const char* Language;
@@ -257,6 +269,7 @@
     const char* Output;
     const char* Object;
     const char* ObjectDir;
+    const char* ObjectFileDir;
     const char* Flags;
     const char* ObjectsQuoted;
     const char* SONameFlag;
@@ -278,14 +291,15 @@
       system to replace make variable references.  Optionally adjust
       escapes for the special case of passing to the native echo
       command.  */
-  std::string EscapeForShell(const char* str, bool makeVars = false,
-                             bool forEcho = false);
+  std::string EscapeForShell(const std::string& str, bool makeVars = false,
+                             bool forEcho = false,
+                             bool useWatcomQuote = false);
 
   /** Backwards-compatibility version of EscapeForShell.  */
-  std::string EscapeForShellOldStyle(const char* str);
+  std::string EscapeForShellOldStyle(const std::string& str);
 
   /** Escape the given string as an argument in a CMake script.  */
-  static std::string EscapeForCMake(const char* str);
+  static std::string EscapeForCMake(const std::string& str);
 
   enum FortranFormat
     {
@@ -303,7 +317,8 @@
    * or quoted.
    */
   std::string ConvertToRelativePath(const std::vector<std::string>& local,
-                                    const char* remote, bool force=false);
+                                    const std::string& remote,
+                                    bool force=false);
 
   /**
    * Get the relative path from the generator output directory to a
@@ -331,17 +346,17 @@
   /**
    * Generate a Mac OS X application bundle Info.plist file.
    */
-  void GenerateAppleInfoPList(cmTarget* target, const char* targetName,
+  void GenerateAppleInfoPList(cmTarget* target, const std::string& targetName,
                               const char* fname);
 
   /**
    * Generate a Mac OS X framework Info.plist file.
    */
   void GenerateFrameworkInfoPList(cmTarget* target,
-                                  const char* targetName,
+                                  const std::string& targetName,
                                   const char* fname);
   /** Construct a comment for a custom command.  */
-  std::string ConstructComment(const cmCustomCommand& cc,
+  std::string ConstructComment(cmCustomCommandGenerator const& ccg,
                                const char* default_comment = "");
   // Compute object file names.
   std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source,
@@ -360,7 +375,12 @@
                       std::string& linkFlags,
                       std::string& frameworkPath,
                       std::string& linkPath,
-                      cmGeneratorTarget* target);
+                      cmGeneratorTarget* target,
+                      bool useWatcomQuote);
+
+  virtual void ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const* gt = 0);
 
 protected:
   ///! put all the libraries for a target on into the given stream
@@ -368,7 +388,9 @@
                                    std::string& frameworkPath,
                                    std::string& linkPath,
                                    cmGeneratorTarget &,
-                                   bool relink);
+                                   bool relink,
+                                   bool forResponseFile,
+                                   bool useWatcomQuote);
 
   // Expand rule variables in CMake of the type found in language rules
   void ExpandRuleVariables(std::string& string,
@@ -377,17 +399,18 @@
   std::string ExpandRuleVariable(std::string const& variable,
                                  const RuleVariables& replaceValues);
 
-  const char* GetRuleLauncher(cmTarget* target, const char* prop);
+  const char* GetRuleLauncher(cmTarget* target, const std::string& prop);
   void InsertRuleLauncher(std::string& s, cmTarget* target,
-                          const char* prop);
+                          const std::string& prop);
 
 
   /** Convert a target to a utility target for unsupported
    *  languages of a generator */
-  void AddBuildTargetRule(const char* llang, cmGeneratorTarget& target);
+  void AddBuildTargetRule(const std::string& llang,
+                          cmGeneratorTarget& target);
   ///! add a custom command to build a .o file that is part of a target
   void AddCustomCommandToCreateObject(const char* ofname,
-                                      const char* lang,
+                                      const std::string& lang,
                                       cmSourceFile& source,
                                       cmGeneratorTarget& target);
   // Create Custom Targets and commands for unsupported languages
@@ -395,14 +418,14 @@
   // generator directly.  Any targets containing files that are not
   // of the types listed will be compiled as custom commands and added
   // to a custom target.
-  void CreateCustomTargetsAndCommands(std::set<cmStdString> const&);
+  void CreateCustomTargetsAndCommands(std::set<std::string> const&);
 
   // Handle old-style install rules stored in the targets.
   void GenerateTargetInstallRules(
-    std::ostream& os, const char* config,
+    std::ostream& os, const std::string& config,
     std::vector<std::string> const& configurationTypes);
 
-  std::string& CreateSafeUniqueObjectFileName(const char* sin,
+  std::string& CreateSafeUniqueObjectFileName(const std::string& sin,
                                               std::string const& dir_max);
   void ComputeObjectMaxPath();
 
@@ -411,7 +434,8 @@
   std::string FindRelativePathTopBinary();
   void SetupPathConversions();
 
-  virtual std::string ConvertToLinkReference(std::string const& lib);
+  virtual std::string ConvertToLinkReference(std::string const& lib,
+                                             OutputFormat format = SHELL);
 
   /** Check whether the native build system supports the given
       definition.  Issues a warning.  */
@@ -431,9 +455,9 @@
   std::vector<std::string> StartOutputDirectoryComponents;
   cmLocalGenerator* Parent;
   std::vector<cmLocalGenerator*> Children;
-  std::map<cmStdString, cmStdString> UniqueObjectNamesMap;
+  std::map<std::string, std::string> UniqueObjectNamesMap;
   std::string::size_type ObjectPathMax;
-  std::set<cmStdString> ObjectMaxPathViolations;
+  std::set<std::string> ObjectMaxPathViolations;
   bool WindowsShell;
   bool WindowsVSIDE;
   bool WatcomWMake;
@@ -463,10 +487,12 @@
   cmIML_INT_uint64_t BackwardsCompatibility;
   bool BackwardsCompatibilityFinal;
 private:
-  std::string ConvertToOutputForExistingCommon(const char* remote,
-                                               std::string const& result);
+  std::string ConvertToOutputForExistingCommon(const std::string& remote,
+                                               std::string const& result,
+                                               OutputFormat format);
 
-  void AddSharedFlags(std::string& flags, const char* lang, bool shared);
+  void AddSharedFlags(std::string& flags, const std::string& lang,
+                      bool shared);
   bool GetShouldUseOldFlags(bool shared, const std::string &lang) const;
   void AddPositionIndependentFlags(std::string& flags, std::string const& l,
                                    int targetType);
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index cd12c9d..2ac8363 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -143,15 +143,17 @@
 // Virtual protected methods.
 
 std::string
-cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib)
+cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib,
+                                              OutputFormat format)
 {
-  return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL);
+  return this->Convert(lib, HOME_OUTPUT, format);
 }
 
 std::string
-cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path)
+cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path,
+                                                 OutputFormat format)
 {
-  return this->Convert(path.c_str(), HOME_OUTPUT, SHELL);
+  return this->Convert(path, HOME_OUTPUT, format);
 }
 
 //----------------------------------------------------------------------------
@@ -265,6 +267,20 @@
     }
 }
 
+//----------------------------------------------------------------------------
+void cmLocalNinjaGenerator::ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const* gt)
+{
+  for(std::map<cmSourceFile const*, std::string>::iterator
+      si = mapping.begin(); si != mapping.end(); ++si)
+    {
+    cmSourceFile const* sf = si->first;
+    si->second = this->GetObjectFileNameWithoutTarget(*sf,
+                                                      gt->ObjectDirectory);
+    }
+}
+
 void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
 {
   cmGlobalNinjaGenerator::WriteDivider(os);
@@ -278,7 +294,7 @@
   os << std::endl;
 }
 
-std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const char *path)
+std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const std::string& path)
 {
   std::string convPath = this->Convert(path, cmLocalGenerator::HOME_OUTPUT);
 #ifdef _WIN32
@@ -301,14 +317,15 @@
   this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs);
 }
 
-void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc,
-                                                    cmNinjaDeps &ninjaDeps)
+void cmLocalNinjaGenerator::AppendCustomCommandDeps(
+  cmCustomCommandGenerator const& ccg,
+  cmNinjaDeps &ninjaDeps)
 {
-  const std::vector<std::string> &deps = cc->GetDepends();
+  const std::vector<std::string> &deps = ccg.GetDepends();
   for (std::vector<std::string>::const_iterator i = deps.begin();
        i != deps.end(); ++i) {
     std::string dep;
-    if (this->GetRealDependency(i->c_str(), this->GetConfigName(), dep))
+    if (this->GetRealDependency(*i, this->GetConfigName(), dep))
       ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str()));
   }
 }
@@ -357,13 +374,13 @@
   return cmd.str();
 }
 
-void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc,
-                                            std::vector<std::string> &cmdLines)
+void cmLocalNinjaGenerator::AppendCustomCommandLines(
+  cmCustomCommandGenerator const& ccg,
+  std::vector<std::string> &cmdLines)
 {
-  cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
   if (ccg.GetNumberOfCommands() > 0) {
-    const char* wd = cc->GetWorkingDirectory();
-    if (!wd)
+    std::string wd = ccg.GetWorkingDirectory();
+    if (wd.empty())
       wd = this->GetMakefile()->GetStartOutputDirectory();
 
     cmOStringStream cdCmd;
@@ -376,11 +393,11 @@
     cmdLines.push_back(cdCmd.str());
   }
 
-  std::string launcher = this->MakeCustomLauncher(*cc);
+  std::string launcher = this->MakeCustomLauncher(ccg);
 
   for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) {
     cmdLines.push_back(launcher +
-      this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), SHELL));
+      this->ConvertToOutputFormat(ccg.GetCommand(i), SHELL));
 
     std::string& cmd = cmdLines.back();
     ccg.AppendArguments(i, cmd);
@@ -394,19 +411,21 @@
   if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc))
     return;
 
-  const std::vector<std::string> &outputs = cc->GetOutputs();
+  cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
+
+  const std::vector<std::string> &outputs = ccg.GetOutputs();
   cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps;
 
   std::transform(outputs.begin(), outputs.end(),
                  ninjaOutputs.begin(), MapToNinjaPath());
-  this->AppendCustomCommandDeps(cc, ninjaDeps);
+  this->AppendCustomCommandDeps(ccg, ninjaDeps);
 
   for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end();
        ++i)
     this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i);
 
   std::vector<std::string> cmdLines;
-  this->AppendCustomCommandLines(cc, cmdLines);
+  this->AppendCustomCommandLines(ccg, cmdLines);
 
   if (cmdLines.empty()) {
     this->GetGlobalNinjaGenerator()->WritePhonyBuild(
@@ -421,7 +440,7 @@
   } else {
     this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild(
       this->BuildCommandLine(cmdLines),
-      this->ConstructComment(*cc),
+      this->ConstructComment(ccg),
       "Custom command for " + ninjaOutputs[0],
       ninjaOutputs,
       ninjaDeps,
@@ -470,7 +489,7 @@
 }
 
 std::string cmLocalNinjaGenerator::MakeCustomLauncher(
-  const cmCustomCommand& cc)
+  cmCustomCommandGenerator const& ccg)
 {
   const char* property = "RULE_LAUNCH_CUSTOM";
   const char* property_value = this->Makefile->GetProperty(property);
@@ -485,13 +504,13 @@
   RuleVariables vars;
   vars.RuleLauncher = property;
   std::string output;
-  const std::vector<std::string>& outputs = cc.GetOutputs();
+  const std::vector<std::string>& outputs = ccg.GetOutputs();
   if(!outputs.empty())
   {
     RelativeRoot relative_root =
-      cc.GetWorkingDirectory() ? NONE : START_OUTPUT;
+      ccg.GetWorkingDirectory().empty() ? START_OUTPUT : NONE;
 
-    output = this->Convert(outputs[0].c_str(), relative_root, SHELL);
+    output = this->Convert(outputs[0], relative_root, SHELL);
   }
   vars.Output = output.c_str();
 
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index ea854c6..11321b8 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -16,6 +16,7 @@
 #  include "cmLocalGenerator.h"
 #  include "cmNinjaTypes.h"
 
+class cmCustomCommandGenerator;
 class cmGlobalNinjaGenerator;
 class cmGeneratedFileStream;
 class cmake;
@@ -55,8 +56,8 @@
   const cmake* GetCMakeInstance() const;
   cmake* GetCMakeInstance();
 
-  const char* GetConfigName() const
-  { return this->ConfigName.c_str(); }
+  std::string const& GetConfigName() const
+  { return this->ConfigName; }
 
   /// @return whether we are processing the top CMakeLists.txt file.
   bool isRootMakefile() const;
@@ -66,7 +67,7 @@
   std::string GetHomeRelativeOutputPath() const
   { return this->HomeRelativeOutputPath; }
 
-  std::string ConvertToNinjaPath(const char *path);
+  std::string ConvertToNinjaPath(const std::string& path);
 
   struct map_to_ninja_path {
     cmLocalNinjaGenerator *LocalGenerator;
@@ -92,16 +93,22 @@
   void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs);
 
   void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target);
-  void AppendCustomCommandLines(const cmCustomCommand *cc,
+  void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
                                 std::vector<std::string> &cmdLines);
-  void AppendCustomCommandDeps(const cmCustomCommand *cc,
+  void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
                                cmNinjaDeps &ninjaDeps);
 
-  virtual std::string ConvertToLinkReference(std::string const& lib);
+  virtual std::string ConvertToLinkReference(std::string const& lib,
+                                             OutputFormat format = SHELL);
+
+  virtual void ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const* gt = 0);
 
 
 protected:
-  virtual std::string ConvertToIncludeReference(std::string const& path);
+  virtual std::string ConvertToIncludeReference(std::string const& path,
+                                                OutputFormat format = SHELL);
 
 
 private:
@@ -122,7 +129,7 @@
 
   void WriteCustomCommandBuildStatements();
 
-  std::string MakeCustomLauncher(const cmCustomCommand& cc);
+  std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
 
   std::string ConfigName;
   std::string HomeRelativeOutputPath;
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 93722d1..94e45e5 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -80,7 +80,6 @@
 //----------------------------------------------------------------------------
 cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3()
 {
-  this->SilentNoColon = false;
   this->WindowsShell = false;
   this->IncludeDirective = "include";
   this->MakefileVariableSize = 0;
@@ -173,26 +172,72 @@
 }
 
 //----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3::AddLocalObjectFile(
-  cmTarget* target, cmSourceFile* sf, std::string objNoTargetDir,
-  bool hasSourceExtension)
+void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const* gt)
 {
-  if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str()))
+  for(std::map<cmSourceFile const*, std::string>::iterator
+      si = mapping.begin(); si != mapping.end(); ++si)
     {
-    objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir);
+    cmSourceFile const* sf = si->first;
+    si->second = this->GetObjectFileNameWithoutTarget(*sf,
+                                                      gt->ObjectDirectory);
     }
-  LocalObjectInfo& info = this->LocalObjectFiles[objNoTargetDir];
-  info.HasSourceExtension = hasSourceExtension;
-  info.push_back(LocalObjectEntry(target, sf->GetLanguage()));
+}
+
+//----------------------------------------------------------------------------
+void cmLocalUnixMakefileGenerator3::
+GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
+{
+  std::set<std::string> emitted;
+  cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
+  for(cmGeneratorTargetsType::iterator ti = targets.begin();
+      ti != targets.end(); ++ti)
+    {
+    cmGeneratorTarget* gt = ti->second;
+    if (gt->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      continue;
+      }
+    std::vector<cmSourceFile const*> objectSources;
+    gt->GetObjectSources(objectSources, this->Makefile
+                                    ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+    // Compute full path to object file directory for this target.
+    std::string dir;
+    dir += gt->Makefile->GetCurrentOutputDirectory();
+    dir += "/";
+    dir += this->GetTargetDirectory(*gt->Target);
+    dir += "/";
+    // Compute the name of each object file.
+    for(std::vector<cmSourceFile const*>::iterator
+          si = objectSources.begin();
+        si != objectSources.end(); ++si)
+      {
+      cmSourceFile const* sf = *si;
+      bool hasSourceExtension = true;
+      std::string objectName = this->GetObjectFileNameWithoutTarget(*sf,
+                                                                    dir,
+                                                        &hasSourceExtension);
+      if(cmSystemTools::FileIsFullPath(objectName.c_str()))
+        {
+        objectName = cmSystemTools::GetFilenameName(objectName);
+        }
+      LocalObjectInfo& info = localObjectFiles[objectName];
+      info.HasSourceExtension = hasSourceExtension;
+      info.push_back(LocalObjectEntry(gt->Target, sf->GetLanguage()));
+      }
+    }
 }
 
 //----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets
                                             (std::vector<std::string>& targets)
 {
-  for (std::map<cmStdString, LocalObjectInfo>::iterator lo =
-         this->LocalObjectFiles.begin();
-       lo != this->LocalObjectFiles.end(); ++lo)
+  std::map<std::string, LocalObjectInfo> localObjectFiles;
+  this->GetLocalObjectFiles(localObjectFiles);
+  for (std::map<std::string, LocalObjectInfo>::iterator lo =
+         localObjectFiles.begin();
+       lo != localObjectFiles.end(); ++lo)
     {
     targets.push_back(lo->first);
 
@@ -235,7 +280,7 @@
 
   // only write local targets unless at the top Keep track of targets already
   // listed.
-  std::set<cmStdString> emittedTargets;
+  std::set<std::string> emittedTargets;
   if (this->Parent)
     {
     // write our targets, and while doing it collect up the object
@@ -254,11 +299,14 @@
   bool do_assembly_rules =
     this->GetCreateAssemblySourceRules();
 
+  std::map<std::string, LocalObjectInfo> localObjectFiles;
+  this->GetLocalObjectFiles(localObjectFiles);
+
   // now write out the object rules
   // for each object file name
-  for (std::map<cmStdString, LocalObjectInfo>::iterator lo =
-         this->LocalObjectFiles.begin();
-       lo != this->LocalObjectFiles.end(); ++lo)
+  for (std::map<std::string, LocalObjectInfo>::iterator lo =
+         localObjectFiles.begin();
+       lo != localObjectFiles.end(); ++lo)
     {
     // Add a convenience rule for building the object file.
     this->WriteObjectConvenienceRule(ruleFileStream,
@@ -339,7 +387,7 @@
     depends.push_back(output);
     std::vector<std::string> no_commands;
     this->WriteMakeRule(ruleFileStream, 0,
-                        outNoExt.c_str(), depends, no_commands, true, true);
+                        outNoExt, depends, no_commands, true, true);
     inHelp = false;
     }
 
@@ -355,7 +403,7 @@
     targetName += "/";
     targetName += output;
     commands.push_back(
-      this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName.c_str())
+      this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName)
       );
     }
   this->CreateCDCommand(commands,
@@ -371,7 +419,7 @@
 //----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3
 ::WriteLocalMakefileTargets(std::ostream& ruleFileStream,
-                            std::set<cmStdString> &emitted)
+                            std::set<std::string> &emitted)
 {
   std::vector<std::string> depends;
   std::vector<std::string> commands;
@@ -407,12 +455,12 @@
       std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash();
       makefile2 += "Makefile2";
       commands.push_back(this->GetRecursiveMakeCall
-                         (makefile2.c_str(),localName.c_str()));
+                         (makefile2.c_str(),localName));
       this->CreateCDCommand(commands,
                             this->Makefile->GetHomeOutputDirectory(),
                             cmLocalGenerator::START_OUTPUT);
       this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
-                          localName.c_str(), depends, commands, true);
+                          localName, depends, commands, true);
 
       // Add a target with the canonical name (no prefix, suffix or path).
       if(localName != t->second->GetName())
@@ -436,17 +484,17 @@
       depends.clear();
       commands.clear();
       commands.push_back(this->GetRecursiveMakeCall
-                         (makefileName.c_str(), makeTargetName.c_str()));
+                         (makefileName.c_str(), makeTargetName));
       this->CreateCDCommand(commands,
                             this->Makefile->GetHomeOutputDirectory(),
                             cmLocalGenerator::START_OUTPUT);
       this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
-                          localName.c_str(), depends, commands, true);
+                          localName, depends, commands, true);
 
       // Add a local name for the rule to relink the target before
       // installation.
       if(t->second->Target
-                  ->NeedRelinkBeforeInstall(this->ConfigurationName.c_str()))
+                  ->NeedRelinkBeforeInstall(this->ConfigurationName))
         {
         makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target);
         makeTargetName += "/preinstall";
@@ -455,13 +503,13 @@
         depends.clear();
         commands.clear();
         commands.push_back(this->GetRecursiveMakeCall
-                           (makefile2.c_str(), makeTargetName.c_str()));
+                           (makefile2.c_str(), makeTargetName));
         this->CreateCDCommand(commands,
                               this->Makefile->GetHomeOutputDirectory(),
                               cmLocalGenerator::START_OUTPUT);
         this->WriteMakeRule(ruleFileStream,
                             "Manual pre-install relink rule for target.",
-                            localName.c_str(), depends, commands, true);
+                            localName, depends, commands, true);
         }
       }
     }
@@ -550,14 +598,14 @@
 cmLocalUnixMakefileGenerator3
 ::WriteMakeRule(std::ostream& os,
                 const char* comment,
-                const char* target,
+                const std::string& target,
                 const std::vector<std::string>& depends,
                 const std::vector<std::string>& commands,
                 bool symbolic,
                 bool in_help)
 {
   // Make sure there is a target.
-  if(!target || !*target)
+  if(target.empty())
     {
     cmSystemTools::Error("No target for WriteMakeRule! called with comment: ",
                          comment);
@@ -582,7 +630,7 @@
 
   // Construct the left hand side of the rule.
   replace = target;
-  std::string tgt = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE);
+  std::string tgt = this->Convert(replace,HOME_OUTPUT,MAKEFILE);
   const char* space = "";
   if(tgt.size() == 1)
     {
@@ -615,7 +663,7 @@
         dep != depends.end(); ++dep)
       {
       replace = *dep;
-      replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE);
+      replace = this->Convert(replace,HOME_OUTPUT,MAKEFILE);
       os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
       }
     }
@@ -625,7 +673,7 @@
       i != commands.end(); ++i)
     {
     replace = *i;
-    os << "\t" << replace.c_str() << "\n";
+    os << "\t" << replace << "\n";
     }
   if(symbolic && !this->WatcomWMake)
     {
@@ -654,10 +702,10 @@
     std::string scmd;
     if(cmSystemTools::GetShortPath(cmd.c_str(), scmd))
       {
-      return this->Convert(scmd.c_str(), NONE, SHELL);
+      return this->Convert(scmd, NONE, SHELL);
       }
     }
-  return this->Convert(cmd.c_str(), root, SHELL);
+  return this->Convert(cmd, root, SHELL);
 }
 
 //----------------------------------------------------------------------------
@@ -758,15 +806,17 @@
   depends.push_back(".hpux_make_needs_suffix_list");
   this->WriteMakeRule(makefileStream, 0,
                       ".SUFFIXES", depends, no_commands, false);
-
-  cmGlobalUnixMakefileGenerator3* gg =
-    static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
-  // Write special target to silence make output.  This must be after
-  // the default target in case VERBOSE is set (which changes the
-  // name).  The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a
-  // "VERBOSE=1" to be added as a make variable which will change the
-  // name of this special target.  This gives a make-time choice to
-  // the user.
+  if(this->WatcomWMake)
+    {
+    // Switch on WMake feature, if an error or interrupt occurs during
+    // makefile processing, the current target being made may be deleted
+    // without prompting (the same as command line -e option).
+    makefileStream <<
+      "\n"
+      ".ERASE\n"
+      "\n"
+      ;
+    }
   if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
     {
     makefileStream
@@ -774,12 +824,23 @@
       << "VERBOSE = 1\n"
       << "\n";
     }
-  if(this->SilentNoColon)
+  if(this->WatcomWMake)
     {
-    makefileStream << "$(VERBOSE).SILENT\n";
+    makefileStream <<
+      "!ifndef VERBOSE\n"
+      ".SILENT\n"
+      "!endif\n"
+      "\n"
+      ;
     }
   else
     {
+    // Write special target to silence make output.  This must be after
+    // the default target in case VERBOSE is set (which changes the
+    // name).  The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a
+    // "VERBOSE=1" to be added as a make variable which will change the
+    // name of this special target.  This gives a make-time choice to
+    // the user.
     this->WriteMakeRule(makefileStream,
                         "Suppress display of executed commands.",
                         "$(VERBOSE).SILENT",
@@ -789,6 +850,8 @@
 
   // Work-around for makes that drop rules that have no dependencies
   // or commands.
+  cmGlobalUnixMakefileGenerator3* gg =
+    static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
   std::string hack = gg->GetEmptyRuleHackDepends();
   if(!hack.empty())
     {
@@ -829,7 +892,7 @@
   std::string runRule =
     "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
   runRule += " --check-build-system ";
-  runRule += this->Convert(cmakefileName.c_str(),NONE,SHELL);
+  runRule += this->Convert(cmakefileName,NONE,SHELL);
   runRule += " 0";
 
   std::vector<std::string> no_depends;
@@ -859,11 +922,11 @@
 void
 cmLocalUnixMakefileGenerator3
 ::WriteConvenienceRule(std::ostream& ruleFileStream,
-                       const char* realTarget,
-                       const char* helpTarget)
+                       const std::string& realTarget,
+                       const std::string& helpTarget)
 {
   // A rule is only needed if the names are different.
-  if(strcmp(realTarget, helpTarget) != 0)
+  if(realTarget != helpTarget)
     {
     // The helper target depends on the real target.
     std::vector<std::string> depends;
@@ -886,22 +949,22 @@
 {
   std::string dir = this->HomeRelativeOutputPath;
   dir += this->GetTargetDirectory(target);
-  return this->Convert(dir.c_str(),NONE,UNCHANGED);
+  return this->Convert(dir,NONE,UNCHANGED);
 }
 
 
 
 //----------------------------------------------------------------------------
 void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
-                                                const char* newFlags)
+                                                const std::string& newFlags)
 {
-  if(this->WatcomWMake && newFlags && *newFlags)
+  if(this->WatcomWMake && !newFlags.empty())
     {
     std::string newf = newFlags;
     if(newf.find("\\\"") != newf.npos)
       {
       cmSystemTools::ReplaceString(newf, "\\\"", "\"");
-      this->cmLocalGenerator::AppendFlags(flags, newf.c_str());
+      this->cmLocalGenerator::AppendFlags(flags, newf);
       return;
       }
     }
@@ -909,6 +972,13 @@
 }
 
 //----------------------------------------------------------------------------
+void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
+                                                const char* newFlags)
+{
+  this->cmLocalGenerator::AppendFlags(flags, newFlags);
+}
+
+//----------------------------------------------------------------------------
 void
 cmLocalUnixMakefileGenerator3
 ::AppendRuleDepend(std::vector<std::string>& depends,
@@ -947,7 +1017,9 @@
   for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
       i != ccs.end(); ++i)
     {
-    this->AppendCustomDepend(depends, *i);
+    cmCustomCommandGenerator ccg(*i, this->ConfigurationName,
+                                 this->Makefile);
+    this->AppendCustomDepend(depends, ccg);
     }
 }
 
@@ -955,14 +1027,14 @@
 void
 cmLocalUnixMakefileGenerator3
 ::AppendCustomDepend(std::vector<std::string>& depends,
-                     const cmCustomCommand& cc)
+                     cmCustomCommandGenerator const& ccg)
 {
-  for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin();
-      d != cc.GetDepends().end(); ++d)
+  for(std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
+      d != ccg.GetDepends().end(); ++d)
     {
     // Lookup the real name of the dependency in case it is a CMake target.
     std::string dep;
-    if(this->GetRealDependency(d->c_str(), this->ConfigurationName.c_str(),
+    if(this->GetRealDependency(*d, this->ConfigurationName,
                                dep))
       {
       depends.push_back(dep);
@@ -981,7 +1053,9 @@
   for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
       i != ccs.end(); ++i)
     {
-    this->AppendCustomCommand(commands, *i, target, true, relative);
+    cmCustomCommandGenerator ccg(*i, this->ConfigurationName,
+                                 this->Makefile);
+    this->AppendCustomCommand(commands, ccg, target, true, relative);
     }
 }
 
@@ -989,7 +1063,7 @@
 void
 cmLocalUnixMakefileGenerator3
 ::AppendCustomCommand(std::vector<std::string>& commands,
-                      const cmCustomCommand& cc,
+                      cmCustomCommandGenerator const& ccg,
                       cmTarget* target,
                       bool echo_comment,
                       cmLocalGenerator::RelativeRoot relative,
@@ -1001,8 +1075,8 @@
   // their comments generated elsewhere.
   if(echo_comment)
     {
-    const char* comment = cc.GetComment();
-    if(comment && *comment)
+    const char* comment = ccg.GetComment();
+    if(comment && !*comment)
       {
       this->AppendEcho(commands, comment,
                        cmLocalUnixMakefileGenerator3::EchoGenerate);
@@ -1010,9 +1084,9 @@
     }
 
   // if the command specified a working directory use it.
-  const char* dir  = this->Makefile->GetStartOutputDirectory();
-  const char* workingDir = cc.GetWorkingDirectory();
-  if(workingDir)
+  std::string dir  = this->Makefile->GetStartOutputDirectory();
+  std::string workingDir = ccg.GetWorkingDirectory();
+  if(!workingDir.empty())
     {
     dir = workingDir;
     }
@@ -1020,8 +1094,6 @@
     {
     *content << dir;
     }
-  cmCustomCommandGenerator ccg(cc, this->ConfigurationName.c_str(),
-                               this->Makefile);
 
   // Add each command line to the set of commands.
   std::vector<std::string> commands1;
@@ -1053,9 +1125,9 @@
       // Convert the command to a relative path only if the current
       // working directory will be the start-output directory.
       bool had_slash = cmd.find("/") != cmd.npos;
-      if(!workingDir)
+      if(workingDir.empty())
         {
-        cmd = this->Convert(cmd.c_str(),START_OUTPUT);
+        cmd = this->Convert(cmd,START_OUTPUT);
         }
       bool has_slash = cmd.find("/") != cmd.npos;
       if(had_slash && !has_slash)
@@ -1066,7 +1138,8 @@
         cmd = "./" + cmd;
         }
       std::string launcher =
-        this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT);
+        this->MakeLauncher(ccg, target,
+                           workingDir.empty()? START_OUTPUT : NONE);
       cmd = launcher + this->ConvertShellCommand(cmd, NONE);
 
       ccg.AppendArguments(c, cmd);
@@ -1112,7 +1185,7 @@
     }
 
   // Setup the proper working directory for the commands.
-  this->CreateCDCommand(commands1, dir, relative);
+  this->CreateCDCommand(commands1, dir.c_str(), relative);
 
   // push back the custom commands
   commands.insert(commands.end(), commands1.begin(), commands1.end());
@@ -1120,9 +1193,9 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc,
-                                            cmTarget* target,
-                                            RelativeRoot relative)
+cmLocalUnixMakefileGenerator3::MakeLauncher(
+  cmCustomCommandGenerator const& ccg,
+  cmTarget* target, RelativeRoot relative)
 {
   // Short-circuit if there is no launcher.
   const char* prop = "RULE_LAUNCH_CUSTOM";
@@ -1138,10 +1211,10 @@
   vars.RuleLauncher = prop;
   vars.CMTarget = target;
   std::string output;
-  const std::vector<std::string>& outputs = cc.GetOutputs();
+  const std::vector<std::string>& outputs = ccg.GetOutputs();
   if(!outputs.empty())
     {
-    output = this->Convert(outputs[0].c_str(), relative, SHELL);
+    output = this->Convert(outputs[0], relative, SHELL);
     }
   vars.Output = output.c_str();
 
@@ -1171,7 +1244,7 @@
     cleanfile += filename;
     }
   cleanfile += ".cmake";
-  std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL);
+  std::string cleanfilePath = this->Convert(cleanfile, FULL);
   cmsys::ofstream fout(cleanfilePath.c_str());
   if(!fout)
     {
@@ -1183,25 +1256,26 @@
     for(std::vector<std::string>::const_iterator f = files.begin();
         f != files.end(); ++f)
       {
-      std::string fc = this->Convert(f->c_str(),START_OUTPUT,UNCHANGED);
-      fout << "  " << this->EscapeForCMake(fc.c_str()) << "\n";
+      std::string fc = this->Convert(*f,START_OUTPUT,UNCHANGED);
+      fout << "  " << this->EscapeForCMake(fc) << "\n";
       }
     fout << ")\n";
     }
   std::string remove = "$(CMAKE_COMMAND) -P ";
-  remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL);
+  remove += this->Convert(cleanfile, START_OUTPUT, SHELL);
   commands.push_back(remove);
 
   // For the main clean rule add per-language cleaning.
   if(!filename)
     {
     // Get the set of source languages in the target.
-    std::set<cmStdString> languages;
-    target.GetLanguages(languages);
+    std::set<std::string> languages;
+    target.GetLanguages(languages,
+                      this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
     fout << "\n"
          << "# Per-language clean rules from dependency scanning.\n"
          << "foreach(lang";
-    for(std::set<cmStdString>::const_iterator l = languages.begin();
+    for(std::set<std::string>::const_iterator l = languages.begin();
         l != languages.end(); ++l)
       {
       fout << " " << *l;
@@ -1267,14 +1341,14 @@
           {
           // Use the native echo command.
           cmd = "@echo ";
-          cmd += this->EscapeForShell(line.c_str(), false, true);
+          cmd += this->EscapeForShell(line, false, true);
           }
         else
           {
           // Use cmake to echo the text in color.
           cmd = "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) ";
           cmd += color_name;
-          cmd += this->EscapeForShell(line.c_str());
+          cmd += this->EscapeForShell(line);
           }
         commands.push_back(cmd);
         }
@@ -1299,7 +1373,7 @@
 //----------------------------------------------------------------------------
 std::string
 cmLocalUnixMakefileGenerator3
-::CreateMakeVariable(const char* sin, const char* s2in)
+::CreateMakeVariable(const std::string& sin, const std::string& s2in)
 {
   std::string s = sin;
   std::string s2 = s2in;
@@ -1317,7 +1391,7 @@
 
   // see if the variable has been defined before and return
   // the modified version of the variable
-  std::map<cmStdString, cmStdString>::iterator i =
+  std::map<std::string, std::string>::iterator i =
     this->MakeVariableMap.find(unmodified);
   if(i != this->MakeVariableMap.end())
     {
@@ -1588,14 +1662,14 @@
          langs.begin(); li != langs.end(); ++li)
     {
     // construct the checker
-    std::string lang = li->c_str();
+    std::string lang = *li;
 
     // Create the scanner for this language
     cmDepends *scanner = 0;
     if(lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM")
       {
       // TODO: Handle RC (resource files) dependencies correctly.
-      scanner = new cmDependsC(this, targetDir, lang.c_str(), &validDeps);
+      scanner = new cmDependsC(this, targetDir, lang, &validDeps);
       }
 #ifdef CMAKE_BUILD_WITH_CMAKE
     else if(lang == "Fortran")
@@ -1613,7 +1687,7 @@
       scanner->SetLocalGenerator(this);
       scanner->SetFileComparison
         (this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
-      scanner->SetLanguage(lang.c_str());
+      scanner->SetLanguage(lang);
       scanner->SetTargetDirectory(dir.c_str());
       scanner->Write(ruleFileStream, internalRuleFileStream);
 
@@ -1721,12 +1795,12 @@
         {
         text = "Running external command ...";
         }
-      std::set<cmStdString>::const_iterator dit;
+      std::set<std::string>::const_iterator dit;
       for ( dit = glIt->second.GetUtilities().begin();
          dit != glIt->second.GetUtilities().end();
         ++ dit )
         {
-        depends.push_back(dit->c_str());
+        depends.push_back(*dit);
         }
       this->AppendEcho(commands, text,
                        cmLocalUnixMakefileGenerator3::EchoGlobal);
@@ -1746,7 +1820,7 @@
                                  cmLocalGenerator::START_OUTPUT);
       std::string targetName = glIt->second.GetName();
       this->WriteMakeRule(ruleFileStream, targetString.c_str(),
-                          targetName.c_str(), depends, commands, true);
+                          targetName, depends, commands, true);
 
       // Provide a "/fast" version of the target.
       depends.clear();
@@ -1766,7 +1840,7 @@
         }
       targetName += "/fast";
       this->WriteMakeRule(ruleFileStream, targetString.c_str(),
-                          targetName.c_str(), depends, commands, true);
+                          targetName, depends, commands, true);
       }
     }
 
@@ -1786,15 +1860,15 @@
     cmOStringStream progCmd;
     progCmd <<
       "$(CMAKE_COMMAND) -E cmake_progress_start ";
-    progCmd << this->Convert(progressDir.c_str(),
+    progCmd << this->Convert(progressDir,
                              cmLocalGenerator::FULL,
                              cmLocalGenerator::SHELL);
 
     std::string progressFile = cmake::GetCMakeFilesDirectory();
     progressFile += "/progress.marks";
     std::string progressFileNameFull =
-      this->ConvertToFullPath(progressFile.c_str());
-    progCmd << " " << this->Convert(progressFileNameFull.c_str(),
+      this->ConvertToFullPath(progressFile);
+    progCmd << " " << this->Convert(progressFileNameFull,
                                     cmLocalGenerator::FULL,
                                     cmLocalGenerator::SHELL);
     commands.push_back(progCmd.str());
@@ -1802,14 +1876,14 @@
   std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash();
   mf2Dir += "Makefile2";
   commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(),
-                                                recursiveTarget.c_str()));
+                                                recursiveTarget));
   this->CreateCDCommand(commands,
                         this->Makefile->GetHomeOutputDirectory(),
                         cmLocalGenerator::START_OUTPUT);
     {
     cmOStringStream progCmd;
     progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
-    progCmd << this->Convert(progressDir.c_str(),
+    progCmd << this->Convert(progressDir,
                              cmLocalGenerator::FULL,
                              cmLocalGenerator::SHELL);
     progCmd << " 0";
@@ -1824,7 +1898,7 @@
   commands.clear();
   depends.clear();
   commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(),
-                                                recursiveTarget.c_str()));
+                                                recursiveTarget));
   this->CreateCDCommand(commands,
                                 this->Makefile->GetHomeOutputDirectory(),
                                 cmLocalGenerator::START_OUTPUT);
@@ -1854,7 +1928,7 @@
     depends.push_back("cmake_check_build_system");
     }
   commands.push_back
-    (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget.c_str()));
+    (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
   this->CreateCDCommand(commands,
                         this->Makefile->GetHomeOutputDirectory(),
                         cmLocalGenerator::START_OUTPUT);
@@ -1872,7 +1946,7 @@
   std::string runRule =
     "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
   runRule += " --check-build-system ";
-  runRule += this->Convert(cmakefileName.c_str(),cmLocalGenerator::NONE,
+  runRule += this->Convert(cmakefileName,cmLocalGenerator::NONE,
                            cmLocalGenerator::SHELL);
   runRule += " 1";
   commands.push_back(runRule);
@@ -1905,7 +1979,7 @@
   for(std::vector<std::string>::iterator l = files.begin();
       l != files.end(); ++l)
     {
-    std::string dir = cmSystemTools::GetFilenamePath(l->c_str());
+    std::string dir = cmSystemTools::GetFilenamePath(*l);
 
     // Clear the implicit dependency makefile.
     std::string dependFile = dir + "/depend.make";
@@ -1933,7 +2007,7 @@
   for(ImplicitDependLanguageMap::const_iterator
         l = implicitLangs.begin(); l != implicitLangs.end(); ++l)
     {
-    cmakefileStream << "  \"" << l->first.c_str() << "\"\n";
+    cmakefileStream << "  \"" << l->first << "\"\n";
     }
   cmakefileStream << "  )\n";
 
@@ -1944,7 +2018,7 @@
         l = implicitLangs.begin(); l != implicitLangs.end(); ++l)
     {
     cmakefileStream
-      << "set(CMAKE_DEPENDS_CHECK_" << l->first.c_str() << "\n";
+      << "set(CMAKE_DEPENDS_CHECK_" << l->first << "\n";
     ImplicitDependFileMap const& implicitPairs = l->second;
 
     // for each file pair
@@ -1964,11 +2038,11 @@
     std::string cidVar = "CMAKE_";
     cidVar += l->first;
     cidVar += "_COMPILER_ID";
-    const char* cid = this->Makefile->GetDefinition(cidVar.c_str());
+    const char* cid = this->Makefile->GetDefinition(cidVar);
     if(cid && *cid)
       {
       cmakefileStream
-        << "set(CMAKE_" << l->first.c_str() << "_COMPILER_ID \""
+        << "set(CMAKE_" << l->first << "_COMPILER_ID \""
         << cid << "\")\n";
       }
     }
@@ -1976,7 +2050,7 @@
   // Build a list of preprocessor definitions for the target.
   std::set<std::string> defines;
   this->AddCompileDefinitions(defines, &target,
-                               this->ConfigurationName.c_str());
+                               this->ConfigurationName);
   if(!defines.empty())
     {
     cmakefileStream
@@ -1987,7 +2061,7 @@
         di != defines.end(); ++di)
       {
       cmakefileStream
-        << "  " << this->EscapeForCMake(di->c_str()) << "\n";
+        << "  " << this->EscapeForCMake(*di) << "\n";
       }
     cmakefileStream
       << "  )\n";
@@ -2013,7 +2087,7 @@
     for(std::vector<std::string>::const_iterator tri = transformRules.begin();
         tri != transformRules.end(); ++tri)
       {
-      cmakefileStream << "  " << this->EscapeForCMake(tri->c_str()) << "\n";
+      cmakefileStream << "  " << this->EscapeForCMake(*tri) << "\n";
       }
     cmakefileStream
       << "  )\n";
@@ -2034,7 +2108,7 @@
 //----------------------------------------------------------------------------
 std::string
 cmLocalUnixMakefileGenerator3
-::GetRecursiveMakeCall(const char *makefile, const char* tgt)
+::GetRecursiveMakeCall(const char *makefile, const std::string& tgt)
 {
   // Call make on the given file.
   std::string cmd;
@@ -2059,7 +2133,7 @@
     }
 
   // Add the target.
-  if (tgt && tgt[0] != '\0')
+  if (!tgt.empty())
     {
     // The make target is always relative to the top of the build tree.
     std::string tgt2 = this->Convert(tgt, HOME_OUTPUT);
@@ -2070,12 +2144,12 @@
     // Escape one extra time if the make tool requires it.
     if(this->MakeCommandEscapeTargetTwice)
       {
-      tgt2 = this->EscapeForShell(tgt2.c_str(), true, false);
+      tgt2 = this->EscapeForShell(tgt2, true, false);
       }
 
     // The target name is now a string that should be passed verbatim
     // on the command line.
-    cmd += this->EscapeForShell(tgt2.c_str(), true, false);
+    cmd += this->EscapeForShell(tgt2, true, false);
     }
   return cmd;
 }
@@ -2116,59 +2190,82 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p)
+cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
+                                                         bool useWatcomQuote)
 {
-
   // Split the path into its components.
   std::vector<std::string> components;
   cmSystemTools::SplitPath(p, components);
 
-  // Return an empty path if there are no components.
-  if(components.empty())
+  // Open the quoted result.
+  std::string result;
+  if(useWatcomQuote)
     {
-    return "\"\"";
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    result = "'";
+#else
+    result = "\"'";
+#endif
+    }
+  else
+    {
+    result = "\"";
     }
 
-  // Choose a slash direction and fix root component.
-  const char* slash = "/";
+  // Return an empty path if there are no components.
+  if(!components.empty())
+    {
+    // Choose a slash direction and fix root component.
+    const char* slash = "/";
 #if defined(_WIN32) && !defined(__CYGWIN__)
-   if(!cmSystemTools::GetForceUnixPaths())
-     {
-     slash = "\\";
-     for(std::string::iterator i = components[0].begin();
-       i != components[0].end(); ++i)
-       {
-       if(*i == '/')
-         {
-         *i = '\\';
-         }
-       }
-     }
+    if(!cmSystemTools::GetForceUnixPaths())
+      {
+      slash = "\\";
+      for(std::string::iterator i = components[0].begin();
+          i != components[0].end(); ++i)
+        {
+        if(*i == '/')
+          {
+          *i = '\\';
+          }
+        }
+      }
 #endif
 
-  // Begin the quoted result with the root component.
-  std::string result = "\"";
-  result += components[0];
+    // Begin the quoted result with the root component.
+    result += components[0];
 
-  // Now add the rest of the components separated by the proper slash
-  // direction for this platform.
-  bool first = true;
-  for(unsigned int i=1; i < components.size(); ++i)
-    {
-    // Only the last component can be empty to avoid double slashes.
-    if(components[i].length() > 0 || (i == (components.size()-1)))
+    // Now add the rest of the components separated by the proper slash
+    // direction for this platform.
+    bool first = true;
+    for(unsigned int i=1; i < components.size(); ++i)
       {
-      if(!first)
+      // Only the last component can be empty to avoid double slashes.
+      if(components[i].length() > 0 || (i == (components.size()-1)))
         {
-        result += slash;
+        if(!first)
+          {
+          result += slash;
+          }
+        result += components[i];
+        first = false;
         }
-      result += components[i];
-      first = false;
       }
     }
 
   // Close the quoted result.
-  result += "\"";
+  if(useWatcomQuote)
+    {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    result += "'";
+#else
+    result += "'\"";
+#endif
+    }
+  else
+    {
+    result += "\"";
+    }
 
   return result;
 }
@@ -2198,7 +2295,7 @@
 //----------------------------------------------------------------------------
 void
 cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt,
-                                                  const char* lang,
+                                                  const std::string& lang,
                                                   const char* obj,
                                                   const char* src)
 {
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 703369e..4f2e4a0 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -18,6 +18,7 @@
 #include "cmDepends.h"
 
 class cmCustomCommand;
+class cmCustomCommandGenerator;
 class cmDependInformation;
 class cmDepends;
 class cmMakefileTargetGenerator;
@@ -55,7 +56,7 @@
   // Write out a make rule
   void WriteMakeRule(std::ostream& os,
                      const char* comment,
-                     const char* target,
+                     const std::string& target,
                      const std::vector<std::string>& depends,
                      const std::vector<std::string>& commands,
                      bool symbolic,
@@ -75,7 +76,7 @@
   /**
    * Set the flag used to keep the make program silent.
    */
-  void SetMakeSilentFlag(const char* s) { this->MakeSilentFlag = s; }
+  void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; }
   std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; }
 
   /**
@@ -121,17 +122,12 @@
   void SetUnixCD(bool v)  {this->UnixCD = v;}
 
   /**
-   * Set Support Verbose Variable.  If true, then .SILENT will
-   * be not end with :  i.e. .SILENT: or .SILENT
-   */
-  void SetSilentNoColon(bool v)  {this->SilentNoColon = v;}
-
-  /**
    * Set the string used to include one makefile into another default
    * is include.
    */
-  void SetIncludeDirective(const char* s) { this->IncludeDirective = s; }
-  const char *GetIncludeDirective() { return this->IncludeDirective.c_str(); }
+  void SetIncludeDirective(const std::string& s)
+    { this->IncludeDirective = s; }
+  const std::string& GetIncludeDirective() { return this->IncludeDirective; }
 
   /**
    * Set max makefile variable size, default is 0 which means unlimited.
@@ -168,9 +164,11 @@
   void WriteDivider(std::ostream& os);
 
   /** used to create a recursive make call */
-  std::string GetRecursiveMakeCall(const char *makefile, const char* tgt);
+  std::string GetRecursiveMakeCall(const char *makefile,
+                                   const std::string& tgt);
 
   // append flags to a string
+  virtual void AppendFlags(std::string& flags, const std::string& newFlags);
   virtual void AppendFlags(std::string& flags, const char* newFlags);
 
   // append an echo command
@@ -189,9 +187,11 @@
                        const char *targetDir,
                        cmLocalGenerator::RelativeRoot returnDir);
 
-  static std::string ConvertToQuotedOutputPath(const char* p);
+  static std::string ConvertToQuotedOutputPath(const char* p,
+                                               bool useWatcomQuote);
 
-  std::string CreateMakeVariable(const char* sin, const char* s2in);
+  std::string CreateMakeVariable(const std::string& sin,
+                                 const std::string& s2in);
 
   /** Called from command-line hook to bring dependencies up to date
       for a target.  */
@@ -210,14 +210,14 @@
   // File pairs for implicit dependency scanning.  The key of the map
   // is the depender and the value is the explicit dependee.
   struct ImplicitDependFileMap:
-    public std::map<cmStdString, cmDepends::DependencyVector> {};
+    public std::map<std::string, cmDepends::DependencyVector> {};
   struct ImplicitDependLanguageMap:
-    public std::map<cmStdString, ImplicitDependFileMap> {};
+    public std::map<std::string, ImplicitDependFileMap> {};
   struct ImplicitDependTargetMap:
-    public std::map<cmStdString, ImplicitDependLanguageMap> {};
+    public std::map<std::string, ImplicitDependLanguageMap> {};
   ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt);
 
-  void AddImplicitDepends(cmTarget const& tgt, const char* lang,
+  void AddImplicitDepends(cmTarget const& tgt, const std::string& lang,
                           const char* obj, const char* src);
 
   void AppendGlobalTargetDepends(std::vector<std::string>& depends,
@@ -226,11 +226,7 @@
   // write the target rules for the local Makefile into the stream
   void WriteLocalAllRules(std::ostream& ruleFileStream);
 
-  void AddLocalObjectFile(cmTarget* target, cmSourceFile* sf,
-                          std::string objNoTargetDir,
-                          bool hasSourceExtension);
-
-  std::vector<cmStdString> const& GetLocalHelp() { return this->LocalHelp; }
+  std::vector<std::string> const& GetLocalHelp() { return this->LocalHelp; }
 
   /** Get whether to create rules to generate preprocessed and
       assembly sources.  This could be converted to a variable lookup
@@ -255,7 +251,7 @@
 
   // write the target rules for the local Makefile into the stream
   void WriteLocalMakefileTargets(std::ostream& ruleFileStream,
-                                 std::set<cmStdString> &emitted);
+                                 std::set<std::string> &emitted);
 
   // this method Writes the Directory information files
   void WriteDirectoryInformationFile();
@@ -273,8 +269,8 @@
 
 
   void WriteConvenienceRule(std::ostream& ruleFileStream,
-                            const char* realTarget,
-                            const char* helpTarget);
+                            const std::string& realTarget,
+                            const std::string& helpTarget);
 
   void WriteTargetDependRule(std::ostream& ruleFileStream,
                              cmTarget& target);
@@ -292,14 +288,14 @@
   void AppendCustomDepends(std::vector<std::string>& depends,
                            const std::vector<cmCustomCommand>& ccs);
   void AppendCustomDepend(std::vector<std::string>& depends,
-                          const cmCustomCommand& cc);
+                          cmCustomCommandGenerator const& cc);
   void AppendCustomCommands(std::vector<std::string>& commands,
                             const std::vector<cmCustomCommand>& ccs,
                             cmTarget* target,
                             cmLocalGenerator::RelativeRoot relative =
                             cmLocalGenerator::HOME_OUTPUT);
   void AppendCustomCommand(std::vector<std::string>& commands,
-                           const cmCustomCommand& cc,
+                           cmCustomCommandGenerator const& ccg,
                            cmTarget* target,
                            bool echo_comment=false,
                            cmLocalGenerator::RelativeRoot relative =
@@ -316,8 +312,12 @@
 
 private:
   std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root);
-  std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target,
-                           RelativeRoot relative);
+  std::string MakeLauncher(cmCustomCommandGenerator const& ccg,
+                           cmTarget* target, RelativeRoot relative);
+
+  virtual void ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const* gt = 0);
 
   friend class cmMakefileTargetGenerator;
   friend class cmMakefileExecutableTargetGenerator;
@@ -336,7 +336,6 @@
   bool DefineWindowsNULL;
   bool UnixCD;
   bool PassMakeflags;
-  bool SilentNoColon;
   bool MakeCommandEscapeTargetTwice;
   bool BorlandMakeCurlyHack;
   //==========================================================================
@@ -358,7 +357,7 @@
     cmTarget* Target;
     std::string Language;
     LocalObjectEntry(): Target(0), Language() {}
-    LocalObjectEntry(cmTarget* t, const char* lang):
+    LocalObjectEntry(cmTarget* t, const std::string& lang):
       Target(t), Language(lang) {}
   };
   struct LocalObjectInfo: public std::vector<LocalObjectEntry>
@@ -369,16 +368,18 @@
     LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false),
                       HasAssembleRule(false) {}
   };
-  std::map<cmStdString, LocalObjectInfo> LocalObjectFiles;
+  void GetLocalObjectFiles(
+                    std::map<std::string, LocalObjectInfo> &localObjectFiles);
+
   void WriteObjectConvenienceRule(std::ostream& ruleFileStream,
                                   const char* comment, const char* output,
                                   LocalObjectInfo const& info);
 
-  std::vector<cmStdString> LocalHelp;
+  std::vector<std::string> LocalHelp;
 
   /* does the work for each target */
-  std::map<cmStdString, cmStdString> MakeVariableMap;
-  std::map<cmStdString, cmStdString> ShortMakeVariableMap;
+  std::map<std::string, std::string> MakeVariableMap;
+  std::map<std::string, std::string> ShortMakeVariableMap;
 };
 
 #endif
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index aedd6ed..aa70ab9 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -19,7 +19,7 @@
 class cmVS10XMLParser : public cmXMLParser
 {
   public:
-  virtual void EndElement(const char* /* name */)
+  virtual void EndElement(const std::string& /* name */)
     {
     }
   virtual void CharacterDataHandler(const char* data, int length)
@@ -30,14 +30,14 @@
         this->DoGUID = false;
         }
     }
-  virtual void StartElement(const char* name, const char**)
+  virtual void StartElement(const std::string& name, const char**)
     {
       // once the GUID is found do nothing
       if(this->GUID.size())
         {
         return;
         }
-      if(strcmp("ProjectGUID", name) == 0 || strcmp("ProjectGuid", name) == 0)
+      if("ProjectGUID" == name || "ProjectGuid" == name)
         {
         this->DoGUID = true;
         }
@@ -98,7 +98,7 @@
 
 
 void cmLocalVisualStudio10Generator
-::ReadAndStoreExternalGUID(const char* name,
+::ReadAndStoreExternalGUID(const std::string& name,
                            const char* path)
 {
   cmVS10XMLParser parser;
diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h
index 41db735..b50e345 100644
--- a/Source/cmLocalVisualStudio10Generator.h
+++ b/Source/cmLocalVisualStudio10Generator.h
@@ -34,7 +34,7 @@
    * Generate the makefile for this directory.
    */
   virtual void Generate();
-  virtual void ReadAndStoreExternalGUID(const char* name,
+  virtual void ReadAndStoreExternalGUID(const std::string& name,
                                         const char* path);
 
 protected:
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index a5e8294..5db735f 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -16,6 +16,7 @@
 #include "cmSourceFile.h"
 #include "cmCacheManager.h"
 #include "cmGeneratorTarget.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmake.h"
 
 #include "cmComputeLinkInformation.h"
@@ -38,7 +39,7 @@
 {
 public:
   EventWriter(cmLocalVisualStudio6Generator* lg,
-              const char* config, std::string& code):
+              const std::string& config, std::string& code):
     LG(lg), Config(config), Code(code), First(true) {}
   void Start(const char* event)
     {
@@ -59,6 +60,7 @@
     }
   void Write(cmCustomCommand const& cc)
     {
+    cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
     if(this->First)
       {
       this->Code += this->Event + "_Cmds=";
@@ -68,11 +70,11 @@
       {
       this->Code += "\\\n\t";
       }
-    this->Code += this->LG->ConstructScript(cc, this->Config, "\\\n\t");
+    this->Code += this->LG->ConstructScript(ccg, "\\\n\t");
     }
 private:
   cmLocalVisualStudio6Generator* LG;
-  const char* Config;
+  std::string Config;
   std::string& Code;
   bool First;
   std::string Event;
@@ -80,7 +82,7 @@
 
 void cmLocalVisualStudio6Generator::AddHelperCommands()
 {
-  std::set<cmStdString> lang;
+  std::set<std::string> lang;
   lang.insert("C");
   lang.insert("CXX");
   this->CreateCustomTargetsAndCommands(lang);
@@ -186,7 +188,7 @@
 //
 extern std::string GetVS6TargetName(const std::string& targetName);
 
-void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
+void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname,
                                                     cmTarget &target)
 {
   // add to the list of projects
@@ -251,9 +253,9 @@
                                            makefileIn.c_str(), commandLines,
                                            comment.c_str(),
                                            no_working_directory, true);
-  if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str()))
+  if(this->Makefile->GetSource(makefileIn.c_str()))
     {
-    tgt.AddSourceFile(file);
+    tgt.AddSource(makefileIn);
     }
   else
     {
@@ -263,7 +265,7 @@
 
 
 void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
-                                                 const char *libName,
+                                                 const std::string& libName,
                                                  cmTarget &target)
 {
   // For utility targets need custom command since pre- and post-
@@ -315,13 +317,21 @@
 
   // get the classes from the source lists then add them to the groups
   std::vector<cmSourceFile*> classes;
-  target.GetSourceFiles(classes);
+  if (!target.GetConfigCommonSourceFiles(classes))
+    {
+    return;
+    }
 
   // now all of the source files have been properly assigned to the target
   // now stick them into source groups using the reg expressions
   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
       i != classes.end(); i++)
     {
+    if (!(*i)->GetObjectLibrary().empty())
+      {
+      continue;
+      }
+
     // Add the file to the list of sources.
     std::string source = (*i)->GetFullPath();
     cmSourceGroup* sourceGroup =
@@ -372,7 +382,7 @@
 
 void cmLocalVisualStudio6Generator
 ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
-             std::ostream &fout, const char *libName)
+             std::ostream &fout, const std::string& libName)
 {
   cmGeneratorTarget* gt =
     this->GlobalGenerator->GetGeneratorTarget(&target);
@@ -396,6 +406,11 @@
   for(std::vector<const cmSourceFile *>::const_iterator sf =
         sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
     {
+    if (!(*sf)->GetObjectLibrary().empty())
+      {
+      continue;
+      }
+
     std::string source = (*sf)->GetFullPath();
     const cmCustomCommand *command =
       (*sf)->GetCustomCommand();
@@ -413,23 +428,20 @@
       compileFlags += cflags;
       }
 
-    const char* lang = this->GetSourceFileLanguage(*(*sf));
-    if(lang)
+    const std::string& lang = this->GetSourceFileLanguage(*(*sf));
+    if(lang == "CXX")
       {
-      if(strcmp(lang, "CXX") == 0)
-        {
-        // force a C++ file type
-        compileFlags += " /TP ";
-        }
-      else if(strcmp(lang, "C") == 0)
-        {
-        // force to c file type
-        compileFlags += " /TC ";
-        }
+      // force a C++ file type
+      compileFlags += " /TP ";
+      }
+    else if(lang == "C")
+      {
+      // force to c file type
+      compileFlags += " /TC ";
       }
 
     // Add per-source and per-configuration preprocessor definitions.
-    std::map<cmStdString, cmStdString> cdmap;
+    std::map<std::string, std::string> cdmap;
 
       {
       std::set<std::string> targetCompileDefinitions;
@@ -469,7 +481,7 @@
       }
 
     bool excludedFromBuild =
-      (lang && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
+      (!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
 
     // Check for extra object-file dependencies.
     const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
@@ -529,7 +541,7 @@
             {
             fout << "\n# ADD CPP " << compileFlags << "\n\n";
             }
-          std::map<cmStdString, cmStdString>::iterator cdi =
+          std::map<std::string, std::string>::iterator cdi =
             cdmap.find(cmSystemTools::UpperCase(config));
           if(cdi != cdmap.end() && !cdi->second.empty())
             {
@@ -575,20 +587,24 @@
 {
   // Create a fake output that forces the rule to run.
   char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) +
-                           strlen(target.GetName()) + 30)];
+                           target.GetName().size() + 30)];
   sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(),
-          target.GetName(), count);
-  std::string comment = this->ConstructComment(origCommand, "<hack>");
+          target.GetName().c_str(), count);
+  const char* comment = origCommand.GetComment();
+  if(!comment && origCommand.GetOutputs().empty())
+    {
+    comment = "<hack>";
+    }
 
   // Add the rule with the given dependencies and commands.
-  const char* no_main_dependency = 0;
+  std::string no_main_dependency = "";
   if(cmSourceFile* outsf =
      this->Makefile->AddCustomCommandToOutput(
        output, depends, no_main_dependency,
-       origCommand.GetCommandLines(), comment.c_str(),
-       origCommand.GetWorkingDirectory()))
+       origCommand.GetCommandLines(), comment,
+       origCommand.GetWorkingDirectory().c_str()))
     {
-    target.AddSourceFile(outsf);
+    target.AddSource(outsf->GetFullPath());
     }
 
   // Replace the dependencies with the output of this rule so that the
@@ -607,20 +623,21 @@
                   const cmCustomCommand& command,
                   const char* flags)
 {
-  std::string comment =
-    this->ConstructComment(command, "Building Custom Rule $(InputPath)");
-  if(comment == "<hack>")
-    {
-    comment = "";
-    }
-
   // Write the rule for each configuration.
   std::vector<std::string>::iterator i;
   for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i)
     {
     std::string config = this->GetConfigName(*i);
+    cmCustomCommandGenerator ccg(command, config, this->Makefile);
+    std::string comment =
+      this->ConstructComment(ccg, "Building Custom Rule $(InputPath)");
+    if(comment == "<hack>")
+      {
+      comment = "";
+      }
+
     std::string script =
-      this->ConstructScript(command, config.c_str(), "\\\n\t");
+      this->ConstructScript(ccg, "\\\n\t");
 
     if (i == this->Configurations.begin())
       {
@@ -637,8 +654,8 @@
     // Write out the dependencies for the rule.
     fout << "USERDEP__HACK=";
     for(std::vector<std::string>::const_iterator d =
-          command.GetDepends().begin();
-        d != command.GetDepends().end();
+          ccg.GetDepends().begin();
+        d != ccg.GetDepends().end();
         ++d)
       {
       // Lookup the real name of the dependency in case it is a CMake target.
@@ -658,7 +675,7 @@
       fout << " " << comment.c_str();
       }
     fout << "\n\n";
-    if(command.GetOutputs().empty())
+    if(ccg.GetOutputs().empty())
       {
       fout << source
            << "_force :  \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
@@ -667,8 +684,8 @@
     else
       {
       for(std::vector<std::string>::const_iterator o =
-          command.GetOutputs().begin();
-          o != command.GetOutputs().end();
+          ccg.GetOutputs().begin();
+          o != ccg.GetOutputs().end();
           ++o)
         {
         // Write a rule for every output generated by this command.
@@ -702,7 +719,7 @@
 
 
 void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
-                                                 const char* libName,
+                                                 const std::string& libName,
                                                  cmTarget& target)
 {
   std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
@@ -788,7 +805,7 @@
 //----------------------------------------------------------------------------
 cmsys::auto_ptr<cmCustomCommand>
 cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
-                                                    const char* config)
+                                                    const std::string& config)
 {
   cmsys::auto_ptr<cmCustomCommand> pcc;
 
@@ -816,8 +833,8 @@
 // look for custom rules on a target and collect them together
 std::string
 cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
-                                                 const char* configName,
-                                                 const char * /* libName */)
+                                              const std::string& configName,
+                                              const std::string& /* libName */)
 {
   if (target.GetType() >= cmTarget::UTILITY )
     {
@@ -866,7 +883,7 @@
 
 std::string
 cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target,
-                                                       const char *config)
+                                                  const std::string& config)
 {
   std::string includeOptions;
 
@@ -929,7 +946,7 @@
 
 void cmLocalVisualStudio6Generator
 ::WriteDSPHeader(std::ostream& fout,
-                 const char *libName, cmTarget &target,
+                 const std::string& libName, cmTarget &target,
                  std::vector<cmSourceGroup> &)
 {
   bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE &&
@@ -1102,7 +1119,7 @@
       // Compute the proper name to use to link this library.
       std::string lib;
       std::string libDebug;
-      cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str());
+      cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str());
       if(tgt)
         {
         lib = cmSystemTools::GetFilenameWithoutExtension
@@ -1255,12 +1272,25 @@
   if(targetBuilds)
     {
     // Get the language to use for linking.
-    const char* linkLanguage = target.GetLinkerLanguage();
-    if(!linkLanguage)
+    std::vector<std::string> configs;
+    target.GetMakefile()->GetConfigurations(configs);
+    std::vector<std::string>::const_iterator it = configs.begin();
+    const std::string& linkLanguage = target.GetLinkerLanguage(*it);
+    for ( ; it != configs.end(); ++it)
+      {
+      const std::string& configLinkLanguage = target.GetLinkerLanguage(*it);
+      if (configLinkLanguage != linkLanguage)
+        {
+        cmSystemTools::Error
+          ("Linker language must not vary by configuration for target: ",
+          target.GetName().c_str());
+        }
+      }
+    if(linkLanguage.empty())
       {
       cmSystemTools::Error
         ("CMake can not determine linker language for target: ",
-         target.GetName());
+         target.GetName().c_str());
       return;
       }
 
@@ -1677,12 +1707,25 @@
     if(target.GetType() >= cmTarget::EXECUTABLE &&
        target.GetType() <= cmTarget::OBJECT_LIBRARY)
       {
-      const char* linkLanguage = target.GetLinkerLanguage();
-      if(!linkLanguage)
+      std::vector<std::string> configs;
+      target.GetMakefile()->GetConfigurations(configs);
+      std::vector<std::string>::const_iterator it = configs.begin();
+      const std::string& linkLanguage = target.GetLinkerLanguage(*it);
+      for ( ; it != configs.end(); ++it)
+        {
+        const std::string& configLinkLanguage = target.GetLinkerLanguage(*it);
+        if (configLinkLanguage != linkLanguage)
+          {
+          cmSystemTools::Error
+            ("Linker language must not vary by configuration for target: ",
+            target.GetName().c_str());
+          }
+        }
+      if(linkLanguage.empty())
         {
         cmSystemTools::Error
           ("CMake can not determine linker language for target: ",
-           target.GetName());
+           target.GetName().c_str());
         return;
         }
       // if CXX is on and the target contains cxx code then add the cxx flags
@@ -1707,7 +1750,7 @@
       flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str());
       flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
 
-      this->AddCompileOptions(flags, &target, linkLanguage, 0);
+      this->AddCompileOptions(flags, &target, linkLanguage, "");
       this->AddCompileOptions(flagsDebug, &target, linkLanguage, "Debug");
       this->AddCompileOptions(flagsRelease, &target, linkLanguage, "Release");
       this->AddCompileOptions(flagsMinSizeRel, &target, linkLanguage,
@@ -1733,7 +1776,7 @@
     std::set<std::string> minsizeDefinesSet;
     std::set<std::string> debugrelDefinesSet;
 
-    this->AddCompileDefinitions(definesSet, &target, 0);
+    this->AddCompileDefinitions(definesSet, &target, "");
     this->AddCompileDefinitions(debugDefinesSet, &target, "DEBUG");
     this->AddCompileDefinitions(releaseDefinesSet, &target, "RELEASE");
     this->AddCompileDefinitions(minsizeDefinesSet, &target, "MINSIZEREL");
@@ -1745,11 +1788,11 @@
     std::string minsizeDefines = " ";
     std::string debugrelDefines = " ";
 
-    this->JoinDefines(definesSet, defines, 0);
-    this->JoinDefines(debugDefinesSet, debugDefines, 0);
-    this->JoinDefines(releaseDefinesSet, releaseDefines, 0);
-    this->JoinDefines(minsizeDefinesSet, minsizeDefines, 0);
-    this->JoinDefines(debugrelDefinesSet, debugrelDefines, 0);
+    this->JoinDefines(definesSet, defines, "");
+    this->JoinDefines(debugDefinesSet, debugDefines, "");
+    this->JoinDefines(releaseDefinesSet, releaseDefines, "");
+    this->JoinDefines(minsizeDefinesSet, minsizeDefines, "");
+    this->JoinDefines(debugrelDefinesSet, debugrelDefines, "");
 
     flags += defines;
     flagsDebug += debugDefines;
@@ -1803,7 +1846,7 @@
 //----------------------------------------------------------------------------
 void cmLocalVisualStudio6Generator
 ::ComputeLinkOptions(cmTarget& target,
-                     const char* configName,
+                     const std::string& configName,
                      const std::string extraOptions,
                      std::string& options)
 {
@@ -1875,7 +1918,7 @@
   cmGeneratorTarget* gt =
     this->GlobalGenerator->GetGeneratorTarget(&target);
   std::vector<std::string> objs;
-  gt->UseObjectLibraries(objs);
+  gt->UseObjectLibraries(objs, "");
   for(std::vector<std::string>::const_iterator
         oi = objs.begin(); oi != objs.end(); ++oi)
     {
diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h
index f45bc17..4771833 100644
--- a/Source/cmLocalVisualStudio6Generator.h
+++ b/Source/cmLocalVisualStudio6Generator.h
@@ -48,7 +48,7 @@
   /**
    * Specify the type of the build: static, dll, or executable.
    */
-  void SetBuildType(BuildType, const char* libName, cmTarget&);
+  void SetBuildType(BuildType, const std::string& libName, cmTarget&);
 
   virtual std::string GetTargetDirectory(cmTarget const& target) const;
   virtual std::string ComputeLongestObjectDirectory(cmTarget&) const;
@@ -56,15 +56,15 @@
   std::string DSPHeaderTemplate;
   std::string DSPFooterTemplate;
 
-  void CreateSingleDSP(const char *lname, cmTarget &tgt);
-  void WriteDSPFile(std::ostream& fout, const char *libName,
+  void CreateSingleDSP(const std::string& lname, cmTarget &tgt);
+  void WriteDSPFile(std::ostream& fout, const std::string& libName,
                     cmTarget &tgt);
   void WriteDSPBeginGroup(std::ostream& fout,
                           const char* group,
                           const char* filter);
   void WriteDSPEndGroup(std::ostream& fout);
 
-  void WriteDSPHeader(std::ostream& fout, const char *libName,
+  void WriteDSPHeader(std::ostream& fout, const std::string& libName,
                       cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
 
   void WriteDSPFooter(std::ostream& fout);
@@ -77,20 +77,21 @@
                              std::vector<std::string>& depends,
                              const cmCustomCommand& origCommand);
   void WriteGroup(const cmSourceGroup *sg, cmTarget& target,
-                  std::ostream &fout, const char *libName);
+                  std::ostream &fout, const std::string& libName);
   class EventWriter;
   friend class EventWriter;
   cmsys::auto_ptr<cmCustomCommand>
-  MaybeCreateOutputDir(cmTarget& target, const char* config);
+  MaybeCreateOutputDir(cmTarget& target, const std::string& config);
   std::string CreateTargetRules(cmTarget &target,
-                                const char* configName,
-                                const char *libName);
-  void ComputeLinkOptions(cmTarget& target, const char* configName,
+                                const std::string& configName,
+                                const std::string& libName);
+  void ComputeLinkOptions(cmTarget& target, const std::string& configName,
                           const std::string extraOptions,
                           std::string& options);
   void OutputObjects(cmTarget& target, const char* tool,
                      std::string& options);
-  std::string GetTargetIncludeOptions(cmTarget &target, const char *config);
+  std::string GetTargetIncludeOptions(cmTarget &target,
+                                      const std::string& config);
   std::vector<std::string> Configurations;
 
   std::string GetConfigName(std::string const& configuration) const;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 212b06b..a6c6e8d 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -18,6 +18,7 @@
 #include "cmSourceFile.h"
 #include "cmCacheManager.h"
 #include "cmGeneratorTarget.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmake.h"
 
 #include "cmComputeLinkInformation.h"
@@ -59,7 +60,7 @@
 
 void cmLocalVisualStudio7Generator::AddHelperCommands()
 {
-  std::set<cmStdString> lang;
+  std::set<std::string> lang;
   lang.insert("C");
   lang.insert("CXX");
   lang.insert("RC");
@@ -83,7 +84,7 @@
     if(path)
       {
       this->ReadAndStoreExternalGUID(
-        l->second.GetName(), path);
+        l->second.GetName().c_str(), path);
       }
     else
       {
@@ -116,7 +117,7 @@
         {
         if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
           {
-          l->second.AddSourceFile(sf);
+          l->second.AddSource(sf->GetFullPath());
           }
         }
       }
@@ -141,7 +142,7 @@
       force_command.push_back(".");
       cmCustomCommandLines force_commands;
       force_commands.push_back(force_command);
-      const char* no_main_dependency = 0;
+      std::string no_main_dependency = "";
       std::string force = this->Makefile->GetStartOutputDirectory();
       force += cmake::GetCMakeFilesDirectory();
       force += "/";
@@ -152,7 +153,7 @@
            force.c_str(), no_depends, no_main_dependency,
            force_commands, " ", 0, true))
         {
-        tgt.AddSourceFile(file);
+        tgt.AddSource(file->GetFullPath());
         }
       }
     }
@@ -228,7 +229,7 @@
 
 //----------------------------------------------------------------------------
 void cmLocalVisualStudio7Generator
-::CreateSingleVCProj(const char *lname, cmTarget &target)
+::CreateSingleVCProj(const std::string& lname, cmTarget &target)
 {
   this->FortranProject =
     static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
@@ -245,8 +246,7 @@
     }
 
   // add to the list of projects
-  std::string pname = lname;
-  target.SetProperty("GENERATOR_FILE_NAME",lname);
+  target.SetProperty("GENERATOR_FILE_NAME",lname.c_str());
   // create the dsp.cmake file
   std::string fname;
   fname = this->Makefile->GetStartOutputDirectory();
@@ -334,8 +334,8 @@
 }
 
 void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
-                                                        const char *libName,
-                                                        cmTarget &target)
+                                                   const std::string& libName,
+                                                   cmTarget &target)
 {
   std::vector<std::string> *configs =
     static_cast<cmGlobalVisualStudio7Generator *>
@@ -486,34 +486,34 @@
    cmVS7FlagTable::UserValue},
 
   // boolean flags
-  {"BufferSecurityCheck", "GS", "Buffer security check", "TRUE", 0},
-  {"BufferSecurityCheck", "GS-", "Turn off Buffer security check", "FALSE", 0},
+  {"BufferSecurityCheck", "GS", "Buffer security check", "true", 0},
+  {"BufferSecurityCheck", "GS-", "Turn off Buffer security check", "false", 0},
   {"Detect64BitPortabilityProblems", "Wp64",
-   "Detect 64-bit Portability Problems", "TRUE", 0},
+   "Detect 64-bit Portability Problems", "true", 0},
   {"EnableFiberSafeOptimizations", "GT", "Enable Fiber-safe Optimizations",
-   "TRUE", 0},
+   "true", 0},
   {"EnableFunctionLevelLinking", "Gy",
-   "EnableFunctionLevelLinking", "TRUE", 0},
-  {"EnableIntrinsicFunctions", "Oi", "EnableIntrinsicFunctions", "TRUE", 0},
-  {"GlobalOptimizations", "Og", "Global Optimize", "TRUE", 0},
+   "EnableFunctionLevelLinking", "true", 0},
+  {"EnableIntrinsicFunctions", "Oi", "EnableIntrinsicFunctions", "true", 0},
+  {"GlobalOptimizations", "Og", "Global Optimize", "true", 0},
   {"ImproveFloatingPointConsistency", "Op",
-   "ImproveFloatingPointConsistency", "TRUE", 0},
-  {"MinimalRebuild", "Gm", "minimal rebuild", "TRUE", 0},
-  {"OmitFramePointers", "Oy", "OmitFramePointers", "TRUE", 0},
-  {"OptimizeForWindowsApplication", "GA", "Optimize for windows", "TRUE", 0},
+   "ImproveFloatingPointConsistency", "true", 0},
+  {"MinimalRebuild", "Gm", "minimal rebuild", "true", 0},
+  {"OmitFramePointers", "Oy", "OmitFramePointers", "true", 0},
+  {"OptimizeForWindowsApplication", "GA", "Optimize for windows", "true", 0},
   {"RuntimeTypeInfo", "GR",
-   "Turn on Run time type information for c++", "TRUE", 0},
+   "Turn on Run time type information for c++", "true", 0},
   {"RuntimeTypeInfo", "GR-",
-   "Turn off Run time type information for c++", "FALSE", 0},
-  {"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE", 0},
-  {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE", 0},
+   "Turn off Run time type information for c++", "false", 0},
+  {"SmallerTypeCheck", "RTCc", "smaller type check", "true", 0},
+  {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "true", 0},
   {"WholeProgramOptimization", "GL",
-   "Enables whole program optimization", "TRUE", 0},
+   "Enables whole program optimization", "true", 0},
   {"WholeProgramOptimization", "GL-",
-   "Disables whole program optimization", "FALSE", 0},
-  {"WarnAsError", "WX", "Treat warnings as errors", "TRUE", 0},
+   "Disables whole program optimization", "false", 0},
+  {"WarnAsError", "WX", "Treat warnings as errors", "true", 0},
   {"BrowseInformation", "FR", "Generate browse information", "1", 0},
-  {"StringPooling", "GF", "Enable StringPooling", "TRUE", 0},
+  {"StringPooling", "GF", "Enable StringPooling", "true", 0},
   {0,0,0,0,0}
 };
 
@@ -523,8 +523,8 @@
 {
   // option flags (some flags map to the same option)
   {"GenerateManifest", "MANIFEST:NO",
-   "disable manifest generation", "FALSE", 0},
-  {"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE", 0},
+   "disable manifest generation", "false", 0},
+  {"GenerateManifest", "MANIFEST", "enable manifest generation", "true", 0},
   {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1", 0},
   {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2", 0},
   {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0},
@@ -540,7 +540,7 @@
   {"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "default libs to ignore", "",
   cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
   {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "ignore all default libs",
-   "TRUE", 0},
+   "true", 0},
   {"FixedBaseAddress", "FIXED:NO", "Generate a relocation section", "1", 0},
   {"FixedBaseAddress", "FIXED", "Image must be loaded at a fixed address",
    "2", 0},
@@ -579,7 +579,7 @@
    "No assembly even if CLR information is present in objects.", "true", 0},
   {"ModuleDefinitionFile", "DEF:", "add an export def file", "",
    cmVS7FlagTable::UserValue},
-  {"GenerateMapFile", "MAP", "enable generation of map file", "TRUE", 0},
+  {"GenerateMapFile", "MAP", "enable generation of map file", "true", 0},
   {0,0,0,0,0}
 };
 
@@ -589,7 +589,7 @@
 {
 public:
   EventWriter(cmLocalVisualStudio7Generator* lg,
-              const char* config, std::ostream& os):
+              const std::string& config, std::ostream& os):
     LG(lg), Config(config), Stream(os), First(true) {}
   void Start(const char* tool)
     {
@@ -610,9 +610,10 @@
     }
   void Write(cmCustomCommand const& cc)
     {
+    cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
     if(this->First)
       {
-      const char* comment = cc.GetComment();
+      const char* comment = ccg.GetComment();
       if(comment && *comment)
         {
         this->Stream << "\nDescription=\""
@@ -625,21 +626,21 @@
       {
       this->Stream << this->LG->EscapeForXML("\n");
       }
-    std::string script = this->LG->ConstructScript(cc, this->Config);
+    std::string script = this->LG->ConstructScript(ccg);
     this->Stream << this->LG->EscapeForXML(script.c_str());
     }
 private:
   cmLocalVisualStudio7Generator* LG;
-  const char* Config;
+  std::string Config;
   std::ostream& Stream;
   bool First;
 };
 
 //----------------------------------------------------------------------------
 void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
-                                                       const char* configName,
-                                                       const char *libName,
-                                                       cmTarget &target)
+                                                const std::string& configName,
+                                                const std::string& libName,
+                                                cmTarget &target)
 {
   const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
   if(!mfcFlag)
@@ -660,7 +661,7 @@
   switch(target.GetType())
     {
     case cmTarget::OBJECT_LIBRARY:
-      targetBuilds = false; // TODO: PDB for object library?
+      targetBuilds = false; // no manifest tool for object library
     case cmTarget::STATIC_LIBRARY:
       projectType = "typeStaticLibrary";
       configType = "4";
@@ -687,17 +688,18 @@
   std::string flags;
   if(strcmp(configType, "10") != 0)
     {
-    const char* linkLanguage = (this->FortranProject? "Fortran":
+    const std::string& linkLanguage = (this->FortranProject?
+                                       std::string("Fortran"):
                                 target.GetLinkerLanguage(configName));
-    if(!linkLanguage)
+    if(linkLanguage.empty())
       {
       cmSystemTools::Error
         ("CMake can not determine linker language for target: ",
-         target.GetName());
+         target.GetName().c_str());
       return;
       }
-    if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
-      || strcmp(linkLanguage, "Fortran") == 0)
+    if(linkLanguage == "C" || linkLanguage == "CXX"
+      || linkLanguage == "Fortran")
       {
       std::string baseFlagVar = "CMAKE_";
       baseFlagVar += linkLanguage;
@@ -709,11 +711,11 @@
       flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
       }
     // set the correct language
-    if(strcmp(linkLanguage, "C") == 0)
+    if(linkLanguage == "C")
       {
       flags += " /TC ";
       }
-    if(strcmp(linkLanguage, "CXX") == 0)
+    if(linkLanguage == "CXX")
       {
       flags += " /TP ";
       }
@@ -745,7 +747,7 @@
                         table,
                         this->ExtraFlagTable);
   targetOptions.FixExceptionHandlingDefault();
-  std::string asmLocation = std::string(configName) + "/";
+  std::string asmLocation = configName + "/";
   targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
   targetOptions.Parse(flags.c_str());
   targetOptions.Parse(defineFlags.c_str());
@@ -780,7 +782,7 @@
        << "\"\n"
        << "\t\t\tConfigurationType=\"" << configType << "\"\n"
        << "\t\t\tUseOfMFC=\"" << mfcFlag << "\"\n"
-       << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n";
+       << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"false\"\n";
 
   // If unicode is enabled change the character set to unicode, if not
   // then default to MBCS.
@@ -846,6 +848,17 @@
   targetOptions.OutputFlagMap(fout, "\t\t\t\t");
   targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
   fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
+  if(target.GetType() <= cmTarget::OBJECT_LIBRARY)
+    {
+    // Specify the compiler program database file if configured.
+    std::string pdb = target.GetCompilePDBPath(configName);
+    if(!pdb.empty())
+      {
+      fout <<  "\t\t\t\tProgramDataBaseFileName=\""
+           << this->ConvertToXMLOutputPathSingle(pdb.c_str())
+           << "\"\n";
+      }
+    }
   fout << "/>\n";  // end of <Tool Name=VCCLCompilerTool
   tool = "VCCustomBuildTool";
   if(this->FortranProject)
@@ -882,7 +895,7 @@
     fout << ipath << ";";
     }
   fout << "\"\n";
-  fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n";
+  fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n";
   if( this->PlatformName == "x64" )
     {
     fout << "\t\t\t\tTargetEnvironment=\"3\"\n";
@@ -895,7 +908,7 @@
     {
     fout << "\t\t\t\tTargetEnvironment=\"1\"\n";
     }
-  fout << "\t\t\t\tGenerateStublessProxies=\"TRUE\"\n";
+  fout << "\t\t\t\tGenerateStublessProxies=\"true\"\n";
   fout << "\t\t\t\tTypeLibraryName=\"$(InputName).tlb\"\n";
   fout << "\t\t\t\tOutputDirectory=\"$(IntDir)\"\n";
   fout << "\t\t\t\tHeaderFileName=\"$(InputName).h\"\n";
@@ -933,7 +946,8 @@
 //----------------------------------------------------------------------------
 std::string
 cmLocalVisualStudio7Generator
-::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName)
+::GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
+                          const std::string& configName)
 {
   std::string configTypeUpper = cmSystemTools::UpperCase(configName);
   std::string extraLinkOptionsBuildTypeDef =
@@ -947,7 +961,8 @@
 }
 
 void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
-  const char* configName, cmTarget &target, const Options& targetOptions)
+  const std::string& configName, cmTarget &target,
+  const Options& targetOptions)
 {
   cmGlobalVisualStudio7Generator* gg =
     static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
@@ -1033,7 +1048,7 @@
     fout << "\t\t\t<Tool\n"
          << "\t\t\t\tName=\"" << tool << "\"\n";
 
-    if(this->GetVersion() < VS8)
+    if(this->GetVersion() < VS8 || this->FortranProject)
       {
       cmOStringStream libdeps;
       this->Internal->OutputObjects(libdeps, &target);
@@ -1070,7 +1085,7 @@
       return;
       }
     cmComputeLinkInformation& cli = *pcli;
-    const char* linkLanguage = cli.GetLinkLanguage();
+    std::string linkLanguage = cli.GetLinkLanguage();
 
     // Compute the variable name to lookup standard libraries for this
     // language.
@@ -1093,7 +1108,7 @@
     // libraries which may be set by the user to something bad.
     fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
          << this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
-    if(this->GetVersion() < VS8)
+    if(this->GetVersion() < VS8 || this->FortranProject)
       {
       this->Internal->OutputObjects(fout, &target, " ");
       }
@@ -1117,7 +1132,7 @@
       this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
     if(targetOptions.IsDebug())
       {
-      fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
+      fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n";
       }
     if(this->WindowsCEProject)
       {
@@ -1166,7 +1181,7 @@
       return;
       }
     cmComputeLinkInformation& cli = *pcli;
-    const char* linkLanguage = cli.GetLinkLanguage();
+    std::string linkLanguage = cli.GetLinkLanguage();
 
     bool isWin32Executable = target.GetPropertyAsBool("WIN32_EXECUTABLE");
 
@@ -1191,7 +1206,7 @@
     // libraries which may be set by the user to something bad.
     fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
          << this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
-    if(this->GetVersion() < VS8)
+    if(this->GetVersion() < VS8 || this->FortranProject)
       {
       this->Internal->OutputObjects(fout, &target, " ");
       }
@@ -1215,7 +1230,7 @@
          << "\"\n";
     if(targetOptions.IsDebug())
       {
-      fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
+      fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n";
       }
     if ( this->WindowsCEProject )
       {
@@ -1315,7 +1330,7 @@
   cmGeneratorTarget* gt =
     lg->GetGlobalGenerator()->GetGeneratorTarget(t);
   std::vector<std::string> objs;
-  gt->UseObjectLibraries(objs);
+  gt->UseObjectLibraries(objs, "");
   const char* sep = isep? isep : "";
   for(std::vector<std::string>::const_iterator
         oi = objs.begin(); oi != objs.end(); ++oi)
@@ -1368,7 +1383,7 @@
 }
 
 void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
-                                                    const char *libName,
+                                                    const std::string& libName,
                                                     cmTarget &target)
 {
   // get the configurations
@@ -1382,10 +1397,17 @@
   // get the classes from the source lists then add them to the groups
   this->ModuleDefinitionFile = "";
   std::vector<cmSourceFile*> classes;
-  target.GetSourceFiles(classes);
+  if (!target.GetConfigCommonSourceFiles(classes))
+    {
+    return;
+    }
   for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
       i != classes.end(); i++)
     {
+    if (!(*i)->GetObjectLibrary().empty())
+      {
+      continue;
+      }
     // Add the file to the list of sources.
     std::string source = (*i)->GetFullPath();
     if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
@@ -1412,14 +1434,14 @@
     this->WriteGroup(&sg, target, fout, libName, configs);
     }
 
-  if(this->GetVersion() >= VS8)
+  if(this->GetVersion() >= VS8 && !this->FortranProject)
     {
     // VS >= 8 support per-config source locations so we
     // list object library content as external objects.
     cmGeneratorTarget* gt =
       this->GlobalGenerator->GetGeneratorTarget(&target);
     std::vector<std::string> objs;
-    gt->UseObjectLibraries(objs);
+    gt->UseObjectLibraries(objs, "");
     if(!objs.empty())
       {
       // TODO: Separate sub-filter for each object library used?
@@ -1457,7 +1479,7 @@
                                       cmTarget& target,
                                       cmSourceFile const& sf,
                                       std::vector<std::string>* configs);
-  std::map<cmStdString, cmLVS7GFileConfig> FileConfigMap;
+  std::map<std::string, cmLVS7GFileConfig> FileConfigMap;
 };
 
 cmLocalVisualStudio7GeneratorFCInfo
@@ -1535,14 +1557,14 @@
         }
       }
 
-    const char* lang =
+    std::string lang =
       lg->GlobalGenerator->GetLanguageFromExtension
       (sf.GetExtension().c_str());
-    const char* sourceLang = lg->GetSourceFileLanguage(sf);
-    const char* linkLanguage = target.GetLinkerLanguage(i->c_str());
+    const std::string& sourceLang = lg->GetSourceFileLanguage(sf);
+    const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str());
     bool needForceLang = false;
     // source file does not match its extension language
-    if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
+    if(lang != sourceLang)
       {
       needForceLang = true;
       lang = sourceLang;
@@ -1558,16 +1580,15 @@
 
     // if the source file does not match the linker language
     // then force c or c++
-    if(needForceLang || (linkLanguage && lang
-                         && strcmp(lang, linkLanguage) != 0))
+    if(needForceLang || (linkLanguage != lang))
       {
-      if(strcmp(lang, "CXX") == 0)
+      if(lang == "CXX")
         {
         // force a C++ file type
         fc.CompileFlags += " /TP ";
         needfc = true;
         }
-      else if(strcmp(lang, "C") == 0)
+      else if(lang == "C")
         {
         // force to c
         fc.CompileFlags += " /TC ";
@@ -1616,7 +1637,7 @@
 
 bool cmLocalVisualStudio7Generator
 ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
-             std::ostream &fout, const char *libName,
+             std::ostream &fout, const std::string& libName,
              std::vector<std::string> *configs)
 {
   const std::vector<const cmSourceFile *> &sourceFiles =
@@ -1702,7 +1723,7 @@
             aCompilerTool = "VFCustomBuildTool";
             }
           }
-        for(std::map<cmStdString, cmLVS7GFileConfig>::const_iterator
+        for(std::map<std::string, cmLVS7GFileConfig>::const_iterator
               fci = fcinfo.FileConfigMap.begin();
             fci != fcinfo.FileConfigMap.end(); ++fci)
           {
@@ -1779,8 +1800,6 @@
                 const cmCustomCommand& command,
                 FCInfo& fcinfo)
 {
-  std::string comment = this->ConstructComment(command);
-
   // Write the rule for each configuration.
   std::vector<std::string>::iterator i;
   std::vector<std::string> *configs =
@@ -1798,6 +1817,7 @@
     }
   for(i = configs->begin(); i != configs->end(); ++i)
     {
+    cmCustomCommandGenerator ccg(command, *i, this->Makefile);
     cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
     fout << "\t\t\t\t<FileConfiguration\n";
     fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n";
@@ -1809,7 +1829,8 @@
            << this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n";
       }
 
-    std::string script = this->ConstructScript(command, i->c_str());
+    std::string comment = this->ConstructComment(ccg);
+    std::string script = this->ConstructScript(ccg);
     if(this->FortranProject)
       {
       cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
@@ -1821,7 +1842,7 @@
          << "\t\t\t\t\tCommandLine=\""
          << this->EscapeForXML(script.c_str()) << "\"\n"
          << "\t\t\t\t\tAdditionalDependencies=\"";
-    if(command.GetDepends().empty())
+    if(ccg.GetDepends().empty())
       {
       // There are no real dependencies.  Produce an artificial one to
       // make sure the rule runs reliably.
@@ -1836,8 +1857,8 @@
       {
       // Write out the dependencies for the rule.
       for(std::vector<std::string>::const_iterator d =
-          command.GetDepends().begin();
-          d != command.GetDepends().end();
+          ccg.GetDepends().begin();
+          d != ccg.GetDepends().end();
           ++d)
         {
         // Get the real name of the dependency in case it is a CMake target.
@@ -1851,7 +1872,7 @@
       }
     fout << "\"\n";
     fout << "\t\t\t\t\tOutputs=\"";
-    if(command.GetOutputs().empty())
+    if(ccg.GetOutputs().empty())
       {
       fout << source << "_force";
       }
@@ -1860,8 +1881,8 @@
       // Write a rule for the output generated by this command.
       const char* sep = "";
       for(std::vector<std::string>::const_iterator o =
-          command.GetOutputs().begin();
-          o != command.GetOutputs().end();
+          ccg.GetOutputs().begin();
+          o != ccg.GetOutputs().end();
           ++o)
         {
         fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
@@ -1893,9 +1914,9 @@
 // look for custom rules on a target and collect them together
 void cmLocalVisualStudio7Generator
 ::OutputTargetRules(std::ostream& fout,
-                    const char* configName,
+                    const std::string& configName,
                     cmTarget &target,
-                    const char * /*libName*/)
+                    const std::string& /*libName*/)
 {
   if (target.GetType() > cmTarget::GLOBAL_TARGET)
     {
@@ -1955,13 +1976,14 @@
 void
 cmLocalVisualStudio7Generator
 ::WriteProjectStartFortran(std::ostream& fout,
-                           const char *libName,
+                           const std::string& libName,
                            cmTarget & target)
 {
 
   cmGlobalVisualStudio7Generator* gg =
     static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
-  fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
+  fout << "<?xml version=\"1.0\" encoding = \""
+       << gg->Encoding() << "\"?>\n"
        << "<VisualStudioProject\n"
        << "\tProjectCreator=\"Intel Fortran\"\n"
        << "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n";
@@ -2006,7 +2028,7 @@
     }
   this->WriteProjectSCC(fout, target);
   fout<< "\tKeyword=\"" << keyword << "\">\n"
-       << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n"
+       << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n"
        << "\t<Platforms>\n"
        << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
        << "\t</Platforms>\n";
@@ -2015,7 +2037,7 @@
 
 void
 cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
-                                                 const char *libName,
+                                                 const std::string& libName,
                                                  cmTarget & target,
                                                  std::vector<cmSourceGroup> &)
 {
@@ -2024,7 +2046,12 @@
     this->WriteProjectStartFortran(fout, libName, target);
     return;
     }
-  fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
+
+  cmGlobalVisualStudio7Generator* gg =
+    static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
+
+  fout << "<?xml version=\"1.0\" encoding = \""
+       << gg->Encoding() << "\"?>\n"
        << "<VisualStudioProject\n"
        << "\tProjectType=\"Visual C++\"\n";
   if(this->Version == VS71)
@@ -2038,19 +2065,17 @@
   const char* projLabel = target.GetProperty("PROJECT_LABEL");
   if(!projLabel)
     {
-    projLabel = libName;
+    projLabel = libName.c_str();
     }
   const char* keyword = target.GetProperty("VS_KEYWORD");
   if(!keyword)
     {
     keyword = "Win32Proj";
     }
-  cmGlobalVisualStudio7Generator* gg =
-    static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
   fout << "\tName=\"" << projLabel << "\"\n";
   if(this->Version >= VS8)
     {
-    fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
+    fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n";
     }
   this->WriteProjectSCC(fout, target);
   if(const char* targetFrameworkVersion =
@@ -2090,7 +2115,7 @@
        << "</VisualStudioProject>\n";
 }
 
-std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s)
+std::string cmLocalVisualStudio7GeneratorEscapeForXML(const std::string& s)
 {
   std::string ret = s;
   cmSystemTools::ReplaceString(ret, "&", "&amp;");
@@ -2101,7 +2126,7 @@
   return ret;
 }
 
-std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
+std::string cmLocalVisualStudio7Generator::EscapeForXML(const std::string& s)
 {
   return cmLocalVisualStudio7GeneratorEscapeForXML(s);
 }
@@ -2134,10 +2159,10 @@
 class cmVS7XMLParser : public cmXMLParser
 {
 public:
-  virtual void EndElement(const char* /* name */)
+  virtual void EndElement(const std::string& /* name */)
     {
     }
-  virtual void StartElement(const char* name, const char** atts)
+  virtual void StartElement(const std::string& name, const char** atts)
     {
       // once the GUID is found do nothing
       if(this->GUID.size())
@@ -2145,7 +2170,7 @@
         return;
         }
       int i =0;
-      if(strcmp("VisualStudioProject", name) == 0)
+      if("VisualStudioProject" == name)
         {
         while(atts[i])
           {
@@ -2182,7 +2207,7 @@
 };
 
 void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
-  const char* name,
+  const std::string& name,
   const char* path)
 {
   cmVS7XMLParser parser;
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 92e4d3c..6c04559 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -51,9 +51,9 @@
   /**
    * Specify the type of the build: static, dll, or executable.
    */
-  void SetBuildType(BuildType,const char *name);
+  void SetBuildType(BuildType,const std::string& name);
 
-  void SetPlatformName(const char* n) { this->PlatformName = n;}
+  void SetPlatformName(const std::string& n) { this->PlatformName = n;}
 
   void SetExtraFlagTable(cmVS7FlagTable const* table)
     { this->ExtraFlagTable = table; }
@@ -62,41 +62,41 @@
   void WriteStampFiles();
   virtual std::string ComputeLongestObjectDirectory(cmTarget&) const;
 
-  virtual void ReadAndStoreExternalGUID(const char* name,
+  virtual void ReadAndStoreExternalGUID(const std::string& name,
                                         const char* path);
   virtual void AddCMakeListsRules();
 protected:
-  void CreateSingleVCProj(const char *lname, cmTarget &tgt);
+  void CreateSingleVCProj(const std::string& lname, cmTarget &tgt);
 private:
   typedef cmVisualStudioGeneratorOptions Options;
   typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
   std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
-                                      const char* configName);
+                                      const std::string& configName);
   void FixGlobalTargets();
   void WriteProjectFiles();
-  void WriteVCProjHeader(std::ostream& fout, const char *libName,
+  void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
                          cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
   void WriteVCProjFooter(std::ostream& fout, cmTarget &target);
-  void WriteVCProjFile(std::ostream& fout, const char *libName,
+  void WriteVCProjFile(std::ostream& fout, const std::string& libName,
                        cmTarget &tgt);
   void WriteConfigurations(std::ostream& fout,
-                           const char *libName, cmTarget &tgt);
+                           const std::string& libName, cmTarget &tgt);
   void WriteConfiguration(std::ostream& fout,
-                          const char* configName,
-                          const char* libName, cmTarget &tgt);
-  std::string EscapeForXML(const char* s);
+                          const std::string& configName,
+                          const std::string& libName, cmTarget &tgt);
+  std::string EscapeForXML(const std::string& s);
   std::string ConvertToXMLOutputPath(const char* path);
   std::string ConvertToXMLOutputPathSingle(const char* path);
-  void OutputTargetRules(std::ostream& fout, const char* configName,
-                         cmTarget &target, const char *libName);
-  void OutputBuildTool(std::ostream& fout, const char* configName,
+  void OutputTargetRules(std::ostream& fout, const std::string& configName,
+                         cmTarget &target, const std::string& libName);
+  void OutputBuildTool(std::ostream& fout, const std::string& configName,
                        cmTarget& t, const Options& targetOptions);
   void OutputLibraryDirectories(std::ostream& fout,
                                 std::vector<std::string> const& dirs);
   void WriteProjectSCC(std::ostream& fout, cmTarget& target);
-  void WriteProjectStart(std::ostream& fout, const char *libName,
+  void WriteProjectStart(std::ostream& fout, const std::string& libName,
                          cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
-  void WriteProjectStartFortran(std::ostream& fout, const char *libName,
+  void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
                                 cmTarget &tgt);
   void WriteVCProjBeginGroup(std::ostream& fout,
                           const char* group,
@@ -111,7 +111,8 @@
 
   bool WriteGroup(const cmSourceGroup *sg,
                   cmTarget& target, std::ostream &fout,
-                  const char *libName, std::vector<std::string> *configs);
+                  const std::string& libName,
+                  std::vector<std::string> *configs);
 
   friend class cmLocalVisualStudio7GeneratorFCInfo;
   friend class cmLocalVisualStudio7GeneratorInternals;
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index ef2bb1d..9680d43 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -31,9 +31,49 @@
 }
 
 //----------------------------------------------------------------------------
+void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const* gt)
+{
+  std::string dir_max = this->ComputeLongestObjectDirectory(*gt->Target);
+
+  // Count the number of object files with each name.  Note that
+  // windows file names are not case sensitive.
+  std::map<std::string, int> counts;
+
+  for(std::map<cmSourceFile const*, std::string>::iterator
+      si = mapping.begin(); si != mapping.end(); ++si)
+    {
+    cmSourceFile const* sf = si->first;
+    std::string objectNameLower = cmSystemTools::LowerCase(
+      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
+    objectNameLower += ".obj";
+    counts[objectNameLower] += 1;
+    }
+
+  // For all source files producing duplicate names we need unique
+  // object name computation.
+
+  for(std::map<cmSourceFile const*, std::string>::iterator
+      si = mapping.begin(); si != mapping.end(); ++si)
+    {
+    cmSourceFile const* sf = si->first;
+    std::string objectName =
+      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
+    objectName += ".obj";
+    if(counts[cmSystemTools::LowerCase(objectName)] > 1)
+      {
+      const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf);
+      objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
+      }
+    si->second = objectName;
+    }
+}
+
+//----------------------------------------------------------------------------
 cmsys::auto_ptr<cmCustomCommand>
 cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
-                                                   const char* config,
+                                                   const std::string& config,
                                                    bool isFortran)
 {
   cmsys::auto_ptr<cmCustomCommand> pcc;
@@ -79,17 +119,15 @@
 //----------------------------------------------------------------------------
 std::string
 cmLocalVisualStudioGenerator
-::ConstructScript(cmCustomCommand const& cc,
-                  const char* configName,
-                  const char* newline_text)
+::ConstructScript(cmCustomCommandGenerator const& ccg,
+                  const std::string& newline_text)
 {
   bool useLocal = this->CustomCommandUseLocal();
-  const char* workingDirectory = cc.GetWorkingDirectory();
-  cmCustomCommandGenerator ccg(cc, configName, this->Makefile);
-  RelativeRoot relativeRoot = workingDirectory? NONE : START_OUTPUT;
+  std::string workingDirectory = ccg.GetWorkingDirectory();
+  RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE;
 
   // Avoid leading or trailing newlines.
-  const char* newline = "";
+  std::string newline = "";
 
   // Line to check for error between commands.
   std::string check_error = newline_text;
@@ -114,7 +152,7 @@
     script += "setlocal";
     }
 
-  if(workingDirectory)
+  if(!workingDirectory.empty())
     {
     // Change the working directory.
     script += newline;
@@ -124,7 +162,7 @@
     script += check_error;
 
     // Change the working drive.
-    if(workingDirectory[0] && workingDirectory[1] == ':')
+    if(workingDirectory.size() > 1 && workingDirectory[1] == ':')
       {
       script += newline;
       newline = newline_text;
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index 1a3499a..3bf4f43 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -19,6 +19,7 @@
 class cmSourceFile;
 class cmSourceGroup;
 class cmCustomCommand;
+class cmCustomCommandGenerator;
 
 /** \class cmLocalVisualStudioGenerator
  * \brief Base class for Visual Studio generators.
@@ -46,9 +47,8 @@
   virtual ~cmLocalVisualStudioGenerator();
 
   /** Construct a script from the given list of command lines.  */
-  std::string ConstructScript(cmCustomCommand const& cc,
-                              const char* configName,
-                              const char* newline = "\n");
+  std::string ConstructScript(cmCustomCommandGenerator const& ccg,
+                              const std::string& newline = "\n");
 
   /** Label to which to jump in a batch file after a failed step in a
       sequence of custom commands. */
@@ -61,13 +61,18 @@
 
   virtual void AddCMakeListsRules() = 0;
 
+  virtual void ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const* = 0);
+
 protected:
   virtual const char* ReportErrorLabel() const;
   virtual bool CustomCommandUseLocal() const { return false; }
 
   /** Construct a custom command to make exe import lib dir.  */
   cmsys::auto_ptr<cmCustomCommand>
-  MaybeCreateImplibDir(cmTarget& target, const char* config, bool isFortran);
+  MaybeCreateImplibDir(cmTarget& target, const std::string& config,
+                       bool isFortran);
 
   VSVersion Version;
 };
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index a9a27b9..8ff6c87 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -37,7 +37,7 @@
 
 //----------------------------------------------------------------------------
 void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
-                                             const char* rawFlag)
+                                             const std::string& rawFlag)
 {
   cmGlobalXCodeGenerator* gg =
     static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator);
@@ -54,7 +54,7 @@
       iter != targets.end(); ++iter)
     {
     cmTarget* t = &iter->second;
-    t->HasMacOSXRpathInstallNameDir(NULL);
+    t->HasMacOSXRpathInstallNameDir("");
     }
 }
 
@@ -68,6 +68,34 @@
       iter != targets.end(); ++iter)
     {
     cmTarget* t = &iter->second;
-    t->HasMacOSXRpathInstallNameDir(NULL);
+    t->HasMacOSXRpathInstallNameDir("");
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmLocalXCodeGenerator::ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const*)
+{
+  // Count the number of object files with each name. Warn about duplicate
+  // names since Xcode names them uniquely automatically with a numeric suffix
+  // to avoid exact duplicate file names. Note that Mac file names are not
+  // typically case sensitive, hence the LowerCase.
+  std::map<std::string, int> counts;
+  for(std::map<cmSourceFile const*, std::string>::iterator
+      si = mapping.begin(); si != mapping.end(); ++si)
+    {
+    cmSourceFile const* sf = si->first;
+    std::string objectName =
+      cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
+    objectName += ".o";
+
+    std::string objectNameLower = cmSystemTools::LowerCase(objectName);
+    counts[objectNameLower] += 1;
+    if (2 == counts[objectNameLower])
+      {
+      // TODO: emit warning about duplicate name?
+      }
+    si->second = objectName;
     }
 }
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index edd2f5b..f553a17 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -28,9 +28,13 @@
 
   virtual ~cmLocalXCodeGenerator();
   virtual std::string GetTargetDirectory(cmTarget const& target) const;
-  virtual void AppendFlagEscape(std::string& flags, const char* rawFlag);
+  virtual void AppendFlagEscape(std::string& flags,
+                                const std::string& rawFlag);
   virtual void Generate();
   virtual void GenerateInstallRules();
+  virtual void ComputeObjectFilenames(
+                        std::map<cmSourceFile const*, std::string>& mapping,
+                        cmGeneratorTarget const* gt = 0);
 private:
 
 };
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 499d3c6..ae81c58 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -20,7 +20,7 @@
   cmMacroHelperCommand() {}
 
   ///! clean up any memory allocated by the macro
-  ~cmMacroHelperCommand() {};
+  ~cmMacroHelperCommand() {}
 
   /**
    * This is used to avoid including this command
@@ -60,12 +60,12 @@
                                  cmExecutionStatus &);
 
   virtual bool InitialPass(std::vector<std::string> const&,
-                           cmExecutionStatus &) { return false; };
+                           cmExecutionStatus &) { return false; }
 
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return this->Args[0].c_str(); }
+  virtual std::string GetName() const { return this->Args[0]; }
 
   cmTypeMacro(cmMacroHelperCommand, cmCommand);
 
@@ -95,7 +95,7 @@
     std::string errorMsg =
       "Macro invoked with incorrect arguments for macro named: ";
     errorMsg += this->Args[0];
-    this->SetError(errorMsg.c_str());
+    this->SetError(errorMsg);
     return false;
     }
 
@@ -276,8 +276,8 @@
       f->Functions = this->Functions;
       mf.RecordPolicies(f->Policies);
       std::string newName = "_" + this->Args[0];
-      mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(),
-                                           newName.c_str());
+      mf.GetCMakeInstance()->RenameCommand(this->Args[0],
+                                           newName);
       mf.AddCommand(f);
 
       // remove the function blocker now that the macro is defined
diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h
index 4c585d8..5c1cc00 100644
--- a/Source/cmMacroCommand.h
+++ b/Source/cmMacroCommand.h
@@ -57,7 +57,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "macro";}
+  virtual std::string GetName() const { return "macro";}
 
   cmTypeMacro(cmMacroCommand, cmCommand);
 };
diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index 615e6f2..52832db 100644
--- a/Source/cmMakeDepend.cxx
+++ b/Source/cmMakeDepend.cxx
@@ -74,7 +74,7 @@
                       cmGeneratorExpression::StripAllGeneratorExpressions);
 
     std::vector<std::string> includes;
-    cmSystemTools::ExpandListArgument(incDirs.c_str(), includes);
+    cmSystemTools::ExpandListArgument(incDirs, includes);
 
     for(std::vector<std::string>::const_iterator j = includes.begin();
         j != includes.end(); ++j)
@@ -93,7 +93,7 @@
     it != orderedAndUniqueIncludes.end();
     ++it)
     {
-    this->AddSearchPath(it->c_str());
+    this->AddSearchPath(*it);
     }
 }
 
@@ -165,7 +165,7 @@
     {
     // Try to find the file amongst the sources
     cmSourceFile *srcFile = this->Makefile->GetSource
-      (cmSystemTools::GetFilenameWithoutExtension(path).c_str());
+      (cmSystemTools::GetFilenameWithoutExtension(path));
     if (srcFile)
       {
       if (srcFile->GetFullPath() == path)
@@ -281,7 +281,7 @@
     // Didn't find an instance.  Create a new one and save it.
     cmDependInformation* info = new cmDependInformation;
     info->FullPath = fullPath;
-    info->PathOnly = cmSystemTools::GetFilenamePath(fullPath.c_str());
+    info->PathOnly = cmSystemTools::GetFilenamePath(fullPath);
     info->IncludeName = file;
     this->DependInformationMap[fullPath] = info;
     return info;
@@ -359,7 +359,7 @@
 }
 
 // Add a directory to the search path
-void cmMakeDepend::AddSearchPath(const char* path)
+void cmMakeDepend::AddSearchPath(const std::string& path)
 {
   this->IncludeDirectories.push_back(path);
 }
diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h
index b6e3928..2c9d515 100644
--- a/Source/cmMakeDepend.h
+++ b/Source/cmMakeDepend.h
@@ -94,7 +94,7 @@
   /**
    * Add a directory to the search path for include files.
    */
-  virtual void AddSearchPath(const char*);
+  virtual void AddSearchPath(const std::string&);
 
   /**
    * Generate dependencies for the file given.  Returns a pointer to
@@ -138,10 +138,10 @@
   cmsys::RegularExpression IncludeFileRegularExpression;
   cmsys::RegularExpression ComplainFileRegularExpression;
   std::vector<std::string> IncludeDirectories;
-  typedef std::map<cmStdString, cmStdString> FileToPathMapType;
-  typedef std::map<cmStdString, FileToPathMapType>
+  typedef std::map<std::string, std::string> FileToPathMapType;
+  typedef std::map<std::string, FileToPathMapType>
   DirectoryToFileToPathMapType;
-  typedef std::map<cmStdString, cmDependInformation*>
+  typedef std::map<std::string, cmDependInformation*>
   DependInformationMapType;
   DependInformationMapType DependInformationMap;
   DirectoryToFileToPathMapType DirectoryToFileToPathMap;
diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx
index 63be627..cc871c9 100644
--- a/Source/cmMakeDirectoryCommand.cxx
+++ b/Source/cmMakeDirectoryCommand.cxx
@@ -24,7 +24,7 @@
       {
       std::string e = "attempted to create a directory: " + args[0]
         + " into a source directory.";
-      this->SetError(e.c_str());
+      this->SetError(e);
       cmSystemTools::SetFatalErrorOccured();
       return false;
       }
diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h
index 49a4009..71b97eb 100644
--- a/Source/cmMakeDirectoryCommand.h
+++ b/Source/cmMakeDirectoryCommand.h
@@ -44,7 +44,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "make_directory";}
+  virtual std::string GetName() const { return "make_directory";}
 
   /**
    * This determines if the command is invoked when in script mode.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 27ce999..630957f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -45,8 +45,8 @@
 {
 public:
   std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack;
-  std::stack<std::set<cmStdString> > VarInitStack;
-  std::stack<std::set<cmStdString> > VarUsageStack;
+  std::stack<std::set<std::string> > VarInitStack;
+  std::stack<std::set<std::string> > VarUsageStack;
   bool IsSourceFileTryCompile;
 };
 
@@ -54,7 +54,7 @@
 cmMakefile::cmMakefile(): Internal(new Internals)
 {
   const cmDefinitions& defs = cmDefinitions();
-  const std::set<cmStdString> globalKeys = defs.LocalKeys();
+  const std::set<std::string> globalKeys = defs.LocalKeys();
   this->Internal->VarStack.push(defs);
   this->Internal->VarInitStack.push(globalKeys);
   this->Internal->VarUsageStack.push(globalKeys);
@@ -101,6 +101,9 @@
   this->Initialize();
   this->PreOrder = false;
   this->GeneratingBuildSystem = false;
+
+  this->NumLastMatches = 0;
+  this->SuppressWatches = false;
 }
 
 cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
@@ -149,6 +152,9 @@
   this->CheckSystemVars = mf.CheckSystemVars;
   this->ListFileStack = mf.ListFileStack;
   this->OutputToSource = mf.OutputToSource;
+
+  this->NumLastMatches = mf.NumLastMatches;
+  this->SuppressWatches = mf.SuppressWatches;
 }
 
 //----------------------------------------------------------------------------
@@ -157,6 +163,7 @@
   this->cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)");
   this->cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");
   this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
+  this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{");
 
   // Enter a policy level for this directory.
   this->PushPolicy();
@@ -203,7 +210,7 @@
     {
     delete *i;
     }
-  for(std::map<cmStdString, cmTest*>::iterator i = this->Tests.begin();
+  for(std::map<std::string, cmTest*>::iterator i = this->Tests.begin();
       i != this->Tests.end(); ++i)
     {
     delete i->second;
@@ -240,20 +247,20 @@
   for(std::vector<std::string>::const_iterator i = v.begin();
       i != v.end(); ++i)
     {
-    std::cout << (*i).c_str() << " ";
+    std::cout << *i << " ";
     }
   std::cout << " )\n";
 }
 
 void cmMakefile
 ::PrintStringVector(const char* s,
-                    const std::vector<std::pair<cmStdString, bool> >& v) const
+                    const std::vector<std::pair<std::string, bool> >& v) const
 {
   std::cout << s << ": ( \n";
-  for(std::vector<std::pair<cmStdString, bool> >::const_iterator i
+  for(std::vector<std::pair<std::string, bool> >::const_iterator i
         = v.begin(); i != v.end(); ++i)
     {
-    std::cout << i->first.c_str() << " " << i->second;
+    std::cout << i->first << " " << i->second;
     }
   std::cout << " )\n";
 }
@@ -273,15 +280,15 @@
     }
 
   std::cout << " this->StartOutputDirectory; " <<
-    this->StartOutputDirectory.c_str() << std::endl;
+    this->StartOutputDirectory << std::endl;
   std::cout << " this->HomeOutputDirectory; " <<
-    this->HomeOutputDirectory.c_str() << std::endl;
+    this->HomeOutputDirectory << std::endl;
   std::cout << " this->cmStartDirectory; " <<
-    this->cmStartDirectory.c_str() << std::endl;
+    this->cmStartDirectory << std::endl;
   std::cout << " this->cmHomeDirectory; " <<
-    this->cmHomeDirectory.c_str() << std::endl;
+    this->cmHomeDirectory << std::endl;
   std::cout << " this->ProjectName; "
-            <<  this->ProjectName.c_str() << std::endl;
+            <<  this->ProjectName << std::endl;
   this->PrintStringVector("this->LinkDirectories", this->LinkDirectories);
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   for( std::vector<cmSourceGroup>::const_iterator i =
@@ -303,14 +310,19 @@
                               std::string const& text) const
 {
   // Collect context information.
-  cmListFileBacktrace backtrace;
+  cmLocalGenerator* localGen = this->GetLocalGenerator();
+  if(this->CallStack.empty() && this->GetCMakeInstance()->GetIsInTryCompile())
+    {
+    localGen = 0;
+    }
+  cmListFileBacktrace backtrace(localGen);
   if(!this->CallStack.empty())
     {
     if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR))
       {
       this->CallStack.back().Status->SetNestedError(true);
       }
-    this->GetBacktrace(backtrace);
+    backtrace = this->GetBacktrace();
     }
   else
     {
@@ -328,11 +340,6 @@
       lfc.FilePath = this->ListFileStack.back();
       }
     lfc.Line = 0;
-    if(!this->GetCMakeInstance()->GetIsInTryCompile())
-      {
-      lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath.c_str(),
-                                                   cmLocalGenerator::HOME);
-      }
     backtrace.push_back(lfc);
     }
 
@@ -341,21 +348,15 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const
+cmListFileBacktrace cmMakefile::GetBacktrace() const
 {
-  if(this->CallStack.empty())
-    {
-    return false;
-    }
+  cmListFileBacktrace backtrace(this->GetLocalGenerator());
   for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin();
       i != this->CallStack.rend(); ++i)
     {
-    cmListFileContext lfc = *(*i).Context;
-    lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath.c_str(),
-                                                 cmLocalGenerator::HOME);
-    backtrace.push_back(lfc);
+    backtrace.push_back(*i->Context);
     }
-  return true;
+  return backtrace;
 }
 
 //----------------------------------------------------------------------------
@@ -394,7 +395,7 @@
   static_cast<void>(stack_manager);
 
   // Lookup the command prototype.
-  if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name.c_str()))
+  if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name))
     {
     // Clone the prototype.
     cmsys::auto_ptr<cmCommand> pcmd(proto->Clone());
@@ -756,7 +757,7 @@
       case cmPolicies::WARN:
         // Warn because the user did not provide a mimimum required
         // version.
-        this->IssueMessage(cmake::AUTHOR_WARNING, msg.str().c_str());
+        this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
       case cmPolicies::OLD:
         // OLD behavior is to use policy version 2.4 set in
         // cmListFileCache.
@@ -765,7 +766,7 @@
       case cmPolicies::REQUIRED_ALWAYS:
       case cmPolicies::NEW:
         // NEW behavior is to issue an error.
-        this->IssueMessage(cmake::FATAL_ERROR, msg.str().c_str());
+        this->IssueMessage(cmake::FATAL_ERROR, msg.str());
         cmSystemTools::SetFatalErrorOccured();
         return;
       }
@@ -878,7 +879,7 @@
 
 //----------------------------------------------------------------------------
 void
-cmMakefile::AddCustomCommandToTarget(const char* target,
+cmMakefile::AddCustomCommandToTarget(const std::string& target,
                                      const std::vector<std::string>& depends,
                                      const cmCustomCommandLines& commandLines,
                                      cmTarget::CustomCommandType type,
@@ -912,7 +913,7 @@
     if(issueMessage)
       {
       e << "The target name \"" << target << "\" is unknown in this context.";
-      IssueMessage(messageType, e.str().c_str());
+      IssueMessage(messageType, e.str());
       }
 
       return;
@@ -958,7 +959,7 @@
 cmSourceFile*
 cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
                                      const std::vector<std::string>& depends,
-                                     const char* main_dependency,
+                                     const std::string& main_dependency,
                                      const cmCustomCommandLines& commandLines,
                                      const char* comment,
                                      const char* workingDir,
@@ -988,7 +989,7 @@
 
   // Choose a source file on which to store the custom command.
   cmSourceFile* file = 0;
-  if(main_dependency && main_dependency[0])
+  if(!main_dependency.empty())
     {
     // The main dependency was specified.  Use it unless a different
     // custom command already used it.
@@ -1026,7 +1027,7 @@
     std::string outName = gg->GenerateRuleFile(outputs[0]);
 
     // Check if the rule file already exists.
-    file = this->GetSource(outName.c_str());
+    file = this->GetSource(outName);
     if(file && file->GetCustomCommand() && !replace)
       {
       // The rule file already exists.
@@ -1040,7 +1041,7 @@
       }
 
     // Create a cmSourceFile for the rule file.
-    file = this->GetOrCreateSource(outName.c_str(), true);
+    file = this->GetOrCreateSource(outName, true);
     file->SetProperty("__CMAKE_RULE", "1");
     }
 
@@ -1048,7 +1049,7 @@
   for(std::vector<std::string>::const_iterator o = outputs.begin();
       o != outputs.end(); ++o)
     {
-    if(cmSourceFile* out = this->GetOrCreateSource(o->c_str(), true))
+    if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
       {
       out->SetProperty("GENERATED", "1");
       }
@@ -1056,7 +1057,7 @@
 
   // Construct a complete list of dependencies.
   std::vector<std::string> depends2(depends);
-  if(main_dependency && main_dependency[0])
+  if(!main_dependency.empty())
     {
     depends2.push_back(main_dependency);
     }
@@ -1110,9 +1111,9 @@
 
 //----------------------------------------------------------------------------
 cmSourceFile*
-cmMakefile::AddCustomCommandToOutput(const char* output,
+cmMakefile::AddCustomCommandToOutput(const std::string& output,
                                      const std::vector<std::string>& depends,
-                                     const char* main_dependency,
+                                     const std::string& main_dependency,
                                      const cmCustomCommandLines& commandLines,
                                      const char* comment,
                                      const char* workingDir,
@@ -1128,16 +1129,16 @@
 
 //----------------------------------------------------------------------------
 void
-cmMakefile::AddCustomCommandOldStyle(const char* target,
+cmMakefile::AddCustomCommandOldStyle(const std::string& target,
                                      const std::vector<std::string>& outputs,
                                      const std::vector<std::string>& depends,
-                                     const char* source,
+                                     const std::string& source,
                                      const cmCustomCommandLines& commandLines,
                                      const char* comment)
 {
   // Translate the old-style signature to one of the new-style
   // signatures.
-  if(strcmp(source, target) == 0)
+  if(source == target)
     {
     // In the old-style signature if the source and target were the
     // same then it added a post-build rule to the target.  Preserve
@@ -1168,7 +1169,7 @@
     else
       {
       // The source may not be a real file.  Do not use a main dependency.
-      const char* no_main_dependency = 0;
+      std::string no_main_dependency = "";
       std::vector<std::string> depends2 = depends;
       depends2.push_back(source);
       sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
@@ -1182,12 +1183,13 @@
       {
       if (this->Targets.find(target) != this->Targets.end())
         {
-        this->Targets[target].AddSourceFile(sf);
+        this->Targets[target].AddSource(sf->GetFullPath());
         }
       else
         {
         cmSystemTools::Error("Attempt to add a custom rule to a target "
-                             "that does not exist yet for target ", target);
+                             "that does not exist yet for target ",
+                             target.c_str());
         return;
         }
       }
@@ -1195,7 +1197,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmMakefile::AddUtilityCommand(const char* utilityName,
+void cmMakefile::AddUtilityCommand(const std::string& utilityName,
                                    bool excludeFromAll,
                                    const std::vector<std::string>& depends,
                                    const char* workingDirectory,
@@ -1234,7 +1236,7 @@
 
 //----------------------------------------------------------------------------
 cmTarget*
-cmMakefile::AddUtilityCommand(const char* utilityName,
+cmMakefile::AddUtilityCommand(const std::string& utilityName,
                               bool excludeFromAll,
                               const char* workingDirectory,
                               const std::vector<std::string>& depends,
@@ -1258,14 +1260,14 @@
   force += cmake::GetCMakeFilesDirectory();
   force += "/";
   force += utilityName;
-  const char* no_main_dependency = 0;
+  std::string no_main_dependency = "";
   bool no_replace = false;
-  this->AddCustomCommandToOutput(force.c_str(), depends,
+  this->AddCustomCommandToOutput(force, depends,
                                  no_main_dependency,
                                  commandLines, comment,
                                  workingDirectory, no_replace,
                                  escapeOldStyle);
-  cmSourceFile* sf = target->AddSource(force.c_str());
+  cmSourceFile* sf = target->AddSourceCMP0049(force);
 
   // The output is not actually created so mark it symbolic.
   if(sf)
@@ -1385,8 +1387,8 @@
 
   // VS6 IDE does not support definition values with spaces in
   // combination with '"', '$', or ';'.
-  if((strcmp(this->LocalGenerator->GetGlobalGenerator()->GetName(),
-             "Visual Studio 6") == 0) &&
+  if((this->LocalGenerator->GetGlobalGenerator()->GetName() ==
+             "Visual Studio 6") &&
      (def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos))
     {
     return false;
@@ -1461,7 +1463,7 @@
   return true;
 }
 
-void cmMakefile::AddLinkLibrary(const char* lib,
+void cmMakefile::AddLinkLibrary(const std::string& lib,
                                 cmTarget::LinkLibraryType llt)
 {
   cmTarget::LibraryID tmp;
@@ -1470,15 +1472,15 @@
   this->LinkLibraries.push_back(tmp);
 }
 
-void cmMakefile::AddLinkLibraryForTarget(const char *target,
-                                         const char* lib,
+void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
+                                         const std::string& lib,
                                          cmTarget::LinkLibraryType llt)
 {
   cmTargets::iterator i = this->Targets.find(target);
   if ( i != this->Targets.end())
     {
     cmTarget* tgt =
-      this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0,lib);
+      this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(lib);
     if(tgt)
       {
       // if it is not a static or shared library then you can not link to it
@@ -1493,7 +1495,7 @@
           << " may not be linked into another target.  "
           << "One may link only to STATIC or SHARED libraries, or "
           << "to executables with the ENABLE_EXPORTS property set.";
-        this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+        this->IssueMessage(cmake::FATAL_ERROR, e.str());
         }
       }
     i->second.AddLinkLibrary( *this, target, lib, llt );
@@ -1504,12 +1506,12 @@
     e << "Attempt to add link library \""
       << lib << "\" to target \""
       << target << "\" which is not built in this directory.";
-    this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    this->IssueMessage(cmake::FATAL_ERROR, e.str());
     }
 }
 
-void cmMakefile::AddLinkDirectoryForTarget(const char *target,
-                                           const char* d)
+void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
+                                           const std::string& d)
 {
   cmTargets::iterator i = this->Targets.find(target);
   if ( i != this->Targets.end())
@@ -1519,7 +1521,7 @@
       cmOStringStream e;
       e << "ALIAS target \"" << target << "\" "
         << "may not be linked into another target.";
-      this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+      this->IssueMessage(cmake::FATAL_ERROR, e.str());
       return;
       }
     i->second.AddLinkDirectory( d );
@@ -1528,46 +1530,37 @@
     {
     cmSystemTools::Error
       ("Attempt to add link directories to non-existent target: ",
-       target, " for directory ", d);
+       target.c_str(), " for directory ", d.c_str());
     }
 }
 
-void cmMakefile::AddLinkLibrary(const char* lib)
+void cmMakefile::AddLinkLibrary(const std::string& lib)
 {
   this->AddLinkLibrary(lib,cmTarget::GENERAL);
 }
 
-void cmMakefile::AddLinkDirectory(const char* dir)
+void cmMakefile::AddLinkDirectory(const std::string& dir)
 {
   // Don't add a link directory that is already present.  Yes, this
   // linear search results in n^2 behavior, but n won't be getting
   // much bigger than 20.  We cannot use a set because of order
   // dependency of the link search path.
 
-  if(!dir)
+  if(dir.empty())
     {
     return;
     }
+  std::string newdir = dir;
   // remove trailing slashes
-  if(dir[strlen(dir)-1] == '/')
+  if(*dir.rbegin() == '/')
     {
-    std::string newdir = dir;
-    newdir = newdir.substr(0, newdir.size()-1);
-    if(std::find(this->LinkDirectories.begin(),
-                 this->LinkDirectories.end(),
-                 newdir.c_str()) == this->LinkDirectories.end())
-      {
-      this->LinkDirectories.push_back(newdir);
-      }
+    newdir = dir.substr(0, dir.size()-1);
     }
-  else
+  if(std::find(this->LinkDirectories.begin(),
+               this->LinkDirectories.end(), newdir)
+      == this->LinkDirectories.end())
     {
-    if(std::find(this->LinkDirectories.begin(),
-                 this->LinkDirectories.end(), dir)
-       == this->LinkDirectories.end())
-      {
-      this->LinkDirectories.push_back(dir);
-      }
+    this->LinkDirectories.push_back(dir);
     }
 }
 
@@ -1621,8 +1614,8 @@
       {
       std::string defPropName = "COMPILE_DEFINITIONS_";
       defPropName += cmSystemTools::UpperCase(*ci);
-      const char* prop = parent->GetProperty(defPropName.c_str());
-      this->SetProperty(defPropName.c_str(), prop);
+      const char* prop = parent->GetProperty(defPropName);
+      this->SetProperty(defPropName, prop);
       }
     }
 
@@ -1664,7 +1657,7 @@
     }
 }
 
-void cmMakefile::AddSubDirectory(const char* sub,
+void cmMakefile::AddSubDirectory(const std::string& sub,
                                  bool excludeFromAll, bool preorder)
 {
   // the source path must be made full if it isn't already
@@ -1686,12 +1679,13 @@
     }
 
 
-  this->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
+  this->AddSubDirectory(srcPath, binPath,
                         excludeFromAll, preorder, false);
 }
 
 
-void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath,
+void cmMakefile::AddSubDirectory(const std::string& srcPath,
+                                 const std::string& binPath,
                                  bool excludeFromAll, bool preorder,
                                  bool immediate)
 {
@@ -1745,8 +1739,7 @@
                               before ? this->IncludeDirectoriesEntries.begin()
                                     : this->IncludeDirectoriesEntries.end();
 
-  cmListFileBacktrace lfbt;
-  this->GetBacktrace(lfbt);
+  cmListFileBacktrace lfbt = this->GetBacktrace();
   cmValueWithOrigin entry(incString, lfbt);
   this->IncludeDirectoriesEntries.insert(position, entry);
 
@@ -1761,9 +1754,9 @@
 
 //----------------------------------------------------------------------------
 void
-cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
+cmMakefile::AddSystemIncludeDirectories(const std::set<std::string> &incs)
 {
-  for(std::set<cmStdString>::const_iterator li = incs.begin();
+  for(std::set<std::string>::const_iterator li = incs.begin();
       li != incs.end(); ++li)
     {
     this->SystemIncludeDirectories.insert(*li);
@@ -1777,7 +1770,7 @@
     }
 }
 
-void cmMakefile::AddDefinition(const char* name, const char* value)
+void cmMakefile::AddDefinition(const std::string& name, const char* value)
 {
   if (!value )
     {
@@ -1806,14 +1799,15 @@
 }
 
 
-void cmMakefile::AddCacheDefinition(const char* name, const char* value,
+void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
                                     const char* doc,
                                     cmCacheManager::CacheEntryType type,
                                     bool force)
 {
-  const char* val = value;
+  bool haveVal = value ? true : false;
+  std::string val = haveVal ? value : "";
   cmCacheManager::CacheIterator it =
-    this->GetCacheManager()->GetCacheIterator(name);
+    this->GetCacheManager()->GetCacheIterator(name.c_str());
   if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) &&
      it.Initialized())
     {
@@ -1822,6 +1816,7 @@
     if(!force)
       {
       val = it.GetValue();
+      haveVal = true;
       }
     if ( type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH )
       {
@@ -1844,16 +1839,18 @@
 
       this->GetCacheManager()->AddCacheEntry(name, nvalue.c_str(), doc, type);
       val = it.GetValue();
+      haveVal = true;
       }
 
     }
-  this->GetCacheManager()->AddCacheEntry(name, val, doc, type);
+  this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc,
+                                         type);
   // if there was a definition then remove it
   this->Internal->VarStack.top().Set(name, 0);
 }
 
 
-void cmMakefile::AddDefinition(const char* name, bool value)
+void cmMakefile::AddDefinition(const std::string& name, bool value)
 {
   this->Internal->VarStack.top().Set(name, value? "ON" : "OFF");
   if (this->Internal->VarUsageStack.size() &&
@@ -1880,20 +1877,20 @@
     return;
     }
   const cmDefinitions& defs = this->Internal->VarStack.top();
-  const std::set<cmStdString>& locals = defs.LocalKeys();
-  std::set<cmStdString>::const_iterator it = locals.begin();
+  const std::set<std::string>& locals = defs.LocalKeys();
+  std::set<std::string>::const_iterator it = locals.begin();
   for (; it != locals.end(); ++it)
     {
-    this->CheckForUnused("out of scope", it->c_str());
+    this->CheckForUnused("out of scope", *it);
     }
 }
 
-void cmMakefile::MarkVariableAsUsed(const char* var)
+void cmMakefile::MarkVariableAsUsed(const std::string& var)
 {
   this->Internal->VarUsageStack.top().insert(var);
 }
 
-bool cmMakefile::VariableInitialized(const char* var) const
+bool cmMakefile::VariableInitialized(const std::string& var) const
 {
   if(this->Internal->VarInitStack.top().find(var) !=
       this->Internal->VarInitStack.top().end())
@@ -1903,7 +1900,7 @@
   return false;
 }
 
-bool cmMakefile::VariableUsed(const char* var) const
+bool cmMakefile::VariableUsed(const std::string& var) const
 {
   if(this->Internal->VarUsageStack.top().find(var) !=
       this->Internal->VarUsageStack.top().end())
@@ -1913,12 +1910,13 @@
   return false;
 }
 
-void cmMakefile::CheckForUnused(const char* reason, const char* name) const
+void cmMakefile::CheckForUnused(const char* reason,
+                                const std::string& name) const
 {
   if (this->WarnUnused && !this->VariableUsed(name))
     {
-    cmStdString path;
-    cmListFileBacktrace bt;
+    std::string path;
+    cmListFileBacktrace bt(this->GetLocalGenerator());
     if (this->CallStack.size())
       {
       const cmListFileContext* file = this->CallStack.back().Context;
@@ -1945,13 +1943,13 @@
       cmOStringStream msg;
       msg << "unused variable (" << reason << ") \'" << name << "\'";
       this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
-                                             msg.str().c_str(),
+                                             msg.str(),
                                              bt);
       }
     }
 }
 
-void cmMakefile::RemoveDefinition(const char* name)
+void cmMakefile::RemoveDefinition(const std::string& name)
 {
   this->Internal->VarStack.top().Set(name, 0);
   if (this->Internal->VarUsageStack.size() &&
@@ -1971,7 +1969,7 @@
 #endif
 }
 
-void cmMakefile::RemoveCacheDefinition(const char* name)
+void cmMakefile::RemoveCacheDefinition(const std::string& name)
 {
   this->GetCacheManager()->RemoveCacheEntry(name);
 }
@@ -1982,7 +1980,8 @@
 }
 
 
-void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
+void cmMakefile::AddGlobalLinkInformation(const std::string& name,
+                                          cmTarget& target)
 {
   // for these targets do not add anything
   switch(target.GetType())
@@ -1997,19 +1996,20 @@
   for(j = this->LinkDirectories.begin();
       j != this->LinkDirectories.end(); ++j)
     {
-    target.AddLinkDirectory(j->c_str());
+    target.AddLinkDirectory(*j);
     }
   target.MergeLinkLibraries( *this, name, this->LinkLibraries );
 }
 
 
-void cmMakefile::AddAlias(const char* lname, cmTarget *tgt)
+void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt)
 {
   this->AliasTargets[lname] = tgt;
   this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt);
 }
 
-cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type,
+cmTarget* cmMakefile::AddLibrary(const std::string& lname,
+                            cmTarget::TargetType type,
                             const std::vector<std::string> &srcs,
                             bool excludeFromAll)
 {
@@ -2055,7 +2055,7 @@
 
 //----------------------------------------------------------------------------
 cmTarget*
-cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name)
+cmMakefile::AddNewTarget(cmTarget::TargetType type, const std::string& name)
 {
   cmTargets::iterator it =
     this->Targets.insert(cmTargets::value_type(name, cmTarget())).first;
@@ -2067,9 +2067,8 @@
 }
 
 cmSourceFile*
-cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const
+cmMakefile::LinearGetSourceFileWithOutput(const std::string& name) const
 {
-  std::string name = cname;
   std::string out;
 
   // look through all the source files that have custom commands
@@ -2080,7 +2079,7 @@
     // does this source file have a custom command?
     if ((*i)->GetCustomCommand())
       {
-      // is the output of the custom command match the source files name
+      // Does the output of the custom command match the source file name?
       const std::vector<std::string>& outputs =
         (*i)->GetCustomCommand()->GetOutputs();
       for(std::vector<std::string>::const_iterator o = outputs.begin();
@@ -2103,15 +2102,14 @@
   return 0;
 }
 
-cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) const
+cmSourceFile *cmMakefile::GetSourceFileWithOutput(
+                                                const std::string& name) const
 {
-  std::string name = cname;
-
   // If the queried path is not absolute we use the backward compatible
   // linear-time search for an output with a matching suffix.
-  if(!cmSystemTools::FileIsFullPath(cname))
+  if(!cmSystemTools::FileIsFullPath(name.c_str()))
     {
-    return LinearGetSourceFileWithOutput(cname);
+    return this->LinearGetSourceFileWithOutput(name);
     }
   // Otherwise we use an efficient lookup map.
   OutputToSourceMap::const_iterator o = this->OutputToSource.find(name);
@@ -2156,15 +2154,12 @@
   return sg;
 }
 
- void cmMakefile::AddSourceGroup(const char* name,
+void cmMakefile::AddSourceGroup(const std::string& name,
                                  const char* regex)
 {
-  if (name)
-    {
-    std::vector<std::string> nameVector;
-    nameVector.push_back(name);
-    AddSourceGroup(nameVector, regex);
-    }
+  std::vector<std::string> nameVector;
+  nameVector.push_back(name);
+  AddSourceGroup(nameVector, regex);
 }
 
 void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
@@ -2212,7 +2207,7 @@
     {
     std::string guidName = "SG_Filter_";
     guidName += fullname;
-    gg->CreateGUID(guidName.c_str());
+    gg->CreateGUID(guidName);
     }
   for(++i; i<=lastElement; ++i)
     {
@@ -2223,7 +2218,7 @@
       {
       std::string guidName = "SG_Filter_";
       guidName += fullname;
-      gg->CreateGUID(guidName.c_str());
+      gg->CreateGUID(guidName);
       }
     }
 
@@ -2337,13 +2332,13 @@
     }
 }
 
-bool cmMakefile::IsOn(const char* name) const
+bool cmMakefile::IsOn(const std::string& name) const
 {
   const char* value = this->GetDefinition(name);
   return cmSystemTools::IsOn(value);
 }
 
-bool cmMakefile::IsSet(const char* name) const
+bool cmMakefile::IsSet(const std::string& name) const
 {
   const char* value = this->GetDefinition(name);
   if ( !value )
@@ -2373,16 +2368,16 @@
   return false;
 }
 
-const char* cmMakefile::GetSONameFlag(const char* language) const
+const char* cmMakefile::GetSONameFlag(const std::string& language) const
 {
   std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
-  if(language)
+  if(!language.empty())
     {
     name += "_";
     name += language;
     }
   name += "_FLAG";
-  return GetDefinition(name.c_str());
+  return GetDefinition(name);
 }
 
 bool cmMakefile::CanIWriteThisFile(const char* fileName) const
@@ -2414,7 +2409,7 @@
   return true;
 }
 
-const char* cmMakefile::GetRequiredDefinition(const char* name) const
+const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
 {
   const char* ret = this->GetDefinition(name);
   if(!ret)
@@ -2422,13 +2417,13 @@
     cmSystemTools::Error("Error required internal CMake variable not "
                          "set, cmake may be not be built correctly.\n",
                          "Missing variable is:\n",
-                         name);
+                         name.c_str());
     return "";
     }
   return ret;
 }
 
-bool cmMakefile::IsDefinitionSet(const char* name) const
+bool cmMakefile::IsDefinitionSet(const std::string& name) const
 {
   const char* def = this->Internal->VarStack.top().Get(name);
   this->Internal->VarUsageStack.top().insert(name);
@@ -2450,7 +2445,7 @@
   return def?true:false;
 }
 
-const char* cmMakefile::GetDefinition(const char* name) const
+const char* cmMakefile::GetDefinition(const std::string& name) const
 {
   if (this->WarnUnused)
     {
@@ -2463,7 +2458,7 @@
     }
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
-  if ( vv )
+  if ( vv && !this->SuppressWatches )
     {
     if ( def )
       {
@@ -2472,26 +2467,15 @@
       }
     else
       {
-      // are unknown access allowed
-      const char* allow = this->Internal->VarStack.top()
-        .Get("CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS");
-      if(cmSystemTools::IsOn(allow))
-        {
-        vv->VariableAccessed(name,
-          cmVariableWatch::ALLOWED_UNKNOWN_VARIABLE_READ_ACCESS, def, this);
-        }
-      else
-        {
-        vv->VariableAccessed(name,
+      vv->VariableAccessed(name,
           cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, def, this);
-        }
       }
     }
 #endif
   return def;
 }
 
-const char* cmMakefile::GetSafeDefinition(const char* def) const
+const char* cmMakefile::GetSafeDefinition(const std::string& def) const
 {
   const char* ret = this->GetDefinition(def);
   if(!ret)
@@ -2504,7 +2488,7 @@
 std::vector<std::string> cmMakefile
 ::GetDefinitions(int cacheonly /* = 0 */) const
 {
-  std::set<cmStdString> definitions;
+  std::set<std::string> definitions;
   if ( !cacheonly )
     {
     definitions = this->Internal->VarStack.top().ClosureKeys();
@@ -2518,7 +2502,7 @@
 
   std::vector<std::string> res;
 
-  std::set<cmStdString>::iterator fit;
+  std::set<std::string>::iterator fit;
   for ( fit = definitions.begin(); fit != definitions.end(); fit ++ )
     {
     res.push_back(*fit);
@@ -2541,23 +2525,133 @@
                                                 bool removeEmpty,
                                                 bool replaceAt) const
 {
-  if ( source.empty() || source.find_first_of("$@\\") == source.npos)
+  bool compareResults = false;
+  cmake::MessageType mtype = cmake::LOG;
+  std::string errorstr;
+  std::string original;
+
+  // Sanity check the @ONLY mode.
+  if(atOnly && (!noEscapes || !removeEmpty))
     {
+    // This case should never be called.  At-only is for
+    // configure-file/string which always does no escapes.
+    this->IssueMessage(cmake::INTERNAL_ERROR,
+                       "ExpandVariablesInString @ONLY called "
+                       "on something with escapes.");
     return source.c_str();
     }
 
+  // Variables used in the WARN case.
+  std::string newResult;
+  std::string newErrorstr;
+  cmake::MessageType newError = cmake::LOG;
+
+  switch(this->GetPolicyStatus(cmPolicies::CMP0053))
+    {
+    case cmPolicies::WARN:
+      {
+      // Save the original string for the warning.
+      original = source;
+      newResult = source;
+      compareResults = true;
+      // Suppress variable watches to avoid calling hooks twice. Suppress new
+      // dereferences since the OLD behavior is still what is actually used.
+      this->SuppressWatches = true;
+      newError =
+        ExpandVariablesInStringNew(newErrorstr, newResult, escapeQuotes,
+                                   noEscapes, atOnly, filename, line,
+                                   removeEmpty, replaceAt);
+      this->SuppressWatches = false;
+      }
+    case cmPolicies::OLD:
+      mtype = ExpandVariablesInStringOld(errorstr, source, escapeQuotes,
+                                         noEscapes, atOnly, filename,
+                                         line, removeEmpty, true);
+      break;
+    case cmPolicies::REQUIRED_IF_USED:
+    case cmPolicies::REQUIRED_ALWAYS:
+      // Messaging here would be *very* verbose.
+    case cmPolicies::NEW:
+      mtype = ExpandVariablesInStringNew(errorstr, source, escapeQuotes,
+                                         noEscapes, atOnly, filename,
+                                         line, removeEmpty, replaceAt);
+      break;
+    }
+
+  // If it's an error in either case, just report the error...
+  if(mtype != cmake::LOG)
+    {
+    if(mtype == cmake::FATAL_ERROR)
+      {
+      cmSystemTools::SetFatalErrorOccured();
+      }
+    this->IssueMessage(mtype, errorstr);
+    }
+  // ...otherwise, see if there's a difference that needs to be warned about.
+  else if(compareResults && (newResult != source || newError != mtype))
+    {
+    std::string msg =
+      this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0053);
+    msg += "\n";
+
+    std::string msg_input = original;
+    cmSystemTools::ReplaceString(msg_input, "\n", "\n  ");
+    msg += "For input:\n  '";
+    msg += msg_input;
+    msg += "'\n";
+
+    std::string msg_old = source;
+    cmSystemTools::ReplaceString(msg_old, "\n", "\n  ");
+    msg += "the old evaluation rules produce:\n  '";
+    msg += msg_old;
+    msg += "'\n";
+
+    if(newError == mtype)
+      {
+      std::string msg_new = newResult;
+      cmSystemTools::ReplaceString(msg_new, "\n", "\n  ");
+      msg += "but the new evaluation rules produce:\n  '";
+      msg += msg_new;
+      msg += "'\n";
+      }
+    else
+      {
+      std::string msg_err = newErrorstr;
+      cmSystemTools::ReplaceString(msg_err, "\n", "\n  ");
+      msg += "but the new evaluation rules produce an error:\n  ";
+      msg += msg_err;
+      msg += "\n";
+      }
+
+    msg +=
+      "Using the old result for compatibility since the policy is not set.";
+
+    this->IssueMessage(cmake::AUTHOR_WARNING, msg);
+    }
+
+  return source.c_str();
+}
+
+cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
+                                                std::string& errorstr,
+                                                std::string& source,
+                                                bool escapeQuotes,
+                                                bool noEscapes,
+                                                bool atOnly,
+                                                const char* filename,
+                                                long line,
+                                                bool removeEmpty,
+                                                bool replaceAt) const
+{
+  // Fast path strings without any special characters.
+  if ( source.find_first_of("$@\\") == source.npos)
+    {
+    return cmake::LOG;
+    }
+
   // Special-case the @ONLY mode.
   if(atOnly)
     {
-    if(!noEscapes || !removeEmpty || !replaceAt)
-      {
-      // This case should never be called.  At-only is for
-      // configure-file/string which always does no escapes.
-      this->IssueMessage(cmake::INTERNAL_ERROR,
-                         "ExpandVariablesInString @ONLY called "
-                         "on something with escapes.");
-      }
-
     // Store an original copy of the input.
     std::string input = source;
 
@@ -2577,7 +2671,7 @@
 
       // Lookup the definition of VAR.
       std::string var(first+1, last-first-2);
-      if(const char* val = this->GetDefinition(var.c_str()))
+      if(const char* val = this->GetDefinition(var))
         {
         // Store the value in the output escaping as requested.
         if(escapeQuotes)
@@ -2597,7 +2691,7 @@
     // Append the rest of the unchanged part of the string.
     source.append(in);
 
-    return source.c_str();
+    return cmake::LOG;
     }
 
   // This method replaces ${VAR} and @VAR@ where VAR is looked up
@@ -2614,6 +2708,7 @@
   parser.SetRemoveEmpty(removeEmpty);
   int res = parser.ParseString(source.c_str(), 0);
   const char* emsg = parser.GetError();
+  cmake::MessageType mtype = cmake::LOG;
   if ( res && !emsg[0] )
     {
     source = parser.GetResult();
@@ -2632,7 +2727,7 @@
             << "  " << filename << ":" << line << "\n";
       }
     error << "when parsing string\n"
-          << "  " << source.c_str() << "\n";
+          << "  " << source << "\n";
     error << emsg;
 
     // If the parser failed ("res" is false) then this is a real
@@ -2640,7 +2735,7 @@
     // parser reported an error message without failing because the
     // helper implementation is unhappy, which has always reported an
     // error.
-    cmake::MessageType mtype = cmake::FATAL_ERROR;
+    mtype = cmake::FATAL_ERROR;
     if(!res)
       {
       // This is a real argument parsing error.  Use policy CMP0010 to
@@ -2662,13 +2757,334 @@
                     ->GetRequiredPolicyError(cmPolicies::CMP0010));
         case cmPolicies::NEW:
           // NEW behavior is to report the error.
-          cmSystemTools::SetFatalErrorOccured();
           break;
         }
       }
-    this->IssueMessage(mtype, error.str());
+    errorstr = error.str();
     }
-  return source.c_str();
+  return mtype;
+}
+
+typedef enum
+  {
+  NORMAL,
+  ENVIRONMENT,
+  CACHE
+  } t_domain;
+struct t_lookup
+  {
+  t_lookup(): domain(NORMAL), loc(0) {}
+  t_domain domain;
+  size_t loc;
+  };
+
+cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
+                                            std::string& errorstr,
+                                            std::string& source,
+                                            bool escapeQuotes,
+                                            bool noEscapes,
+                                            bool atOnly,
+                                            const char* filename,
+                                            long line,
+                                            bool removeEmpty,
+                                            bool replaceAt) const
+{
+  // This method replaces ${VAR} and @VAR@ where VAR is looked up
+  // with GetDefinition(), if not found in the map, nothing is expanded.
+  // It also supports the $ENV{VAR} syntax where VAR is looked up in
+  // the current environment variables.
+
+  const char* in = source.c_str();
+  const char* last = in;
+  std::string result;
+  result.reserve(source.size());
+  std::stack<t_lookup> openstack;
+  bool error = false;
+  bool done = false;
+  openstack.push(t_lookup());
+  cmake::MessageType mtype = cmake::LOG;
+
+  do
+    {
+    char inc = *in;
+    switch(inc)
+      {
+      case '}':
+        if(openstack.size() > 1)
+          {
+          t_lookup var = openstack.top();
+          openstack.pop();
+          result.append(last, in - last);
+          std::string const& lookup = result.substr(var.loc);
+          const char* value = NULL;
+          std::string varresult;
+          static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
+          switch(var.domain)
+            {
+            case NORMAL:
+              if(filename && lookup == lineVar)
+                {
+                cmOStringStream ostr;
+                ostr << line;
+                varresult = ostr.str();
+                }
+              else
+                {
+                value = this->GetDefinition(lookup);
+                }
+              break;
+            case ENVIRONMENT:
+              value = cmSystemTools::GetEnv(lookup.c_str());
+              break;
+            case CACHE:
+              value = this->GetCacheManager()->GetCacheValue(lookup);
+              break;
+            }
+          // Get the string we're meant to append to.
+          if(value)
+            {
+            if(escapeQuotes)
+              {
+              varresult = cmSystemTools::EscapeQuotes(value);
+              }
+            else
+              {
+              varresult = value;
+              }
+            }
+          else if(!removeEmpty)
+            {
+            // check to see if we need to print a warning
+            // if strict mode is on and the variable has
+            // not been "cleared"/initialized with a set(foo ) call
+            if(this->GetCMakeInstance()->GetWarnUninitialized() &&
+               !this->VariableInitialized(lookup))
+              {
+              if (this->CheckSystemVars ||
+                  cmSystemTools::IsSubDirectory(filename,
+                                                this->GetHomeDirectory()) ||
+                  cmSystemTools::IsSubDirectory(filename,
+                                             this->GetHomeOutputDirectory()))
+                {
+                cmOStringStream msg;
+                cmListFileBacktrace bt(this->GetLocalGenerator());
+                cmListFileContext lfc;
+                lfc.FilePath = filename;
+                lfc.Line = line;
+                bt.push_back(lfc);
+                msg << "uninitialized variable \'" << lookup << "\'";
+                this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
+                                                       msg.str().c_str(), bt);
+                }
+              }
+            }
+          result.replace(var.loc, result.size() - var.loc, varresult);
+          // Start looking from here on out.
+          last = in + 1;
+          }
+        break;
+      case '$':
+        if(!atOnly)
+          {
+          t_lookup lookup;
+          const char* next = in + 1;
+          const char* start = NULL;
+          char nextc = *next;
+          if(nextc == '{')
+            {
+            // Looking for a variable.
+            start = in + 2;
+            lookup.domain = NORMAL;
+            }
+          else if(nextc == '<')
+            {
+            }
+          else if(!nextc)
+            {
+            result.append(last, next - last);
+            last = next;
+            }
+          else if(cmHasLiteralPrefix(next, "ENV{"))
+            {
+            // Looking for an environment variable.
+            start = in + 5;
+            lookup.domain = ENVIRONMENT;
+            }
+          else if(cmHasLiteralPrefix(next, "CACHE{"))
+            {
+            // Looking for a cache variable.
+            start = in + 7;
+            lookup.domain = CACHE;
+            }
+          else
+            {
+            if(this->cmNamedCurly.find(next))
+              {
+              errorstr = "Syntax $"
+                  + std::string(next, this->cmNamedCurly.end())
+                  + "{} is not supported.  Only ${}, $ENV{}, "
+                    "and $CACHE{} are allowed.";
+              mtype = cmake::FATAL_ERROR;
+              error = true;
+              }
+            }
+          if(start)
+            {
+            result.append(last, in - last);
+            last = start;
+            in = start - 1;
+            lookup.loc = result.size();
+            openstack.push(lookup);
+            }
+          break;
+          }
+      case '\\':
+        if(!noEscapes)
+          {
+          const char* next = in + 1;
+          char nextc = *next;
+          if(nextc == 't')
+            {
+            result.append(last, in - last);
+            result.append("\t");
+            last = next + 1;
+            }
+          else if(nextc == 'n')
+            {
+            result.append(last, in - last);
+            result.append("\n");
+            last = next + 1;
+            }
+          else if(nextc == 'r')
+            {
+            result.append(last, in - last);
+            result.append("\r");
+            last = next + 1;
+            }
+          else if(nextc == ';' && openstack.size() == 1)
+            {
+            // Handled in ExpandListArgument; pass the backslash literally.
+            }
+          else if (isalnum(nextc) || nextc == '\0')
+            {
+            errorstr += "Invalid character escape '\\";
+            if (nextc)
+              {
+              errorstr += nextc;
+              errorstr += "'.";
+              }
+            else
+              {
+              errorstr += "' (at end of input).";
+              }
+            error = true;
+            }
+          else
+            {
+            // Take what we've found so far, skipping the escape character.
+            result.append(last, in - last);
+            // Start tracking from the next character.
+            last = in + 1;
+            }
+          // Skip the next character since it was escaped, but don't read past
+          // the end of the string.
+          if(*last)
+            {
+            ++in;
+            }
+          }
+        break;
+      case '\n':
+        // Onto the next line.
+        ++line;
+        break;
+      case '\0':
+        done = true;
+        break;
+      case '@':
+        if(replaceAt)
+          {
+          const char* nextAt = strchr(in + 1, '@');
+          if(nextAt && nextAt != in + 1 &&
+             nextAt == in + 1 + strspn(in + 1,
+                "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                "abcdefghijklmnopqrstuvwxyz"
+                "0123456789/_.+-"))
+            {
+            std::string variable(in + 1, nextAt - in - 1);
+            std::string varresult = this->GetSafeDefinition(variable);
+            if(escapeQuotes)
+              {
+              varresult = cmSystemTools::EscapeQuotes(varresult);
+              }
+            // Skip over the variable.
+            result.append(last, in - last);
+            result.append(varresult);
+            in = nextAt;
+            last = in + 1;
+            break;
+            }
+          }
+        // Failed to find a valid @ expansion; treat it as literal.
+        /* FALLTHROUGH */
+      default:
+        {
+        if(openstack.size() > 1 &&
+           !(isalnum(inc) || inc == '_' ||
+             inc == '/' || inc == '.' ||
+             inc == '+' || inc == '-'))
+          {
+          errorstr += "Invalid character (\'";
+          errorstr += inc;
+          result.append(last, in - last);
+          errorstr += "\') in a variable name: "
+                      "'" + result.substr(openstack.top().loc) + "'";
+          mtype = cmake::FATAL_ERROR;
+          error = true;
+          }
+        break;
+        }
+      }
+    // Look at the next character.
+    } while(!error && !done && *++in);
+
+  // Check for open variable references yet.
+  if(!error && openstack.size() != 1)
+    {
+    // There's an open variable reference waiting.  Policy CMP0010 flags
+    // whether this is an error or not.  The new parser now enforces
+    // CMP0010 as well.
+    errorstr += "There is an unterminated variable reference.";
+    error = true;
+    }
+
+  if(error)
+    {
+    cmOStringStream emsg;
+    emsg << "Syntax error in cmake code ";
+    if(filename)
+      {
+      // This filename and line number may be more specific than the
+      // command context because one command invocation can have
+      // arguments on multiple lines.
+      emsg << "at\n"
+            << "  " << filename << ":" << line << "\n";
+      }
+    emsg << "when parsing string\n"
+         << "  " << source << "\n";
+    emsg << errorstr;
+    mtype = cmake::FATAL_ERROR;
+    errorstr = emsg.str();
+    }
+  else
+    {
+    // Append the rest of the unchanged part of the string.
+    result.append(last);
+
+    source = result;
+    }
+
+  return mtype;
 }
 
 void cmMakefile::RemoveVariablesInString(std::string& source,
@@ -2751,7 +3167,7 @@
 }
 
 //----------------------------------------------------------------------------
-const char*
+std::string
 cmMakefile::GetConfigurations(std::vector<std::string>& configs,
                               bool single) const
 {
@@ -2762,12 +3178,12 @@
       {
       cmSystemTools::ExpandListArgument(configTypes, configs);
       }
-    return 0;
+    return "";
     }
   else
     {
-    const char* buildType = this->GetDefinition("CMAKE_BUILD_TYPE");
-    if(single && buildType && *buildType)
+    const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
+    if(single && !buildType.empty())
       {
       configs.push_back(buildType);
       }
@@ -2891,7 +3307,7 @@
     value = i->Value;
     this->ExpandVariablesInString(value, false, false, false,
                                   i->FilePath, i->Line,
-                                  false, true);
+                                  false, false);
 
     // If the argument is quoted, it should be one argument.
     // Otherwise, it may be a list of arguments.
@@ -2973,7 +3389,7 @@
   this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
 }
 
-void cmMakefile::SetHomeDirectory(const char* dir)
+void cmMakefile::SetHomeDirectory(const std::string& dir)
 {
   this->cmHomeDirectory = dir;
   cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory);
@@ -2984,7 +3400,7 @@
     }
 }
 
-void cmMakefile::SetHomeOutputDirectory(const char* lib)
+void cmMakefile::SetHomeOutputDirectory(const std::string& lib)
 {
   this->HomeOutputDirectory = lib;
   cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory);
@@ -3012,13 +3428,13 @@
   {
     cmOStringStream tmpStream;
     tmpStream << "CMAKE_ARGV" << t;
-    this->AddDefinition(tmpStream.str().c_str(), args[t].c_str());
+    this->AddDefinition(tmpStream.str(), args[t].c_str());
     //this->MarkVariableAsUsed(tmpStream.str().c_str());
   }
 }
 
 //----------------------------------------------------------------------------
-cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
+cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
 {
   cmSourceFileLocation sfl(this, sourceName);
   for(std::vector<cmSourceFile*>::const_iterator
@@ -3035,7 +3451,7 @@
 }
 
 //----------------------------------------------------------------------------
-cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
+cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
                                             bool generated)
 {
   if(cmSourceFile* esf = this->GetSource(sourceName))
@@ -3077,23 +3493,25 @@
     }
 }
 
-int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
-                           const char *projectName, const char *targetName,
+int cmMakefile::TryCompile(const std::string& srcdir,
+                           const std::string& bindir,
+                           const std::string& projectName,
+                           const std::string& targetName,
                            bool fast,
                            const std::vector<std::string> *cmakeArgs,
                            std::string *output)
 {
   this->Internal->IsSourceFileTryCompile = fast;
   // does the binary directory exist ? If not create it...
-  if (!cmSystemTools::FileIsDirectory(bindir))
+  if (!cmSystemTools::FileIsDirectory(bindir.c_str()))
     {
-    cmSystemTools::MakeDirectory(bindir);
+    cmSystemTools::MakeDirectory(bindir.c_str());
     }
 
   // change to the tests directory and run cmake
   // use the cmake object instead of calling cmake
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(bindir);
+  cmSystemTools::ChangeDirectory(bindir.c_str());
 
   // make sure the same generator is used
   // use this program as the cmake to be run, it should not
@@ -3345,7 +3763,8 @@
   if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0))
     {
     const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
-    if (currentFile && (strstr(currentFile, cmakeRoot) == currentFile))
+    std::string mods = cmakeRoot + std::string("/Modules/");
+    if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0)
       {
       switch (this->GetPolicyStatus(cmPolicies::CMP0017))
         {
@@ -3367,7 +3786,6 @@
         case cmPolicies::REQUIRED_IF_USED:
         case cmPolicies::REQUIRED_ALWAYS:
         case cmPolicies::NEW:
-        default:
           result = moduleInCMakeRoot;
           break;
         }
@@ -3406,7 +3824,7 @@
     if(this->cmDefineRegex.find(line))
       {
       const char* def =
-        this->GetDefinition(this->cmDefineRegex.match(1).c_str());
+        this->GetDefinition(this->cmDefineRegex.match(1));
       if(!cmSystemTools::IsOff(def))
         {
         cmSystemTools::ReplaceString(line, "#cmakedefine", "#define");
@@ -3422,7 +3840,7 @@
     else if(this->cmDefine01Regex.find(line))
       {
       const char* def =
-        this->GetDefinition(this->cmDefine01Regex.match(1).c_str());
+        this->GetDefinition(this->cmDefine01Regex.match(1));
       cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define");
       output += line;
       if(!cmSystemTools::IsOff(def))
@@ -3450,7 +3868,7 @@
 
   // Perform variable replacements.
   this->ExpandVariablesInString(output, escapeQuotes, true,
-                                atOnly, 0, -1, true);
+                                atOnly, 0, -1, true, true);
 }
 
 int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
@@ -3528,6 +3946,20 @@
       return 0;
       }
 
+    cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin);
+    if(bom != cmsys::FStream::BOM_None &&
+       bom != cmsys::FStream::BOM_UTF8)
+      {
+      cmOStringStream e;
+      e << "File starts with a Byte-Order-Mark that is not UTF-8:\n  "
+        << sinfile;
+      this->IssueMessage(cmake::FATAL_ERROR, e.str());
+      return 0;
+      }
+    // rewind to copy BOM to output file
+    fin.seekg(0);
+
+
     // now copy input to output and expand variables in the
     // input file at the same time
     std::string inLine;
@@ -3555,17 +3987,9 @@
   return res;
 }
 
-void cmMakefile::SetProperty(const char* prop, const char* value)
+void cmMakefile::SetProperty(const std::string& prop, const char* value)
 {
-  if (!prop)
-    {
-    return;
-    }
-
-  // handle special props
-  std::string propname = prop;
-
-  if ( propname == "LINK_DIRECTORIES" )
+  if ( prop == "LINK_DIRECTORIES" )
     {
     std::vector<std::string> varArgsExpanded;
     if(value)
@@ -3575,52 +3999,49 @@
     this->SetLinkDirectories(varArgsExpanded);
     return;
     }
-  if (propname == "INCLUDE_DIRECTORIES")
+  if (prop == "INCLUDE_DIRECTORIES")
     {
     this->IncludeDirectoriesEntries.clear();
       if (!value)
         {
         return;
         }
-    cmListFileBacktrace lfbt;
-    this->GetBacktrace(lfbt);
+    cmListFileBacktrace lfbt = this->GetBacktrace();
     this->IncludeDirectoriesEntries.push_back(
                                         cmValueWithOrigin(value, lfbt));
     return;
     }
-  if (propname == "COMPILE_OPTIONS")
+  if (prop == "COMPILE_OPTIONS")
     {
     this->CompileOptionsEntries.clear();
       if (!value)
         {
         return;
         }
-    cmListFileBacktrace lfbt;
-    this->GetBacktrace(lfbt);
+    cmListFileBacktrace lfbt = this->GetBacktrace();
     this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt));
     return;
     }
-  if (propname == "COMPILE_DEFINITIONS")
+  if (prop == "COMPILE_DEFINITIONS")
     {
     this->CompileDefinitionsEntries.clear();
     if (!value)
       {
       return;
       }
-    cmListFileBacktrace lfbt;
-    this->GetBacktrace(lfbt);
+    cmListFileBacktrace lfbt = this->GetBacktrace();
     cmValueWithOrigin entry(value, lfbt);
     this->CompileDefinitionsEntries.push_back(entry);
     return;
     }
 
-  if ( propname == "INCLUDE_REGULAR_EXPRESSION" )
+  if ( prop == "INCLUDE_REGULAR_EXPRESSION" )
     {
     this->SetIncludeRegularExpression(value);
     return;
     }
 
-  if ( propname == "ADDITIONAL_MAKE_CLEAN_FILES" )
+  if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" )
     {
     // This property is not inherrited
     if ( strcmp(this->GetCurrentDirectory(),
@@ -3633,49 +4054,39 @@
   this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY);
 }
 
-void cmMakefile::AppendProperty(const char* prop, const char* value,
+void cmMakefile::AppendProperty(const std::string& prop,
+                                const char* value,
                                 bool asString)
 {
-  if (!prop)
+  if (prop == "INCLUDE_DIRECTORIES")
     {
-    return;
-    }
-
-  // handle special props
-  std::string propname = prop;
-
-  if (propname == "INCLUDE_DIRECTORIES")
-    {
-    cmListFileBacktrace lfbt;
-    this->GetBacktrace(lfbt);
+    cmListFileBacktrace lfbt = this->GetBacktrace();
     this->IncludeDirectoriesEntries.push_back(
                                         cmValueWithOrigin(value, lfbt));
     return;
     }
-  if (propname == "COMPILE_OPTIONS")
+  if (prop == "COMPILE_OPTIONS")
     {
-    cmListFileBacktrace lfbt;
-    this->GetBacktrace(lfbt);
+    cmListFileBacktrace lfbt = this->GetBacktrace();
     this->CompileOptionsEntries.push_back(
                                         cmValueWithOrigin(value, lfbt));
     return;
     }
-  if (propname == "COMPILE_DEFINITIONS")
+  if (prop == "COMPILE_DEFINITIONS")
     {
-    cmListFileBacktrace lfbt;
-    this->GetBacktrace(lfbt);
+    cmListFileBacktrace lfbt = this->GetBacktrace();
     this->CompileDefinitionsEntries.push_back(
                                         cmValueWithOrigin(value, lfbt));
     return;
     }
-  if ( propname == "LINK_DIRECTORIES" )
+  if ( prop == "LINK_DIRECTORIES" )
     {
     std::vector<std::string> varArgsExpanded;
     cmSystemTools::ExpandListArgument(value, varArgsExpanded);
     for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
         vi != varArgsExpanded.end(); ++vi)
       {
-      this->AddLinkDirectory(vi->c_str());
+      this->AddLinkDirectory(*vi);
       }
     return;
     }
@@ -3683,32 +4094,18 @@
   this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString);
 }
 
-const char *cmMakefile::GetPropertyOrDefinition(const char* prop) const
-{
-  const char *ret = this->GetProperty(prop, cmProperty::DIRECTORY);
-  if (!ret)
-    {
-    ret = this->GetDefinition(prop);
-    }
-  return ret;
-}
-
-const char *cmMakefile::GetProperty(const char* prop) const
+const char *cmMakefile::GetProperty(const std::string& prop) const
 {
   return this->GetProperty(prop, cmProperty::DIRECTORY);
 }
 
-const char *cmMakefile::GetProperty(const char* prop,
+const char *cmMakefile::GetProperty(const std::string& prop,
                                     cmProperty::ScopeType scope) const
 {
-  if(!prop)
-    {
-    return 0;
-    }
   // watch for specific properties
   static std::string output;
   output = "";
-  if (!strcmp("PARENT_DIRECTORY",prop))
+  if (prop == "PARENT_DIRECTORY")
     {
     if(cmLocalGenerator* plg = this->LocalGenerator->GetParent())
       {
@@ -3716,14 +4113,14 @@
       }
     return output.c_str();
     }
-  else if (!strcmp("INCLUDE_REGULAR_EXPRESSION",prop) )
+  else if (prop == "INCLUDE_REGULAR_EXPRESSION" )
     {
     output = this->GetIncludeRegularExpression();
     return output.c_str();
     }
-  else if (!strcmp("LISTFILE_STACK",prop))
+  else if (prop == "LISTFILE_STACK")
     {
-    for (std::deque<cmStdString>::const_iterator
+    for (std::deque<std::string>::const_iterator
         i = this->ListFileStack.begin();
         i != this->ListFileStack.end(); ++i)
       {
@@ -3735,10 +4132,10 @@
       }
     return output.c_str();
     }
-  else if (!strcmp("VARIABLES",prop) || !strcmp("CACHE_VARIABLES",prop))
+  else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES")
     {
     int cacheonly = 0;
-    if ( !strcmp("CACHE_VARIABLES",prop) )
+    if ( prop == "CACHE_VARIABLES" )
       {
       cacheonly = 1;
       }
@@ -3753,17 +4150,17 @@
       }
     return output.c_str();
     }
-  else if (!strcmp("MACROS",prop))
+  else if (prop == "MACROS")
     {
     this->GetListOfMacros(output);
     return output.c_str();
     }
-  else if (!strcmp("DEFINITIONS",prop))
+  else if (prop == "DEFINITIONS")
     {
     output += this->DefineFlagsOrig;
     return output.c_str();
     }
-  else if (!strcmp("LINK_DIRECTORIES",prop))
+  else if (prop == "LINK_DIRECTORIES")
     {
     cmOStringStream str;
     for (std::vector<std::string>::const_iterator
@@ -3780,7 +4177,7 @@
     output = str.str();
     return output.c_str();
     }
-  else if (!strcmp("INCLUDE_DIRECTORIES",prop))
+  else if (prop == "INCLUDE_DIRECTORIES")
     {
     std::string sep;
     for (std::vector<cmValueWithOrigin>::const_iterator
@@ -3794,7 +4191,7 @@
       }
     return output.c_str();
     }
-  else if (!strcmp("COMPILE_OPTIONS",prop))
+  else if (prop == "COMPILE_OPTIONS")
     {
     std::string sep;
     for (std::vector<cmValueWithOrigin>::const_iterator
@@ -3808,7 +4205,7 @@
       }
     return output.c_str();
     }
-  else if (!strcmp("COMPILE_DEFINITIONS",prop))
+  else if (prop == "COMPILE_DEFINITIONS")
     {
     std::string sep;
     for (std::vector<cmValueWithOrigin>::const_iterator
@@ -3839,22 +4236,23 @@
   return retVal;
 }
 
-bool cmMakefile::GetPropertyAsBool(const char* prop) const
+bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
 
 //----------------------------------------------------------------------------
-const char* cmMakefile::GetFeature(const char* feature, const char* config)
+const char* cmMakefile::GetFeature(const std::string& feature,
+                                   const std::string& config)
 {
   // TODO: Define accumulation policy for features (prepend, append, replace).
   // Currently we always replace.
-  if(config && *config)
+  if(!config.empty())
     {
     std::string featureConfig = feature;
     featureConfig += "_";
     featureConfig += cmSystemTools::UpperCase(config);
-    if(const char* value = this->GetProperty(featureConfig.c_str()))
+    if(const char* value = this->GetProperty(featureConfig))
       {
       return value;
       }
@@ -3875,8 +4273,7 @@
 {
   if (!excludeAliases)
     {
-    std::map<std::string, cmTarget*>::const_iterator i
-                                              = this->AliasTargets.find(name);
+    TargetMap::const_iterator i = this->AliasTargets.find(name);
     if (i != this->AliasTargets.end())
       {
       return i->second;
@@ -3892,12 +4289,8 @@
 }
 
 //----------------------------------------------------------------------------
-cmTest* cmMakefile::CreateTest(const char* testName)
+cmTest* cmMakefile::CreateTest(const std::string& testName)
 {
-  if ( !testName )
-    {
-    return 0;
-    }
   cmTest* test = this->GetTest(testName);
   if ( test )
     {
@@ -3910,16 +4303,13 @@
 }
 
 //----------------------------------------------------------------------------
-cmTest* cmMakefile::GetTest(const char* testName) const
+cmTest* cmMakefile::GetTest(const std::string& testName) const
 {
-  if(testName)
+  std::map<std::string, cmTest*>::const_iterator
+    mi = this->Tests.find(testName);
+  if(mi != this->Tests.end())
     {
-    std::map<cmStdString, cmTest*>::const_iterator
-      mi = this->Tests.find(testName);
-    if(mi != this->Tests.end())
-      {
-      return mi->second;
-      }
+    return mi->second;
     }
   return 0;
 }
@@ -3954,7 +4344,7 @@
   size_t depth = this->ListFileStack.size();
   if (depth > 0)
     {
-    std::deque<cmStdString>::const_iterator it = this->ListFileStack.end();
+    std::deque<std::string>::const_iterator it = this->ListFileStack.end();
     do
       {
       if (depth != this->ListFileStack.size())
@@ -3977,8 +4367,8 @@
 void cmMakefile::PushScope()
 {
   cmDefinitions* parent = &this->Internal->VarStack.top();
-  const std::set<cmStdString>& init = this->Internal->VarInitStack.top();
-  const std::set<cmStdString>& usage = this->Internal->VarUsageStack.top();
+  const std::set<std::string>& init = this->Internal->VarInitStack.top();
+  const std::set<std::string>& usage = this->Internal->VarUsageStack.top();
   this->Internal->VarStack.push(cmDefinitions(parent));
   this->Internal->VarInitStack.push(init);
   this->Internal->VarUsageStack.push(usage);
@@ -3987,18 +4377,18 @@
 void cmMakefile::PopScope()
 {
   cmDefinitions* current = &this->Internal->VarStack.top();
-  std::set<cmStdString> init = this->Internal->VarInitStack.top();
-  std::set<cmStdString> usage = this->Internal->VarUsageStack.top();
-  const std::set<cmStdString>& locals = current->LocalKeys();
+  std::set<std::string> init = this->Internal->VarInitStack.top();
+  std::set<std::string> usage = this->Internal->VarUsageStack.top();
+  const std::set<std::string>& locals = current->LocalKeys();
   // Remove initialization and usage information for variables in the local
   // scope.
-  std::set<cmStdString>::const_iterator it = locals.begin();
+  std::set<std::string>::const_iterator it = locals.begin();
   for (; it != locals.end(); ++it)
     {
     init.erase(*it);
-    if (!this->VariableUsed(it->c_str()))
+    if (!this->VariableUsed(*it))
       {
-      this->CheckForUnused("out of scope", it->c_str());
+      this->CheckForUnused("out of scope", *it);
       }
     else
       {
@@ -4021,9 +4411,9 @@
     }
 }
 
-void cmMakefile::RaiseScope(const char *var, const char *varDef)
+void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
 {
-  if (!var || !strlen(var))
+  if (var.empty())
     {
     return;
     }
@@ -4077,7 +4467,8 @@
 
 //----------------------------------------------------------------------------
 cmTarget*
-cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
+cmMakefile::AddImportedTarget(const std::string& name,
+                              cmTarget::TargetType type,
                               bool global)
 {
   // Create the target.
@@ -4104,7 +4495,7 @@
 {
   // Look for an imported target.  These take priority because they
   // are more local in scope and do not have to be globally unique.
-  std::map<cmStdString, cmTarget*>::const_iterator
+  TargetMap::const_iterator
     imported = this->ImportedTargets.find(name);
   if(imported != this->ImportedTargets.end())
     {
@@ -4118,8 +4509,7 @@
     }
 
   // Look for a target built in this project.
-  return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0,
-                                                              name.c_str(),
+  return this->LocalGenerator->GetGlobalGenerator()->FindTarget(name,
                                                               excludeAliases);
 }
 
@@ -4129,12 +4519,12 @@
   if (this->AliasTargets.find(name) != this->AliasTargets.end())
     return true;
   return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias(
-                                                              name.c_str());
+                                                              name);
 }
 
 //----------------------------------------------------------------------------
 cmGeneratorTarget*
-cmMakefile::FindGeneratorTargetToUse(const char* name) const
+cmMakefile::FindGeneratorTargetToUse(const std::string& name) const
 {
   if (cmTarget *t = this->FindTargetToUse(name))
     {
@@ -4223,6 +4613,9 @@
         case cmTarget::UTILITY:
           e << "a custom target ";
           break;
+        case cmTarget::INTERFACE_LIBRARY:
+          e << "an interface library ";
+          break;
         default: break;
         }
       e << "created in source directory \""
@@ -4236,8 +4629,8 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmMakefile::EnforceUniqueDir(const char* srcPath,
-                                  const char* binPath) const
+bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
+                                  const std::string& binPath) const
 {
   // Make sure the binary directory is unique.
   cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
@@ -4296,6 +4689,51 @@
   return this->QtUiFilesWithOptions;
 }
 
+static std::string matchVariables[] = {
+  "CMAKE_MATCH_0",
+  "CMAKE_MATCH_1",
+  "CMAKE_MATCH_2",
+  "CMAKE_MATCH_3",
+  "CMAKE_MATCH_4",
+  "CMAKE_MATCH_5",
+  "CMAKE_MATCH_6",
+  "CMAKE_MATCH_7",
+  "CMAKE_MATCH_8",
+  "CMAKE_MATCH_9"
+};
+
+//----------------------------------------------------------------------------
+void cmMakefile::ClearMatches()
+{
+  for (unsigned int i=0; i<this->NumLastMatches; i++)
+    {
+    std::string const& var = matchVariables[i];
+    std::string const& s = this->GetSafeDefinition(var);
+    if(!s.empty())
+      {
+      this->AddDefinition(var, "");
+      this->MarkVariableAsUsed(var);
+      }
+    }
+  this->NumLastMatches = 0;
+}
+
+//----------------------------------------------------------------------------
+void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
+{
+  for (unsigned int i=0; i<10; i++)
+    {
+    std::string const& m = re.match(i);
+    if(!m.empty())
+      {
+      std::string const& var = matchVariables[i];
+      this->AddDefinition(var, m.c_str());
+      this->MarkVariableAsUsed(var);
+      this->NumLastMatches = i + 1;
+      }
+    }
+}
+
 //----------------------------------------------------------------------------
 cmPolicies::PolicyStatus
 cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
@@ -4356,7 +4794,7 @@
   // Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting.
   if(!var.empty())
     {
-    if(const char* val = this->GetDefinition(var.c_str()))
+    if(const char* val = this->GetDefinition(var))
       {
       return cmSystemTools::IsOn(val);
       }
@@ -4391,7 +4829,7 @@
     {
     std::string msg =
       this->GetPolicies()->GetRequiredAlwaysPolicyError(id);
-    this->IssueMessage(cmake::FATAL_ERROR, msg.c_str());
+    this->IssueMessage(cmake::FATAL_ERROR, msg);
     return false;
     }
 
@@ -4515,3 +4953,486 @@
     pm[pid] = this->GetPolicyStatus(pid);
     }
 }
+
+#define FEATURE_STRING(F) , #F
+static const char * const C_FEATURES[] = {
+  0
+  FOR_EACH_C_FEATURE(FEATURE_STRING)
+};
+
+static const char * const CXX_FEATURES[] = {
+  0
+  FOR_EACH_CXX_FEATURE(FEATURE_STRING)
+};
+#undef FEATURE_STRING
+
+static const char * const C_STANDARDS[] = {
+    "90"
+  , "99"
+  , "11"
+};
+static const char * const CXX_STANDARDS[] = {
+    "98"
+  , "11"
+  , "14"
+};
+
+//----------------------------------------------------------------------------
+bool cmMakefile::
+AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
+                         std::string *error) const
+{
+  if (cmGeneratorExpression::Find(feature) != std::string::npos)
+    {
+    target->AppendProperty("COMPILE_FEATURES", feature.c_str());
+    return true;
+    }
+
+  std::string lang;
+  if (!this->CompileFeatureKnown(target, feature, lang, error))
+    {
+    return false;
+    }
+
+  const char* features = this->CompileFeaturesAvailable(lang, error);
+  if (!features)
+    {
+    return false;
+    }
+
+  std::vector<std::string> availableFeatures;
+  cmSystemTools::ExpandListArgument(features, availableFeatures);
+  if (std::find(availableFeatures.begin(),
+                availableFeatures.end(),
+                feature) == availableFeatures.end())
+    {
+    cmOStringStream e;
+    e << "The compiler feature \"" << feature
+      << "\" is not known to " << lang << " compiler\n\""
+      << this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
+      << "\"\nversion "
+      << this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
+    this->IssueMessage(cmake::FATAL_ERROR, e.str());
+    return false;
+    }
+
+  target->AppendProperty("COMPILE_FEATURES", feature.c_str());
+
+  return lang == "C"
+      ? this->AddRequiredTargetCFeature(target, feature)
+      : this->AddRequiredTargetCxxFeature(target, feature);
+}
+
+//----------------------------------------------------------------------------
+bool cmMakefile::
+CompileFeatureKnown(cmTarget const* target, const std::string& feature,
+                    std::string& lang, std::string *error) const
+{
+  assert(cmGeneratorExpression::Find(feature) == std::string::npos);
+
+  bool isCFeature = std::find_if(cmArrayBegin(C_FEATURES) + 1,
+              cmArrayEnd(C_FEATURES), cmStrCmp(feature))
+              != cmArrayEnd(C_FEATURES);
+  if (isCFeature)
+    {
+    lang = "C";
+    return true;
+    }
+  bool isCxxFeature = std::find_if(cmArrayBegin(CXX_FEATURES) + 1,
+              cmArrayEnd(CXX_FEATURES), cmStrCmp(feature))
+              != cmArrayEnd(CXX_FEATURES);
+  if (isCxxFeature)
+    {
+    lang = "CXX";
+    return true;
+    }
+  cmOStringStream e;
+  if (error)
+    {
+    e << "specified";
+    }
+  else
+    {
+    e << "Specified";
+    }
+  e << " unknown feature \"" << feature << "\" for "
+    "target \"" << target->GetName() << "\".";
+  if (error)
+    {
+    *error = e.str();
+    }
+  else
+    {
+    this->IssueMessage(cmake::FATAL_ERROR, e.str());
+    }
+  return false;
+}
+
+//----------------------------------------------------------------------------
+const char* cmMakefile::
+CompileFeaturesAvailable(const std::string& lang, std::string *error) const
+{
+  const char* featuresKnown =
+    this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES");
+
+  if (!featuresKnown || !*featuresKnown)
+    {
+    cmOStringStream e;
+    if (error)
+      {
+      e << "no";
+      }
+    else
+      {
+      e << "No";
+      }
+    e << " known features for " << lang << " compiler\n\""
+      << this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
+      << "\"\nversion "
+      << this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
+    if (error)
+      {
+      *error = e.str();
+      }
+    else
+      {
+      this->IssueMessage(cmake::FATAL_ERROR, e.str());
+      }
+    return 0;
+    }
+  return featuresKnown;
+}
+
+//----------------------------------------------------------------------------
+bool cmMakefile::HaveFeatureAvailable(cmTarget const* target,
+                                      std::string const& lang,
+                                      const std::string& feature) const
+{
+  return lang == "C"
+      ? this->HaveCFeatureAvailable(target, feature)
+      : this->HaveCxxFeatureAvailable(target, feature);
+}
+
+//----------------------------------------------------------------------------
+bool cmMakefile::
+HaveCFeatureAvailable(cmTarget const* target, const std::string& feature) const
+{
+  bool needC90 = false;
+  bool needC99 = false;
+  bool needC11 = false;
+
+  this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
+
+  const char *existingCStandard = target->GetProperty("C_STANDARD");
+  if (!existingCStandard)
+    {
+    existingCStandard = this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
+    }
+
+  if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
+                cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS))
+    {
+    cmOStringStream e;
+    e << "The C_STANDARD property on target \"" << target->GetName()
+      << "\" contained an invalid value: \"" << existingCStandard << "\".";
+    this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    return false;
+    }
+
+  const char * const *existingCIt = existingCStandard
+                                    ? std::find_if(cmArrayBegin(C_STANDARDS),
+                                      cmArrayEnd(C_STANDARDS),
+                                      cmStrCmp(existingCStandard))
+                                    : cmArrayEnd(C_STANDARDS);
+
+  if (needC11 && existingCStandard && existingCIt <
+                                    std::find_if(cmArrayBegin(C_STANDARDS),
+                                      cmArrayEnd(C_STANDARDS),
+                                      cmStrCmp("11")))
+    {
+    return false;
+    }
+  else if(needC99 && existingCStandard && existingCIt <
+                                    std::find_if(cmArrayBegin(C_STANDARDS),
+                                      cmArrayEnd(C_STANDARDS),
+                                      cmStrCmp("99")))
+    {
+    return false;
+    }
+  else if(needC90 && existingCStandard && existingCIt <
+                                    std::find_if(cmArrayBegin(C_STANDARDS),
+                                      cmArrayEnd(C_STANDARDS),
+                                      cmStrCmp("90")))
+    {
+    return false;
+    }
+  return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmMakefile::IsLaterStandard(std::string const& lang,
+                                 std::string const& lhs,
+                                 std::string const& rhs)
+{
+  if (lang == "C")
+    {
+    const char * const *rhsIt = std::find_if(cmArrayBegin(C_STANDARDS),
+                                            cmArrayEnd(C_STANDARDS),
+                                            cmStrCmp(rhs));
+
+    return std::find_if(rhsIt, cmArrayEnd(C_STANDARDS),
+                        cmStrCmp(lhs)) != cmArrayEnd(C_STANDARDS);
+    }
+  const char * const *rhsIt = std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                           cmArrayEnd(CXX_STANDARDS),
+                                           cmStrCmp(rhs));
+
+  return std::find_if(rhsIt, cmArrayEnd(CXX_STANDARDS),
+                      cmStrCmp(lhs)) != cmArrayEnd(CXX_STANDARDS);
+}
+
+//----------------------------------------------------------------------------
+bool cmMakefile::HaveCxxFeatureAvailable(cmTarget const* target,
+                                         const std::string& feature) const
+{
+  bool needCxx98 = false;
+  bool needCxx11 = false;
+  bool needCxx14 = false;
+  this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14);
+
+  const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
+  if (!existingCxxStandard)
+    {
+    existingCxxStandard = this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
+    }
+
+  if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
+                cmStrCmp(existingCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
+    {
+    cmOStringStream e;
+    e << "The CXX_STANDARD property on target \"" << target->GetName()
+      << "\" contained an invalid value: \"" << existingCxxStandard << "\".";
+    this->IssueMessage(cmake::FATAL_ERROR, e.str());
+    return false;
+    }
+
+  const char * const *existingCxxIt = existingCxxStandard
+                                    ? std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp(existingCxxStandard))
+                                    : cmArrayEnd(CXX_STANDARDS);
+
+  if (needCxx11 && existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp("11")))
+    {
+    return false;
+    }
+  else if(needCxx98 && existingCxxIt <
+                                    std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp("98")))
+    {
+    return false;
+    }
+  return true;
+}
+
+//----------------------------------------------------------------------------
+void cmMakefile::CheckNeededCxxLanguage(const std::string& feature,
+                                        bool& needCxx98,
+                                        bool& needCxx11,
+                                        bool& needCxx14) const
+{
+  if (const char *propCxx98 =
+          this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(propCxx98, props);
+    needCxx98 = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+  if (const char *propCxx11 =
+          this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(propCxx11, props);
+    needCxx11 = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+  if (const char *propCxx14 =
+          this->GetDefinition("CMAKE_CXX14_COMPILE_FEATURES"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(propCxx14, props);
+    needCxx14 = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+}
+
+//----------------------------------------------------------------------------
+bool cmMakefile::
+AddRequiredTargetCxxFeature(cmTarget *target,
+                            const std::string& feature) const
+{
+  bool needCxx98 = false;
+  bool needCxx11 = false;
+  bool needCxx14 = false;
+
+  this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14);
+
+  const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
+  if (existingCxxStandard)
+    {
+    if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
+                  cmStrCmp(existingCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
+      {
+      cmOStringStream e;
+      e << "The CXX_STANDARD property on target \"" << target->GetName()
+        << "\" contained an invalid value: \"" << existingCxxStandard << "\".";
+      this->IssueMessage(cmake::FATAL_ERROR, e.str());
+      return false;
+      }
+    }
+  const char * const *existingCxxIt = existingCxxStandard
+                                    ? std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp(existingCxxStandard))
+                                    : cmArrayEnd(CXX_STANDARDS);
+
+  bool setCxx98 = needCxx98 && !existingCxxStandard;
+  bool setCxx11 = needCxx11 && !existingCxxStandard;
+  bool setCxx14 = needCxx14 && !existingCxxStandard;
+
+  if (needCxx14 && existingCxxStandard && existingCxxIt <
+                                    std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp("14")))
+    {
+    setCxx14 = true;
+    }
+  else if (needCxx11 && existingCxxStandard && existingCxxIt <
+                                    std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp("11")))
+    {
+    setCxx11 = true;
+    }
+  else if(needCxx98 && existingCxxStandard && existingCxxIt <
+                                    std::find_if(cmArrayBegin(CXX_STANDARDS),
+                                      cmArrayEnd(CXX_STANDARDS),
+                                      cmStrCmp("98")))
+    {
+    setCxx98 = true;
+    }
+
+  if (setCxx14)
+    {
+    target->SetProperty("CXX_STANDARD", "14");
+    }
+  else if (setCxx11)
+    {
+    target->SetProperty("CXX_STANDARD", "11");
+    }
+  else if (setCxx98)
+    {
+    target->SetProperty("CXX_STANDARD", "98");
+    }
+  return true;
+}
+
+//----------------------------------------------------------------------------
+void cmMakefile::CheckNeededCLanguage(const std::string& feature,
+                                        bool& needC90,
+                                        bool& needC99,
+                                        bool& needC11) const
+{
+  if (const char *propC90 =
+          this->GetDefinition("CMAKE_C90_COMPILE_FEATURES"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(propC90, props);
+    needC90 = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+  if (const char *propC99 =
+          this->GetDefinition("CMAKE_C99_COMPILE_FEATURES"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(propC99, props);
+    needC99 = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+  if (const char *propC11 =
+          this->GetDefinition("CMAKE_C11_COMPILE_FEATURES"))
+    {
+    std::vector<std::string> props;
+    cmSystemTools::ExpandListArgument(propC11, props);
+    needC11 = std::find(props.begin(), props.end(), feature) != props.end();
+    }
+}
+
+//----------------------------------------------------------------------------
+bool cmMakefile::
+AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const
+{
+  bool needC90 = false;
+  bool needC99 = false;
+  bool needC11 = false;
+
+  this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
+
+  const char *existingCStandard = target->GetProperty("C_STANDARD");
+  if (existingCStandard)
+    {
+    if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
+                  cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS))
+      {
+      cmOStringStream e;
+      e << "The C_STANDARD property on target \"" << target->GetName()
+        << "\" contained an invalid value: \"" << existingCStandard << "\".";
+      this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+      return false;
+      }
+    }
+  const char * const *existingCIt = existingCStandard
+                                    ? std::find_if(cmArrayBegin(C_STANDARDS),
+                                      cmArrayEnd(C_STANDARDS),
+                                      cmStrCmp(existingCStandard))
+                                    : cmArrayEnd(C_STANDARDS);
+
+  bool setC90 = needC90 && !existingCStandard;
+  bool setC99 = needC99 && !existingCStandard;
+  bool setC11 = needC11 && !existingCStandard;
+
+  if (needC11 && existingCStandard && existingCIt <
+                                    std::find_if(cmArrayBegin(C_STANDARDS),
+                                      cmArrayEnd(C_STANDARDS),
+                                      cmStrCmp("11")))
+    {
+    setC11 = true;
+    }
+  else if(needC99 && existingCStandard && existingCIt <
+                                    std::find_if(cmArrayBegin(C_STANDARDS),
+                                      cmArrayEnd(C_STANDARDS),
+                                      cmStrCmp("99")))
+    {
+    setC99 = true;
+    }
+  else if(needC90 && existingCStandard && existingCIt <
+                                    std::find_if(cmArrayBegin(C_STANDARDS),
+                                      cmArrayEnd(C_STANDARDS),
+                                      cmStrCmp("90")))
+    {
+    setC90 = true;
+    }
+
+  if (setC11)
+    {
+    target->SetProperty("C_STANDARD", "11");
+    }
+  else if (setC99)
+    {
+    target->SetProperty("C_STANDARD", "99");
+    }
+  else if (setC90)
+    {
+    target->SetProperty("C_STANDARD", "90");
+    }
+  return true;
+}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index f00fd20..d5ffd98 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -69,11 +69,11 @@
   /* Check for unused variables in this scope */
   void CheckForUnusedVariables() const;
   /* Mark a variable as used */
-  void MarkVariableAsUsed(const char* var);
+  void MarkVariableAsUsed(const std::string& var);
   /* return true if a variable has been initialized */
-  bool VariableInitialized(const char* ) const;
+  bool VariableInitialized(const std::string& ) const;
   /* return true if a variable has been used */
-  bool VariableUsed(const char* ) const;
+  bool VariableUsed(const std::string& ) const;
   /** Return whether compatibility features needed for a version of
       the cache or lower should be enabled.  */
   bool NeedCacheCompatibility(int major, int minor) const;
@@ -126,8 +126,8 @@
    * Try running cmake and building a file. This is used for dynalically
    * loaded commands, not as part of the usual build process.
    */
-  int TryCompile(const char *srcdir, const char *bindir,
-                 const char *projectName, const char *targetName,
+  int TryCompile(const std::string& srcdir, const std::string& bindir,
+                 const std::string& projectName, const std::string& targetName,
                  bool fast,
                  const std::vector<std::string> *cmakeArgs,
                  std::string *output);
@@ -168,7 +168,7 @@
   void Print() const;
 
   /** Add a custom command to the build.  */
-  void AddCustomCommandToTarget(const char* target,
+  void AddCustomCommandToTarget(const std::string& target,
                                 const std::vector<std::string>& depends,
                                 const cmCustomCommandLines& commandLines,
                                 cmTarget::CustomCommandType type,
@@ -177,23 +177,23 @@
   cmSourceFile* AddCustomCommandToOutput(
     const std::vector<std::string>& outputs,
     const std::vector<std::string>& depends,
-    const char* main_dependency,
+    const std::string& main_dependency,
     const cmCustomCommandLines& commandLines,
     const char* comment, const char* workingDir,
     bool replace = false,
     bool escapeOldStyle = true);
   cmSourceFile* AddCustomCommandToOutput(
-    const char* output,
+    const std::string& output,
     const std::vector<std::string>& depends,
-    const char* main_dependency,
+    const std::string& main_dependency,
     const cmCustomCommandLines& commandLines,
     const char* comment, const char* workingDir,
     bool replace = false,
     bool escapeOldStyle = true);
-  void AddCustomCommandOldStyle(const char* target,
+  void AddCustomCommandOldStyle(const std::string& target,
                                 const std::vector<std::string>& outputs,
                                 const std::vector<std::string>& depends,
-                                const char* source,
+                                const std::string& source,
                                 const cmCustomCommandLines& commandLines,
                                 const char* comment);
 
@@ -205,10 +205,11 @@
   void AddCompileOption(const char* option);
 
   /** Create a new imported target with the name and type given.  */
-  cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type,
+  cmTarget* AddImportedTarget(const std::string& name,
+                              cmTarget::TargetType type,
                               bool global);
 
-  cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name);
+  cmTarget* AddNewTarget(cmTarget::TargetType type, const std::string& name);
 
   /**
    * Add an executable to the build.
@@ -221,7 +222,7 @@
    * Add a utility to the build.  A utiltity target is a command that
    * is run every time the target is built.
    */
-  void AddUtilityCommand(const char* utilityName, bool excludeFromAll,
+  void AddUtilityCommand(const std::string& utilityName, bool excludeFromAll,
                          const std::vector<std::string>& depends,
                          const char* workingDirectory,
                          const char* command,
@@ -229,7 +230,8 @@
                          const char* arg2=0,
                          const char* arg3=0,
                          const char* arg4=0);
-  cmTarget* AddUtilityCommand(const char* utilityName, bool excludeFromAll,
+  cmTarget* AddUtilityCommand(const std::string& utilityName,
+                              bool excludeFromAll,
                               const char* workingDirectory,
                               const std::vector<std::string>& depends,
                               const cmCustomCommandLines& commandLines,
@@ -239,16 +241,16 @@
   /**
    * Add a link library to the build.
    */
-  void AddLinkLibrary(const char*);
-  void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
-  void AddLinkLibraryForTarget(const char *tgt, const char*,
+  void AddLinkLibrary(const std::string&);
+  void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type);
+  void AddLinkLibraryForTarget(const std::string& tgt, const std::string&,
                                cmTarget::LinkLibraryType type);
-  void AddLinkDirectoryForTarget(const char *tgt, const char* d);
+  void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d);
 
   /**
    * Add a link directory to the build.
    */
-  void AddLinkDirectory(const char*);
+  void AddLinkDirectory(const std::string&);
 
   const std::vector<std::string>& GetLinkDirectories() const
     {
@@ -262,9 +264,10 @@
   /**
    * Add a subdirectory to the build.
    */
-  void AddSubDirectory(const char*, bool excludeFromAll=false,
+  void AddSubDirectory(const std::string&, bool excludeFromAll=false,
                        bool preorder = false);
-  void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir,
+  void AddSubDirectory(const std::string& fullSrcDir,
+                       const std::string& fullBinDir,
                        bool excludeFromAll, bool preorder,
                        bool immediate);
 
@@ -283,9 +286,9 @@
    * Add a variable definition to the build. This variable
    * can be used in CMake to refer to lists, directories, etc.
    */
-  void AddDefinition(const char* name, const char* value);
+  void AddDefinition(const std::string& name, const char* value);
   ///! Add a definition to this makefile and the global cmake cache.
-  void AddCacheDefinition(const char* name, const char* value,
+  void AddCacheDefinition(const std::string& name, const char* value,
                           const char* doc,
                           cmCacheManager::CacheEntryType type,
                           bool force = false);
@@ -293,15 +296,15 @@
   /**
    * Add bool variable definition to the build.
    */
-  void AddDefinition(const char* name, bool);
+  void AddDefinition(const std::string& name, bool);
 
   /**
    * Remove a variable definition from the build.  This is not valid
    * for cache entries, and will only affect the current makefile.
    */
-  void RemoveDefinition(const char* name);
+  void RemoveDefinition(const std::string& name);
   ///! Remove a definition from the cache.
-  void RemoveCacheDefinition(const char* name);
+  void RemoveCacheDefinition(const std::string& name);
 
   /**
    * Specify the name of the project for this build.
@@ -317,22 +320,22 @@
     }
 
   /** Get the configurations to be generated.  */
-  const char* GetConfigurations(std::vector<std::string>& configs,
+  std::string GetConfigurations(std::vector<std::string>& configs,
                                 bool single = true) const;
 
   /**
    * Set the name of the library.
    */
-  cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type,
+  cmTarget* AddLibrary(const std::string& libname, cmTarget::TargetType type,
                   const std::vector<std::string> &srcs,
                   bool excludeFromAll = false);
-  void AddAlias(const char *libname, cmTarget *tgt);
+  void AddAlias(const std::string& libname, cmTarget *tgt);
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**
    * Add a root source group for consideration when adding a new source.
    */
-  void AddSourceGroup(const char* name, const char* regex=0);
+  void AddSourceGroup(const std::string& name, const char* regex=0);
 
   /**
    * Add a source group for consideration when adding a new source.
@@ -399,12 +402,12 @@
    * CMakeLists files by recursing up the tree starting at the StartDirectory
    * and going up until it reaches the HomeDirectory.
    */
-  void SetHomeDirectory(const char* dir);
+  void SetHomeDirectory(const std::string& dir);
   const char* GetHomeDirectory() const
     {
       return this->cmHomeDirectory.c_str();
     }
-  void SetHomeOutputDirectory(const char* lib);
+  void SetHomeOutputDirectory(const std::string& lib);
   const char* GetHomeOutputDirectory() const
     {
       return this->HomeOutputDirectory.c_str();
@@ -429,7 +432,7 @@
    * recursing up the tree starting at the StartDirectory and going up until
    * it reaches the HomeDirectory.
    */
-  void SetStartDirectory(const char* dir)
+  void SetStartDirectory(const std::string& dir)
     {
       this->cmStartDirectory = dir;
       cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
@@ -442,7 +445,7 @@
     {
       return this->cmStartDirectory.c_str();
     }
-  void SetStartOutputDirectory(const char* lib)
+  void SetStartOutputDirectory(const std::string& lib)
     {
       this->StartOutputDirectory = lib;
       cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
@@ -494,7 +497,7 @@
    * Set a regular expression that include files that are not found
    * must match in order to be considered a problem.
    */
-  void SetComplainRegularExpression(const char* regex)
+  void SetComplainRegularExpression(const std::string& regex)
     {
       this->ComplainFileRegularExpression = regex;
     }
@@ -534,12 +537,12 @@
   cmTarget* FindTargetToUse(const std::string& name,
                             bool excludeAliases = false) const;
   bool IsAlias(const std::string& name) const;
-  cmGeneratorTarget* FindGeneratorTargetToUse(const char* name) const;
+  cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
 
   /**
    * Mark include directories as system directories.
    */
-  void AddSystemIncludeDirectories(const std::set<cmStdString> &incs);
+  void AddSystemIncludeDirectories(const std::set<std::string> &incs);
 
   /** Expand out any arguements in the vector that have ; separated
    *  strings into multiple arguements.  A new vector is created
@@ -555,14 +558,14 @@
   /** Get a cmSourceFile pointer for a given source name, if the name is
    *  not found, then a null pointer is returned.
    */
-  cmSourceFile* GetSource(const char* sourceName) const;
+  cmSourceFile* GetSource(const std::string& sourceName) const;
 
   /** Get a cmSourceFile pointer for a given source name, if the name is
    *  not found, then create the source file and return it. generated
    * indicates if it is a generated file, this is used in determining
    * how to create the source file instance e.g. name
    */
-  cmSourceFile* GetOrCreateSource(const char* sourceName,
+  cmSourceFile* GetOrCreateSource(const std::string& sourceName,
                                   bool generated = false);
 
   /**
@@ -587,10 +590,10 @@
    * If the variable is not found in this makefile instance, the
    * cache is then queried.
    */
-  const char* GetDefinition(const char*) const;
-  const char* GetSafeDefinition(const char*) const;
-  const char* GetRequiredDefinition(const char* name) const;
-  bool IsDefinitionSet(const char*) const;
+  const char* GetDefinition(const std::string&) const;
+  const char* GetSafeDefinition(const std::string&) const;
+  const char* GetRequiredDefinition(const std::string& name) const;
+  bool IsDefinitionSet(const std::string&) const;
   /**
    * Get the list of all variables in the current space. If argument
    * cacheonly is specified and is greater than 0, then only cache
@@ -598,17 +601,20 @@
    */
   std::vector<std::string> GetDefinitions(int cacheonly=0) const;
 
-  /** Test a boolean cache entry to see if it is true or false,
-   *  returns false if no entry defined.
+  /**
+   * Test a boolean variable to see if it is true or false.
+   * If the variable is not found in this makefile instance, the
+   * cache is then queried.
+   * Returns false if no entry defined.
    */
-  bool IsOn(const char* name) const;
-  bool IsSet(const char* name) const;
+  bool IsOn(const std::string& name) const;
+  bool IsSet(const std::string& name) const;
 
   /** Return whether the target platform is 64-bit.  */
   bool PlatformIs64Bit() const;
 
   /** Retrieve soname flag for the specified language if supported */
-  const char* GetSONameFlag(const char* language) const;
+  const char* GetSONameFlag(const std::string& language) const;
 
   /**
    * Get a list of preprocessor define flags.
@@ -649,7 +655,7 @@
   /**
    * Get the current context backtrace.
    */
-  bool GetBacktrace(cmListFileBacktrace& backtrace) const;
+  cmListFileBacktrace GetBacktrace() const;
 
   /**
    * Get the vector of  files created by this makefile
@@ -673,7 +679,7 @@
                                       const char* filename = 0,
                                       long line = -1,
                                       bool removeEmpty = false,
-                                      bool replaceAt = true) const;
+                                      bool replaceAt = false) const;
 
   /**
    * Remove any remaining variables in the string. Anything with ${var} or
@@ -773,7 +779,7 @@
    * Is there a source file that has the provided source file as an output?
    * if so then return it
    */
-  cmSourceFile *GetSourceFileWithOutput(const char *outName) const;
+  cmSourceFile *GetSourceFileWithOutput(const std::string& outName) const;
 
   /**
    * Add a macro to the list of macros. The arguments should be name of the
@@ -782,12 +788,12 @@
   void AddMacro(const char* name, const char* signature);
 
   ///! Add a new cmTest to the list of tests for this makefile.
-  cmTest* CreateTest(const char* testName);
+  cmTest* CreateTest(const std::string& testName);
 
   /** Get a cmTest pointer for a given test name, if the name is
    *  not found, then a null pointer is returned.
    */
-  cmTest* GetTest(const char* testName) const;
+  cmTest* GetTest(const std::string& testName) const;
 
   /**
    * Get a list of macros as a ; separated string
@@ -800,17 +806,19 @@
   std::string GetModulesFile(const char* name) const;
 
   ///! Set/Get a property of this directory
-  void SetProperty(const char *prop, const char *value);
-  void AppendProperty(const char *prop, const char *value,bool asString=false);
-  const char *GetProperty(const char *prop) const;
-  const char *GetPropertyOrDefinition(const char *prop) const;
-  const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const;
-  bool GetPropertyAsBool(const char *prop) const;
+  void SetProperty(const std::string& prop, const char *value);
+  void AppendProperty(const std::string& prop, const char *value,
+                      bool asString=false);
+  const char *GetProperty(const std::string& prop) const;
+  const char *GetProperty(const std::string& prop,
+                          cmProperty::ScopeType scope) const;
+  bool GetPropertyAsBool(const std::string& prop) const;
 
-  const char* GetFeature(const char* feature, const char* config);
+  const char* GetFeature(const std::string& feature,
+                         const std::string& config);
 
   // Get the properties
-  cmPropertyMap &GetProperties() { return this->Properties; };
+  cmPropertyMap &GetProperties() { return this->Properties; }
 
   ///! Initialize a makefile from its parent
   void InitializeFromParent();
@@ -835,7 +843,7 @@
   // push and pop variable scopes
   void PushScope();
   void PopScope();
-  void RaiseScope(const char *var, const char *value);
+  void RaiseScope(const std::string& var, const char *value);
 
   /** Helper class to push and pop scopes automatically.  */
   class ScopePushPop
@@ -872,17 +880,37 @@
   void AddQtUiFileWithOptions(cmSourceFile *sf);
   std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const;
 
-  std::set<cmStdString> const & GetSystemIncludeDirectories() const
+  std::set<std::string> const & GetSystemIncludeDirectories() const
     { return this->SystemIncludeDirectories; }
 
   bool PolicyOptionalWarningEnabled(std::string const& var);
 
+  bool AddRequiredTargetFeature(cmTarget *target,
+                                const std::string& feature,
+                                std::string *error = 0) const;
+
+  bool CompileFeatureKnown(cmTarget const* target, const std::string& feature,
+                           std::string& lang, std::string *error) const;
+
+  const char* CompileFeaturesAvailable(const std::string& lang,
+                                       std::string *error) const;
+
+  bool HaveFeatureAvailable(cmTarget const* target, std::string const& lang,
+                            const std::string& feature) const;
+
+  bool IsLaterStandard(std::string const& lang,
+                       std::string const& lhs,
+                       std::string const& rhs);
+
+  void ClearMatches();
+  void StoreMatches(cmsys::RegularExpression& re);
+
 protected:
   // add link libraries and directories to the target
-  void AddGlobalLinkInformation(const char* name, cmTarget& target);
+  void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
 
   // Check for a an unused variable
-  void CheckForUnused(const char* reason, const char* name) const;
+  void CheckForUnused(const char* reason, const std::string& name) const;
 
   std::string Prefix;
   std::vector<std::string> AuxSourceDirectories; //
@@ -897,19 +925,24 @@
 
   // libraries, classes, and executables
   mutable cmTargets Targets;
-  std::map<std::string, cmTarget*> AliasTargets;
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+  typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
+#else
+  typedef std::map<std::string, cmTarget*> TargetMap;
+#endif
+  TargetMap AliasTargets;
   cmGeneratorTargetsType GeneratorTargets;
   std::vector<cmSourceFile*> SourceFiles;
 
   // Tests
-  std::map<cmStdString, cmTest*> Tests;
+  std::map<std::string, cmTest*> Tests;
 
   // The link-library paths.  Order matters, use std::vector (not std::set).
   std::vector<std::string> LinkDirectories;
 
   // The set of include directories that are marked as system include
   // directories.
-  std::set<cmStdString> SystemIncludeDirectories;
+  std::set<std::string> SystemIncludeDirectories;
 
   std::vector<std::string> ListFiles; // list of command files loaded
   std::vector<std::string> OutputFiles; // list of command files loaded
@@ -949,12 +982,13 @@
 
   bool ParseDefineFlag(std::string const& definition, bool remove);
 
-  bool EnforceUniqueDir(const char* srcPath, const char* binPath) const;
+  bool EnforceUniqueDir(const std::string& srcPath,
+                        const std::string& binPath) const;
 
   friend class cmMakeDepend;    // make depend needs direct access
                                 // to the Sources array
   void PrintStringVector(const char* s, const
-                         std::vector<std::pair<cmStdString, bool> >& v) const;
+                         std::vector<std::pair<std::string, bool> >& v) const;
   void PrintStringVector(const char* s,
                          const std::vector<std::string>& v) const;
 
@@ -965,14 +999,15 @@
   void PushFunctionBlockerBarrier();
   void PopFunctionBlockerBarrier(bool reportError = true);
 
-  typedef std::map<cmStdString, cmStdString> StringStringMap;
+  typedef std::map<std::string, std::string> StringStringMap;
   StringStringMap MacrosMap;
 
-  std::map<cmStdString, bool> SubDirectoryOrder;
+  std::map<std::string, bool> SubDirectoryOrder;
 
   mutable cmsys::RegularExpression cmDefineRegex;
   mutable cmsys::RegularExpression cmDefine01Regex;
   mutable cmsys::RegularExpression cmAtVarRegex;
+  mutable cmsys::RegularExpression cmNamedCurly;
 
   cmPropertyMap Properties;
 
@@ -984,7 +1019,7 @@
   bool CheckSystemVars;
 
   // stack of list files being read
-  std::deque<cmStdString> ListFileStack;
+  std::deque<std::string> ListFileStack;
 
   // stack of commands being invoked.
   struct CallStackEntry
@@ -997,7 +1032,7 @@
   friend class cmMakefileCall;
 
   std::vector<cmTarget*> ImportedTargetsOwned;
-  std::map<cmStdString, cmTarget*> ImportedTargets;
+  TargetMap ImportedTargets;
 
   // Internal policy stack management.
   void PushPolicy(bool weak = false,
@@ -1029,14 +1064,36 @@
   // Enforce rules about CMakeLists.txt files.
   void EnforceDirectoryLevelRules() const;
 
+  // CMP0053 == old
+  cmake::MessageType ExpandVariablesInStringOld(
+                                  std::string& errorstr,
+                                  std::string& source,
+                                  bool escapeQuotes,
+                                  bool noEscapes,
+                                  bool atOnly,
+                                  const char* filename,
+                                  long line,
+                                  bool removeEmpty,
+                                  bool replaceAt) const;
+  // CMP0053 == new
+  cmake::MessageType ExpandVariablesInStringNew(
+                                  std::string& errorstr,
+                                  std::string& source,
+                                  bool escapeQuotes,
+                                  bool noEscapes,
+                                  bool atOnly,
+                                  const char* filename,
+                                  long line,
+                                  bool removeEmpty,
+                                  bool replaceAt) const;
   bool GeneratingBuildSystem;
   /**
-   * Old version of GetSourceFileWithOutput(const char*) kept for
+   * Old version of GetSourceFileWithOutput(const std::string&) kept for
    * backward-compatibility. It implements a linear search and support
    * relative file paths. It is used as a fall back by
-   * GetSourceFileWithOutput(const char*).
+   * GetSourceFileWithOutput(const std::string&).
    */
-  cmSourceFile *LinearGetSourceFileWithOutput(const char *cname) const;
+  cmSourceFile *LinearGetSourceFileWithOutput(const std::string& cname) const;
 
   // A map for fast output to input look up.
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -1052,6 +1109,26 @@
                                cmSourceFile* source);
 
   std::vector<cmSourceFile*> QtUiFilesWithOptions;
+
+  unsigned int NumLastMatches;
+
+  bool AddRequiredTargetCFeature(cmTarget *target,
+                                 const std::string& feature) const;
+
+  bool AddRequiredTargetCxxFeature(cmTarget *target,
+                                   const std::string& feature) const;
+
+  void CheckNeededCLanguage(const std::string& feature, bool& needC90,
+                            bool& needC99, bool& needC11) const;
+  void CheckNeededCxxLanguage(const std::string& feature, bool& needCxx98,
+                              bool& needCxx11, bool& needCxx14) const;
+
+  bool HaveCFeatureAvailable(cmTarget const* target,
+                             const std::string& feature) const;
+  bool HaveCxxFeatureAvailable(cmTarget const* target,
+                               const std::string& feature) const;
+
+  mutable bool SuppressWatches;
 };
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 69b8092..fc52ccc 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -129,7 +129,11 @@
       }
     }
 
-  std::string pdbOutputPath = this->Target->GetPDBDirectory();
+  std::string compilePdbOutputPath =
+    this->Target->GetCompilePDBDirectory(this->ConfigName);
+  cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+
+  std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName);
   cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
   pdbOutputPath += "/";
 
@@ -138,32 +142,32 @@
   std::string targetFullPathPDB =  pdbOutputPath + targetNamePDB;
   std::string targetFullPathImport = outpathImp + targetNameImport;
   std::string targetOutPathPDB =
-    this->Convert(targetFullPathPDB.c_str(),
+    this->Convert(targetFullPathPDB,
                   cmLocalGenerator::NONE,
                   cmLocalGenerator::SHELL);
   // Convert to the output path to use in constructing commands.
   std::string targetOutPath =
-    this->Convert(targetFullPath.c_str(),
+    this->Convert(targetFullPath,
                   cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
   std::string targetOutPathReal =
-    this->Convert(targetFullPathReal.c_str(),
+    this->Convert(targetFullPathReal,
                   cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
   std::string targetOutPathImport =
-    this->Convert(targetFullPathImport.c_str(),
+    this->Convert(targetFullPathImport,
                   cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
 
   // Get the language to use for linking this executable.
-  const char* linkLanguage =
+  std::string linkLanguage =
     this->Target->GetLinkerLanguage(this->ConfigName);
 
   // Make sure we have a link language.
-  if(!linkLanguage)
+  if(linkLanguage.empty())
     {
     cmSystemTools::Error("Cannot determine link language for target \"",
-                         this->Target->GetName(), "\".");
+                         this->Target->GetName().c_str(), "\".");
     return;
     }
 
@@ -206,7 +210,7 @@
     export_flag_var += linkLanguage;
     export_flag_var += "_FLAG";
     this->LocalGenerator->AppendFlags
-      (linkFlags, this->Makefile->GetDefinition(export_flag_var.c_str()));
+      (linkFlags, this->Makefile->GetDefinition(export_flag_var));
     }
 
   // Add language feature flags.
@@ -221,14 +225,14 @@
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
-    (linkFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+    (linkFlags, this->Target->GetProperty(linkFlagsConfig));
 
   this->AddModuleDefinitionFlag(linkFlags);
 
   // Construct a list of files associated with this executable that
   // may need to be cleaned.
   std::vector<std::string> exeCleanFiles;
-  exeCleanFiles.push_back(this->Convert(targetFullPath.c_str(),
+  exeCleanFiles.push_back(this->Convert(targetFullPath,
                                         cmLocalGenerator::START_OUTPUT,
                                         cmLocalGenerator::UNCHANGED));
 #ifdef _WIN32
@@ -240,19 +244,19 @@
 #endif
   if(targetNameReal != targetName)
     {
-    exeCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(),
+    exeCleanFiles.push_back(this->Convert(targetFullPathReal,
                                           cmLocalGenerator::START_OUTPUT,
                                           cmLocalGenerator::UNCHANGED));
     }
   if(!targetNameImport.empty())
     {
-    exeCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
+    exeCleanFiles.push_back(this->Convert(targetFullPathImport,
                                           cmLocalGenerator::START_OUTPUT,
                                           cmLocalGenerator::UNCHANGED));
     std::string implib;
     if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
       {
-      exeCleanFiles.push_back(this->Convert(implib.c_str(),
+      exeCleanFiles.push_back(this->Convert(implib,
                                             cmLocalGenerator::START_OUTPUT,
                                             cmLocalGenerator::UNCHANGED));
       }
@@ -262,7 +266,7 @@
   // cleaned.  We do not want to delete the .pdb file just before
   // linking the target.
   this->CleanFiles.push_back
-    (this->Convert(targetFullPathPDB.c_str(),
+    (this->Convert(targetFullPathPDB,
                    cmLocalGenerator::START_OUTPUT,
                    cmLocalGenerator::UNCHANGED));
 
@@ -285,7 +289,7 @@
   std::string linkRuleVar = "CMAKE_";
   linkRuleVar += linkLanguage;
   linkRuleVar += "_LINK_EXECUTABLE";
-  std::string linkRule = this->GetLinkRule(linkRuleVar.c_str());
+  std::string linkRule = this->GetLinkRule(linkRuleVar);
   std::vector<std::string> commands1;
   cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
   if(this->Target->IsExecutableWithExports())
@@ -296,54 +300,71 @@
     implibRuleVar += linkLanguage;
     implibRuleVar += "_CREATE_IMPORT_LIBRARY";
     if(const char* rule =
-       this->Makefile->GetDefinition(implibRuleVar.c_str()))
+       this->Makefile->GetDefinition(implibRuleVar))
       {
       cmSystemTools::ExpandListArgument(rule, real_link_commands);
       }
     }
 
   // Select whether to use a response file for objects.
-  bool useResponseFile = false;
+  bool useResponseFileForObjects = false;
   {
   std::string responseVar = "CMAKE_";
   responseVar += linkLanguage;
   responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
-  if(this->Makefile->IsOn(responseVar.c_str()))
+  if(this->Makefile->IsOn(responseVar))
     {
-    useResponseFile = true;
+    useResponseFileForObjects = true;
+    }
+  }
+
+  // Select whether to use a response file for libraries.
+  bool useResponseFileForLibs = false;
+  {
+  std::string responseVar = "CMAKE_";
+  responseVar += linkLanguage;
+  responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+  if(this->Makefile->IsOn(responseVar))
+    {
+    useResponseFileForLibs = true;
     }
   }
 
   // Expand the rule variables.
   {
+  bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
+
   // Set path conversion for link script shells.
   this->LocalGenerator->SetLinkScriptShell(useLinkScript);
 
   // Collect up flags to link in needed libraries.
   std::string linkLibs;
-  std::string frameworkPath;
-  std::string linkPath;
-  this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                                            *this->GeneratorTarget,
-                                            relink);
-  linkLibs = frameworkPath + linkPath + linkLibs;
+  this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
+                       useWatcomQuote);
+
   // Construct object file lists that may be needed to expand the
   // rule.
   std::string buildObjs;
-  this->CreateObjectLists(useLinkScript, false, useResponseFile,
-                          buildObjs, depends);
+  this->CreateObjectLists(useLinkScript, false,
+                          useResponseFileForObjects, buildObjs, depends,
+                          useWatcomQuote);
 
   cmLocalGenerator::RuleVariables vars;
   vars.RuleLauncher = "RULE_LAUNCH_LINK";
   vars.CMTarget = this->Target;
-  vars.Language = linkLanguage;
+  vars.Language = linkLanguage.c_str();
   vars.Objects = buildObjs.c_str();
   std::string objectDir = this->Target->GetSupportDirectory();
-  objectDir = this->Convert(objectDir.c_str(),
+  objectDir = this->Convert(objectDir,
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::SHELL);
   vars.ObjectDir = objectDir.c_str();
-  vars.Target = targetOutPathReal.c_str();
+  cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
+    cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
+  std::string target = this->Convert(targetFullPathReal,
+                                     cmLocalGenerator::START_OUTPUT,
+                                     output);
+  vars.Target = target.c_str();
   vars.TargetPDB = targetOutPathPDB.c_str();
 
   // Setup the target version.
@@ -425,7 +446,7 @@
   // Write the build rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream,
                                       0,
-                                      targetFullPathReal.c_str(),
+                                      targetFullPathReal,
                                       depends, commands, false);
 
   // The symlink name for the target should depend on the real target
@@ -435,14 +456,14 @@
     {
     depends.clear();
     commands.clear();
-    depends.push_back(targetFullPathReal.c_str());
+    depends.push_back(targetFullPathReal);
     this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                        targetFullPath.c_str(),
+                                        targetFullPath,
                                         depends, commands, false);
     }
 
   // Write the main driver rule to build everything in this target.
-  this->WriteTargetDriverRule(targetFullPath.c_str(), relink);
+  this->WriteTargetDriverRule(targetFullPath, relink);
 
   // Clean all the possible executable names and symlinks.
   this->CleanFiles.insert(this->CleanFiles.end(),
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index d6a0cd4..80473f6 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -131,17 +131,14 @@
 //----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
 {
-  const char* linkLanguage =
+  std::string linkLanguage =
     this->Target->GetLinkerLanguage(this->ConfigName);
   std::string linkRuleVar = "CMAKE_";
-  if (linkLanguage)
-    {
-    linkRuleVar += linkLanguage;
-    }
+  linkRuleVar += linkLanguage;
   linkRuleVar += "_CREATE_STATIC_LIBRARY";
 
   if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
-     this->Makefile->GetDefinition((linkRuleVar+"_IPO").c_str()))
+     this->Makefile->GetDefinition(linkRuleVar+"_IPO"))
     {
     linkRuleVar += "_IPO";
     }
@@ -149,7 +146,7 @@
   std::string extraFlags;
   this->LocalGenerator->GetStaticLibraryFlags(extraFlags,
     cmSystemTools::UpperCase(this->ConfigName), this->Target);
-  this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false);
+  this->WriteLibraryRules(linkRuleVar, extraFlags, false);
 }
 
 //----------------------------------------------------------------------------
@@ -160,13 +157,10 @@
     this->WriteFrameworkRules(relink);
     return;
     }
-  const char* linkLanguage =
+  std::string linkLanguage =
     this->Target->GetLinkerLanguage(this->ConfigName);
   std::string linkRuleVar = "CMAKE_";
-  if (linkLanguage)
-    {
-    linkRuleVar += linkLanguage;
-    }
+  linkRuleVar += linkLanguage;
   linkRuleVar += "_CREATE_SHARED_LIBRARY";
 
   std::string extraFlags;
@@ -175,25 +169,22 @@
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
-    (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+    (extraFlags, this->Target->GetProperty(linkFlagsConfig));
 
   this->LocalGenerator->AddConfigVariableFlags
     (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
   this->AddModuleDefinitionFlag(extraFlags);
 
-  this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+  this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
 }
 
 //----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
 {
-  const char* linkLanguage =
+  std::string linkLanguage =
     this->Target->GetLinkerLanguage(this->ConfigName);
   std::string linkRuleVar = "CMAKE_";
-  if (linkLanguage)
-    {
-    linkRuleVar += linkLanguage;
-    }
+  linkRuleVar += linkLanguage;
   linkRuleVar += "_CREATE_SHARED_MODULE";
 
   std::string extraFlags;
@@ -202,24 +193,21 @@
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
-    (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+    (extraFlags, this->Target->GetProperty(linkFlagsConfig));
   this->LocalGenerator->AddConfigVariableFlags
     (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
   this->AddModuleDefinitionFlag(extraFlags);
 
-  this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+  this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
 }
 
 //----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
 {
-  const char* linkLanguage =
+  std::string linkLanguage =
     this->Target->GetLinkerLanguage(this->ConfigName);
   std::string linkRuleVar = "CMAKE_";
-  if (linkLanguage)
-    {
-    linkRuleVar += linkLanguage;
-    }
+  linkRuleVar += linkLanguage;
   linkRuleVar += "_CREATE_MACOSX_FRAMEWORK";
 
   std::string extraFlags;
@@ -228,16 +216,16 @@
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
-    (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+    (extraFlags, this->Target->GetProperty(linkFlagsConfig));
   this->LocalGenerator->AddConfigVariableFlags
     (extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName);
 
-  this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+  this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
 }
 
 //----------------------------------------------------------------------------
 void cmMakefileLibraryTargetGenerator::WriteLibraryRules
-(const char* linkRuleVar, const char* extraFlags, bool relink)
+(const std::string& linkRuleVar, const std::string& extraFlags, bool relink)
 {
   // TODO: Merge the methods that call this method to avoid
   // code duplication.
@@ -248,14 +236,14 @@
   this->AppendLinkDepends(depends);
 
   // Get the language to use for linking this library.
-  const char* linkLanguage =
+  std::string linkLanguage =
     this->Target->GetLinkerLanguage(this->ConfigName);
 
   // Make sure we have a link language.
-  if(!linkLanguage)
+  if(linkLanguage.empty())
     {
     cmSystemTools::Error("Cannot determine link language for target \"",
-                         this->Target->GetName(), "\".");
+                         this->Target->GetName().c_str(), "\".");
     return;
     }
 
@@ -321,7 +309,11 @@
       }
     }
 
-  std::string pdbOutputPath = this->Target->GetPDBDirectory();
+  std::string compilePdbOutputPath =
+    this->Target->GetCompilePDBDirectory(this->ConfigName);
+  cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+
+  std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName);
   cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
   pdbOutputPath += "/";
 
@@ -334,19 +326,19 @@
   // Construct the output path version of the names for use in command
   // arguments.
   std::string targetOutPathPDB =
-    this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE,
+    this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
                   cmLocalGenerator::SHELL);
   std::string targetOutPath =
-    this->Convert(targetFullPath.c_str(),cmLocalGenerator::START_OUTPUT,
+    this->Convert(targetFullPath,cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
   std::string targetOutPathSO =
-    this->Convert(targetFullPathSO.c_str(),cmLocalGenerator::START_OUTPUT,
+    this->Convert(targetFullPathSO,cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
   std::string targetOutPathReal =
-    this->Convert(targetFullPathReal.c_str(),cmLocalGenerator::START_OUTPUT,
+    this->Convert(targetFullPathReal,cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
   std::string targetOutPathImport =
-    this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT,
+    this->Convert(targetFullPathImport,cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
 
   if(!this->NoRuleMessages)
@@ -390,31 +382,31 @@
 
   // Clean files associated with this library.
   std::vector<std::string> libCleanFiles;
-  libCleanFiles.push_back(this->Convert(targetFullPath.c_str(),
+  libCleanFiles.push_back(this->Convert(targetFullPath,
         cmLocalGenerator::START_OUTPUT,
         cmLocalGenerator::UNCHANGED));
   if(targetNameReal != targetName)
     {
-    libCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(),
+    libCleanFiles.push_back(this->Convert(targetFullPathReal,
         cmLocalGenerator::START_OUTPUT,
         cmLocalGenerator::UNCHANGED));
     }
   if(targetNameSO != targetName &&
      targetNameSO != targetNameReal)
     {
-    libCleanFiles.push_back(this->Convert(targetFullPathSO.c_str(),
+    libCleanFiles.push_back(this->Convert(targetFullPathSO,
         cmLocalGenerator::START_OUTPUT,
         cmLocalGenerator::UNCHANGED));
     }
   if(!targetNameImport.empty())
     {
-    libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
+    libCleanFiles.push_back(this->Convert(targetFullPathImport,
         cmLocalGenerator::START_OUTPUT,
         cmLocalGenerator::UNCHANGED));
     std::string implib;
     if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
       {
-      libCleanFiles.push_back(this->Convert(implib.c_str(),
+      libCleanFiles.push_back(this->Convert(implib,
                                             cmLocalGenerator::START_OUTPUT,
                                             cmLocalGenerator::UNCHANGED));
       }
@@ -424,7 +416,7 @@
   // cleaned.  We do not want to delete the .pdb file just before
   // linking the target.
   this->CleanFiles.push_back
-    (this->Convert(targetFullPathPDB.c_str(),
+    (this->Convert(targetFullPathPDB,
                    cmLocalGenerator::START_OUTPUT,
                    cmLocalGenerator::UNCHANGED));
 
@@ -470,14 +462,26 @@
   bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
 
   // Select whether to use a response file for objects.
-  bool useResponseFile = false;
+  bool useResponseFileForObjects = false;
   {
   std::string responseVar = "CMAKE_";
   responseVar += linkLanguage;
   responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
-  if(this->Makefile->IsOn(responseVar.c_str()))
+  if(this->Makefile->IsOn(responseVar))
     {
-    useResponseFile = true;
+    useResponseFileForObjects = true;
+    }
+  }
+
+  // Select whether to use a response file for libraries.
+  bool useResponseFileForLibs = false;
+  {
+  std::string responseVar = "CMAKE_";
+  responseVar += linkLanguage;
+  responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+  if(this->Makefile->IsOn(responseVar))
+    {
+    useResponseFileForLibs = true;
     }
   }
 
@@ -494,21 +498,21 @@
     std::string arCreateVar = "CMAKE_";
     arCreateVar += linkLanguage;
     arCreateVar += "_ARCHIVE_CREATE";
-    if(const char* rule = this->Makefile->GetDefinition(arCreateVar.c_str()))
+    if(const char* rule = this->Makefile->GetDefinition(arCreateVar))
       {
       cmSystemTools::ExpandListArgument(rule, archiveCreateCommands);
       }
     std::string arAppendVar = "CMAKE_";
     arAppendVar += linkLanguage;
     arAppendVar += "_ARCHIVE_APPEND";
-    if(const char* rule = this->Makefile->GetDefinition(arAppendVar.c_str()))
+    if(const char* rule = this->Makefile->GetDefinition(arAppendVar))
       {
       cmSystemTools::ExpandListArgument(rule, archiveAppendCommands);
       }
     std::string arFinishVar = "CMAKE_";
     arFinishVar += linkLanguage;
     arFinishVar += "_ARCHIVE_FINISH";
-    if(const char* rule = this->Makefile->GetDefinition(arFinishVar.c_str()))
+    if(const char* rule = this->Makefile->GetDefinition(arFinishVar))
       {
       cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
       }
@@ -524,7 +528,7 @@
     useLinkScript = true;
 
     // Archiving rules never use a response file.
-    useResponseFile = false;
+    useResponseFileForObjects = false;
 
     // Limit the length of individual object lists to less than the
     // 32K command line length limit on Windows.  We could make this a
@@ -535,6 +539,8 @@
   // Expand the rule variables.
   std::vector<std::string> real_link_commands;
   {
+  bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
+
   // Set path conversion for link script shells.
   this->LocalGenerator->SetLinkScriptShell(useLinkScript);
 
@@ -542,19 +548,16 @@
   std::string linkLibs;
   if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
     {
-    std::string frameworkPath;
-    std::string linkPath;
-    this->LocalGenerator
-      ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
-                            *this->GeneratorTarget, relink);
-    linkLibs = frameworkPath + linkPath + linkLibs;
+    this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
+                         useWatcomQuote);
     }
 
   // Construct object file lists that may be needed to expand the
   // rule.
   std::string buildObjs;
-  this->CreateObjectLists(useLinkScript, useArchiveRules, useResponseFile,
-                          buildObjs, depends);
+  this->CreateObjectLists(useLinkScript, useArchiveRules,
+                          useResponseFileForObjects, buildObjs, depends,
+                          useWatcomQuote);
 
   cmLocalGenerator::RuleVariables vars;
   vars.TargetPDB = targetOutPathPDB.c_str();
@@ -578,14 +581,19 @@
 
   vars.RuleLauncher = "RULE_LAUNCH_LINK";
   vars.CMTarget = this->Target;
-  vars.Language = linkLanguage;
+  vars.Language = linkLanguage.c_str();
   vars.Objects = buildObjs.c_str();
   std::string objectDir = this->Target->GetSupportDirectory();
-  objectDir = this->Convert(objectDir.c_str(),
+  objectDir = this->Convert(objectDir,
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::SHELL);
   vars.ObjectDir = objectDir.c_str();
-  vars.Target = targetOutPathReal.c_str();
+  cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
+    cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
+  std::string target = this->Convert(targetFullPathReal,
+                                     cmLocalGenerator::START_OUTPUT,
+                                     output);
+  vars.Target = target.c_str();
   vars.LinkLibraries = linkLibs.c_str();
   vars.ObjectsQuoted = buildObjs.c_str();
   if (this->Target->HasSOName(this->ConfigName))
@@ -612,7 +620,7 @@
       {
       // Convert to a path for the native build tool.
       install_name_dir =
-        this->LocalGenerator->Convert(install_name_dir.c_str(),
+        this->LocalGenerator->Convert(install_name_dir,
                                       cmLocalGenerator::NONE,
                                       cmLocalGenerator::SHELL, false);
       vars.TargetInstallNameDir = install_name_dir.c_str();
@@ -746,7 +754,7 @@
 
   // Write the build rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      targetFullPathReal.c_str(),
+                                      targetFullPathReal,
                                       depends, commands, false);
 
   // Some targets have more than one output file.  Create rules to
@@ -765,7 +773,7 @@
     }
 
   // Write the main driver rule to build everything in this target.
-  this->WriteTargetDriverRule(targetFullPath.c_str(), relink);
+  this->WriteTargetDriverRule(targetFullPath, relink);
 
   // Clean all the possible library names and symlinks.
   this->CleanFiles.insert(this->CleanFiles.end(),
@@ -775,7 +783,7 @@
 //----------------------------------------------------------------------------
 void
 cmMakefileLibraryTargetGenerator
-::AppendOSXVerFlag(std::string& flags, const char* lang,
+::AppendOSXVerFlag(std::string& flags, const std::string& lang,
                    const char* name, bool so)
 {
   // Lookup the flag to specify the version.
@@ -784,7 +792,7 @@
   fvar += "_OSX_";
   fvar += name;
   fvar += "_VERSION_FLAG";
-  const char* flag = this->Makefile->GetDefinition(fvar.c_str());
+  const char* flag = this->Makefile->GetDefinition(fvar);
 
   // Skip if no such flag.
   if(!flag)
@@ -802,6 +810,6 @@
     // Append the flag since a non-zero version is specified.
     cmOStringStream vflag;
     vflag << flag << major << "." << minor << "." << patch;
-    this->LocalGenerator->AppendFlags(flags, vflag.str().c_str());
+    this->LocalGenerator->AppendFlags(flags, vflag.str());
     }
 }
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index 1487b56..68980c3 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -30,7 +30,8 @@
   void WriteStaticLibraryRules();
   void WriteSharedLibraryRules(bool relink);
   void WriteModuleLibraryRules(bool relink);
-  void WriteLibraryRules(const char *linkRule, const char *extraFlags,
+  void WriteLibraryRules(const std::string& linkRule,
+                         const std::string& extraFlags,
                          bool relink);
   // MacOSX Framework support methods
   void WriteFrameworkRules(bool relink);
@@ -38,7 +39,7 @@
   // Store the computd framework version for OS X Frameworks.
   std::string FrameworkVersion;
 
-  void AppendOSXVerFlag(std::string& flags, const char* lang,
+  void AppendOSXVerFlag(std::string& flags, const std::string& lang,
                         const char* name, bool so);
 };
 
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index c3ca85d..403f6e6 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -21,6 +21,7 @@
 #include "cmTarget.h"
 #include "cmake.h"
 #include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmGeneratorExpression.h"
 
 #include "cmMakefileExecutableTargetGenerator.h"
@@ -127,15 +128,16 @@
 //----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::WriteTargetBuildRules()
 {
+  const std::string& config =
+    this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+
   // write the custom commands for this target
   // Look for files registered for cleaning in this directory.
   if(const char* additional_clean_files =
      this->Makefile->GetProperty
      ("ADDITIONAL_MAKE_CLEAN_FILES"))
     {
-    const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
-    cmListFileBacktrace lfbt;
-    cmGeneratorExpression ge(lfbt);
+    cmGeneratorExpression ge;
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
                                             ge.Parse(additional_clean_files);
 
@@ -151,56 +153,55 @@
 
   // First generate the object rule files.  Save a list of all object
   // files for this target.
-  std::vector<cmSourceFile*> customCommands;
-  this->GeneratorTarget->GetCustomCommands(customCommands);
-  for(std::vector<cmSourceFile*>::const_iterator
+  std::vector<cmSourceFile const*> customCommands;
+  this->GeneratorTarget->GetCustomCommands(customCommands, config);
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = customCommands.begin();
       si != customCommands.end(); ++si)
     {
-    cmCustomCommand const* cc = (*si)->GetCustomCommand();
-    this->GenerateCustomRuleFile(*cc);
+    cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(),
+                                 this->ConfigName,
+                                 this->Makefile);
+    this->GenerateCustomRuleFile(ccg);
     if (clean)
       {
-      const std::vector<std::string>& outputs = cc->GetOutputs();
+      const std::vector<std::string>& outputs = ccg.GetOutputs();
       for(std::vector<std::string>::const_iterator o = outputs.begin();
           o != outputs.end(); ++o)
         {
         this->CleanFiles.push_back
-          (this->Convert(o->c_str(),
+          (this->Convert(*o,
                          cmLocalGenerator::START_OUTPUT,
                          cmLocalGenerator::UNCHANGED));
         }
       }
     }
-  std::vector<cmSourceFile*> headerSources;
-  this->GeneratorTarget->GetHeaderSources(headerSources);
+  std::vector<cmSourceFile const*> headerSources;
+  this->GeneratorTarget->GetHeaderSources(headerSources, config);
   this->OSXBundleGenerator->GenerateMacOSXContentStatements(
     headerSources,
     this->MacOSXContentGenerator);
-  std::vector<cmSourceFile*> extraSources;
-  this->GeneratorTarget->GetExtraSources(extraSources);
+  std::vector<cmSourceFile const*> extraSources;
+  this->GeneratorTarget->GetExtraSources(extraSources, config);
   this->OSXBundleGenerator->GenerateMacOSXContentStatements(
     extraSources,
     this->MacOSXContentGenerator);
-  std::vector<cmSourceFile*> externalObjects;
-  this->GeneratorTarget->GetExternalObjects(externalObjects);
-  for(std::vector<cmSourceFile*>::const_iterator
+  std::vector<cmSourceFile const*> externalObjects;
+  this->GeneratorTarget->GetExternalObjects(externalObjects, config);
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = externalObjects.begin();
       si != externalObjects.end(); ++si)
     {
     this->ExternalObjects.push_back((*si)->GetFullPath());
     }
-  std::vector<cmSourceFile*> objectSources;
-  this->GeneratorTarget->GetObjectSources(objectSources);
-  for(std::vector<cmSourceFile*>::const_iterator
+  std::vector<cmSourceFile const*> objectSources;
+  this->GeneratorTarget->GetObjectSources(objectSources, config);
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = objectSources.begin(); si != objectSources.end(); ++si)
     {
     // Generate this object file's rule file.
     this->WriteObjectRuleFiles(**si);
     }
-
-  // Add object library contents as external objects.
-  this->GeneratorTarget->UseObjectLibraries(this->ExternalObjects);
 }
 
 //----------------------------------------------------------------------------
@@ -215,7 +216,7 @@
   *this->BuildFileStream
     << "# Include any dependencies generated for this target.\n"
     << this->LocalGenerator->IncludeDirective << " " << root
-    << this->Convert(dependFileNameFull.c_str(),
+    << this->Convert(dependFileNameFull,
                      cmLocalGenerator::HOME_OUTPUT,
                      cmLocalGenerator::MAKEFILE)
     << "\n\n";
@@ -226,7 +227,7 @@
     *this->BuildFileStream
       << "# Include the progress variables for this target.\n"
       << this->LocalGenerator->IncludeDirective << " " << root
-      << this->Convert(this->ProgressFileNameFull.c_str(),
+      << this->Convert(this->ProgressFileNameFull,
                        cmLocalGenerator::HOME_OUTPUT,
                        cmLocalGenerator::MAKEFILE)
       << "\n\n";
@@ -259,7 +260,7 @@
   *this->BuildFileStream
     << "# Include the compile flags for this target's objects.\n"
     << this->LocalGenerator->IncludeDirective << " " << root
-    << this->Convert(this->FlagFileNameFull.c_str(),
+    << this->Convert(this->FlagFileNameFull,
                                      cmLocalGenerator::HOME_OUTPUT,
                                      cmLocalGenerator::MAKEFILE)
     << "\n\n";
@@ -301,7 +302,7 @@
 
     // Add include directory flags.
     this->LocalGenerator->
-      AppendFlags(flags,this->GetFrameworkFlags(l).c_str());
+      AppendFlags(flags,this->GetFrameworkFlags(l));
 
     // Add target-specific flags.
     this->LocalGenerator->AddCompileOptions(flags, this->Target,
@@ -328,7 +329,7 @@
 
     // Add preprocessor definitions for this target and configuration.
     this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
-                            this->LocalGenerator->ConfigurationName.c_str());
+                            this->LocalGenerator->ConfigurationName);
 
     std::string definesString;
     this->LocalGenerator->JoinDefines(defines, definesString, lang);
@@ -342,21 +343,22 @@
 void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
 {
   // write language flags for target
-  std::set<cmStdString> languages;
-  this->Target->GetLanguages(languages);
+  std::set<std::string> languages;
+  this->Target->GetLanguages(languages,
+                      this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
   // put the compiler in the rules.make file so that if it changes
   // things rebuild
-  for(std::set<cmStdString>::const_iterator l = languages.begin();
+  for(std::set<std::string>::const_iterator l = languages.begin();
       l != languages.end(); ++l)
     {
-    cmStdString compiler = "CMAKE_";
+    std::string compiler = "CMAKE_";
     compiler += *l;
     compiler += "_COMPILER";
-    *this->FlagFileStream << "# compile " << l->c_str() << " with " <<
-      this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n";
+    *this->FlagFileStream << "# compile " << *l << " with " <<
+      this->Makefile->GetSafeDefinition(compiler) << "\n";
     }
 
-  for(std::set<cmStdString>::const_iterator l = languages.begin();
+  for(std::set<std::string>::const_iterator l = languages.begin();
       l != languages.end(); ++l)
     {
     *this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n";
@@ -369,7 +371,7 @@
 //----------------------------------------------------------------------------
 void
 cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
-  (cmSourceFile& source, const char* pkgloc)
+  (cmSourceFile const& source, const char* pkgloc)
 {
   // Skip OS X content when not building a Framework or Bundle.
   if(!this->Generator->GetTarget()->IsBundleOnApple())
@@ -388,9 +390,9 @@
   output += "/";
   output += cmSystemTools::GetFilenameName(input);
   this->Generator->CleanFiles.push_back(
-    this->Generator->Convert(output.c_str(),
+    this->Generator->Convert(output,
                              cmLocalGenerator::START_OUTPUT));
-  output = this->Generator->Convert(output.c_str(),
+  output = this->Generator->Convert(output,
                                     cmLocalGenerator::HOME_OUTPUT);
 
   // Create a rule to copy the content into the bundle.
@@ -403,27 +405,29 @@
     commands, copyEcho.c_str(),
     cmLocalUnixMakefileGenerator3::EchoBuild);
   std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
-  copyCommand += this->Generator->Convert(input.c_str(),
+  copyCommand += this->Generator->Convert(input,
                                           cmLocalGenerator::NONE,
                                           cmLocalGenerator::SHELL);
   copyCommand += " ";
-  copyCommand += this->Generator->Convert(output.c_str(),
+  copyCommand += this->Generator->Convert(output,
                                           cmLocalGenerator::NONE,
                                           cmLocalGenerator::SHELL);
   commands.push_back(copyCommand);
   this->Generator->LocalGenerator->WriteMakeRule(
     *this->Generator->BuildFileStream, 0,
-    output.c_str(),
+    output,
     depends, commands, false);
   this->Generator->ExtraFiles.insert(output);
 }
 
 //----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
+void cmMakefileTargetGenerator
+::WriteObjectRuleFiles(cmSourceFile const& source)
 {
   // Identify the language of the source file.
-  const char* lang = this->LocalGenerator->GetSourceFileLanguage(source);
-  if(!lang)
+  const std::string& lang =
+    this->LocalGenerator->GetSourceFileLanguage(source);
+  if(lang.empty())
     {
     // don't know anything about this file so skip it
     return;
@@ -455,7 +459,7 @@
 
   // Create the directory containing the object file.  This may be a
   // subdirectory under the target's directory.
-  std::string dir = cmSystemTools::GetFilenamePath(obj.c_str());
+  std::string dir = cmSystemTools::GetFilenamePath(obj);
   cmSystemTools::MakeDirectory
     (this->LocalGenerator->ConvertToFullPath(dir).c_str());
 
@@ -481,9 +485,9 @@
   objFullPath += "/";
   objFullPath += obj;
   objFullPath =
-    this->Convert(objFullPath.c_str(), cmLocalGenerator::FULL);
+    this->Convert(objFullPath, cmLocalGenerator::FULL);
   std::string srcFullPath =
-    this->Convert(source.GetFullPath().c_str(), cmLocalGenerator::FULL);
+    this->Convert(source.GetFullPath(), cmLocalGenerator::FULL);
   this->LocalGenerator->
     AddImplicitDepends(*this->Target, lang,
                        objFullPath.c_str(),
@@ -493,7 +497,7 @@
 //----------------------------------------------------------------------------
 void
 cmMakefileTargetGenerator
-::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source)
+::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source)
 {
   const char* srcfmt = source.GetProperty("Fortran_FORMAT");
   cmLocalGenerator::FortranFormat format =
@@ -523,8 +527,8 @@
 void
 cmMakefileTargetGenerator
 ::WriteObjectBuildFile(std::string &obj,
-                       const char *lang,
-                       cmSourceFile& source,
+                       const std::string& lang,
+                       cmSourceFile const& source,
                        std::vector<std::string>& depends)
 {
   this->LocalGenerator->AppendRuleDepend(depends,
@@ -546,13 +550,13 @@
   std::string langFlags = "$(";
   langFlags += lang;
   langFlags += "_FLAGS)";
-  this->LocalGenerator->AppendFlags(flags, langFlags.c_str());
+  this->LocalGenerator->AppendFlags(flags, langFlags);
 
   std::string configUpper =
     cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
 
   // Add Fortran format flags.
-  if(strcmp(lang, "Fortran") == 0)
+  if(lang == "Fortran")
     {
     this->AppendFortranFormatFlags(flags, source);
     }
@@ -584,7 +588,7 @@
   std::string defPropName = "COMPILE_DEFINITIONS_";
   defPropName += configUpper;
   if(const char* config_compile_defs =
-     source.GetProperty(defPropName.c_str()))
+     source.GetProperty(defPropName))
     {
     this->LocalGenerator->AppendDefines(defines, config_compile_defs);
     *this->FlagFileStream
@@ -598,10 +602,10 @@
   std::string sourceFile = source.GetFullPath();
   if(this->LocalGenerator->UseRelativePaths)
     {
-    sourceFile = this->Convert(sourceFile.c_str(),
+    sourceFile = this->Convert(sourceFile,
                                cmLocalGenerator::START_OUTPUT);
     }
-  sourceFile = this->Convert(sourceFile.c_str(),
+  sourceFile = this->Convert(sourceFile,
                              cmLocalGenerator::NONE,
                              cmLocalGenerator::SHELL);
 
@@ -624,9 +628,11 @@
 
   std::string targetOutPathReal;
   std::string targetOutPathPDB;
+  std::string targetOutPathCompilePDB;
   {
   std::string targetFullPathReal;
   std::string targetFullPathPDB;
+  std::string targetFullPathCompilePDB;
   if(this->Target->GetType() == cmTarget::EXECUTABLE ||
      this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
      this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -638,30 +644,50 @@
     targetFullPathPDB += "/";
     targetFullPathPDB += this->Target->GetPDBName(this->ConfigName);
     }
-  targetOutPathReal = this->Convert(targetFullPathReal.c_str(),
+  if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
+    {
+    targetFullPathCompilePDB =
+      this->Target->GetCompilePDBPath(this->ConfigName);
+    if(targetFullPathCompilePDB.empty())
+      {
+      targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/";
+      }
+    }
+
+  targetOutPathReal = this->Convert(targetFullPathReal,
                                     cmLocalGenerator::START_OUTPUT,
                                     cmLocalGenerator::SHELL);
   targetOutPathPDB =
-    this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE,
+    this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
+                  cmLocalGenerator::SHELL);
+  targetOutPathCompilePDB =
+    this->Convert(targetFullPathCompilePDB,
+                  cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
   }
   cmLocalGenerator::RuleVariables vars;
   vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
   vars.CMTarget = this->Target;
-  vars.Language = lang;
+  vars.Language = lang.c_str();
   vars.Target = targetOutPathReal.c_str();
   vars.TargetPDB = targetOutPathPDB.c_str();
+  vars.TargetCompilePDB = targetOutPathCompilePDB.c_str();
   vars.Source = sourceFile.c_str();
   std::string shellObj =
-    this->Convert(obj.c_str(),
+    this->Convert(obj,
                   cmLocalGenerator::NONE,
-                  cmLocalGenerator::SHELL).c_str();
+                  cmLocalGenerator::SHELL);
   vars.Object = shellObj.c_str();
   std::string objectDir = this->Target->GetSupportDirectory();
-  objectDir = this->Convert(objectDir.c_str(),
+  objectDir = this->Convert(objectDir,
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::SHELL);
   vars.ObjectDir = objectDir.c_str();
+  std::string objectFileDir = cmSystemTools::GetFilenamePath(obj);
+  objectFileDir = this->Convert(objectFileDir,
+                                cmLocalGenerator::START_OUTPUT,
+                                cmLocalGenerator::SHELL);
+  vars.ObjectFileDir = objectFileDir.c_str();
   vars.Flags = flags.c_str();
 
   std::string definesString = "$(";
@@ -672,8 +698,7 @@
 
   vars.Defines = definesString.c_str();
 
-  bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) ||
-                           (strcmp(lang, "CXX") == 0));
+  bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX"));
 
   // Construct the compile rules.
   {
@@ -681,7 +706,7 @@
   compileRuleVar += lang;
   compileRuleVar += "_COMPILE_OBJECT";
   std::string compileRule =
-    this->Makefile->GetRequiredDefinition(compileRuleVar.c_str());
+    this->Makefile->GetRequiredDefinition(compileRuleVar);
   std::vector<std::string> compileCommands;
   cmSystemTools::ExpandListArgument(compileRule, compileCommands);
 
@@ -720,7 +745,7 @@
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      relativeObj.c_str(),
+                                      relativeObj,
                                       depends, commands, false);
 
   // Check for extra outputs created by the compilation.
@@ -738,7 +763,7 @@
       this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false);
 
       // Register this as an extra file to clean.
-      this->CleanFiles.push_back(eoi->c_str());
+      this->CleanFiles.push_back(*eoi);
       }
     }
 
@@ -774,15 +799,15 @@
       preprocessRuleVar += lang;
       preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE";
       if(const char* preprocessRule =
-         this->Makefile->GetDefinition(preprocessRuleVar.c_str()))
+         this->Makefile->GetDefinition(preprocessRuleVar))
         {
         std::vector<std::string> preprocessCommands;
         cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands);
 
         std::string shellObjI =
-          this->Convert(objI.c_str(),
+          this->Convert(objI,
                         cmLocalGenerator::NONE,
-                        cmLocalGenerator::SHELL).c_str();
+                        cmLocalGenerator::SHELL);
         vars.PreprocessedSource = shellObjI.c_str();
 
         // Expand placeholders in the commands.
@@ -808,7 +833,7 @@
         }
 
       this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                          relativeObjI.c_str(),
+                                          relativeObjI,
                                           force_depends, commands, false);
       }
 
@@ -831,15 +856,15 @@
       assemblyRuleVar += lang;
       assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE";
       if(const char* assemblyRule =
-         this->Makefile->GetDefinition(assemblyRuleVar.c_str()))
+         this->Makefile->GetDefinition(assemblyRuleVar))
         {
         std::vector<std::string> assemblyCommands;
         cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands);
 
         std::string shellObjS =
-          this->Convert(objS.c_str(),
+          this->Convert(objS,
                         cmLocalGenerator::NONE,
-                        cmLocalGenerator::SHELL).c_str();
+                        cmLocalGenerator::SHELL);
         vars.AssemblySource = shellObjS.c_str();
 
         // Expand placeholders in the commands.
@@ -865,7 +890,7 @@
         }
 
       this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                          relativeObjS.c_str(),
+                                          relativeObjS,
                                           force_depends, commands, false);
       }
     }
@@ -877,7 +902,7 @@
   std::vector<std::string> p_depends;
   // always provide an empty requires target
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      objectRequires.c_str(), p_depends,
+                                      objectRequires, p_depends,
                                       no_commands, true);
 
   // write a build rule to recursively build what this obj provides
@@ -891,19 +916,19 @@
   tgtMakefileName += "/build.make";
   r_commands.push_back
     (this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(),
-                                                temp.c_str()));
+                                                temp));
 
   p_depends.clear();
   p_depends.push_back(objectRequires);
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      objectProvides.c_str(), p_depends,
+                                      objectProvides, p_depends,
                                       r_commands, true);
 
   // write the provides.build rule dependency on the obj file
   p_depends.clear();
   p_depends.push_back(relativeObj);
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      temp.c_str(), p_depends, no_commands,
+                                      temp, p_depends, no_commands,
                                       false);
 }
 
@@ -932,7 +957,7 @@
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      depTarget.c_str(),
+                                      depTarget,
                                       depends, no_commands, true);
 }
 
@@ -957,7 +982,7 @@
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      cleanTarget.c_str(),
+                                      cleanTarget,
                                       depends, commands, true);
 }
 
@@ -993,8 +1018,8 @@
         pi != this->MultipleOutputPairs.end(); ++pi)
       {
       *this->InfoFileStream
-        << "  " << this->LocalGenerator->EscapeForCMake(pi->first.c_str())
-        << " "  << this->LocalGenerator->EscapeForCMake(pi->second.c_str())
+        << "  " << this->LocalGenerator->EscapeForCMake(pi->first)
+        << " "  << this->LocalGenerator->EscapeForCMake(pi->second)
         << "\n";
       }
     *this->InfoFileStream << "  )\n\n";
@@ -1053,7 +1078,8 @@
     << "set(CMAKE_C_TARGET_INCLUDE_PATH\n";
   std::vector<std::string> includes;
 
-  const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+  const std::string& config =
+    this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
   this->LocalGenerator->GetIncludeDirectories(includes,
                                               this->GeneratorTarget,
                                               "C", config);
@@ -1062,7 +1088,7 @@
     {
     *this->InfoFileStream
       << "  \""
-      << this->LocalGenerator->Convert(i->c_str(),
+      << this->LocalGenerator->Convert(*i,
                                        cmLocalGenerator::HOME_OUTPUT)
       << "\"\n";
     }
@@ -1126,7 +1152,7 @@
          << this->Convert(this->Makefile->GetStartOutputDirectory(),
                           cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
          << " "
-         << this->Convert(this->InfoFileNameFull.c_str(),
+         << this->Convert(this->InfoFileNameFull,
                           cmLocalGenerator::FULL, cmLocalGenerator::SHELL);
   if(this->LocalGenerator->GetColorMakefile())
     {
@@ -1142,7 +1168,7 @@
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      depTarget.c_str(),
+                                      depTarget,
                                       depends, commands, true);
 }
 
@@ -1153,13 +1179,15 @@
 {
   // Depend on all custom command outputs.
   std::vector<cmSourceFile*> sources;
-  this->Target->GetSourceFiles(sources);
+  this->Target->GetSourceFiles(sources,
+                      this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
   for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
       source != sources.end(); ++source)
     {
     if(cmCustomCommand* cc = (*source)->GetCustomCommand())
       {
-      const std::vector<std::string>& outputs = cc->GetOutputs();
+      cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile);
+      const std::vector<std::string>& outputs = ccg.GetOutputs();
       for(std::vector<std::string>::const_iterator o = outputs.begin();
           o != outputs.end(); ++o)
         {
@@ -1171,7 +1199,7 @@
 
 //----------------------------------------------------------------------------
 void cmMakefileTargetGenerator
-::WriteObjectDependRules(cmSourceFile& source,
+::WriteObjectDependRules(cmSourceFile const& source,
                          std::vector<std::string>& depends)
 {
   // Create the list of dependencies known at cmake time.  These are
@@ -1184,18 +1212,18 @@
     for(std::vector<std::string>::iterator i = deps.begin();
         i != deps.end(); ++i)
       {
-      depends.push_back(i->c_str());
+      depends.push_back(*i);
       }
     }
 }
 
 //----------------------------------------------------------------------------
 void cmMakefileTargetGenerator
-::GenerateCustomRuleFile(const cmCustomCommand& cc)
+::GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg)
 {
   // Collect the commands.
   std::vector<std::string> commands;
-  std::string comment = this->LocalGenerator->ConstructComment(cc);
+  std::string comment = this->LocalGenerator->ConstructComment(ccg);
   if(!comment.empty())
     {
     // add in a progress call if needed
@@ -1210,37 +1238,37 @@
 
   // Now append the actual user-specified commands.
   cmOStringStream content;
-  this->LocalGenerator->AppendCustomCommand(commands, cc, this->Target, false,
+  this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false,
                                             cmLocalGenerator::HOME_OUTPUT,
                                             &content);
 
   // Collect the dependencies.
   std::vector<std::string> depends;
-  this->LocalGenerator->AppendCustomDepend(depends, cc);
+  this->LocalGenerator->AppendCustomDepend(depends, ccg);
 
   // Check whether we need to bother checking for a symbolic output.
   bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
 
   // Write the rule.
-  const std::vector<std::string>& outputs = cc.GetOutputs();
+  const std::vector<std::string>& outputs = ccg.GetOutputs();
   std::vector<std::string>::const_iterator o = outputs.begin();
   {
   bool symbolic = false;
   if(need_symbolic)
     {
-    if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str()))
+    if(cmSourceFile* sf = this->Makefile->GetSource(*o))
       {
       symbolic = sf->GetPropertyAsBool("SYMBOLIC");
       }
     }
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      o->c_str(), depends, commands,
+                                      *o, depends, commands,
                                       symbolic);
 
   // If the rule has changed make sure the output is rebuilt.
   if(!symbolic)
     {
-    this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), content.str());
+    this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str());
     }
   }
 
@@ -1251,7 +1279,7 @@
     bool symbolic = false;
     if(need_symbolic)
       {
-      if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str()))
+      if(cmSourceFile* sf = this->Makefile->GetSource(*o))
         {
         symbolic = sf->GetPropertyAsBool("SYMBOLIC");
         }
@@ -1261,15 +1289,15 @@
 
   // Setup implicit dependency scanning.
   for(cmCustomCommand::ImplicitDependsList::const_iterator
-        idi = cc.GetImplicitDepends().begin();
-      idi != cc.GetImplicitDepends().end(); ++idi)
+        idi = ccg.GetCC().GetImplicitDepends().begin();
+      idi != ccg.GetCC().GetImplicitDepends().end(); ++idi)
     {
     std::string objFullPath =
-      this->Convert(outputs[0].c_str(), cmLocalGenerator::FULL);
+      this->Convert(outputs[0], cmLocalGenerator::FULL);
     std::string srcFullPath =
-      this->Convert(idi->second.c_str(), cmLocalGenerator::FULL);
+      this->Convert(idi->second, cmLocalGenerator::FULL);
     this->LocalGenerator->
-      AddImplicitDepends(*this->Target, idi->first.c_str(),
+      AddImplicitDepends(*this->Target, idi->first,
                          objFullPath.c_str(),
                          srcFullPath.c_str());
     }
@@ -1314,7 +1342,7 @@
   progressDir += cmake::GetCMakeFilesDirectory();
   cmOStringStream progCmd;
   progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
-  progCmd << this->LocalGenerator->Convert(progressDir.c_str(),
+  progCmd << this->LocalGenerator->Convert(progressDir,
                                            cmLocalGenerator::FULL,
                                            cmLocalGenerator::SHELL);
   progCmd << " $(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")";
@@ -1325,7 +1353,8 @@
 void
 cmMakefileTargetGenerator
 ::WriteObjectsVariable(std::string& variableName,
-                       std::string& variableNameExternal)
+                       std::string& variableNameExternal,
+                       bool useWatcomQuote)
 {
   // Write a make variable assignment that lists all objects for the
   // target.
@@ -1334,10 +1363,8 @@
                                              "_OBJECTS");
   *this->BuildFileStream
     << "# Object files for target " << this->Target->GetName() << "\n"
-    << variableName.c_str() << " =";
+    << variableName << " =";
   std::string object;
-  const char* objName =
-    this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS");
   const char* lineContinue =
     this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE");
   if(!lineContinue)
@@ -1348,17 +1375,9 @@
       i != this->Objects.end(); ++i)
     {
     *this->BuildFileStream << " " << lineContinue << "\n";
-    if(objName)
-      {
-      *this->BuildFileStream <<
-        this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT,
-                      cmLocalGenerator::MAKEFILE);
-      }
-    else
-      {
-      *this->BuildFileStream  <<
-        this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str());
-      }
+    *this->BuildFileStream  <<
+      this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(),
+                                                      useWatcomQuote);
     }
   *this->BuildFileStream << "\n";
 
@@ -1371,26 +1390,18 @@
     << "\n"
     << "# External object files for target "
     << this->Target->GetName() << "\n"
-    << variableNameExternal.c_str() << " =";
+    << variableNameExternal << " =";
   for(std::vector<std::string>::const_iterator i =
         this->ExternalObjects.begin();
       i != this->ExternalObjects.end(); ++i)
     {
-    object = this->Convert(i->c_str(),cmLocalGenerator::START_OUTPUT);
+    object = this->Convert(*i,cmLocalGenerator::START_OUTPUT);
     *this->BuildFileStream
       << " " << lineContinue << "\n"
       << this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME");
-    if(objName)
-      {
-      *this->BuildFileStream  <<
-        this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT,
-                      cmLocalGenerator::MAKEFILE);
-      }
-    else
-      {
-      *this->BuildFileStream  <<
-        this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str());
-      }
+    *this->BuildFileStream  <<
+      this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(),
+                                                      useWatcomQuote);
     }
   *this->BuildFileStream << "\n" << "\n";
 }
@@ -1420,7 +1431,7 @@
     {
     // Construct the name of the next object.
     this->NextObject =
-      this->LocalGenerator->Convert(obj.c_str(),
+      this->LocalGenerator->Convert(obj,
                                     cmLocalGenerator::START_OUTPUT,
                                     cmLocalGenerator::RESPONSE);
 
@@ -1477,24 +1488,22 @@
 }
 
 //----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
-                                                      bool relink)
+void cmMakefileTargetGenerator::WriteTargetDriverRule(
+                                                const std::string& main_output,
+                                                bool relink)
 {
   // Compute the name of the driver target.
   std::string dir =
     this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
   std::string buildTargetRuleName = dir;
   buildTargetRuleName += relink?"/preinstall":"/build";
-  buildTargetRuleName = this->Convert(buildTargetRuleName.c_str(),
+  buildTargetRuleName = this->Convert(buildTargetRuleName,
                                       cmLocalGenerator::HOME_OUTPUT,
                                       cmLocalGenerator::UNCHANGED);
 
   // Build the list of target outputs to drive.
   std::vector<std::string> depends;
-  if(main_output)
-    {
-    depends.push_back(main_output);
-    }
+  depends.push_back(main_output);
 
   const char* comment = 0;
   if(relink)
@@ -1514,7 +1523,7 @@
       }
 
     // Make sure the extra files are built.
-    for(std::set<cmStdString>::const_iterator i = this->ExtraFiles.begin();
+    for(std::set<std::string>::const_iterator i = this->ExtraFiles.begin();
         i != this->ExtraFiles.end(); ++i)
       {
       depends.push_back(*i);
@@ -1524,7 +1533,7 @@
   // Write the driver rule.
   std::vector<std::string> no_commands;
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment,
-                                      buildTargetRuleName.c_str(),
+                                      buildTargetRuleName,
                                       depends, no_commands, true);
 }
 
@@ -1538,19 +1547,20 @@
 
   std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG";
   const char* fwSearchFlag =
-    this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
+    this->Makefile->GetDefinition(fwSearchFlagVar);
   if(!(fwSearchFlag && *fwSearchFlag))
     {
     return std::string();
     }
 
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
 #ifdef __APPLE__  /* don't insert this when crosscompiling e.g. to iphone */
   emitted.insert("/System/Library/Frameworks");
 #endif
   std::vector<std::string> includes;
 
-  const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+  const std::string& config =
+    this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
   this->LocalGenerator->GetIncludeDirectories(includes,
                                               this->GeneratorTarget,
                                               "C", config);
@@ -1559,7 +1569,7 @@
   for(std::vector<std::string>::iterator i = includes.begin();
       i != includes.end(); ++i)
     {
-    if(this->Target->NameResolvesToFramework(i->c_str()))
+    if(this->Target->NameResolvesToFramework(*i))
       {
       std::string frameworkDir = *i;
       frameworkDir += "/../";
@@ -1579,7 +1589,7 @@
       if(emitted.insert(*i).second)
         {
         flags += fwSearchFlag;
-        flags += this->Convert(i->c_str(),
+        flags += this->Convert(*i,
                                cmLocalGenerator::START_OUTPUT,
                                cmLocalGenerator::SHELL, true);
         flags += " ";
@@ -1650,9 +1660,11 @@
   this->AppendTargetDepends(depends);
 
   // Add a dependency on the link definitions file, if any.
-  if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+  std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
+                      this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+  if(!def.empty())
     {
-    depends.push_back(this->GeneratorTarget->ModuleDefinitionFile);
+    depends.push_back(def);
     }
 
   // Add user-specified dependencies.
@@ -1664,7 +1676,8 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
+std::string cmMakefileTargetGenerator::GetLinkRule(
+                                              const std::string& linkRuleVar)
 {
   std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
   if(this->Target->HasImplibGNUtoMS())
@@ -1672,7 +1685,7 @@
     std::string ruleVar = "CMAKE_";
     ruleVar += this->Target->GetLinkerLanguage(this->ConfigName);
     ruleVar += "_GNUtoMS_RULE";
-    if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str()))
+    if(const char* rule = this->Makefile->GetDefinition(ruleVar))
       {
       linkRule += rule;
       }
@@ -1690,8 +1703,8 @@
 }
 
 void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
-                                                     const char* linkLang,
-                                                     std::string& linkFlags)
+                                                const std::string& linkLang,
+                                                std::string& linkFlags)
 {
   // check for language flags that are not allowed at link time, and
   // remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool
@@ -1701,7 +1714,7 @@
   removeFlags += linkLang;
   removeFlags += flagVar;
   std::string removeflags =
-    this->Makefile->GetSafeDefinition(removeFlags.c_str());
+    this->Makefile->GetSafeDefinition(removeFlags);
   std::vector<std::string> removeList;
   cmSystemTools::ExpandListArgument(removeflags, removeList);
 
@@ -1779,7 +1792,7 @@
 
   // Create the makefile command to invoke the link script.
   std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script ";
-  link_command += this->Convert(linkScriptName.c_str(),
+  link_command += this->Convert(linkScriptName,
                                 cmLocalGenerator::START_OUTPUT,
                                 cmLocalGenerator::SHELL);
   link_command += " --verbose=$(VERBOSE)";
@@ -1815,13 +1828,57 @@
 //----------------------------------------------------------------------------
 void
 cmMakefileTargetGenerator
+::CreateLinkLibs(std::string& linkLibs, bool relink,
+                 bool useResponseFile,
+                 std::vector<std::string>& makefile_depends,
+                 bool useWatcomQuote)
+{
+  std::string frameworkPath;
+  std::string linkPath;
+  this->LocalGenerator
+    ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
+                          *this->GeneratorTarget, relink,
+                          useResponseFile,
+                          useWatcomQuote);
+  linkLibs = frameworkPath + linkPath + linkLibs;
+
+  if(useResponseFile)
+    {
+    // Lookup the response file reference flag.
+    std::string responseFlagVar = "CMAKE_";
+    responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
+    responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
+    const char* responseFlag =
+      this->Makefile->GetDefinition(responseFlagVar);
+    if(!responseFlag)
+      {
+      responseFlag = "@";
+      }
+
+    // Create this response file.
+    std::string link_rsp =
+      this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends);
+
+    // Reference the response file.
+    linkLibs = responseFlag;
+    linkLibs += this->Convert(link_rsp,
+                              cmLocalGenerator::NONE,
+                              cmLocalGenerator::SHELL);
+    }
+}
+
+//----------------------------------------------------------------------------
+void
+cmMakefileTargetGenerator
 ::CreateObjectLists(bool useLinkScript, bool useArchiveRules,
                     bool useResponseFile, std::string& buildObjs,
-                    std::vector<std::string>& makefile_depends)
+                    std::vector<std::string>& makefile_depends,
+                    bool useWatcomQuote)
 {
   std::string variableName;
   std::string variableNameExternal;
-  this->WriteObjectsVariable(variableName, variableNameExternal);
+  this->WriteObjectsVariable(variableName, variableNameExternal,
+                             useWatcomQuote);
   if(useResponseFile)
     {
     // MSVC response files cannot exceed 128K.
@@ -1836,7 +1893,7 @@
     responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
     responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
     const char* responseFlag =
-      this->Makefile->GetDefinition(responseFlagVar.c_str());
+      this->Makefile->GetDefinition(responseFlagVar);
     if(!responseFlag)
       {
       responseFlag = "@";
@@ -1860,7 +1917,7 @@
 
       // Reference the response file.
       buildObjs += responseFlag;
-      buildObjs += this->Convert(objects_rsp.c_str(),
+      buildObjs += this->Convert(objects_rsp,
                                  cmLocalGenerator::NONE,
                                  cmLocalGenerator::SHELL);
       }
@@ -1884,16 +1941,17 @@
 
 //----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
-                                                const char* lang)
+                                                const std::string& lang)
 {
   std::string responseVar = "CMAKE_";
   responseVar += lang;
   responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES";
-  bool useResponseFile = this->Makefile->IsOn(responseVar.c_str());
+  bool useResponseFile = this->Makefile->IsOn(responseVar);
 
 
   std::vector<std::string> includes;
-  const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+  const std::string& config =
+    this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
   this->LocalGenerator->GetIncludeDirectories(includes,
                                               this->GeneratorTarget,
                                               lang, config);
@@ -1914,11 +1972,11 @@
     std::string arg = "@" +
       this->CreateResponseFile(name.c_str(), includeFlags,
                                this->FlagFileDepends[lang]);
-    this->LocalGenerator->AppendFlags(flags, arg.c_str());
+    this->LocalGenerator->AppendFlags(flags, arg);
     }
   else
     {
-    this->LocalGenerator->AppendFlags(flags, includeFlags.c_str());
+    this->LocalGenerator->AppendFlags(flags, includeFlags);
     }
 }
 
@@ -1990,7 +2048,7 @@
     modflag += this->Convert(mod_dir,
                              cmLocalGenerator::START_OUTPUT,
                              cmLocalGenerator::SHELL);
-    this->LocalGenerator->AppendFlags(flags, modflag.c_str());
+    this->LocalGenerator->AppendFlags(flags, modflag);
     }
 
   // If there is a separate module path flag then duplicate the
@@ -2000,7 +2058,8 @@
      this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
     {
     std::vector<std::string> includes;
-    const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+    const std::string& config =
+      this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
     this->LocalGenerator->GetIncludeDirectories(includes,
                                                 this->GeneratorTarget,
                                                 "C", config);
@@ -2008,10 +2067,10 @@
         idi != includes.end(); ++idi)
       {
       std::string flg = modpath_flag;
-      flg += this->Convert(idi->c_str(),
+      flg += this->Convert(*idi,
                            cmLocalGenerator::NONE,
                            cmLocalGenerator::SHELL);
-      this->LocalGenerator->AppendFlags(flags, flg.c_str());
+      this->LocalGenerator->AppendFlags(flags, flg);
       }
     }
 }
@@ -2019,7 +2078,9 @@
 //----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
 {
-  if(this->GeneratorTarget->ModuleDefinitionFile.empty())
+  std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
+                      this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+  if(def.empty())
     {
     return;
     }
@@ -2035,26 +2096,25 @@
   // Append the flag and value.  Use ConvertToLinkReference to help
   // vs6's "cl -link" pass it to the linker.
   std::string flag = defFileFlag;
-  flag += (this->LocalGenerator->ConvertToLinkReference(
-             this->GeneratorTarget->ModuleDefinitionFile.c_str()));
-  this->LocalGenerator->AppendFlags(flags, flag.c_str());
+  flag += (this->LocalGenerator->ConvertToLinkReference(def));
+  this->LocalGenerator->AppendFlags(flags, flag);
 }
 
 //----------------------------------------------------------------------------
-const char* cmMakefileTargetGenerator::GetFeature(const char* feature)
+const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature)
 {
   return this->Target->GetFeature(feature, this->ConfigName);
 }
 
 //----------------------------------------------------------------------------
-bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature)
+bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature)
 {
-  return cmSystemTools::IsOn(this->GetFeature(feature));
+  return this->Target->GetFeatureAsBool(feature, this->ConfigName);
 }
 
 //----------------------------------------------------------------------------
 void cmMakefileTargetGenerator::AddFeatureFlags(
-  std::string& flags, const char* lang
+  std::string& flags, const std::string& lang
   )
 {
   // Add language-specific flags.
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 4f8fafa..9fac574 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -15,7 +15,7 @@
 #include "cmLocalUnixMakefileGenerator3.h"
 #include "cmOSXBundleGenerator.h"
 
-class cmCustomCommand;
+class cmCustomCommandGenerator;
 class cmDependInformation;
 class cmDepends;
 class cmGeneratorTarget;
@@ -81,7 +81,7 @@
     MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen) :
       Generator(gen) {}
 
-    void operator()(cmSourceFile& source, const char* pkgloc);
+    void operator()(cmSourceFile const& source, const char* pkgloc);
 
   private:
     cmMakefileTargetGenerator* Generator;
@@ -89,20 +89,20 @@
   friend struct MacOSXContentGeneratorType;
 
   // write the rules for an object
-  void WriteObjectRuleFiles(cmSourceFile& source);
+  void WriteObjectRuleFiles(cmSourceFile const& source);
 
   // write the build rule for an object
   void WriteObjectBuildFile(std::string &obj,
-                            const char *lang,
-                            cmSourceFile& source,
+                            const std::string& lang,
+                            cmSourceFile const& source,
                             std::vector<std::string>& depends);
 
   // write the depend.make file for an object
-  void WriteObjectDependRules(cmSourceFile& source,
+  void WriteObjectDependRules(cmSourceFile const& source,
                               std::vector<std::string>& depends);
 
   // write the build rule for a custom command
-  void GenerateCustomRuleFile(const cmCustomCommand& cc);
+  void GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg);
 
   // write a rule to drive building of more than one output from
   // another rule
@@ -113,20 +113,22 @@
 
   // write out the variable that lists the objects for this target
   void WriteObjectsVariable(std::string& variableName,
-                            std::string& variableNameExternal);
+                            std::string& variableNameExternal,
+                            bool useWatcomQuote);
   void WriteObjectsString(std::string& buildObjs);
   void WriteObjectsStrings(std::vector<std::string>& objStrings,
                            std::string::size_type limit = std::string::npos);
 
   // write the driver rule to build target outputs
-  void WriteTargetDriverRule(const char* main_output, bool relink);
+  void WriteTargetDriverRule(const std::string& main_output, bool relink);
 
   void DriveCustomCommands(std::vector<std::string>& depends);
 
   // Return the a string with -F flags on apple
   std::string GetFrameworkFlags(std::string const& l);
 
-  void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source);
+  void AppendFortranFormatFlags(std::string& flags,
+                                cmSourceFile const& source);
 
   // append intertarget dependencies
   void AppendTargetDepends(std::vector<std::string>& depends);
@@ -138,7 +140,7 @@
   void AppendLinkDepends(std::vector<std::string>& depends);
 
   // Lookup the link rule for this target.
-  std::string GetLinkRule(const char* linkRuleVar);
+  std::string GetLinkRule(const std::string& linkRuleVar);
 
   /** In order to support parallel builds for custom commands with
       multiple outputs the outputs are given a serial order, and only
@@ -163,22 +165,29 @@
                                  std::string const& options,
                                  std::vector<std::string>& makefile_depends);
 
+  /** Create list of flags for link libraries. */
+  void CreateLinkLibs(std::string& linkLibs, bool relink,
+                      bool useResponseFile,
+                      std::vector<std::string>& makefile_depends,
+                      bool useWatcomQuote);
+
   /** Create lists of object files for linking and cleaning.  */
   void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
                          bool useResponseFile, std::string& buildObjs,
-                         std::vector<std::string>& makefile_depends);
+                         std::vector<std::string>& makefile_depends,
+                         bool useWatcomQuote);
 
-  void AddIncludeFlags(std::string& flags, const char* lang);
+  void AddIncludeFlags(std::string& flags, const std::string& lang);
 
   virtual void CloseFileStreams();
-  void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
+  void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang,
                             std::string& linkFlags);
   cmTarget *Target;
   cmGeneratorTarget* GeneratorTarget;
   cmLocalUnixMakefileGenerator3 *LocalGenerator;
   cmGlobalUnixMakefileGenerator3 *GlobalGenerator;
   cmMakefile *Makefile;
-  const char *ConfigName;
+  std::string ConfigName;
 
   enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility };
   CustomCommandDriveType CustomCommandDriver;
@@ -203,7 +212,7 @@
   std::string FlagFileNameFull;
   cmGeneratedFileStream *FlagFileStream;
   class StringList: public std::vector<std::string> {};
-  std::map<cmStdString, StringList> FlagFileDepends;
+  std::map<std::string, StringList> FlagFileDepends;
 
   // the stream for the info file
   std::string InfoFileNameFull;
@@ -217,12 +226,12 @@
   std::vector<std::string> ExternalObjects;
 
   // Set of object file names that will be built in this directory.
-  std::set<cmStdString> ObjectFiles;
+  std::set<std::string> ObjectFiles;
 
   // Set of extra output files to be driven by the build.
-  std::set<cmStdString> ExtraFiles;
+  std::set<std::string> ExtraFiles;
 
-  typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
+  typedef std::map<std::string, std::string> MultipleOutputPairsType;
   MultipleOutputPairsType MultipleOutputPairs;
 
   // Target name info.
@@ -233,11 +242,11 @@
   std::string TargetNamePDB;
 
   // Mac OS X content info.
-  std::set<cmStdString> MacContentFolders;
+  std::set<std::string> MacContentFolders;
   cmOSXBundleGenerator* OSXBundleGenerator;
   MacOSXContentGeneratorType* MacOSXContentGenerator;
 
-  typedef std::map<cmStdString, cmStdString> ByLanguageMap;
+  typedef std::map<std::string, std::string> ByLanguageMap;
   std::string GetFlags(const std::string &l);
   ByLanguageMap FlagsByLanguage;
   std::string GetDefines(const std::string &l);
@@ -255,16 +264,16 @@
   void AddModuleDefinitionFlag(std::string& flags);
 
   // Add language feature flags.
-  void AddFeatureFlags(std::string& flags, const char* lang);
+  void AddFeatureFlags(std::string& flags, const std::string& lang);
 
   // Feature query methods.
-  const char* GetFeature(const char* feature);
-  bool GetFeatureAsBool(const char* feature);
+  const char* GetFeature(const std::string& feature);
+  bool GetFeatureAsBool(const std::string& feature);
 
   //==================================================================
   // Convenience routines that do nothing more than forward to
   // implementaitons
-  std::string Convert(const char* source,
+  std::string Convert(const std::string& source,
                       cmLocalGenerator::RelativeRoot relative,
                       cmLocalGenerator::OutputFormat output =
                       cmLocalGenerator::UNCHANGED,
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index 7751ad9..6b039bb 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -52,7 +52,7 @@
     *this->BuildFileStream
       << "# Include the progress variables for this target.\n"
       << this->LocalGenerator->IncludeDirective << " " << root
-      << this->Convert(this->ProgressFileNameFull.c_str(),
+      << this->Convert(this->ProgressFileNameFull,
                        cmLocalGenerator::HOME_OUTPUT,
                        cmLocalGenerator::MAKEFILE)
       << "\n\n";
diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx
index 4236d10..f6a2c26 100644
--- a/Source/cmMarkAsAdvancedCommand.cxx
+++ b/Source/cmMarkAsAdvancedCommand.cxx
@@ -42,11 +42,11 @@
     if ( it.IsAtEnd() )
       {
       this->Makefile->GetCacheManager()
-        ->AddCacheEntry(variable.c_str(), 0, 0,
+        ->AddCacheEntry(variable, 0, 0,
           cmCacheManager::UNINITIALIZED);
       overwrite = true;
       }
-    it.Find(variable.c_str());
+    it.Find(variable);
     if ( it.IsAtEnd() )
       {
       cmSystemTools::Error("This should never happen...");
diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h
index b65e4a8..38064a3 100644
--- a/Source/cmMarkAsAdvancedCommand.h
+++ b/Source/cmMarkAsAdvancedCommand.h
@@ -40,7 +40,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "mark_as_advanced";}
+  virtual std::string GetName() const {return "mark_as_advanced";}
 
   /**
    * This determines if the command is invoked when in script mode.
diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx
index 9fc4265..f1942c5 100644
--- a/Source/cmMathCommand.cxx
+++ b/Source/cmMathCommand.cxx
@@ -28,7 +28,7 @@
     return this->HandleExprCommand(args);
     }
   std::string e = "does not recognize sub-command "+subCommand;
-  this->SetError(e.c_str());
+  this->SetError(e);
   return false;
 }
 
@@ -49,13 +49,13 @@
     {
     std::string e = "cannot parse the expression: \""+expression+"\": ";
     e += helper.GetError();
-    this->SetError(e.c_str());
+    this->SetError(e);
     return false;
     }
 
   char buffer[1024];
   sprintf(buffer, "%d", helper.GetResult());
 
-  this->Makefile->AddDefinition(outputVariable.c_str(), buffer);
+  this->Makefile->AddDefinition(outputVariable, buffer);
   return true;
 }
diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h
index c826ef1..76dc102 100644
--- a/Source/cmMathCommand.h
+++ b/Source/cmMathCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "math";}
+  virtual std::string GetName() const { return "math";}
 
   cmTypeMacro(cmMathCommand, cmCommand);
 protected:
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index d85e720..88d6a77 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -77,7 +77,7 @@
 
   if (type != cmake::MESSAGE)
     {
-    this->Makefile->IssueMessage(type, message.c_str());
+    this->Makefile->IssueMessage(type, message);
     }
   else
     {
diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h
index fec9a32..c0ae2a3 100644
--- a/Source/cmMessageCommand.h
+++ b/Source/cmMessageCommand.h
@@ -39,7 +39,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "message";}
+  virtual std::string GetName() const { return "message";}
 
   /**
    * This determines if the command is invoked when in script mode.
diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx
index a7d7429..08f0b5b 100644
--- a/Source/cmNewLineStyle.cxx
+++ b/Source/cmNewLineStyle.cxx
@@ -76,8 +76,6 @@
       return "\n";
     case CRLF:
       return "\r\n";
-    default:
-      ;
     }
   return "";
 }
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 73ba815..cfcf9f4 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -18,6 +18,7 @@
 #include "cmMakefile.h"
 #include "cmOSXBundleGenerator.h"
 #include "cmGeneratorTarget.h"
+#include "cmCustomCommandGenerator.h"
 
 #include <assert.h>
 #include <algorithm>
@@ -35,7 +36,7 @@
   , TargetNameReal()
   , TargetNameImport()
   , TargetNamePDB()
-  , TargetLinkLanguage(0)
+  , TargetLinkLanguage("")
 {
   this->TargetLinkLanguage = target->Target
                                    ->GetLinkerLanguage(this->GetConfigName());
@@ -72,10 +73,10 @@
 
 void cmNinjaNormalTargetGenerator::Generate()
 {
-  if (!this->TargetLinkLanguage) {
+  if (this->TargetLinkLanguage.empty()) {
     cmSystemTools::Error("CMake can not determine linker language for "
                          "target: ",
-                         this->GetTarget()->GetName());
+                         this->GetTarget()->GetName().c_str());
     return;
   }
 
@@ -109,9 +110,10 @@
     << "\n\n";
 #endif
 
-  std::set<cmStdString> languages;
-  this->GetTarget()->GetLanguages(languages);
-  for(std::set<cmStdString>::const_iterator l = languages.begin();
+  std::set<std::string> languages;
+  this->GetTarget()->GetLanguages(languages,
+                  this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+  for(std::set<std::string>::const_iterator l = languages.begin();
       l != languages.end();
       ++l)
     this->WriteLanguageRules(*l);
@@ -140,7 +142,7 @@
 cmNinjaNormalTargetGenerator
 ::LanguageLinkerRule() const
 {
-  return std::string(this->TargetLinkLanguage)
+  return this->TargetLinkLanguage
     + "_"
     + cmTarget::GetTargetTypeName(this->GetTarget()->GetType())
     + "_LINKER";
@@ -163,7 +165,7 @@
     cmLocalGenerator::RuleVariables vars;
     vars.RuleLauncher = "RULE_LAUNCH_LINK";
     vars.CMTarget = this->GetTarget();
-    vars.Language = this->TargetLinkLanguage;
+    vars.Language = this->TargetLinkLanguage.c_str();
 
     std::string responseFlag;
     if (!useResponseFile) {
@@ -175,7 +177,7 @@
 
         // build response file name
         std::string cmakeLinkVar =  cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
-        const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar.c_str());
+        const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar);
         if(flag) {
           responseFlag = flag;
         } else {
@@ -189,7 +191,7 @@
         linkOptionVar += "_COMPILER_LINKER_OPTION_FLAG_";
         linkOptionVar += cmTarget::GetTargetTypeName(targetType);
         const std::string linkOption =
-                GetMakefile()->GetSafeDefinition(linkOptionVar.c_str());
+                GetMakefile()->GetSafeDefinition(linkOptionVar);
         rspcontent = "$in_newline "+linkOption+" $LINK_PATH $LINK_LIBRARIES";
         vars.Objects = responseFlag.c_str();
         vars.LinkLibraries = "";
@@ -230,13 +232,11 @@
     vars.LinkFlags = "$LINK_FLAGS";
 
     std::string langFlags;
-    if (targetType != cmTarget::EXECUTABLE) {
-      this->GetLocalGenerator()->AddLanguageFlags(langFlags,
-                                                  this->TargetLinkLanguage,
-                                                  this->GetConfigName());
-      langFlags += " $ARCH_FLAGS";
+    if (targetType != cmTarget::EXECUTABLE)
+      {
+      langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS";
       vars.LanguageCompileFlags = langFlags.c_str();
-    }
+      }
 
     // Rule for linking library/executable.
     std::vector<std::string> linkCmds = this->ComputeLinkCmd();
@@ -312,97 +312,87 @@
 ::ComputeLinkCmd()
 {
   std::vector<std::string> linkCmds;
-  cmTarget::TargetType targetType = this->GetTarget()->GetType();
-  switch (targetType) {
+  cmMakefile* mf = this->GetMakefile();
+  {
+  std::string linkCmdVar = this->GetGeneratorTarget()
+    ->GetCreateRuleVariable(this->TargetLinkLanguage, this->GetConfigName());
+  const char *linkCmd = mf->GetDefinition(linkCmdVar);
+  if (linkCmd)
+    {
+    cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
+    return linkCmds;
+    }
+  }
+  switch (this->GetTarget()->GetType()) {
     case cmTarget::STATIC_LIBRARY: {
-      // Check if you have a non archive way to create the static library.
-      {
-      std::string linkCmdVar = "CMAKE_";
-      linkCmdVar += this->TargetLinkLanguage;
-      linkCmdVar += "_CREATE_STATIC_LIBRARY";
-      if (const char *linkCmd =
-            this->GetMakefile()->GetDefinition(linkCmdVar.c_str()))
-        {
-        cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
-        return linkCmds;
-        }
-      }
-
       // We have archive link commands set. First, delete the existing archive.
+      {
       std::string cmakeCommand =
         this->GetLocalGenerator()->ConvertToOutputFormat(
-          this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"),
+          mf->GetRequiredDefinition("CMAKE_COMMAND"),
           cmLocalGenerator::SHELL);
       linkCmds.push_back(cmakeCommand + " -E remove $out");
-
+      }
       // TODO: Use ARCHIVE_APPEND for archives over a certain size.
       {
       std::string linkCmdVar = "CMAKE_";
       linkCmdVar += this->TargetLinkLanguage;
       linkCmdVar += "_ARCHIVE_CREATE";
-      const char *linkCmd =
-        this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
+      const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar);
       cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
       }
       {
       std::string linkCmdVar = "CMAKE_";
       linkCmdVar += this->TargetLinkLanguage;
       linkCmdVar += "_ARCHIVE_FINISH";
-      const char *linkCmd =
-        this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
+      const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar);
       cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
       }
       return linkCmds;
     }
     case cmTarget::SHARED_LIBRARY:
     case cmTarget::MODULE_LIBRARY:
-    case cmTarget::EXECUTABLE: {
-      std::string linkCmdVar = "CMAKE_";
-      linkCmdVar += this->TargetLinkLanguage;
-      switch (targetType) {
-      case cmTarget::SHARED_LIBRARY:
-        linkCmdVar += "_CREATE_SHARED_LIBRARY";
-        break;
-      case cmTarget::MODULE_LIBRARY:
-        linkCmdVar += "_CREATE_SHARED_MODULE";
-        break;
-      case cmTarget::EXECUTABLE:
-        linkCmdVar += "_LINK_EXECUTABLE";
-        break;
-      default:
-        assert(0 && "Unexpected target type");
-      }
-
-      const char *linkCmd =
-        this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
-      cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
-      return linkCmds;
-    }
+    case cmTarget::EXECUTABLE:
+      break;
     default:
       assert(0 && "Unexpected target type");
   }
   return std::vector<std::string>();
 }
 
+
+static int calculateCommandLineLengthLimit(int linkRuleLength)
+{
+#ifdef _WIN32
+  return 8000 - linkRuleLength;
+#elif defined(__linux) || defined(__APPLE__) || defined(__HAIKU__)
+  // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
+  return ((int)sysconf(_SC_ARG_MAX)) - linkRuleLength - 1000;
+#else
+  (void)linkRuleLength;
+  return -1;
+#endif
+}
+
+
 void cmNinjaNormalTargetGenerator::WriteLinkStatement()
 {
-  cmTarget::TargetType targetType = this->GetTarget()->GetType();
-
+  cmTarget& target = *this->GetTarget();
+  const std::string cfgName = this->GetConfigName();
   std::string targetOutput = ConvertToNinjaPath(
-    this->GetTarget()->GetFullPath(this->GetConfigName()).c_str());
+                               target.GetFullPath(cfgName).c_str());
   std::string targetOutputReal = ConvertToNinjaPath(
-    this->GetTarget()->GetFullPath(this->GetConfigName(),
-                                   /*implib=*/false,
-                                   /*realpath=*/true).c_str());
+                                   target.GetFullPath(cfgName,
+                                      /*implib=*/false,
+                                      /*realpath=*/true).c_str());
   std::string targetOutputImplib = ConvertToNinjaPath(
-    this->GetTarget()->GetFullPath(this->GetConfigName(),
-                                   /*implib=*/true).c_str());
+                                     target.GetFullPath(cfgName,
+                                       /*implib=*/true).c_str());
 
-  if (this->GetTarget()->IsAppBundleOnApple())
+  if (target.IsAppBundleOnApple())
     {
     // Create the app bundle
-    std::string outpath =
-      this->GetTarget()->GetDirectory(this->GetConfigName());
+    std::string outpath = target.GetDirectory(cfgName);
     this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath);
 
     // Calculate the output path
@@ -415,23 +405,22 @@
     targetOutputReal += this->TargetNameReal;
     targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
     }
-  else if (this->GetTarget()->IsFrameworkOnApple())
+  else if (target.IsFrameworkOnApple())
     {
     // Create the library framework.
-    std::string outpath =
-      this->GetTarget()->GetDirectory(this->GetConfigName());
-    this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, outpath);
+    this->OSXBundleGenerator->CreateFramework(this->TargetNameOut,
+                                              target.GetDirectory(cfgName));
     }
-  else if(this->GetTarget()->IsCFBundleOnApple())
+  else if(target.IsCFBundleOnApple())
     {
     // Create the core foundation bundle.
-    std::string outpath =
-      this->GetTarget()->GetDirectory(this->GetConfigName());
-    this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, outpath);
+    this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut,
+                                             target.GetDirectory(cfgName));
     }
 
   // Write comments.
   cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
+  const cmTarget::TargetType targetType = target.GetType();
   this->GetBuildFileStream()
     << "# Link build statements for "
     << cmTarget::GetTargetTypeName(targetType)
@@ -444,8 +433,8 @@
 
   // Compute the comment.
   cmOStringStream comment;
-  comment << "Link the " << this->GetVisibleTypeName() << " "
-          << targetOutputReal;
+  comment <<
+    "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal;
 
   // Compute outputs.
   cmNinjaDeps outputs;
@@ -455,16 +444,26 @@
   cmNinjaDeps explicitDeps = this->GetObjects();
   cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
 
+  cmMakefile* mf = this->GetMakefile();
+
   std::string frameworkPath;
   std::string linkPath;
-  this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
-                                            vars["FLAGS"],
-                                            vars["LINK_FLAGS"],
-                                            frameworkPath,
-                                            linkPath,
-                                            this->GetGeneratorTarget());
+  cmGeneratorTarget& genTarget = *this->GetGeneratorTarget();
 
-  this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars);
+  std::string createRule =
+    genTarget.GetCreateRuleVariable(this->TargetLinkLanguage,
+                                    this->GetConfigName());
+  bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE");
+  cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
+  localGen.GetTargetFlags(vars["LINK_LIBRARIES"],
+                          vars["FLAGS"],
+                          vars["LINK_FLAGS"],
+                          frameworkPath,
+                          linkPath,
+                          &genTarget,
+                          useWatcomQuote);
+
+  this->addPoolNinjaVariable("JOB_POOL_LINK", &target, vars);
 
   this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
   vars["LINK_FLAGS"] = cmGlobalNinjaGenerator
@@ -475,44 +474,48 @@
   // Compute architecture specific link flags.  Yes, these go into a different
   // variable for executables, probably due to a mistake made when duplicating
   // code between the Makefile executable and library generators.
-  std::string flags = (targetType == cmTarget::EXECUTABLE
-                               ? vars["FLAGS"]
-                               : vars["ARCH_FLAGS"]);
-  this->GetLocalGenerator()->AddArchitectureFlags(flags,
-                             this->GetGeneratorTarget(),
-                             this->TargetLinkLanguage,
-                             this->GetConfigName());
-  if (targetType == cmTarget::EXECUTABLE) {
-    vars["FLAGS"] = flags;
-  } else {
-    vars["ARCH_FLAGS"] = flags;
-  }
-  if (this->GetTarget()->HasSOName(this->GetConfigName())) {
-    vars["SONAME_FLAG"] =
-      this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage);
-    vars["SONAME"] = this->TargetNameSO;
-    if (targetType == cmTarget::SHARED_LIBRARY) {
-      std::string install_name_dir = this->GetTarget()
-        ->GetInstallNameDirForBuildTree(this->GetConfigName());
+  if (targetType == cmTarget::EXECUTABLE)
+    {
+    std::string t = vars["FLAGS"];
+    localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+    vars["FLAGS"] = t;
+    }
+  else
+    {
+    std::string t = vars["ARCH_FLAGS"];
+    localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+    vars["ARCH_FLAGS"] = t;
+    t = "";
+    localGen.AddLanguageFlags(t, TargetLinkLanguage, cfgName);
+    vars["LANGUAGE_COMPILE_FLAGS"] = t;
+    }
 
-      if (!install_name_dir.empty()) {
-        vars["INSTALLNAME_DIR"] =
-          this->GetLocalGenerator()->Convert(install_name_dir.c_str(),
-              cmLocalGenerator::NONE,
-              cmLocalGenerator::SHELL, false);
+  if (target.HasSOName(cfgName))
+    {
+    vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage);
+    vars["SONAME"] = this->TargetNameSO;
+    if (targetType == cmTarget::SHARED_LIBRARY)
+      {
+      std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName);
+      if (!install_dir.empty())
+        {
+        vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir,
+                                                   cmLocalGenerator::NONE,
+                                                   cmLocalGenerator::SHELL,
+                                                   false);
+        }
       }
     }
-  }
 
-  if (!this->TargetNameImport.empty()) {
-    const std::string impLibPath = this->GetLocalGenerator()
-      ->ConvertToOutputFormat(targetOutputImplib.c_str(),
-                              cmLocalGenerator::SHELL);
+  if (!this->TargetNameImport.empty())
+    {
+    const std::string impLibPath = localGen.ConvertToOutputFormat(
+                                              targetOutputImplib,
+                                              cmLocalGenerator::SHELL);
     vars["TARGET_IMPLIB"] = impLibPath;
     EnsureParentDirectoryExists(impLibPath);
-  }
+    }
 
-  cmMakefile* mf = this->GetMakefile();
   if (!this->SetMsvcTargetPdbVariable(vars))
     {
     // It is common to place debug symbols at a specific place,
@@ -520,11 +523,13 @@
     std::string prefix;
     std::string base;
     std::string suffix;
-    this->GetTarget()->GetFullNameComponents(prefix, base, suffix);
+    target.GetFullNameComponents(prefix, base, suffix);
     std::string dbg_suffix = ".dbg";
     // TODO: Where to document?
     if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX"))
+      {
       dbg_suffix = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX");
+      }
     vars["TARGET_PDB"] = base + suffix + dbg_suffix;
     }
 
@@ -536,12 +541,14 @@
     // ar.exe can't handle backslashes in rsp files (implicitly used by gcc)
     std::string& linkLibraries = vars["LINK_LIBRARIES"];
     std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
+    std::string& link_path = vars["LINK_PATH"];
+    std::replace(link_path.begin(), link_path.end(), '\\', '/');
     }
 
   const std::vector<cmCustomCommand> *cmdLists[3] = {
-    &this->GetTarget()->GetPreBuildCommands(),
-    &this->GetTarget()->GetPreLinkCommands(),
-    &this->GetTarget()->GetPostBuildCommands()
+    &target.GetPreBuildCommands(),
+    &target.GetPreLinkCommands(),
+    &target.GetPostBuildCommands()
   };
 
   std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
@@ -551,99 +558,97 @@
     &postBuildCmdLines
   };
 
-  for (unsigned i = 0; i != 3; ++i) {
+  for (unsigned i = 0; i != 3; ++i)
+    {
     for (std::vector<cmCustomCommand>::const_iterator
          ci = cmdLists[i]->begin();
-         ci != cmdLists[i]->end(); ++ci) {
-      this->GetLocalGenerator()->AppendCustomCommandLines(&*ci,
-                                                          *cmdLineLists[i]);
+         ci != cmdLists[i]->end(); ++ci)
+      {
+      cmCustomCommandGenerator ccg(*ci, cfgName, mf);
+      localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
+      }
     }
-  }
 
   // If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
   // the link commands.
-  if (!preLinkCmdLines.empty()) {
-    const std::string homeOutDir = this->GetLocalGenerator()
-      ->ConvertToOutputFormat(this->GetMakefile()->GetHomeOutputDirectory(),
-                              cmLocalGenerator::SHELL);
+  if (!preLinkCmdLines.empty())
+    {
+    const std::string homeOutDir = localGen.ConvertToOutputFormat(
+                                              mf->GetHomeOutputDirectory(),
+                                              cmLocalGenerator::SHELL);
     preLinkCmdLines.push_back("cd " + homeOutDir);
-  }
+    }
 
-  vars["PRE_LINK"] =
-    this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines);
-  std::string postBuildCmdLine =
-    this->GetLocalGenerator()->BuildCommandLine(postBuildCmdLines);
+  vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines);
+  std::string postBuildCmdLine = localGen.BuildCommandLine(postBuildCmdLines);
 
   cmNinjaVars symlinkVars;
-  if (targetOutput == targetOutputReal) {
+  if (targetOutput == targetOutputReal)
+    {
     vars["POST_BUILD"] = postBuildCmdLine;
-  } else {
+    }
+  else
+    {
     vars["POST_BUILD"] = ":";
     symlinkVars["POST_BUILD"] = postBuildCmdLine;
-  }
+    }
 
-  int linkRuleLength = this->GetGlobalGenerator()->
-                                 GetRuleCmdLength(this->LanguageLinkerRule());
+  cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
 
   int commandLineLengthLimit = 1;
   const char* forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE";
-  if (!this->GetMakefile()->IsDefinitionSet(forceRspFile) &&
-      cmSystemTools::GetEnv(forceRspFile) == 0) {
-#ifdef _WIN32
-    commandLineLengthLimit = 8000 - linkRuleLength;
-#elif defined(__linux) || defined(__APPLE__)
-    // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
-    commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))-linkRuleLength-1000;
-#else
-    (void)linkRuleLength;
-    commandLineLengthLimit = -1;
-#endif
-  }
+  if (!mf->IsDefinitionSet(forceRspFile) &&
+      cmSystemTools::GetEnv(forceRspFile) == 0)
+    {
+    commandLineLengthLimit = calculateCommandLineLengthLimit(
+                globalGen.GetRuleCmdLength(this->LanguageLinkerRule()));
+    }
 
-  //Get the global generator as we are going to be call WriteBuild numerous
-  //times in the following section
-  cmGlobalNinjaGenerator* globalGenerator = this->GetGlobalGenerator();
-
-
-  const std::string rspfile = std::string
-                              (cmake::GetCMakeFilesDirectoryPostSlash()) +
-                              this->GetTarget()->GetName() + ".rsp";
+  const std::string rspfile =
+      std::string(cmake::GetCMakeFilesDirectoryPostSlash())
+      + target.GetName() + ".rsp";
 
   // Write the build statement for this target.
-  globalGenerator->WriteBuild(this->GetBuildFileStream(),
-                              comment.str(),
-                              this->LanguageLinkerRule(),
-                              outputs,
-                              explicitDeps,
-                              implicitDeps,
-                              emptyDeps,
-                              vars,
-                              rspfile,
-                              commandLineLengthLimit);
+  globalGen.WriteBuild(this->GetBuildFileStream(),
+                        comment.str(),
+                        this->LanguageLinkerRule(),
+                        outputs,
+                        explicitDeps,
+                        implicitDeps,
+                        emptyDeps,
+                        vars,
+                        rspfile,
+                        commandLineLengthLimit);
 
-  if (targetOutput != targetOutputReal &&
-    !this->GetTarget()->IsFrameworkOnApple()) {
-    if (targetType == cmTarget::EXECUTABLE) {
-      globalGenerator->WriteBuild(this->GetBuildFileStream(),
-                                  "Create executable symlink " + targetOutput,
-                                  "CMAKE_SYMLINK_EXECUTABLE",
-                                  cmNinjaDeps(1, targetOutput),
-                                  cmNinjaDeps(1, targetOutputReal),
-                                  emptyDeps,
-                                  emptyDeps,
-                                  symlinkVars);
-    } else {
+  if (targetOutput != targetOutputReal && !target.IsFrameworkOnApple())
+    {
+    if (targetType == cmTarget::EXECUTABLE)
+      {
+      globalGen.WriteBuild(this->GetBuildFileStream(),
+                            "Create executable symlink " + targetOutput,
+                            "CMAKE_SYMLINK_EXECUTABLE",
+                            cmNinjaDeps(1, targetOutput),
+                            cmNinjaDeps(1, targetOutputReal),
+                            emptyDeps,
+                            emptyDeps,
+                            symlinkVars);
+      }
+   else
+     {
       cmNinjaDeps symlinks;
       const std::string soName = this->GetTargetFilePath(this->TargetNameSO);
       // If one link has to be created.
-      if (targetOutputReal == soName || targetOutput == soName) {
+      if (targetOutputReal == soName || targetOutput == soName)
+        {
         symlinkVars["SONAME"] = soName;
-      } else {
+        }
+      else
+        {
         symlinkVars["SONAME"] = "";
         symlinks.push_back(soName);
-      }
+        }
       symlinks.push_back(targetOutput);
-      globalGenerator->WriteBuild(this->GetBuildFileStream(),
+      globalGen.WriteBuild(this->GetBuildFileStream(),
                                   "Create library symlink " + targetOutput,
                                      "CMAKE_SYMLINK_LIBRARY",
                                   symlinks,
@@ -651,23 +656,22 @@
                                   emptyDeps,
                                   emptyDeps,
                                   symlinkVars);
+      }
     }
-  }
 
-  if (!this->TargetNameImport.empty()) {
+  if (!this->TargetNameImport.empty())
+    {
     // Since using multiple outputs would mess up the $out variable, use an
     // alias for the import library.
-    globalGenerator->WritePhonyBuild(this->GetBuildFileStream(),
-                                     "Alias for import library.",
-                                     cmNinjaDeps(1, targetOutputImplib),
-                                     cmNinjaDeps(1, targetOutputReal));
-  }
+    globalGen.WritePhonyBuild(this->GetBuildFileStream(),
+                              "Alias for import library.",
+                              cmNinjaDeps(1, targetOutputImplib),
+                              cmNinjaDeps(1, targetOutputReal));
+    }
 
   // Add aliases for the file name and the target name.
-  globalGenerator->AddTargetAlias(this->TargetNameOut,
-                                             this->GetTarget());
-  globalGenerator->AddTargetAlias(this->GetTargetName(),
-                                             this->GetTarget());
+  globalGen.AddTargetAlias(this->TargetNameOut, &target);
+  globalGen.AddTargetAlias(this->GetTargetName(), &target);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index c7a089c..556ed5e 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -47,7 +47,7 @@
   std::string TargetNameReal;
   std::string TargetNameImport;
   std::string TargetNamePDB;
-  const char *TargetLinkLanguage;
+  std::string TargetLinkLanguage;
 };
 
 #endif // ! cmNinjaNormalTargetGenerator_h
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 3220fba..24689fb 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -91,26 +91,26 @@
   return this->LocalGenerator->GetGlobalNinjaGenerator();
 }
 
-const char* cmNinjaTargetGenerator::GetConfigName() const
+std::string const& cmNinjaTargetGenerator::GetConfigName() const
 {
   return this->LocalGenerator->GetConfigName();
 }
 
 // TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.
-const char* cmNinjaTargetGenerator::GetFeature(const char* feature)
+const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature)
 {
   return this->Target->GetFeature(feature, this->GetConfigName());
 }
 
 // TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.
-bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature)
+bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature)
 {
-  return cmSystemTools::IsOn(this->GetFeature(feature));
+  return this->Target->GetFeatureAsBool(feature, this->GetConfigName());
 }
 
 // TODO: Picked up from cmMakefileTargetGenerator.  Refactor it.
 void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags,
-                                             const char* lang)
+                                             const std::string& lang)
 {
   // Add language-specific flags.
   this->LocalGenerator->AddLanguageFlags(flags, lang, this->GetConfigName());
@@ -121,12 +121,18 @@
     }
 }
 
+std::string
+cmNinjaTargetGenerator::OrderDependsTargetForTarget()
+{
+  return "cmake_order_depends_target_" + this->GetTargetName();
+}
+
 // TODO: Most of the code is picked up from
 // void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink),
 // void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
 // Refactor it.
 std::string
-cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
+cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
                                               const std::string& language)
 {
   // TODO: Fortran support.
@@ -140,11 +146,11 @@
   std::string& languageFlags = this->LanguageFlags[language];
   if(!hasLangCached)
     {
-    this->AddFeatureFlags(languageFlags, language.c_str());
+    this->AddFeatureFlags(languageFlags, language);
 
     this->GetLocalGenerator()->AddArchitectureFlags(languageFlags,
                                                     this->GeneratorTarget,
-                                                    language.c_str(),
+                                                    language,
                                                     this->GetConfigName());
 
     // Add shared-library flags if needed.
@@ -153,23 +159,23 @@
                                           this->GetConfigName());
 
     this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target,
-                                                   language.c_str());
+                                                   language);
 
     std::vector<std::string> includes;
     this->LocalGenerator->GetIncludeDirectories(includes,
                                                 this->GeneratorTarget,
-                                                language.c_str(),
+                                                language,
                                                 this->GetConfigName());
     // Add include directory flags.
     std::string includeFlags =
       this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
-                                            language.c_str(),
+                                            language,
       language == "RC" ? true : false); // full include paths for RC
                                         // needed by cmcldeps
     if(cmGlobalNinjaGenerator::IsMinGW())
       cmSystemTools::ReplaceString(includeFlags, "\\", "/");
 
-    this->LocalGenerator->AppendFlags(languageFlags, includeFlags.c_str());
+    this->LocalGenerator->AppendFlags(languageFlags, includeFlags);
 
     // Append old-style preprocessor definition flags.
     this->LocalGenerator->AppendFlags(languageFlags,
@@ -177,7 +183,7 @@
 
     // Add target-specific flags.
     this->LocalGenerator->AddCompileOptions(languageFlags, this->Target,
-                                            language.c_str(),
+                                            language,
                                             this->GetConfigName());
     }
 
@@ -211,7 +217,7 @@
 // void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
 std::string
 cmNinjaTargetGenerator::
-ComputeDefines(cmSourceFile *source, const std::string& language)
+ComputeDefines(cmSourceFile const* source, const std::string& language)
 {
   std::set<std::string> defines;
 
@@ -232,12 +238,12 @@
   defPropName += cmSystemTools::UpperCase(this->GetConfigName());
   this->LocalGenerator->AppendDefines
     (defines,
-     source->GetProperty(defPropName.c_str()));
+     source->GetProperty(defPropName));
   }
 
   std::string definesString;
   this->LocalGenerator->JoinDefines(defines, definesString,
-     language.c_str());
+     language);
 
   return definesString;
 }
@@ -269,14 +275,14 @@
 
 std::string
 cmNinjaTargetGenerator
-::GetSourceFilePath(cmSourceFile* source) const
+::GetSourceFilePath(cmSourceFile const* source) const
 {
   return ConvertToNinjaPath(source->GetFullPath().c_str());
 }
 
 std::string
 cmNinjaTargetGenerator
-::GetObjectFilePath(cmSourceFile* source) const
+::GetObjectFilePath(cmSourceFile const* source) const
 {
   std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
   if(!path.empty())
@@ -320,6 +326,7 @@
       mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
     {
     std::string pdbPath;
+    std::string compilePdbPath;
     if(this->Target->GetType() == cmTarget::EXECUTABLE ||
        this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
        this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -329,11 +336,25 @@
       pdbPath += "/";
       pdbPath += this->Target->GetPDBName(this->GetConfigName());
       }
+    if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
+      {
+      compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName());
+      if(compilePdbPath.empty())
+        {
+        compilePdbPath = this->Target->GetSupportDirectory() + "/";
+        }
+      }
 
     vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
-                          ConvertToNinjaPath(pdbPath.c_str()).c_str(),
+                          ConvertToNinjaPath(pdbPath.c_str()),
                           cmLocalGenerator::SHELL);
+    vars["TARGET_COMPILE_PDB"] =
+      this->GetLocalGenerator()->ConvertToOutputFormat(
+        ConvertToNinjaPath(compilePdbPath.c_str()),
+        cmLocalGenerator::SHELL);
+
     EnsureParentDirectoryExists(pdbPath);
+    EnsureParentDirectoryExists(compilePdbPath);
     return true;
     }
   return false;
@@ -362,7 +383,9 @@
   vars.Object = "$out";
   vars.Defines = "$DEFINES";
   vars.TargetPDB = "$TARGET_PDB";
+  vars.TargetCompilePDB = "$TARGET_COMPILE_PDB";
   vars.ObjectDir = "$OBJECT_DIR";
+  vars.ObjectFileDir = "$OBJECT_FILE_DIR";
 
   cmMakefile* mf = this->GetMakefile();
 
@@ -404,9 +427,14 @@
   else
     {
     deptype = "gcc";
+    const char* langdeptype = mf->GetDefinition("CMAKE_NINJA_DEPTYPE_" + lang);
+    if (langdeptype)
+      {
+      deptype = langdeptype;
+      }
     depfile = "$DEP_FILE";
     const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang;
-    std::string depfileFlags = mf->GetSafeDefinition(flagsName.c_str());
+    std::string depfileFlags = mf->GetSafeDefinition(flagsName);
     if (!depfileFlags.empty())
       {
       cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE");
@@ -422,7 +450,7 @@
 
   // Rule for compiling object file.
   const std::string cmdVar = std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
-  std::string compileCmd = mf->GetRequiredDefinition(cmdVar.c_str());
+  std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
   std::vector<std::string> compileCmds;
   cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
 
@@ -466,63 +494,83 @@
     << this->GetTargetName()
     << "\n\n";
 
-  std::vector<cmSourceFile*> customCommands;
-  this->GeneratorTarget->GetCustomCommands(customCommands);
-  for(std::vector<cmSourceFile*>::const_iterator
+  std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+  std::vector<cmSourceFile const*> customCommands;
+  this->GeneratorTarget->GetCustomCommands(customCommands, config);
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = customCommands.begin();
       si != customCommands.end(); ++si)
      {
      cmCustomCommand const* cc = (*si)->GetCustomCommand();
      this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
+     // Record the custom commands for this target. The container is used
+     // in WriteObjectBuildStatement when called in a loop below.
+     this->CustomCommands.push_back(cc);
      }
-  std::vector<cmSourceFile*> headerSources;
-  this->GeneratorTarget->GetHeaderSources(headerSources);
+  std::vector<cmSourceFile const*> headerSources;
+  this->GeneratorTarget->GetHeaderSources(headerSources, config);
   this->OSXBundleGenerator->GenerateMacOSXContentStatements(
     headerSources,
     this->MacOSXContentGenerator);
-  std::vector<cmSourceFile*> extraSources;
-  this->GeneratorTarget->GetExtraSources(extraSources);
+  std::vector<cmSourceFile const*> extraSources;
+  this->GeneratorTarget->GetExtraSources(extraSources, config);
   this->OSXBundleGenerator->GenerateMacOSXContentStatements(
     extraSources,
     this->MacOSXContentGenerator);
-  std::vector<cmSourceFile*> externalObjects;
-  this->GeneratorTarget->GetExternalObjects(externalObjects);
-  for(std::vector<cmSourceFile*>::const_iterator
+  std::vector<cmSourceFile const*> externalObjects;
+  this->GeneratorTarget->GetExternalObjects(externalObjects, config);
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = externalObjects.begin();
       si != externalObjects.end(); ++si)
     {
     this->Objects.push_back(this->GetSourceFilePath(*si));
     }
-  std::vector<cmSourceFile*> objectSources;
-  this->GeneratorTarget->GetObjectSources(objectSources);
-  for(std::vector<cmSourceFile*>::const_iterator
+
+  cmNinjaDeps orderOnlyDeps;
+  this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps);
+
+  // Add order-only dependencies on custom command outputs.
+  for(std::vector<cmCustomCommand const*>::const_iterator
+        cci = this->CustomCommands.begin();
+      cci != this->CustomCommands.end(); ++cci)
+    {
+    cmCustomCommand const* cc = *cci;
+    cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
+                                 this->GetMakefile());
+    const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
+    std::transform(ccoutputs.begin(), ccoutputs.end(),
+                   std::back_inserter(orderOnlyDeps), MapToNinjaPath());
+    }
+
+  cmNinjaDeps orderOnlyTarget;
+  orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
+  this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
+                                          "Order-only phony target for "
+                                            + this->GetTargetName(),
+                                          orderOnlyTarget,
+                                          cmNinjaDeps(),
+                                          cmNinjaDeps(),
+                                          orderOnlyDeps);
+
+  std::vector<cmSourceFile const*> objectSources;
+  this->GeneratorTarget->GetObjectSources(objectSources, config);
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = objectSources.begin(); si != objectSources.end(); ++si)
     {
     this->WriteObjectBuildStatement(*si);
     }
-  if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+  std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config);
+  if(!def.empty())
     {
-    this->ModuleDefinitionFile = this->ConvertToNinjaPath(
-      this->GeneratorTarget->ModuleDefinitionFile.c_str());
+    this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str());
     }
 
-  {
-  // Add object library contents as external objects.
-  std::vector<std::string> objs;
-  this->GeneratorTarget->UseObjectLibraries(objs);
-  for(std::vector<std::string>::iterator oi = objs.begin();
-      oi != objs.end(); ++oi)
-    {
-    this->Objects.push_back(ConvertToNinjaPath(oi->c_str()));
-    }
-  }
-
   this->GetBuildFileStream() << "\n";
 }
 
 void
 cmNinjaTargetGenerator
-::WriteObjectBuildStatement(cmSourceFile* source)
+::WriteObjectBuildStatement(cmSourceFile const* source)
 {
   std::string comment;
   const std::string language = source->GetLanguage();
@@ -542,11 +590,6 @@
     sourceFileName = this->GetSourceFilePath(source);
   explicitDeps.push_back(sourceFileName);
 
-  // Ensure that the target dependencies are built before any source file in
-  // the target, using order-only dependencies.
-  cmNinjaDeps orderOnlyDeps;
-  this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps);
-
   cmNinjaDeps implicitDeps;
   if(const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
     std::vector<std::string> depList;
@@ -555,18 +598,8 @@
                    std::back_inserter(implicitDeps), MapToNinjaPath());
   }
 
-  // Add order-only dependencies on custom command outputs.
-  std::vector<cmSourceFile*> customCommands;
-  this->GeneratorTarget->GetCustomCommands(customCommands);
-  for(std::vector<cmSourceFile*>::const_iterator
-        si = customCommands.begin();
-      si != customCommands.end(); ++si)
-    {
-    cmCustomCommand const* cc = (*si)->GetCustomCommand();
-    const std::vector<std::string>& ccoutputs = cc->GetOutputs();
-    std::transform(ccoutputs.begin(), ccoutputs.end(),
-                   std::back_inserter(orderOnlyDeps), MapToNinjaPath());
-    }
+  cmNinjaDeps orderOnlyDeps;
+  orderOnlyDeps.push_back(this->OrderDependsTargetForTarget());
 
   // If the source file is GENERATED and does not have a custom command
   // (either attached to this source file or another one), assume that one of
@@ -589,8 +622,12 @@
 
   std::string objectDir = this->Target->GetSupportDirectory();
   vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
-                         ConvertToNinjaPath(objectDir.c_str()).c_str(),
+                         ConvertToNinjaPath(objectDir.c_str()),
                          cmLocalGenerator::SHELL);
+  std::string objectFileDir = cmSystemTools::GetFilenamePath(objectFileName);
+  vars["OBJECT_FILE_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
+                              ConvertToNinjaPath(objectFileDir.c_str()),
+                              cmLocalGenerator::SHELL);
 
   this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars);
 
@@ -614,11 +651,12 @@
 
     escapedSourceFileName =
       this->LocalGenerator->ConvertToOutputFormat(
-        escapedSourceFileName.c_str(), cmLocalGenerator::SHELL);
+        escapedSourceFileName, cmLocalGenerator::SHELL);
 
     compileObjectVars.Source = escapedSourceFileName.c_str();
     compileObjectVars.Object = objectFileName.c_str();
     compileObjectVars.ObjectDir = objectDir.c_str();
+    compileObjectVars.ObjectFileDir = objectFileDir.c_str();
     compileObjectVars.Flags = vars["FLAGS"].c_str();
     compileObjectVars.Defines = vars["DEFINES"].c_str();
 
@@ -627,7 +665,7 @@
     compileCmdVar += language;
     compileCmdVar += "_COMPILE_OBJECT";
     std::string compileCmd =
-      this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str());
+      this->GetMakefile()->GetRequiredDefinition(compileCmdVar);
     std::vector<std::string> compileCmds;
     cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
 
@@ -685,8 +723,8 @@
   // vs6's "cl -link" pass it to the linker.
   std::string flag = defFileFlag;
   flag += (this->LocalGenerator->ConvertToLinkReference(
-             this->ModuleDefinitionFile.c_str()));
-  this->LocalGenerator->AppendFlags(flags, flag.c_str());
+             this->ModuleDefinitionFile));
+  this->LocalGenerator->AppendFlags(flags, flag);
 }
 
 void
@@ -717,7 +755,7 @@
 //----------------------------------------------------------------------------
 void
 cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
-  cmSourceFile& source, const char* pkgloc)
+  cmSourceFile const& source, const char* pkgloc)
 {
   // Skip OS X content when not building a Framework or Bundle.
   if(!this->Generator->GetTarget()->IsBundleOnApple())
@@ -748,9 +786,10 @@
   this->Generator->GetGlobalGenerator()->AddDependencyToAll(output);
 }
 
-void cmNinjaTargetGenerator::addPoolNinjaVariable(const char* pool_property,
-                                                  cmTarget* target,
-                                                  cmNinjaVars& vars)
+void cmNinjaTargetGenerator::addPoolNinjaVariable(
+                                              const std::string& pool_property,
+                                              cmTarget* target,
+                                              cmNinjaVars& vars)
 {
     const char* pool = target->GetProperty(pool_property);
     if (pool)
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 43f2279..94c420f 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -65,27 +65,31 @@
   cmMakefile* GetMakefile() const
   { return this->Makefile; }
 
-  const char* GetConfigName() const;
+  std::string const& GetConfigName() const;
 
   std::string LanguageCompilerRule(const std::string& lang) const
   { return lang + "_COMPILER"; }
 
-  const char* GetFeature(const char* feature);
-  bool GetFeatureAsBool(const char* feature);
-  void AddFeatureFlags(std::string& flags, const char* lang);
+  const char* GetFeature(const std::string& feature);
+  bool GetFeatureAsBool(const std::string& feature);
+  void AddFeatureFlags(std::string& flags, const std::string& lang);
+
+  std::string OrderDependsTargetForTarget();
+
+  std::string ComputeOrderDependsForTarget();
 
   /**
    * Compute the flags for compilation of object files for a given @a language.
    * @note Generally it is the value of the variable whose name is computed
    *       by LanguageFlagsVarName().
    */
-  std::string ComputeFlagsForObject(cmSourceFile *source,
+  std::string ComputeFlagsForObject(cmSourceFile const* source,
                                     const std::string& language);
 
-  std::string ComputeDefines(cmSourceFile *source,
+  std::string ComputeDefines(cmSourceFile const* source,
                              const std::string& language);
 
-  std::string ConvertToNinjaPath(const char *path) const {
+  std::string ConvertToNinjaPath(const std::string& path) const {
     return this->GetLocalGenerator()->ConvertToNinjaPath(path);
   }
   cmLocalNinjaGenerator::map_to_ninja_path MapToNinjaPath() const {
@@ -96,10 +100,10 @@
   cmNinjaDeps ComputeLinkDeps() const;
 
   /// @return the source file path for the given @a source.
-  std::string GetSourceFilePath(cmSourceFile* source) const;
+  std::string GetSourceFilePath(cmSourceFile const* source) const;
 
   /// @return the object file path for the given @a source.
-  std::string GetObjectFilePath(cmSourceFile* source) const;
+  std::string GetObjectFilePath(cmSourceFile const* source) const;
 
   /// @return the file path where the target named @a name is generated.
   std::string GetTargetFilePath(const std::string& name) const;
@@ -110,7 +114,7 @@
   void WriteLanguageRules(const std::string& language);
   void WriteCompileRule(const std::string& language);
   void WriteObjectBuildStatements();
-  void WriteObjectBuildStatement(cmSourceFile* source);
+  void WriteObjectBuildStatement(cmSourceFile const* source);
   void WriteCustomCommandBuildStatement(cmCustomCommand *cc);
 
   cmNinjaDeps GetObjects() const
@@ -129,7 +133,7 @@
     MacOSXContentGeneratorType(cmNinjaTargetGenerator* g) :
       Generator(g)  {}
 
-    void operator()(cmSourceFile& source, const char* pkgloc);
+    void operator()(cmSourceFile const& source, const char* pkgloc);
 
   private:
     cmNinjaTargetGenerator* Generator;
@@ -140,9 +144,9 @@
   MacOSXContentGeneratorType* MacOSXContentGenerator;
   // Properly initialized by sub-classes.
   cmOSXBundleGenerator* OSXBundleGenerator;
-  std::set<cmStdString> MacContentFolders;
+  std::set<std::string> MacContentFolders;
 
-  void addPoolNinjaVariable(const char* pool_property,
+  void addPoolNinjaVariable(const std::string& pool_property,
                             cmTarget* target,
                             cmNinjaVars& vars);
 
@@ -153,6 +157,7 @@
   cmLocalNinjaGenerator* LocalGenerator;
   /// List of object files for this target.
   cmNinjaDeps Objects;
+  std::vector<cmCustomCommand const*> CustomCommands;
 
   typedef std::map<std::string, std::string> LanguageFlagMap;
   LanguageFlagMap LanguageFlags;
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index 1a7b445..f5d18dc 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -17,6 +17,7 @@
 #include "cmMakefile.h"
 #include "cmSourceFile.h"
 #include "cmTarget.h"
+#include "cmCustomCommandGenerator.h"
 
 cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(
     cmGeneratorTarget *target)
@@ -37,22 +38,28 @@
   for (unsigned i = 0; i != 2; ++i) {
     for (std::vector<cmCustomCommand>::const_iterator
          ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) {
-      this->GetLocalGenerator()->AppendCustomCommandDeps(&*ci, deps);
-      this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, commands);
+      cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
+                                   this->GetMakefile());
+      this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
+      this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands);
     }
   }
 
   std::vector<cmSourceFile*> sources;
-  this->GetTarget()->GetSourceFiles(sources);
+  std::string config = this->GetMakefile()
+                           ->GetSafeDefinition("CMAKE_BUILD_TYPE");
+  this->GetTarget()->GetSourceFiles(sources, config);
   for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
       source != sources.end(); ++source)
     {
     if(cmCustomCommand* cc = (*source)->GetCustomCommand())
       {
+      cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
+                                   this->GetMakefile());
       this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
 
       // Depend on all custom command outputs.
-      const std::vector<std::string>& ccOutputs = cc->GetOutputs();
+      const std::vector<std::string>& ccOutputs = ccg.GetOutputs();
       std::transform(ccOutputs.begin(), ccOutputs.end(),
                      std::back_inserter(deps), MapToNinjaPath());
       }
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 448d77c..786e6e2 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -19,8 +19,8 @@
 //----------------------------------------------------------------------------
 cmOSXBundleGenerator::
 cmOSXBundleGenerator(cmGeneratorTarget* target,
-                     const char* configName)
- : Target(target->Target)
+                     const std::string& configName)
+ : GT(target)
  , Makefile(target->Target->GetMakefile())
  , LocalGenerator(Makefile->GetLocalGenerator())
  , ConfigName(configName)
@@ -34,7 +34,7 @@
 //----------------------------------------------------------------------------
 bool cmOSXBundleGenerator::MustSkip()
 {
-  return !this->Target->HaveWellDefinedOutputFiles();
+  return !this->GT->Target->HaveWellDefinedOutputFiles();
 }
 
 //----------------------------------------------------------------------------
@@ -47,7 +47,7 @@
   // Compute bundle directory names.
   std::string out = outpath;
   out += "/";
-  out += this->Target->GetAppBundleDirectory(this->ConfigName, false);
+  out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false);
   cmSystemTools::MakeDirectory(out.c_str());
   this->Makefile->AddCMakeOutputFile(out);
 
@@ -57,10 +57,10 @@
   // to be set.
   std::string plist = outpath;
   plist += "/";
-  plist += this->Target->GetAppBundleDirectory(this->ConfigName, true);
+  plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true);
   plist += "/Info.plist";
-  this->LocalGenerator->GenerateAppleInfoPList(this->Target,
-                                               targetName.c_str(),
+  this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target,
+                                               targetName,
                                                plist.c_str());
   this->Makefile->AddCMakeOutputFile(plist);
   outpath = newoutpath;
@@ -77,21 +77,21 @@
 
   // Compute the location of the top-level foo.framework directory.
   std::string contentdir = outpath + "/" +
-    this->Target->GetFrameworkDirectory(this->ConfigName, true);
+    this->GT->Target->GetFrameworkDirectory(this->ConfigName, true);
   contentdir += "/";
 
   std::string newoutpath = outpath + "/" +
-    this->Target->GetFrameworkDirectory(this->ConfigName, false);
+    this->GT->Target->GetFrameworkDirectory(this->ConfigName, false);
 
-  std::string frameworkVersion = this->Target->GetFrameworkVersion();
+  std::string frameworkVersion = this->GT->Target->GetFrameworkVersion();
 
   // Configure the Info.plist file into the Resources directory.
   this->MacContentFolders->insert("Resources");
   std::string plist = newoutpath;
   plist += "/Resources/Info.plist";
   std::string name = cmSystemTools::GetFilenameName(targetName);
-  this->LocalGenerator->GenerateFrameworkInfoPList(this->Target,
-                                                   name.c_str(),
+  this->LocalGenerator->GenerateFrameworkInfoPList(this->GT->Target,
+                                                   name,
                                                    plist.c_str());
 
   // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
@@ -172,17 +172,17 @@
   // Compute bundle directory names.
   std::string out = root;
   out += "/";
-  out += this->Target->GetCFBundleDirectory(this->ConfigName, false);
+  out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false);
   cmSystemTools::MakeDirectory(out.c_str());
   this->Makefile->AddCMakeOutputFile(out);
 
   // Configure the Info.plist file.  Note that it needs the executable name
   // to be set.
   std::string plist = root + "/" +
-    this->Target->GetCFBundleDirectory(this->ConfigName, true);
+    this->GT->Target->GetCFBundleDirectory(this->ConfigName, true);
   plist += "/Info.plist";
-  this->LocalGenerator->GenerateAppleInfoPList(this->Target,
-                                               targetName.c_str(),
+  this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target,
+                                               targetName,
                                                plist.c_str());
   this->Makefile->AddCMakeOutputFile(plist);
 }
@@ -190,18 +190,19 @@
 //----------------------------------------------------------------------------
 void
 cmOSXBundleGenerator::
-GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources,
-                                MacOSXContentGeneratorType* generator)
+GenerateMacOSXContentStatements(
+                              std::vector<cmSourceFile const*> const& sources,
+                              MacOSXContentGeneratorType* generator)
 {
   if (this->MustSkip())
     return;
 
-  for(std::vector<cmSourceFile*>::const_iterator
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = sources.begin(); si != sources.end(); ++si)
     {
-    cmTarget::SourceFileFlags tsFlags =
-      this->Target->GetTargetSourceFileFlags(*si);
-    if(tsFlags.Type != cmTarget::SourceFileTypeNormal)
+    cmGeneratorTarget::SourceFileFlags tsFlags =
+      this->GT->GetTargetSourceFileFlags(*si);
+    if(tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal)
       {
       (*generator)(**si, tsFlags.MacFolder);
       }
@@ -215,7 +216,7 @@
   // Construct the full path to the content subdirectory.
 
   std::string macdir =
-    this->Target->GetMacContentDirectory(this->ConfigName,
+    this->GT->Target->GetMacContentDirectory(this->ConfigName,
                                          /*implib*/ false);
   macdir += "/";
   macdir += pkgloc;
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index 29b7611..f945c15 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -27,7 +27,7 @@
 {
 public:
   cmOSXBundleGenerator(cmGeneratorTarget* target,
-                       const char* configName);
+                       const std::string& configName);
 
   // create an app bundle at a given root, and return
   // the directory within the bundle that contains the executable
@@ -44,26 +44,27 @@
   struct MacOSXContentGeneratorType
   {
     virtual ~MacOSXContentGeneratorType() {}
-    virtual void operator()(cmSourceFile& source, const char* pkgloc) = 0;
+    virtual void operator()(cmSourceFile const& source,
+                            const char* pkgloc) = 0;
   };
 
   void GenerateMacOSXContentStatements(
-    std::vector<cmSourceFile*> const& sources,
+    std::vector<cmSourceFile const*> const& sources,
     MacOSXContentGeneratorType* generator);
   std::string InitMacOSXContentDirectory(const char* pkgloc);
 
-  void SetMacContentFolders(std::set<cmStdString>* macContentFolders)
+  void SetMacContentFolders(std::set<std::string>* macContentFolders)
   { this->MacContentFolders = macContentFolders; }
 
 private:
   bool MustSkip();
 
 private:
-  cmTarget* Target;
+  cmGeneratorTarget* GT;
   cmMakefile* Makefile;
   cmLocalGenerator* LocalGenerator;
-  const char* ConfigName;
-  std::set<cmStdString>* MacContentFolders;
+  std::string ConfigName;
+  std::set<std::string>* MacContentFolders;
 };
 
 
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index 776a3a4..e505440 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -39,7 +39,7 @@
       m += args[i];
       m += " ";
       }
-    this->SetError(m.c_str());
+    this->SetError(m);
     return false;
     }
 
@@ -55,17 +55,14 @@
       it.SetProperty("HELPSTRING", args[1].c_str());
       return true;
       }
-    if ( it.GetValue() )
-      {
-      initialValue = it.GetValue();
-      }
+    initialValue = it.GetValue();
     }
   if(args.size() == 3)
     {
     initialValue = args[2];
     }
   bool init = cmSystemTools::IsOn(initialValue.c_str());
-  this->Makefile->AddCacheDefinition(args[0].c_str(), init? "ON":"OFF",
+  this->Makefile->AddCacheDefinition(args[0], init? "ON":"OFF",
                                      args[1].c_str(), cmCacheManager::BOOL);
   return true;
 }
diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h
index 89e3ac1..12a6472 100644
--- a/Source/cmOptionCommand.h
+++ b/Source/cmOptionCommand.h
@@ -40,7 +40,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "option";}
+  virtual std::string GetName() const {return "option";}
 
   /**
    * This determines if the command is invoked when in script mode.
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 86beb97..ec671fc 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -138,9 +138,9 @@
     }
 
   // Check if the file will be built by cmake.
-  std::set<cmStdString> const& files =
+  std::set<std::string> const& files =
     (this->GlobalGenerator->GetDirectoryContent(dir, false));
-  std::set<cmStdString>::const_iterator fi = files.find(name);
+  std::set<std::string>::const_iterator fi = files.find(name);
   return fi != files.end();
 }
 
@@ -200,7 +200,7 @@
     {
     // We do not have the soname.  Look for files in the directory
     // that may conflict.
-    std::set<cmStdString> const& files =
+    std::set<std::string> const& files =
       (this->GlobalGenerator
        ->GetDirectoryContent(dir, true));
 
@@ -208,9 +208,9 @@
     // know the soname just look at all files that start with the
     // file name.  Usually the soname starts with the library name.
     std::string base = this->FileName;
-    std::set<cmStdString>::const_iterator first = files.lower_bound(base);
+    std::set<std::string>::const_iterator first = files.lower_bound(base);
     ++base[base.size()-1];
-    std::set<cmStdString>::const_iterator last = files.upper_bound(base);
+    std::set<std::string>::const_iterator last = files.upper_bound(base);
     if(first != last)
       {
       return true;
@@ -251,8 +251,8 @@
   if(!this->OD->LinkExtensions.empty() &&
      this->OD->RemoveLibraryExtension.find(this->FileName))
     {
-    cmStdString lib = this->OD->RemoveLibraryExtension.match(1);
-    cmStdString ext = this->OD->RemoveLibraryExtension.match(2);
+    std::string lib = this->OD->RemoveLibraryExtension.match(1);
+    std::string ext = this->OD->RemoveLibraryExtension.match(2);
     for(std::vector<std::string>::iterator
           i = this->OD->LinkExtensions.begin();
         i != this->OD->LinkExtensions.end(); ++i)
@@ -261,7 +261,7 @@
         {
         std::string fname = lib;
         fname += *i;
-        if(this->FileMayConflict(dir, fname.c_str()))
+        if(this->FileMayConflict(dir, fname))
           {
           return true;
           }
@@ -407,7 +407,7 @@
 //----------------------------------------------------------------------------
 void
 cmOrderDirectories
-::SetImplicitDirectories(std::set<cmStdString> const& implicitDirs)
+::SetImplicitDirectories(std::set<std::string> const& implicitDirs)
 {
   this->ImplicitDirectories = implicitDirs;
 }
@@ -444,11 +444,11 @@
 int cmOrderDirectories::AddOriginalDirectory(std::string const& dir)
 {
   // Add the runtime directory with a unique index.
-  std::map<cmStdString, int>::iterator i =
+  std::map<std::string, int>::iterator i =
     this->DirectoryIndex.find(dir);
   if(i == this->DirectoryIndex.end())
     {
-    std::map<cmStdString, int>::value_type
+    std::map<std::string, int>::value_type
       entry(dir, static_cast<int>(this->OriginalDirectories.size()));
     i = this->DirectoryIndex.insert(entry).first;
     this->OriginalDirectories.push_back(dir);
diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h
index 76bf429..07c85dd 100644
--- a/Source/cmOrderDirectories.h
+++ b/Source/cmOrderDirectories.h
@@ -34,7 +34,7 @@
   void AddLinkLibrary(std::string const& fullPath);
   void AddUserDirectories(std::vector<std::string> const& extra);
   void AddLanguageDirectories(std::vector<std::string> const& dirs);
-  void SetImplicitDirectories(std::set<cmStdString> const& implicitDirs);
+  void SetImplicitDirectories(std::set<std::string> const& implicitDirs);
   void SetLinkExtensionInfo(std::vector<std::string> const& linkExtensions,
                             std::string const& removeExtRegex);
 
@@ -54,11 +54,11 @@
   std::vector<std::string> LanguageDirectories;
   cmsys::RegularExpression RemoveLibraryExtension;
   std::vector<std::string> LinkExtensions;
-  std::set<cmStdString> ImplicitDirectories;
-  std::set<cmStdString> EmmittedConstraintSOName;
-  std::set<cmStdString> EmmittedConstraintLibrary;
+  std::set<std::string> ImplicitDirectories;
+  std::set<std::string> EmmittedConstraintSOName;
+  std::set<std::string> EmmittedConstraintLibrary;
   std::vector<std::string> OriginalDirectories;
-  std::map<cmStdString, int> DirectoryIndex;
+  std::map<std::string, int> DirectoryIndex;
   std::vector<int> DirectoryVisited;
   void CollectOriginalDirectories();
   int AddOriginalDirectory(std::string const& dir);
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index c0d9e99..5016493 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -202,7 +202,7 @@
       {
       std::string err = "Can not open output file: ";
       err += this->OutputFile;
-      this->SetError(err.c_str());
+      this->SetError(err);
       return false;
       }
     std::set<cmDependInformation const*> visited;
diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h
index dd5ed6c..95eba38 100644
--- a/Source/cmOutputRequiredFilesCommand.h
+++ b/Source/cmOutputRequiredFilesCommand.h
@@ -22,7 +22,7 @@
   virtual cmCommand* Clone() { return new cmOutputRequiredFilesCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
-  virtual const char* GetName() const { return "output_required_files";}
+  virtual std::string GetName() const { return "output_required_files";}
   virtual bool IsDiscouraged() const { return true; }
 
   void ListDependencies(cmDependInformation const *info,
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 93072f5..693945d 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -343,6 +343,22 @@
     CMP0050, "CMP0050",
     "Disallow add_custom_command SOURCE signatures.",
     3,0,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0051, "CMP0051",
+    "List TARGET_OBJECTS in SOURCES target property.",
+    3,1,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0052, "CMP0052",
+    "Reject source and build dirs in installed "
+    "INTERFACE_INCLUDE_DIRECTORIES.",
+    3,1,0, cmPolicies::WARN);
+
+  this->DefinePolicy(
+    CMP0053, "CMP0053",
+    "Simplify variable reference and escape sequence evaluation.",
+    3,1,0, cmPolicies::WARN);
 }
 
 cmPolicies::~cmPolicies()
@@ -488,7 +504,7 @@
                                   cmPolicies::PolicyStatus* defaultSetting)
 {
   std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
-  std::string defaultValue = mf->GetSafeDefinition(defaultVar.c_str());
+  std::string defaultValue = mf->GetSafeDefinition(defaultVar);
   if(defaultValue == "NEW")
     {
     *defaultSetting = cmPolicies::NEW;
@@ -506,7 +522,7 @@
     cmOStringStream e;
     e << defaultVar << " has value \"" << defaultValue
       << "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
-    mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    mf->IssueMessage(cmake::FATAL_ERROR, e.str());
     return false;
     }
 
@@ -651,5 +667,5 @@
     << "Please either update your CMakeLists.txt files to conform to "
     << "the new behavior or use an older version of CMake that still "
     << "supports the old behavior.";
-  mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+  mf->IssueMessage(cmake::FATAL_ERROR, e.str());
 }
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index b77235d..5d69d14 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -104,6 +104,11 @@
     CMP0048, ///< project() command manages VERSION variables
     CMP0049, ///< Do not expand variables in target source entries
     CMP0050, ///< Disallow add_custom_command SOURCE signatures
+    CMP0051, ///< List TARGET_OBJECTS in SOURCES target property
+    CMP0052, ///< Reject source and build dirs in installed
+    /// INTERFACE_INCLUDE_DIRECTORIES
+
+    CMP0053, ///< Simplify variable reference and escape sequence evaluation
 
     /** \brief Always the last entry.
      *
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index a9ce0cc..12318c8 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -28,20 +28,20 @@
   srcdir += "_SOURCE_DIR";
 
   this->Makefile->AddCacheDefinition
-    (bindir.c_str(),
+    (bindir,
      this->Makefile->GetCurrentOutputDirectory(),
      "Value Computed by CMake", cmCacheManager::STATIC);
   this->Makefile->AddCacheDefinition
-    (srcdir.c_str(),
+    (srcdir,
      this->Makefile->GetCurrentDirectory(),
      "Value Computed by CMake", cmCacheManager::STATIC);
 
   bindir = "PROJECT_BINARY_DIR";
   srcdir = "PROJECT_SOURCE_DIR";
 
-  this->Makefile->AddDefinition(bindir.c_str(),
+  this->Makefile->AddDefinition(bindir,
           this->Makefile->GetCurrentOutputDirectory());
-  this->Makefile->AddDefinition(srcdir.c_str(),
+  this->Makefile->AddDefinition(srcdir,
           this->Makefile->GetCurrentDirectory());
 
   this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
@@ -167,19 +167,19 @@
     std::string vv;
     vv = args[0] + "_VERSION";
     this->Makefile->AddDefinition("PROJECT_VERSION", vs.c_str());
-    this->Makefile->AddDefinition(vv.c_str(), vs.c_str());
+    this->Makefile->AddDefinition(vv, vs.c_str());
     vv = args[0] + "_VERSION_MAJOR";
     this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR", vb[0]);
-    this->Makefile->AddDefinition(vv.c_str(), vb[0]);
+    this->Makefile->AddDefinition(vv, vb[0]);
     vv = args[0] + "_VERSION_MINOR";
     this->Makefile->AddDefinition("PROJECT_VERSION_MINOR", vb[1]);
-    this->Makefile->AddDefinition(vv.c_str(), vb[1]);
+    this->Makefile->AddDefinition(vv, vb[1]);
     vv = args[0] + "_VERSION_PATCH";
     this->Makefile->AddDefinition("PROJECT_VERSION_PATCH", vb[2]);
-    this->Makefile->AddDefinition(vv.c_str(), vb[2]);
+    this->Makefile->AddDefinition(vv, vb[2]);
     vv = args[0] + "_VERSION_TWEAK";
     this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]);
-    this->Makefile->AddDefinition(vv.c_str(), vb[3]);
+    this->Makefile->AddDefinition(vv, vb[3]);
     }
   else if(cmp0048 != cmPolicies::OLD)
     {
@@ -199,7 +199,7 @@
     for(std::vector<std::string>::iterator i = vv.begin();
         i != vv.end(); ++i)
       {
-      const char* v = this->Makefile->GetDefinition(i->c_str());
+      const char* v = this->Makefile->GetDefinition(*i);
       if(v && *v)
         {
         if(cmp0048 == cmPolicies::WARN)
@@ -209,7 +209,7 @@
           }
         else
           {
-          this->Makefile->AddDefinition(i->c_str(), "");
+          this->Makefile->AddDefinition(*i, "");
           }
         }
       }
@@ -231,7 +231,7 @@
     }
   this->Makefile->EnableLanguage(languages, false);
   std::string extraInclude = "CMAKE_PROJECT_" + args[0] + "_INCLUDE";
-  const char* include = this->Makefile->GetDefinition(extraInclude.c_str());
+  const char* include = this->Makefile->GetDefinition(extraInclude);
   if(include)
     {
     std::string fullFilePath;
@@ -244,7 +244,7 @@
         "could not find file:\n"
         "  ";
       m += include;
-      this->SetError(m.c_str());
+      this->SetError(m);
       return false;
       }
     }
diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h
index f7d086d..7aacb55 100644
--- a/Source/cmProjectCommand.h
+++ b/Source/cmProjectCommand.h
@@ -43,7 +43,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "project";}
+  virtual std::string GetName() const {return "project";}
 
   cmTypeMacro(cmProjectCommand, cmCommand);
 };
diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx
index 3b37cf3..40976db 100644
--- a/Source/cmProperty.cxx
+++ b/Source/cmProperty.cxx
@@ -12,14 +12,15 @@
 #include "cmProperty.h"
 #include "cmSystemTools.h"
 
-void cmProperty::Set(const char *name, const char *value)
+void cmProperty::Set(const std::string& name, const char *value)
 {
   this->Name = name;
   this->Value = value;
   this->ValueHasBeenSet = true;
 }
 
-void cmProperty::Append(const char *name, const char *value, bool asString)
+void cmProperty::Append(const std::string& name, const char *value,
+                        bool asString)
 {
   this->Name = name;
   if(!this->Value.empty() && *value && !asString)
diff --git a/Source/cmProperty.h b/Source/cmProperty.h
index bb75bb0..659c4c3 100644
--- a/Source/cmProperty.h
+++ b/Source/cmProperty.h
@@ -18,19 +18,20 @@
 {
 public:
   enum ScopeType { TARGET, SOURCE_FILE, DIRECTORY, GLOBAL, CACHE,
-                   TEST, VARIABLE, CACHED_VARIABLE };
+                   TEST, VARIABLE, CACHED_VARIABLE, INSTALL };
 
   // set this property
-  void Set(const char *name, const char *value);
+  void Set(const std::string& name, const char *value);
 
   // append to this property
-  void Append(const char *name, const char *value, bool asString = false);
+  void Append(const std::string& name, const char *value,
+              bool asString = false);
 
   // get the value
   const char *GetValue() const;
 
   // construct with the value not set
-  cmProperty() { this->ValueHasBeenSet = false; };
+  cmProperty() { this->ValueHasBeenSet = false; }
 
 protected:
   std::string Name;
diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx
index abc57ce..1af967c 100644
--- a/Source/cmPropertyDefinition.cxx
+++ b/Source/cmPropertyDefinition.cxx
@@ -13,7 +13,7 @@
 #include "cmSystemTools.h"
 
 void cmPropertyDefinition
-::DefineProperty(const char *name, cmProperty::ScopeType scope,
+::DefineProperty(const std::string& name, cmProperty::ScopeType scope,
                  const char *shortDescription,
                  const char *fullDescription,
                  bool chain)
diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h
index 1b6a7a6..098fadb 100644
--- a/Source/cmPropertyDefinition.h
+++ b/Source/cmPropertyDefinition.h
@@ -27,28 +27,28 @@
 {
 public:
   /// Define this property
-  void DefineProperty(const char *name, cmProperty::ScopeType scope,
+  void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
                       const char *ShortDescription,
                       const char *FullDescription,
                       bool chained);
 
   /// Default constructor
-  cmPropertyDefinition() { this->Chained = false; };
+  cmPropertyDefinition() { this->Chained = false; }
 
   /// Is the property chained?
-  bool IsChained() const { return this->Chained; };
+  bool IsChained() const { return this->Chained; }
 
   /// Get the scope
   cmProperty::ScopeType GetScope() const {
-    return this->Scope; };
+    return this->Scope; }
 
   /// Get the documentation (short version)
   const std::string &GetShortDescription() const {
-    return this->ShortDescription; };
+    return this->ShortDescription; }
 
   /// Get the documentation (full version)
   const std::string &GetFullDescription() const {
-    return this->FullDescription; };
+    return this->FullDescription; }
 
 protected:
   std::string Name;
diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx
index db29504..3875318 100644
--- a/Source/cmPropertyDefinitionMap.cxx
+++ b/Source/cmPropertyDefinitionMap.cxx
@@ -14,16 +14,11 @@
 #include "cmDocumentationSection.h"
 
 void cmPropertyDefinitionMap
-::DefineProperty(const char *name, cmProperty::ScopeType scope,
+::DefineProperty(const std::string& name, cmProperty::ScopeType scope,
                  const char *ShortDescription,
                  const char *FullDescription,
                  bool chain)
 {
-  if (!name)
-    {
-    return;
-    }
-
   cmPropertyDefinitionMap::iterator it = this->find(name);
   cmPropertyDefinition *prop;
   if (it == this->end())
@@ -34,13 +29,8 @@
     }
 }
 
-bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name)
+bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name)
 {
-  if (!name)
-    {
-    return false;
-    }
-
   cmPropertyDefinitionMap::iterator it = this->find(name);
   if (it == this->end())
     {
@@ -50,13 +40,8 @@
   return true;
 }
 
-bool cmPropertyDefinitionMap::IsPropertyChained(const char *name)
+bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name)
 {
-  if (!name)
-    {
-    return false;
-    }
-
   cmPropertyDefinitionMap::iterator it = this->find(name);
   if (it == this->end())
     {
diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h
index 736e243..00c7328 100644
--- a/Source/cmPropertyDefinitionMap.h
+++ b/Source/cmPropertyDefinitionMap.h
@@ -17,20 +17,20 @@
 class cmDocumentationSection;
 
 class cmPropertyDefinitionMap :
-public std::map<cmStdString,cmPropertyDefinition>
+public std::map<std::string,cmPropertyDefinition>
 {
 public:
   // define the property
-  void DefineProperty(const char *name, cmProperty::ScopeType scope,
+  void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
                       const char *ShortDescription,
                       const char *FullDescription,
                       bool chain);
 
   // has a named property been defined
-  bool IsPropertyDefined(const char *name);
+  bool IsPropertyDefined(const std::string& name);
 
   // is a named property set to chain
-  bool IsPropertyChained(const char *name);
+  bool IsPropertyChained(const std::string& name);
 };
 
 #endif
diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx
index e94e3e9..e335b3b 100644
--- a/Source/cmPropertyMap.cxx
+++ b/Source/cmPropertyMap.cxx
@@ -13,7 +13,7 @@
 #include "cmSystemTools.h"
 #include "cmake.h"
 
-cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
+cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
 {
   cmPropertyMap::iterator it = this->find(name);
   cmProperty *prop;
@@ -28,13 +28,9 @@
   return prop;
 }
 
-void cmPropertyMap::SetProperty(const char *name, const char *value,
+void cmPropertyMap::SetProperty(const std::string& name, const char *value,
                                 cmProperty::ScopeType scope)
 {
-  if (!name)
-    {
-    return;
-    }
   if(!value)
     {
     this->erase(name);
@@ -46,11 +42,11 @@
   prop->Set(name,value);
 }
 
-void cmPropertyMap::AppendProperty(const char* name, const char* value,
+void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
                                    cmProperty::ScopeType scope, bool asString)
 {
   // Skip if nothing to append.
-  if(!name || !value || !*value)
+  if(!value || !*value)
     {
     return;
     }
@@ -61,12 +57,12 @@
 }
 
 const char *cmPropertyMap
-::GetPropertyValue(const char *name,
+::GetPropertyValue(const std::string& name,
                    cmProperty::ScopeType scope,
                    bool &chain) const
 {
   chain = false;
-  if (!name)
+  if (name.empty())
     {
     return 0;
     }
diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h
index 0c3aad4..02d4235 100644
--- a/Source/cmPropertyMap.h
+++ b/Source/cmPropertyMap.h
@@ -16,24 +16,24 @@
 
 class cmake;
 
-class cmPropertyMap : public std::map<cmStdString,cmProperty>
+class cmPropertyMap : public std::map<std::string,cmProperty>
 {
 public:
-  cmProperty *GetOrCreateProperty(const char *name);
+  cmProperty *GetOrCreateProperty(const std::string& name);
 
-  void SetProperty(const char *name, const char *value,
+  void SetProperty(const std::string& name, const char *value,
                    cmProperty::ScopeType scope);
 
-  void AppendProperty(const char* name, const char* value,
+  void AppendProperty(const std::string& name, const char* value,
                       cmProperty::ScopeType scope, bool asString=false);
 
-  const char *GetPropertyValue(const char *name,
+  const char *GetPropertyValue(const std::string& name,
                                cmProperty::ScopeType scope,
                                bool &chain) const;
 
-  void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; };
+  void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; }
 
-  cmPropertyMap() { this->CMakeInstance = 0;};
+  cmPropertyMap() { this->CMakeInstance = 0;}
 
 private:
   cmake *CMakeInstance;
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index 0d3c994..a984260 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -32,13 +32,13 @@
   // Get the variable holding the list of sources.
   std::string const& sourceList = args[1];
   std::string sourceListValue =
-    this->Makefile->GetSafeDefinition(sourceList.c_str());
+    this->Makefile->GetSafeDefinition(sourceList);
 
   // Create a rule for all sources listed.
   for(std::vector<std::string>::iterator j = (args.begin() + 2);
       j != args.end(); ++j)
     {
-    cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
+    cmSourceFile *curr = this->Makefile->GetSource(*j);
     // if we should wrap the class
     if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
       {
@@ -50,7 +50,7 @@
       newName += srcName;
       newName += ".cxx";
       cmSourceFile* sf =
-        this->Makefile->GetOrCreateSource(newName.c_str(), true);
+        this->Makefile->GetOrCreateSource(newName, true);
       if (curr)
         {
         sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT"));
@@ -97,9 +97,9 @@
       depends.push_back(moc_exe);
       depends.push_back(hname);
 
-      const char* no_main_dependency = 0;
+      std::string no_main_dependency = "";
       const char* no_working_dir = 0;
-      this->Makefile->AddCustomCommandToOutput(newName.c_str(),
+      this->Makefile->AddCustomCommandToOutput(newName,
                                                depends,
                                                no_main_dependency,
                                                commandLines,
@@ -109,7 +109,7 @@
     }
 
   // Store the final list of source files.
-  this->Makefile->AddDefinition(sourceList.c_str(),
+  this->Makefile->AddDefinition(sourceList,
                                 sourceListValue.c_str());
   return true;
 }
diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h
index 868eb91..85729dd 100644
--- a/Source/cmQTWrapCPPCommand.h
+++ b/Source/cmQTWrapCPPCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "qt_wrap_cpp";}
+  virtual std::string GetName() const { return "qt_wrap_cpp";}
 };
 
 
diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx
index a6a4b51..dce59ef 100644
--- a/Source/cmQTWrapUICommand.cxx
+++ b/Source/cmQTWrapUICommand.cxx
@@ -35,15 +35,15 @@
   std::string const& headerList = args[1];
   std::string const& sourceList = args[2];
   std::string headerListValue =
-    this->Makefile->GetSafeDefinition(headerList.c_str());
+    this->Makefile->GetSafeDefinition(headerList);
   std::string sourceListValue =
-    this->Makefile->GetSafeDefinition(sourceList.c_str());
+    this->Makefile->GetSafeDefinition(sourceList);
 
   // Create rules for all sources listed.
   for(std::vector<std::string>::iterator j = (args.begin() + 3);
       j != args.end(); ++j)
     {
-    cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
+    cmSourceFile *curr = this->Makefile->GetSource(*j);
     // if we should wrap the class
     if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
       {
@@ -128,10 +128,10 @@
 
       std::vector<std::string> depends;
       depends.push_back(uiName);
-      const char* no_main_dependency = 0;
+      std::string no_main_dependency = "";
       const char* no_comment = 0;
       const char* no_working_dir = 0;
-      this->Makefile->AddCustomCommandToOutput(hName.c_str(),
+      this->Makefile->AddCustomCommandToOutput(hName,
                                                depends,
                                                no_main_dependency,
                                                hCommandLines,
@@ -139,7 +139,7 @@
                                                no_working_dir);
 
       depends.push_back(hName);
-      this->Makefile->AddCustomCommandToOutput(cxxName.c_str(),
+      this->Makefile->AddCustomCommandToOutput(cxxName,
                                                depends,
                                                no_main_dependency,
                                                cxxCommandLines,
@@ -148,7 +148,7 @@
 
       depends.clear();
       depends.push_back(hName);
-      this->Makefile->AddCustomCommandToOutput(mocName.c_str(),
+      this->Makefile->AddCustomCommandToOutput(mocName,
                                                depends,
                                                no_main_dependency,
                                                mocCommandLines,
@@ -158,9 +158,9 @@
     }
 
   // Store the final list of source files and headers.
-  this->Makefile->AddDefinition(sourceList.c_str(),
+  this->Makefile->AddDefinition(sourceList,
                                 sourceListValue.c_str());
-  this->Makefile->AddDefinition(headerList.c_str(),
+  this->Makefile->AddDefinition(headerList,
                                 headerListValue.c_str());
   return true;
 }
diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h
index 3406dac..4aa9a61 100644
--- a/Source/cmQTWrapUICommand.h
+++ b/Source/cmQTWrapUICommand.h
@@ -43,7 +43,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "qt_wrap_ui";}
+  virtual std::string GetName() const { return "qt_wrap_ui";}
 };
 
 
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 2c5dd45..cc6932d 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -105,7 +105,7 @@
 
 static void copyTargetProperty(cmTarget* destinationTarget,
                                cmTarget* sourceTarget,
-                               const char* propertyName)
+                               const std::string& propertyName)
 {
   const char* propertyValue = sourceTarget->GetProperty(propertyName);
   if (propertyValue)
@@ -187,13 +187,11 @@
     mocCppFile += "/";
     mocCppFile += automocTargetName;
     mocCppFile += ".cpp";
-    cmSourceFile* mocCppSource = makefile->GetOrCreateSource(
-                                                          mocCppFile.c_str(),
-                                                          true);
+    makefile->GetOrCreateSource(mocCppFile, true);
     makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
                             mocCppFile.c_str(), false);
 
-    target->AddSourceFile(mocCppSource);
+    target->AddSource(mocCppFile);
     }
   // create a custom target for running generators at buildtime:
   std::string autogenTargetName = getAutogenTargetName(target);
@@ -251,7 +249,7 @@
   bool usePRE_BUILD = false;
   cmLocalGenerator* localGen = makefile->GetLocalGenerator();
   cmGlobalGenerator* gg = localGen->GetGlobalGenerator();
-  if(strstr(gg->GetName(), "Visual Studio"))
+  if(gg->GetName().find("Visual Studio") != std::string::npos)
     {
     cmLocalVisualStudioGenerator* vslg =
       static_cast<cmLocalVisualStudioGenerator*>(localGen);
@@ -290,7 +288,7 @@
 #endif
     {
     cmTarget* autogenTarget = makefile->AddUtilityCommand(
-                                autogenTargetName.c_str(), true,
+                                autogenTargetName, true,
                                 workingDirectory.c_str(), depends,
                                 commandLines, false, autogenComment.c_str());
     // Set target folder
@@ -311,14 +309,14 @@
       copyTargetProperty(autogenTarget, target, "FOLDER");
       }
 
-    target->AddUtility(autogenTargetName.c_str());
+    target->AddUtility(autogenTargetName);
     }
 
   return true;
 }
 
 static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
-                                                const char * config,
+                                                const std::string& config,
                                                 std::string &incs,
                                                 std::string &defs)
 {
@@ -368,7 +366,9 @@
   std::string autogenTargetName = getAutogenTargetName(target);
 
   makefile->AddDefinition("_moc_target_name",
-          cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(autogenTargetName).c_str());
+  makefile->AddDefinition("_origin_target_name",
+          cmLocalGenerator::EscapeForCMake(target->GetName()).c_str());
 
   std::string targetDir = getAutogenTargetDir(target);
 
@@ -378,7 +378,7 @@
     qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
     }
   if (const char *targetQtVersion =
-      target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0))
+      target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
     {
     qtVersion = targetQtVersion;
     }
@@ -397,7 +397,7 @@
     this->SetupSourceFiles(target);
     }
   makefile->AddDefinition("_cpp_files",
-          cmLocalGenerator::EscapeForCMake(this->Sources.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(this->Sources).c_str());
   if (target->GetPropertyAsBool("AUTOMOC"))
     {
     this->SetupAutoMocTarget(target, autogenTargetName,
@@ -474,12 +474,12 @@
   const char* sepHeaders = "";
 
   std::vector<cmSourceFile*> srcFiles;
-  target->GetSourceFiles(srcFiles);
+  target->GetConfigCommonSourceFiles(srcFiles);
 
   const char *skipMocSep = "";
   const char *skipUicSep = "";
 
-  std::vector<cmSourceFile*> newRccFiles;
+  std::vector<std::string> newRccFiles;
 
   for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
       fileIt != srcFiles.end();
@@ -508,13 +508,14 @@
         std::string basename = cmsys::SystemTools::
                                       GetFilenameWithoutLastExtension(absFile);
 
-        std::string rcc_output_file = makefile->GetCurrentOutputDirectory();
+        std::string rcc_output_dir = target->GetSupportDirectory();
+        cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+        std::string rcc_output_file = rcc_output_dir;
         rcc_output_file += "/qrc_" + basename + ".cpp";
         makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
                                 rcc_output_file.c_str(), false);
-        cmSourceFile* rccCppSource
-                = makefile->GetOrCreateSource(rcc_output_file.c_str(), true);
-        newRccFiles.push_back(rccCppSource);
+        makefile->GetOrCreateSource(rcc_output_file, true);
+        newRccFiles.push_back(rcc_output_file);
         }
       }
 
@@ -546,11 +547,11 @@
       }
     }
 
-  for(std::vector<cmSourceFile*>::const_iterator fileIt = newRccFiles.begin();
+  for(std::vector<std::string>::const_iterator fileIt = newRccFiles.begin();
       fileIt != newRccFiles.end();
       ++fileIt)
     {
-    const_cast<cmTarget*>(target)->AddSourceFile(*fileIt);
+    const_cast<cmTarget*>(target)->AddSource(*fileIt);
     }
 }
 
@@ -564,38 +565,38 @@
   const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
   std::string _moc_options = (tmp!=0 ? tmp : "");
   makefile->AddDefinition("_moc_options",
-          cmLocalGenerator::EscapeForCMake(_moc_options.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(_moc_options).c_str());
   makefile->AddDefinition("_skip_moc",
-          cmLocalGenerator::EscapeForCMake(this->SkipMoc.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(this->SkipMoc).c_str());
   makefile->AddDefinition("_moc_headers",
-          cmLocalGenerator::EscapeForCMake(this->Headers.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(this->Headers).c_str());
   bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
   makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
 
   std::string _moc_incs;
   std::string _moc_compile_defs;
   std::vector<std::string> configs;
-  const char *config = makefile->GetConfigurations(configs);
+  const std::string& config = makefile->GetConfigurations(configs);
   GetCompileDefinitionsAndDirectories(target, config,
                                       _moc_incs, _moc_compile_defs);
 
   makefile->AddDefinition("_moc_incs",
-          cmLocalGenerator::EscapeForCMake(_moc_incs.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(_moc_incs).c_str());
   makefile->AddDefinition("_moc_compile_defs",
-          cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(_moc_compile_defs).c_str());
 
   for (std::vector<std::string>::const_iterator li = configs.begin();
        li != configs.end(); ++li)
     {
     std::string config_moc_incs;
     std::string config_moc_compile_defs;
-    GetCompileDefinitionsAndDirectories(target, li->c_str(),
+    GetCompileDefinitionsAndDirectories(target, *li,
                                         config_moc_incs,
                                         config_moc_compile_defs);
     if (config_moc_incs != _moc_incs)
       {
       configIncludes[*li] =
-                    cmLocalGenerator::EscapeForCMake(config_moc_incs.c_str());
+                    cmLocalGenerator::EscapeForCMake(config_moc_incs);
       if(_moc_incs.empty())
         {
         _moc_incs = config_moc_incs;
@@ -604,7 +605,7 @@
     if (config_moc_compile_defs != _moc_compile_defs)
       {
       configDefines[*li] =
-            cmLocalGenerator::EscapeForCMake(config_moc_compile_defs.c_str());
+            cmLocalGenerator::EscapeForCMake(config_moc_compile_defs);
       if(_moc_compile_defs.empty())
         {
         _moc_compile_defs = config_moc_compile_defs;
@@ -622,7 +623,7 @@
                           autogenTargetName.c_str());
       return;
       }
-    makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0));
+    makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(""));
     }
   else if (strcmp(qtVersion, "4") == 0)
     {
@@ -633,7 +634,7 @@
                           autogenTargetName.c_str());
       return;
       }
-    makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(0));
+    makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(""));
     }
   else
     {
@@ -672,7 +673,7 @@
         ++o;
         }
       if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
-                  cmStrCmp(o)) != cmArrayEnd(valueOptions))
+                  cmStrCmp(*it)) != cmArrayEnd(valueOptions))
         {
         assert(existingIt + 1 != opts.end());
         *(existingIt + 1) = *(it + 1);
@@ -687,7 +688,7 @@
   opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
 }
 
-static void GetUicOpts(cmTarget const* target, const char * config,
+static void GetUicOpts(cmTarget const* target, const std::string& config,
                        std::string &optString)
 {
   std::vector<std::string> opts;
@@ -709,9 +710,9 @@
 {
   cmMakefile *makefile = target->GetMakefile();
 
-  std::set<cmStdString> skipped;
+  std::set<std::string> skipped;
   std::vector<std::string> skipVec;
-  cmSystemTools::ExpandListArgument(this->SkipUic.c_str(), skipVec);
+  cmSystemTools::ExpandListArgument(this->SkipUic, skipVec);
 
   for (std::vector<std::string>::const_iterator li = skipVec.begin();
        li != skipVec.end(); ++li)
@@ -720,7 +721,7 @@
     }
 
   makefile->AddDefinition("_skip_uic",
-          cmLocalGenerator::EscapeForCMake(this->SkipUic.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(this->SkipUic).c_str());
 
   std::vector<cmSourceFile*> uiFilesWithOptions
                                         = makefile->GetQtUiFilesWithOptions();
@@ -729,23 +730,23 @@
 
   std::string _uic_opts;
   std::vector<std::string> configs;
-  const char *config = makefile->GetConfigurations(configs);
+  const std::string& config = makefile->GetConfigurations(configs);
   GetUicOpts(target, config, _uic_opts);
 
   if (!_uic_opts.empty())
     {
-    _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts.c_str());
+    _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts);
     makefile->AddDefinition("_uic_target_options", _uic_opts.c_str());
     }
   for (std::vector<std::string>::const_iterator li = configs.begin();
        li != configs.end(); ++li)
     {
     std::string config_uic_opts;
-    GetUicOpts(target, li->c_str(), config_uic_opts);
+    GetUicOpts(target, *li, config_uic_opts);
     if (config_uic_opts != _uic_opts)
       {
       configUicOptions[*li] =
-                    cmLocalGenerator::EscapeForCMake(config_uic_opts.c_str());
+                    cmLocalGenerator::EscapeForCMake(config_uic_opts);
       if(_uic_opts.empty())
         {
         _uic_opts = config_uic_opts;
@@ -780,11 +781,11 @@
     }
 
   makefile->AddDefinition("_qt_uic_options_files",
-              cmLocalGenerator::EscapeForCMake(uiFileFiles.c_str()).c_str());
+              cmLocalGenerator::EscapeForCMake(uiFileFiles).c_str());
   makefile->AddDefinition("_qt_uic_options_options",
-            cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str());
+            cmLocalGenerator::EscapeForCMake(uiFileOptions).c_str());
 
-  const char* targetName = target->GetName();
+  std::string targetName = target->GetName();
   if (strcmp(qtVersion, "5") == 0)
     {
     cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic");
@@ -794,7 +795,7 @@
       }
     else
       {
-      makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0));
+      makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(""));
       }
     }
   else if (strcmp(qtVersion, "4") == 0)
@@ -803,15 +804,15 @@
     if (!qt4Uic)
       {
       cmSystemTools::Error("Qt4::uic target not found ",
-                          targetName);
+                          targetName.c_str());
       return;
       }
-    makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0));
+    makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(""));
     }
   else
     {
     cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
-                        "Qt 5 ", targetName);
+                        "Qt 5 ", targetName.c_str());
     }
 }
 
@@ -843,7 +844,7 @@
         ++o;
         }
       if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
-                  cmStrCmp(o)) != cmArrayEnd(valueOptions))
+                  cmStrCmp(*it)) != cmArrayEnd(valueOptions))
         {
         assert(existingIt + 1 != opts.end());
         *(existingIt + 1) = *(it + 1);
@@ -865,7 +866,7 @@
   cmMakefile *makefile = target->GetMakefile();
 
   std::vector<cmSourceFile*> srcFiles;
-  target->GetSourceFiles(srcFiles);
+  target->GetConfigCommonSourceFiles(srcFiles);
 
   std::string rccFileFiles;
   std::string rccFileOptions;
@@ -926,24 +927,24 @@
     }
 
   makefile->AddDefinition("_rcc_files",
-          cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str());
+          cmLocalGenerator::EscapeForCMake(_rcc_files).c_str());
 
   makefile->AddDefinition("_qt_rcc_options_files",
-              cmLocalGenerator::EscapeForCMake(rccFileFiles.c_str()).c_str());
+              cmLocalGenerator::EscapeForCMake(rccFileFiles).c_str());
   makefile->AddDefinition("_qt_rcc_options_options",
-            cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str());
+            cmLocalGenerator::EscapeForCMake(rccFileOptions).c_str());
 
-  const char* targetName = target->GetName();
+  std::string targetName = target->GetName();
   if (strcmp(qtVersion, "5") == 0)
     {
     cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc");
     if (!qt5Rcc)
       {
       cmSystemTools::Error("Qt5::rcc target not found ",
-                          targetName);
+                          targetName.c_str());
       return;
       }
-    makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0));
+    makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(""));
     }
   else if (strcmp(qtVersion, "4") == 0)
     {
@@ -951,20 +952,20 @@
     if (!qt4Rcc)
       {
       cmSystemTools::Error("Qt4::rcc target not found ",
-                          targetName);
+                          targetName.c_str());
       return;
       }
-    makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0));
+    makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(""));
     }
   else
     {
     cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
-                        "Qt 5 ", targetName);
+                        "Qt 5 ", targetName.c_str());
     }
 }
 
 static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
-                                                  const char* targetDirectory)
+                                            const std::string& targetDirectory)
 {
   cmGlobalGenerator* gg = new cmGlobalGenerator();
   gg->SetCMakeInstance(cm);
@@ -979,7 +980,8 @@
   return gg;
 }
 
-bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config)
+bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
+                             const std::string& config)
 {
   bool success = true;
   cmake cm;
@@ -1005,10 +1007,11 @@
 }
 
 bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile,
-                                      const char* targetDirectory,
-                                      const char *config)
+                                      const std::string& targetDirectory,
+                                      const std::string& config)
 {
-  std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
+  std::string filename(
+      cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
   cmSystemTools::ConvertToUnixSlashes(filename);
   filename += "/AutogenInfo.cmake";
 
@@ -1039,47 +1042,49 @@
   {
   std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS";
   std::string compileDefsProp = compileDefsPropOrig;
-  if(config)
+  if(!config.empty())
     {
     compileDefsProp += "_";
     compileDefsProp += config;
     }
-  const char *compileDefs = makefile->GetDefinition(compileDefsProp.c_str());
+  const char *compileDefs = makefile->GetDefinition(compileDefsProp);
   this->MocCompileDefinitionsStr = compileDefs ? compileDefs
-                  : makefile->GetSafeDefinition(compileDefsPropOrig.c_str());
+                  : makefile->GetSafeDefinition(compileDefsPropOrig);
   }
   {
   std::string includesPropOrig = "AM_MOC_INCLUDES";
   std::string includesProp = includesPropOrig;
-  if(config)
+  if(!config.empty())
     {
     includesProp += "_";
     includesProp += config;
     }
-  const char *includes = makefile->GetDefinition(includesProp.c_str());
+  const char *includes = makefile->GetDefinition(includesProp);
   this->MocIncludesStr = includes ? includes
-                      : makefile->GetSafeDefinition(includesPropOrig.c_str());
+                      : makefile->GetSafeDefinition(includesPropOrig);
   }
   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");
+  this->OriginTargetName
+                      = makefile->GetSafeDefinition("AM_ORIGIN_TARGET_NAME");
 
   {
   const char *uicOptionsFiles
                         = makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES");
   std::string uicOptionsPropOrig = "AM_UIC_TARGET_OPTIONS";
   std::string uicOptionsProp = uicOptionsPropOrig;
-  if(config)
+  if(!config.empty())
     {
     uicOptionsProp += "_";
     uicOptionsProp += config;
     }
   const char *uicTargetOptions
-                        = makefile->GetSafeDefinition(uicOptionsProp.c_str());
+                        = makefile->GetSafeDefinition(uicOptionsProp);
   cmSystemTools::ExpandListArgument(
       uicTargetOptions ? uicTargetOptions
-                    : makefile->GetSafeDefinition(uicOptionsPropOrig.c_str()),
+                    : makefile->GetSafeDefinition(uicOptionsPropOrig),
     this->UicTargetOptions);
   const char *uicOptionsOptions
                       = makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS");
@@ -1148,9 +1153,10 @@
 
 
 bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile,
-                                            const char* targetDirectory)
+                                            const std::string& targetDirectory)
 {
-  std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
+  std::string filename(
+      cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
   cmSystemTools::ConvertToUnixSlashes(filename);
   filename += "/AutomocOldMocDefinitions.cmake";
 
@@ -1164,9 +1170,11 @@
 
 
 void
-cmQtAutoGenerators::WriteOldMocDefinitionsFile(const char* targetDirectory)
+cmQtAutoGenerators::WriteOldMocDefinitionsFile(
+                                            const std::string& targetDirectory)
 {
-  std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
+  std::string filename(
+      cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
   cmSystemTools::ConvertToUnixSlashes(filename);
   filename += "/AutomocOldMocDefinitions.cmake";
 
@@ -1175,7 +1183,7 @@
                std::ios::out | std::ios::trunc);
   outfile << "set(AM_OLD_COMPILE_SETTINGS "
               << cmLocalGenerator::EscapeForCMake(
-                 this->CurrentCompileSettingsStr.c_str()) << ")\n";
+                 this->CurrentCompileSettingsStr) << ")\n";
 
   outfile.close();
 }
@@ -1786,8 +1794,8 @@
 
   std::string::size_type matchOffset = 0;
 
-  const std::string absPath = cmsys::SystemTools::GetFilenamePath(
-                   cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+  const std::string realName =
+                   cmsys::SystemTools::GetRealPath(absFilename.c_str());
 
   matchOffset = 0;
   if ((strstr(contentsString.c_str(), "ui_") != NULL)
@@ -1804,7 +1812,7 @@
       // finding the correct header, so we need to remove the ui_ part
       basename = basename.substr(3);
 
-      includedUis[absPath] = basename;
+      includedUis[realName] = basename;
 
       matchOffset += uiIncludeRegExp.end();
       } while(uiIncludeRegExp.find(contentsString.c_str() + matchOffset));
@@ -1907,7 +1915,7 @@
                                            |cmsysTerminal_Color_ForegroundBold,
                                      msg.c_str(), true, this->ColorOutput);
 
-    std::vector<cmStdString> command;
+    std::vector<std::string> command;
     command.push_back(this->MocExecutable);
     for (std::list<std::string>::const_iterator it = this->MocIncludes.begin();
          it != this->MocIncludes.end();
@@ -1936,7 +1944,7 @@
 
     if (this->Verbose)
       {
-      for(std::vector<cmStdString>::const_iterator cmdIt = command.begin();
+      for(std::vector<std::string>::const_iterator cmdIt = command.begin();
           cmdIt != command.end();
           ++cmdIt)
         {
@@ -1960,7 +1968,7 @@
   return false;
 }
 
-bool cmQtAutoGenerators::GenerateUi(const std::string& path,
+bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
                                     const std::string& uiFileName)
 {
   if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false))
@@ -1968,6 +1976,9 @@
     cmsys::SystemTools::MakeDirectory(this->Builddir.c_str());
     }
 
+  const std::string path = cmsys::SystemTools::GetFilenamePath(
+                                                      realName.c_str()) + '/';
+
   std::string ui_output_file = "ui_" + uiFileName + ".h";
   std::string ui_input_file = path + uiFileName + ".ui";
 
@@ -1983,7 +1994,7 @@
                                           |cmsysTerminal_Color_ForegroundBold,
                                       msg.c_str(), true, this->ColorOutput);
 
-    std::vector<cmStdString> command;
+    std::vector<std::string> command;
     command.push_back(this->UicExecutable);
 
     std::vector<std::string> opts = this->UicTargetOptions;
@@ -2008,7 +2019,7 @@
 
     if (this->Verbose)
       {
-      for(std::vector<cmStdString>::const_iterator cmdIt = command.begin();
+      for(std::vector<std::string>::const_iterator cmdIt = command.begin();
           cmdIt != command.end();
           ++cmdIt)
         {
@@ -2046,13 +2057,15 @@
       {
       continue;
       }
-    std::vector<cmStdString> command;
+    std::vector<std::string> command;
     command.push_back(this->RccExecutable);
 
     std::string basename = cmsys::SystemTools::
                                   GetFilenameWithoutLastExtension(*si);
 
-    std::string rcc_output_file = this->Builddir + "qrc_" + basename + ".cpp";
+    std::string rcc_output_file = this->Builddir
+                                + "CMakeFiles/" + this->OriginTargetName
+                                + ".dir/qrc_" + basename + ".cpp";
 
     int sourceNewerThanQrc = 0;
     bool success = cmsys::SystemTools::FileTimeCompare(si->c_str(),
@@ -2074,13 +2087,15 @@
           }
         }
 
+      command.push_back("-name");
+      command.push_back(basename);
       command.push_back("-o");
       command.push_back(rcc_output_file);
       command.push_back(*si);
 
       if (this->Verbose)
         {
-        for(std::vector<cmStdString>::const_iterator cmdIt = command.begin();
+        for(std::vector<std::string>::const_iterator cmdIt = command.begin();
             cmdIt != command.end();
             ++cmdIt)
           {
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 2840fbf..501e13a 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -21,7 +21,7 @@
 {
 public:
   cmQtAutoGenerators();
-  bool Run(const char* targetDirectory, const char *config);
+  bool Run(const std::string& targetDirectory, const std::string& config);
 
   bool InitializeAutogenTarget(cmTarget* target);
   void SetupAutoGenerateTarget(cmTarget const* target);
@@ -37,18 +37,18 @@
   void SetupAutoRccTarget(cmTarget const* target);
 
   bool ReadAutogenInfoFile(cmMakefile* makefile,
-                           const char* targetDirectory,
-                           const char *config);
+                           const std::string& targetDirectory,
+                           const std::string& config);
   bool ReadOldMocDefinitionsFile(cmMakefile* makefile,
-                                 const char* targetDirectory);
-  void WriteOldMocDefinitionsFile(const char* targetDirectory);
+                                 const std::string& targetDirectory);
+  void WriteOldMocDefinitionsFile(const std::string& targetDirectory);
 
   std::string MakeCompileSettingsString(cmMakefile* makefile);
 
   bool RunAutogen(cmMakefile* makefile);
   bool GenerateMoc(const std::string& sourceFile,
                    const std::string& mocFileName);
-  bool GenerateUi(const std::string& path, const std::string& uiFileName);
+  bool GenerateUi(const std::string& realName, const std::string& uiFileName);
   bool GenerateQrc();
   void ParseCppFile(const std::string& absFilename,
                     const std::vector<std::string>& headerExtensions,
@@ -104,6 +104,7 @@
   std::string ProjectBinaryDir;
   std::string ProjectSourceDir;
   std::string TargetName;
+  std::string OriginTargetName;
 
   std::string CurrentCompileSettingsStr;
   std::string OldCompileSettingsStr;
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index 11a9913..cca995b 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -39,7 +39,8 @@
   ModuleRST("^#\\[(=*)\\[\\.rst:$"),
   CMakeRole("(:cmake)?:("
             "command|generator|variable|module|policy|"
-            "prop_cache|prop_dir|prop_gbl|prop_sf|prop_test|prop_tgt|"
+            "prop_cache|prop_dir|prop_gbl|prop_inst|prop_sf|"
+            "prop_test|prop_tgt|"
             "manual"
             "):`(<*([^`<]|[^` \t]<)*)([ \t]+<[^`]*>)?`"),
   Substitution("(^|[^A-Za-z0-9_])"
@@ -326,11 +327,11 @@
     std::string::size_type start = this->Substitution.start(2);
     std::string::size_type end = this->Substitution.end(2);
     std::string substitute = this->Substitution.match(3);
-    std::map<cmStdString, cmStdString>::iterator
+    std::map<std::string, std::string>::iterator
       replace = this->Replace.find(substitute);
     if(replace != this->Replace.end())
       {
-      std::pair<std::set<cmStdString>::iterator, bool> replaced =
+      std::pair<std::set<std::string>::iterator, bool> replaced =
         this->Replaced.insert(substitute);
       if(replaced.second)
         {
diff --git a/Source/cmRST.h b/Source/cmRST.h
index 3356008..b9b2366 100644
--- a/Source/cmRST.h
+++ b/Source/cmRST.h
@@ -92,8 +92,8 @@
 
   std::vector<std::string> MarkupLines;
   std::string DocDir;
-  std::map<cmStdString, cmStdString> Replace;
-  std::set<cmStdString> Replaced;
+  std::map<std::string, std::string> Replace;
+  std::set<std::string> Replaced;
   std::string ReplaceName;
 };
 
diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h
index ad73908..94161f8 100644
--- a/Source/cmRemoveCommand.h
+++ b/Source/cmRemoveCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "remove";}
+  virtual std::string GetName() const {return "remove";}
 
   /** This command is kept for compatibility with older CMake versions. */
   virtual bool IsDiscouraged() const
diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h
index 4e291fc..cac94be 100644
--- a/Source/cmRemoveDefinitionsCommand.h
+++ b/Source/cmRemoveDefinitionsCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "remove_definitions";}
+  virtual std::string GetName() const {return "remove_definitions";}
 
   cmTypeMacro(cmRemoveDefinitionsCommand, cmCommand);
 };
diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h
index 2822b62..4ff81ef 100644
--- a/Source/cmReturnCommand.h
+++ b/Source/cmReturnCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "return";}
+  virtual std::string GetName() const {return "return";}
 
   cmTypeMacro(cmReturnCommand, cmCommand);
 };
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx
index 3b6a49b..e44b236 100644
--- a/Source/cmScriptGenerator.cxx
+++ b/Source/cmScriptGenerator.cxx
@@ -15,11 +15,11 @@
 
 //----------------------------------------------------------------------------
 cmScriptGenerator
-::cmScriptGenerator(const char* config_var,
+::cmScriptGenerator(const std::string& config_var,
                     std::vector<std::string> const& configurations):
   RuntimeConfigVariable(config_var),
   Configurations(configurations),
-  ConfigurationName(0),
+  ConfigurationName(""),
   ConfigurationTypes(0),
   ActionsPerConfig(false)
 {
@@ -34,21 +34,21 @@
 //----------------------------------------------------------------------------
 void
 cmScriptGenerator
-::Generate(std::ostream& os, const char* config,
+::Generate(std::ostream& os, const std::string& config,
            std::vector<std::string> const& configurationTypes)
 {
   this->ConfigurationName = config;
   this->ConfigurationTypes = &configurationTypes;
   this->GenerateScript(os);
-  this->ConfigurationName = 0;
+  this->ConfigurationName = "";
   this->ConfigurationTypes = 0;
 }
 
 //----------------------------------------------------------------------------
-static void cmScriptGeneratorEncodeConfig(const char* config,
+static void cmScriptGeneratorEncodeConfig(const std::string& config,
                                           std::string& result)
 {
-  for(const char* c = config; *c; ++c)
+  for(const char* c = config.c_str(); *c; ++c)
     {
     if(*c >= 'a' && *c <= 'z')
       {
@@ -73,12 +73,12 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmScriptGenerator::CreateConfigTest(const char* config)
+cmScriptGenerator::CreateConfigTest(const std::string& config)
 {
   std::string result = "\"${";
   result += this->RuntimeConfigVariable;
   result += "}\" MATCHES \"^(";
-  if(config && *config)
+  if(!config.empty())
     {
     cmScriptGeneratorEncodeConfig(config, result);
     }
@@ -99,7 +99,7 @@
     {
     result += sep;
     sep = "|";
-    cmScriptGeneratorEncodeConfig(ci->c_str(), result);
+    cmScriptGeneratorEncodeConfig(*ci, result);
     }
   result += ")$\"";
   return result;
@@ -142,14 +142,15 @@
 }
 
 //----------------------------------------------------------------------------
-void cmScriptGenerator::GenerateScriptForConfig(std::ostream&, const char*,
+void cmScriptGenerator::GenerateScriptForConfig(std::ostream&,
+                                                const std::string&,
                                                 Indent const&)
 {
   // No actions for this generator.
 }
 
 //----------------------------------------------------------------------------
-bool cmScriptGenerator::GeneratesForConfig(const char* config)
+bool cmScriptGenerator::GeneratesForConfig(const std::string& config)
 {
   // If this is not a configuration-specific rule then we install.
   if(this->Configurations.empty())
@@ -159,7 +160,7 @@
 
   // This is a configuration-specific rule.  Check if the config
   // matches this rule.
-  std::string config_upper = cmSystemTools::UpperCase(config?config:"");
+  std::string config_upper = cmSystemTools::UpperCase(config);
   for(std::vector<std::string>::const_iterator i =
         this->Configurations.begin();
       i != this->Configurations.end(); ++i)
diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h
index 8b2ca33..9ab04f1 100644
--- a/Source/cmScriptGenerator.h
+++ b/Source/cmScriptGenerator.h
@@ -47,11 +47,11 @@
 class cmScriptGenerator
 {
 public:
-  cmScriptGenerator(const char* config_var,
+  cmScriptGenerator(const std::string& config_var,
                     std::vector<std::string> const& configurations);
   virtual ~cmScriptGenerator();
 
-  void Generate(std::ostream& os, const char* config,
+  void Generate(std::ostream& os, const std::string& config,
                 std::vector<std::string> const& configurationTypes);
 
   const std::vector<std::string>& GetConfigurations() const
@@ -63,15 +63,15 @@
   virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
   virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
   virtual void GenerateScriptForConfig(std::ostream& os,
-                                       const char* config,
+                                       const std::string& config,
                                        Indent const& indent);
   virtual void GenerateScriptNoConfig(std::ostream&, Indent const&) {}
   virtual bool NeedsScriptNoConfig() const { return false; }
 
   // Test if this generator does something for a given configuration.
-  bool GeneratesForConfig(const char*);
+  bool GeneratesForConfig(const std::string&);
 
-  std::string CreateConfigTest(const char* config);
+  std::string CreateConfigTest(const std::string& config);
   std::string CreateConfigTest(std::vector<std::string> const& configs);
   std::string CreateComponentTest(const char* component);
 
@@ -80,7 +80,7 @@
   std::vector<std::string> const Configurations;
 
   // Information used during generation.
-  const char* ConfigurationName;
+  std::string ConfigurationName;
   std::vector<std::string> const* ConfigurationTypes;
 
   // True if the subclass needs to generate an explicit rule for each
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 6f62091..1ee3f29 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -53,7 +53,7 @@
       {
       cmOStringStream e;
       e << "given unknown argument " << args[i];
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -61,11 +61,11 @@
   if(mode == ModeOld)
     {
     // Original space-replacement version of command.
-    if(const char* def = this->Makefile->GetDefinition(var.c_str()))
+    if(const char* def = this->Makefile->GetDefinition(var))
       {
       std::string value = def;
       cmSystemTools::ReplaceString(value, " ", ";");
-      this->Makefile->AddDefinition(var.c_str(), value.c_str());
+      this->Makefile->AddDefinition(var, value.c_str());
       }
     }
   else
@@ -102,7 +102,7 @@
         value += *si;
         }
       }
-    this->Makefile->AddDefinition(var.c_str(), value.c_str());
+    this->Makefile->AddDefinition(var, value.c_str());
     }
 
   return true;
diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h
index ce02360..a527ae7 100644
--- a/Source/cmSeparateArgumentsCommand.h
+++ b/Source/cmSeparateArgumentsCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "separate_arguments";}
+  virtual std::string GetName() const {return "separate_arguments";}
 
   cmTypeMacro(cmSeparateArgumentsCommand, cmCommand);
 };
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 36363a1..0ca36eb 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -59,7 +59,7 @@
   // SET (VAR) // Removes the definition of VAR.
   if (args.size() == 1)
     {
-    this->Makefile->RemoveDefinition(args[0].c_str());
+    this->Makefile->RemoveDefinition(args[0]);
     return true;
     }
   // SET (VAR PARENT_SCOPE) // Removes the definition of VAR
diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h
index 6cef0a0..4adc2d9 100644
--- a/Source/cmSetCommand.h
+++ b/Source/cmSetCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "set";}
+  virtual std::string GetName() const {return "set";}
 
   cmTypeMacro(cmSetCommand, cmCommand);
 };
diff --git a/Source/cmSetDirectoryPropertiesCommand.cxx b/Source/cmSetDirectoryPropertiesCommand.cxx
index 62c9b87..3d4b7a9 100644
--- a/Source/cmSetDirectoryPropertiesCommand.cxx
+++ b/Source/cmSetDirectoryPropertiesCommand.cxx
@@ -30,7 +30,7 @@
                                                 args.end(), errors);
   if (!ret)
     {
-    this->SetError(errors.c_str());
+    this->SetError(errors);
     }
   return ret;
 }
@@ -62,7 +62,7 @@
         "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
       return false;
       }
-    mf->SetProperty(prop.c_str(), value.c_str());
+    mf->SetProperty(prop, value.c_str());
     }
 
   return true;
diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h
index 6240598..f444a1b 100644
--- a/Source/cmSetDirectoryPropertiesCommand.h
+++ b/Source/cmSetDirectoryPropertiesCommand.h
@@ -37,7 +37,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "set_directory_properties";}
+  virtual std::string GetName() const { return "set_directory_properties";}
 
   /**
    * Static entry point for use by other commands
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 1a6f1d6..c624d17 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -61,12 +61,17 @@
     {
     scope = cmProperty::CACHE;
     }
+  else if(*arg == "INSTALL")
+    {
+    scope = cmProperty::INSTALL;
+    }
   else
     {
     cmOStringStream e;
     e << "given invalid scope " << *arg << ".  "
-      << "Valid scopes are GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, CACHE.";
-    this->SetError(e.str().c_str());
+      << "Valid scopes are GLOBAL, DIRECTORY, "
+        "TARGET, SOURCE, TEST, CACHE, INSTALL.";
+    this->SetError(e.str());
     return false;
     }
 
@@ -114,7 +119,7 @@
       {
       cmOStringStream e;
       e << "given invalid argument \"" << *arg << "\".";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -135,6 +140,7 @@
     case cmProperty::SOURCE_FILE: return this->HandleSourceMode();
     case cmProperty::TEST:        return this->HandleTestMode();
     case cmProperty::CACHE:       return this->HandleCacheMode();
+    case cmProperty::INSTALL:     return this->HandleInstallMode();
 
     case cmProperty::VARIABLE:
     case cmProperty::CACHED_VARIABLE:
@@ -203,7 +209,7 @@
     // Lookup the generator.
     if(cmLocalGenerator* lg =
        (this->Makefile->GetLocalGenerator()
-        ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str())))
+        ->GetGlobalGenerator()->FindLocalGenerator(dir)))
       {
       // Use the makefile for the directory found.
       mf = lg->GetMakefile();
@@ -241,7 +247,7 @@
 //----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleTargetMode()
 {
-  for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
+  for(std::set<std::string>::const_iterator ni = this->Names.begin();
       ni != this->Names.end(); ++ni)
     {
     if (this->Makefile->IsAlias(*ni))
@@ -262,7 +268,7 @@
       cmOStringStream e;
       e << "could not find TARGET " << *ni
         << ".  Perhaps it has not yet been created.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -297,11 +303,11 @@
 //----------------------------------------------------------------------------
 bool cmSetPropertyCommand::HandleSourceMode()
 {
-  for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
+  for(std::set<std::string>::const_iterator ni = this->Names.begin();
       ni != this->Names.end(); ++ni)
     {
     // Get the source file.
-    if(cmSourceFile* sf = this->Makefile->GetOrCreateSource(ni->c_str()))
+    if(cmSourceFile* sf = this->Makefile->GetOrCreateSource(*ni))
       {
       if(!this->HandleSource(sf))
         {
@@ -312,7 +318,7 @@
       {
       cmOStringStream e;
       e << "given SOURCE name that could not be found or created: " << *ni;
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -345,13 +351,13 @@
 bool cmSetPropertyCommand::HandleTestMode()
 {
   // Look for tests with all names given.
-  std::set<cmStdString>::iterator next;
-  for(std::set<cmStdString>::iterator ni = this->Names.begin();
+  std::set<std::string>::iterator next;
+  for(std::set<std::string>::iterator ni = this->Names.begin();
       ni != this->Names.end(); ni = next)
     {
     next = ni;
     ++next;
-    if(cmTest* test = this->Makefile->GetTest(ni->c_str()))
+    if(cmTest* test = this->Makefile->GetTest(*ni))
       {
       if(this->HandleTest(test))
         {
@@ -369,12 +375,12 @@
     {
     cmOStringStream e;
     e << "given TEST names that do not exist:\n";
-    for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
+    for(std::set<std::string>::const_iterator ni = this->Names.begin();
         ni != this->Names.end(); ++ni)
       {
       e << "  " << *ni << "\n";
       }
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
   return true;
@@ -414,7 +420,7 @@
       cmOStringStream e;
       e << "given non-boolean value \"" << this->PropertyValue
         << "\" for CACHE property \"ADVANCED\".  ";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -424,7 +430,7 @@
       {
       cmOStringStream e;
       e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\"";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -436,11 +442,11 @@
     e << "given invalid CACHE property " << this->PropertyName << ".  "
       << "Settable CACHE properties are: "
       << "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE.";
-    this->SetError(e.str().c_str());
+    this->SetError(e.str());
     return false;
     }
 
-  for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
+  for(std::set<std::string>::const_iterator ni = this->Names.begin();
       ni != this->Names.end(); ++ni)
     {
     // Get the source file.
@@ -460,7 +466,7 @@
       cmOStringStream e;
       e << "could not find CACHE variable " << *ni
         << ".  Perhaps it has not yet been created.";
-      this->SetError(e.str().c_str());
+      this->SetError(e.str());
       return false;
       }
     }
@@ -488,3 +494,54 @@
 
   return true;
 }
+
+//----------------------------------------------------------------------------
+bool cmSetPropertyCommand::HandleInstallMode()
+{
+  cmake* cm = this->Makefile->GetCMakeInstance();
+
+  for(std::set<std::string>::const_iterator i = this->Names.begin();
+      i != this->Names.end(); ++i)
+    {
+    if(cmInstalledFile* file = cm->GetOrCreateInstalledFile(
+      this->Makefile, *i))
+      {
+      if(!this->HandleInstall(file))
+        {
+        return false;
+        }
+      }
+    else
+      {
+      cmOStringStream e;
+      e << "given INSTALL name that could not be found or created: " << *i;
+      this->SetError(e.str());
+      return false;
+      }
+    }
+  return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmSetPropertyCommand::HandleInstall(cmInstalledFile* file)
+{
+  // Set or append the property.
+  std::string const& name = this->PropertyName;
+
+  cmMakefile* mf = this->Makefile;
+
+  const char *value = this->PropertyValue.c_str();
+  if (this->Remove)
+    {
+    file->RemoveProperty(name);
+    }
+  else if(this->AppendMode)
+    {
+    file->AppendProperty(mf, name, value, this->AppendAsString);
+    }
+  else
+    {
+    file->SetProperty(mf, name, value);
+    }
+  return true;
+}
diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h
index 5470314..b06cb68 100644
--- a/Source/cmSetPropertyCommand.h
+++ b/Source/cmSetPropertyCommand.h
@@ -34,7 +34,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "set_property";}
+  virtual std::string GetName() const { return "set_property";}
 
   /**
    * This determines if the command is invoked when in script mode.
@@ -44,7 +44,7 @@
   cmTypeMacro(cmSetPropertyCommand, cmCommand);
 
 private:
-  std::set<cmStdString> Names;
+  std::set<std::string> Names;
   std::string PropertyName;
   std::string PropertyValue;
   bool Remove;
@@ -62,6 +62,8 @@
   bool HandleTest(cmTest* test);
   bool HandleCacheMode();
   bool HandleCacheEntry(cmCacheManager::CacheIterator&);
+  bool HandleInstallMode();
+  bool HandleInstall(cmInstalledFile* file);
 };
 
 
diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx
index 619dfc5..19c6819 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.cxx
+++ b/Source/cmSetSourceFilesPropertiesCommand.cxx
@@ -51,7 +51,7 @@
                  args.end(), errors);
   if (!ret)
     {
-    this->SetError(errors.c_str());
+    this->SetError(errors);
     }
   return ret;
 }
@@ -154,14 +154,14 @@
     {
     // get the source file
     cmSourceFile* sf =
-      mf->GetOrCreateSource(j->c_str(), generated);
+      mf->GetOrCreateSource(*j, generated);
     if(sf)
       {
       // now loop through all the props and set them
       unsigned int k;
       for (k = 0; k < propertyPairs.size(); k = k + 2)
         {
-        sf->SetProperty(propertyPairs[k].c_str(),propertyPairs[k+1].c_str());
+        sf->SetProperty(propertyPairs[k],propertyPairs[k+1].c_str());
         }
       }
     }
diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h
index 8541a96..5fa5a3a 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.h
+++ b/Source/cmSetSourceFilesPropertiesCommand.h
@@ -32,7 +32,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "set_source_files_properties";}
+  virtual std::string GetName() const { return "set_source_files_properties";}
 
   cmTypeMacro(cmSetSourceFilesPropertiesCommand, cmCommand);
 
diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx
index dab4180..bf3519c 100644
--- a/Source/cmSetTargetPropertiesCommand.cxx
+++ b/Source/cmSetTargetPropertiesCommand.cxx
@@ -78,12 +78,12 @@
       return false;
       }
     bool ret = cmSetTargetPropertiesCommand::SetOneTarget
-      (args[i].c_str(),propertyPairs,this->Makefile);
+      (args[i],propertyPairs,this->Makefile);
     if (!ret)
       {
       std::string message = "Can not find target to add properties to: ";
       message += args[i];
-      this->SetError(message.c_str());
+      this->SetError(message);
       return false;
       }
     }
@@ -91,7 +91,7 @@
 }
 
 bool cmSetTargetPropertiesCommand
-::SetOneTarget(const char *tname,
+::SetOneTarget(const std::string& tname,
                std::vector<std::string> &propertyPairs,
                cmMakefile *mf)
 {
@@ -101,9 +101,9 @@
     unsigned int k;
     for (k = 0; k < propertyPairs.size(); k = k + 2)
       {
-      target->SetProperty(propertyPairs[k].c_str(),
+      target->SetProperty(propertyPairs[k],
                           propertyPairs[k+1].c_str());
-      target->CheckProperty(propertyPairs[k].c_str(), mf);
+      target->CheckProperty(propertyPairs[k], mf);
       }
     }
   // if file is not already in the makefile, then add it
diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h
index 6221a18..3981ef3 100644
--- a/Source/cmSetTargetPropertiesCommand.h
+++ b/Source/cmSetTargetPropertiesCommand.h
@@ -32,12 +32,12 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "set_target_properties";}
+  virtual std::string GetName() const { return "set_target_properties";}
 
   /**
    *  Used by this command and cmSetPropertiesCommand
    */
-  static bool SetOneTarget(const char *tname,
+  static bool SetOneTarget(const std::string& tname,
                            std::vector<std::string> &propertyPairs,
                            cmMakefile *mf);
 
diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx
index 3d52cf2..b026ff3 100644
--- a/Source/cmSetTestsPropertiesCommand.cxx
+++ b/Source/cmSetTestsPropertiesCommand.cxx
@@ -76,12 +76,12 @@
     {
     std::string errors;
     bool ret =
-      cmSetTestsPropertiesCommand::SetOneTest(args[i].c_str(),
+      cmSetTestsPropertiesCommand::SetOneTest(args[i],
                                               propertyPairs,
                                               this->Makefile, errors);
     if (!ret)
       {
-      this->SetError(errors.c_str());
+      this->SetError(errors);
       return ret;
       }
     }
@@ -91,7 +91,7 @@
 
 
 bool cmSetTestsPropertiesCommand
-::SetOneTest(const char *tname,
+::SetOneTest(const std::string& tname,
              std::vector<std::string> &propertyPairs,
              cmMakefile *mf, std::string &errors)
 {
@@ -101,7 +101,7 @@
     unsigned int k;
     for (k = 0; k < propertyPairs.size(); k = k + 2)
       {
-      test->SetProperty(propertyPairs[k].c_str(),
+      test->SetProperty(propertyPairs[k],
                         propertyPairs[k+1].c_str());
       }
     }
diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h
index 9e85495..dabe944 100644
--- a/Source/cmSetTestsPropertiesCommand.h
+++ b/Source/cmSetTestsPropertiesCommand.h
@@ -32,11 +32,11 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "set_tests_properties";}
+  virtual std::string GetName() const { return "set_tests_properties";}
 
   cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);
 
-  static bool SetOneTest(const char *tname,
+  static bool SetOneTest(const std::string& tname,
                          std::vector<std::string> &propertyPairs,
                          cmMakefile *mf,
                          std::string &errors);
diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx
index 2bdd1ad..e61caab 100644
--- a/Source/cmSiteNameCommand.cxx
+++ b/Source/cmSiteNameCommand.cxx
@@ -31,7 +31,7 @@
   paths.push_back("/usr/local/bin");
 
   const char* cacheValue
-    = this->Makefile->GetDefinition(args[0].c_str());
+    = this->Makefile->GetDefinition(args[0]);
   if(cacheValue)
     {
     return true;
@@ -85,7 +85,7 @@
     }
 #endif
   this->Makefile->
-    AddCacheDefinition(args[0].c_str(),
+    AddCacheDefinition(args[0],
                        siteName.c_str(),
                        "Name of the computer/site where compile is being run",
                        cmCacheManager::STRING);
diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h
index eb9d4d8..ec63ef8 100644
--- a/Source/cmSiteNameCommand.h
+++ b/Source/cmSiteNameCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "site_name";}
+  virtual std::string GetName() const {return "site_name";}
 
   cmTypeMacro(cmSiteNameCommand, cmCommand);
 };
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 23422a2..b833d3f 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -18,12 +18,14 @@
 #include "cmake.h"
 
 //----------------------------------------------------------------------------
-cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name):
+cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name):
   Location(mf, name)
 {
   this->CustomCommand = 0;
   this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
   this->FindFullPathFailed = false;
+  this->IsUiFile = ("ui" ==
+          cmSystemTools::GetFilenameLastExtension(this->Location.GetName()));
 }
 
 //----------------------------------------------------------------------------
@@ -38,11 +40,25 @@
   return this->Extension;
 }
 
+const std::string cmSourceFile::propLANGUAGE = "LANGUAGE";
+
 //----------------------------------------------------------------------------
-const char* cmSourceFile::GetLanguage()
+void cmSourceFile::SetObjectLibrary(std::string const& objlib)
+{
+  this->ObjectLibrary = objlib;
+}
+
+//----------------------------------------------------------------------------
+std::string cmSourceFile::GetObjectLibrary() const
+{
+  return this->ObjectLibrary;
+}
+
+//----------------------------------------------------------------------------
+std::string cmSourceFile::GetLanguage()
 {
   // If the language was set explicitly by the user then use it.
-  if(const char* lang = this->GetProperty("LANGUAGE"))
+  if(const char* lang = this->GetProperty(propLANGUAGE))
     {
     return lang;
     }
@@ -76,10 +92,10 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmSourceFile::GetLanguage() const
+std::string cmSourceFile::GetLanguage() const
 {
   // If the language was set explicitly by the user then use it.
-  if(const char* lang = this->GetProperty("LANGUAGE"))
+  if(const char* lang = this->GetProperty(propLANGUAGE))
     {
     return lang;
     }
@@ -87,11 +103,11 @@
   // If the language was determined from the source file extension use it.
   if(!this->Language.empty())
     {
-    return this->Language.c_str();
+    return this->Language;
     }
 
   // The language is not known.
-  return 0;
+  return "";
 }
 
 //----------------------------------------------------------------------------
@@ -164,14 +180,14 @@
       }
     tryPath += this->Location.GetName();
     tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str(), *di);
-    if(this->TryFullPath(tryPath.c_str(), 0))
+    if(this->TryFullPath(tryPath, ""))
       {
       return true;
       }
     for(std::vector<std::string>::const_iterator ei = srcExts.begin();
         ei != srcExts.end(); ++ei)
       {
-      if(this->TryFullPath(tryPath.c_str(), ei->c_str()))
+      if(this->TryFullPath(tryPath, *ei))
         {
         return true;
         }
@@ -179,7 +195,7 @@
     for(std::vector<std::string>::const_iterator ei = hdrExts.begin();
         ei != hdrExts.end(); ++ei)
       {
-      if(this->TryFullPath(tryPath.c_str(), ei->c_str()))
+      if(this->TryFullPath(tryPath, *ei))
         {
         return true;
         }
@@ -217,10 +233,11 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmSourceFile::TryFullPath(const char* tp, const char* ext)
+bool cmSourceFile::TryFullPath(const std::string& path,
+                               const std::string& ext)
 {
-  std::string tryPath = tp;
-  if(ext && *ext)
+  std::string tryPath = path;
+  if(!ext.empty())
     {
     tryPath += ".";
     tryPath += ext;
@@ -266,7 +283,8 @@
   // Try to identify the source file language from the extension.
   cmMakefile const* mf = this->Location.GetMakefile();
   cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
-  if(const char* l = gg->GetLanguageFromExtension(ext.c_str()))
+  std::string l = gg->GetLanguageFromExtension(ext.c_str());
+  if(!l.empty())
     {
     this->Language = l;
     }
@@ -279,21 +297,14 @@
 }
 
 //----------------------------------------------------------------------------
-void cmSourceFile::SetProperty(const char* prop, const char* value)
+void cmSourceFile::SetProperty(const std::string& prop, const char* value)
 {
-  if (!prop)
-    {
-    return;
-    }
-
   this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE);
 
-  std::string ext =
-          cmSystemTools::GetFilenameLastExtension(this->Location.GetName());
-  if (ext == ".ui")
+  if (this->IsUiFile)
     {
     cmMakefile const* mf = this->Location.GetMakefile();
-    if (strcmp(prop, "AUTOUIC_OPTIONS") == 0)
+    if (prop == "AUTOUIC_OPTIONS")
       {
       const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this);
       }
@@ -301,19 +312,15 @@
 }
 
 //----------------------------------------------------------------------------
-void cmSourceFile::AppendProperty(const char* prop, const char* value,
+void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
                                   bool asString)
 {
-  if (!prop)
-    {
-    return;
-    }
   this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE,
                                   asString);
 }
 
 //----------------------------------------------------------------------------
-const char* cmSourceFile::GetPropertyForUser(const char *prop)
+const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
 {
   // This method is a consequence of design history and backwards
   // compatibility.  GetProperty is (and should be) a const method.
@@ -329,7 +336,7 @@
   // cmSourceFileLocation class to commit to a particular full path to
   // the source file as late as possible.  If the users requests the
   // LOCATION property we must commit now.
-  if(strcmp(prop, "LOCATION") == 0)
+  if(prop == "LOCATION")
     {
     // Commit to a location.
     this->GetFullPath();
@@ -340,10 +347,10 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmSourceFile::GetProperty(const char* prop) const
+const char* cmSourceFile::GetProperty(const std::string& prop) const
 {
   // Check for computed properties.
-  if(strcmp(prop, "LOCATION") == 0)
+  if(prop == "LOCATION")
     {
     if(this->FullPath.empty())
       {
@@ -368,7 +375,7 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmSourceFile::GetPropertyAsBool(const char* prop) const
+bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 4440b05..f898260 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -31,7 +31,7 @@
    * Construct with the makefile storing the source and the initial
    * name referencing it.
    */
-  cmSourceFile(cmMakefile* mf, const char* name);
+  cmSourceFile(cmMakefile* mf, const std::string& name);
 
   ~cmSourceFile();
 
@@ -43,14 +43,15 @@
   void SetCustomCommand(cmCustomCommand *cc);
 
   ///! Set/Get a property of this source file
-  void SetProperty(const char *prop, const char *value);
-  void AppendProperty(const char* prop, const char* value,bool asString=false);
-  const char *GetProperty(const char *prop) const;
-  bool GetPropertyAsBool(const char *prop) const;
+  void SetProperty(const std::string& prop, const char *value);
+  void AppendProperty(const std::string& prop,
+                      const char* value,bool asString=false);
+  const char *GetProperty(const std::string& prop) const;
+  bool GetPropertyAsBool(const std::string& prop) const;
 
   /** Implement getting a property when called from a CMake language
       command like get_property or get_source_file_property.  */
-  const char* GetPropertyForUser(const char *prop);
+  const char* GetPropertyForUser(const std::string& prop);
 
   /**
    * The full path to the file.  The non-const version of this method
@@ -78,17 +79,17 @@
   /**
    * Get the language of the compiler to use for this source file.
    */
-  const char* GetLanguage();
-  const char* GetLanguage() const;
+  std::string GetLanguage();
+  std::string GetLanguage() const;
 
   /**
    * Return the vector that holds the list of dependencies
    */
   const std::vector<std::string> &GetDepends() const {return this->Depends;}
-  void AddDepend(const char* d) { this->Depends.push_back(d); }
+  void AddDepend(const std::string& d) { this->Depends.push_back(d); }
 
   // Get the properties
-  cmPropertyMap &GetProperties() { return this->Properties; };
+  cmPropertyMap &GetProperties() { return this->Properties; }
 
   /**
    * Check whether the given source file location could refer to this
@@ -96,6 +97,9 @@
    */
   bool Matches(cmSourceFileLocation const&);
 
+  void SetObjectLibrary(std::string const& objlib);
+  std::string GetObjectLibrary() const;
+
 private:
   cmSourceFileLocation Location;
   cmPropertyMap Properties;
@@ -104,13 +108,17 @@
   std::string Language;
   std::string FullPath;
   bool FindFullPathFailed;
+  std::string ObjectLibrary;
+  bool IsUiFile;
 
   bool FindFullPath(std::string* error);
-  bool TryFullPath(const char* tryPath, const char* ext);
+  bool TryFullPath(const std::string& path, const std::string& ext);
   void CheckExtension();
   void CheckLanguage(std::string const& ext);
 
   std::vector<std::string> Depends;
+
+  static const std::string propLANGUAGE;
 };
 
 // TODO: Factor out into platform information modules.
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 5a8578b..1c2454e 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -16,28 +16,57 @@
 #include "cmGlobalGenerator.h"
 #include "cmSystemTools.h"
 
+#include "assert.h"
+
 //----------------------------------------------------------------------------
-cmSourceFileLocation
-::cmSourceFileLocation(cmMakefile const* mf, const char* name): Makefile(mf)
+cmSourceFileLocation::cmSourceFileLocation()
+  : Makefile(0), AmbiguousDirectory(true), AmbiguousExtension(true)
 {
-  this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name);
-  this->AmbiguousExtension = true;
-  this->Directory = cmSystemTools::GetFilenamePath(name);
-  this->Name = cmSystemTools::GetFilenameName(name);
-  this->UpdateExtension(name);
+
 }
 
 //----------------------------------------------------------------------------
-void cmSourceFileLocation::Update(const char* name)
+cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc)
+  : Makefile(loc.Makefile)
 {
-  if(this->AmbiguousDirectory)
+  this->AmbiguousDirectory = loc.AmbiguousDirectory;
+  this->AmbiguousExtension = loc.AmbiguousExtension;
+  this->Directory = loc.Directory;
+  this->Name = loc.Name;
+}
+
+//----------------------------------------------------------------------------
+cmSourceFileLocation&
+cmSourceFileLocation::operator=(const cmSourceFileLocation& loc)
+{
+  if(this == &loc)
     {
-    this->UpdateDirectory(name);
+    return *this;
     }
-  if(this->AmbiguousExtension)
+  this->Makefile = loc.Makefile;
+  this->AmbiguousDirectory = loc.AmbiguousDirectory;
+  this->AmbiguousExtension = loc.AmbiguousExtension;
+  this->Directory = loc.Directory;
+  this->Name = loc.Name;
+  this->UpdateExtension(this->Name);
+  return *this;
+}
+
+//----------------------------------------------------------------------------
+cmSourceFileLocation
+::cmSourceFileLocation(cmMakefile const* mf, const std::string& name)
+  : Makefile(mf)
+{
+  this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str());
+  this->AmbiguousExtension = true;
+  this->Directory = cmSystemTools::GetFilenamePath(name);
+  if (cmSystemTools::FileIsFullPath(this->Directory.c_str()))
     {
-    this->UpdateExtension(name);
+    this->Directory
+                  = cmSystemTools::CollapseFullPath(this->Directory.c_str());
     }
+  this->Name = cmSystemTools::GetFilenameName(name);
+  this->UpdateExtension(name);
 }
 
 //----------------------------------------------------------------------------
@@ -58,6 +87,7 @@
 //----------------------------------------------------------------------------
 void cmSourceFileLocation::DirectoryUseSource()
 {
+  assert(this->Makefile);
   if(this->AmbiguousDirectory)
     {
     this->Directory =
@@ -70,6 +100,7 @@
 //----------------------------------------------------------------------------
 void cmSourceFileLocation::DirectoryUseBinary()
 {
+  assert(this->Makefile);
   if(this->AmbiguousDirectory)
     {
     this->Directory =
@@ -80,8 +111,9 @@
 }
 
 //----------------------------------------------------------------------------
-void cmSourceFileLocation::UpdateExtension(const char* name)
+void cmSourceFileLocation::UpdateExtension(const std::string& name)
 {
+  assert(this->Makefile);
   // Check the extension.
   std::string ext = cmSystemTools::GetFilenameLastExtension(name);
   if(!ext.empty()) { ext = ext.substr(1); }
@@ -92,7 +124,7 @@
   cmMakefile const* mf = this->Makefile;
   const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
   const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
-  if(gg->GetLanguageFromExtension(ext.c_str()) ||
+  if(!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
      std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
      std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
     {
@@ -136,21 +168,11 @@
 }
 
 //----------------------------------------------------------------------------
-void cmSourceFileLocation::UpdateDirectory(const char* name)
-{
-  // If a full path was given we know the directory.
-  if(cmSystemTools::FileIsFullPath(name))
-    {
-    this->Directory = cmSystemTools::GetFilenamePath(name);
-    this->AmbiguousDirectory = false;
-    }
-}
-
-//----------------------------------------------------------------------------
 bool
 cmSourceFileLocation
 ::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const
 {
+  assert(this->Makefile);
   // This location's extension is not ambiguous but loc's extension
   // is.  See if the names match as-is.
   if(this->Name == loc.Name)
@@ -161,15 +183,16 @@
   // Check if loc's name could possibly be extended to our name by
   // adding an extension.
   if(!(this->Name.size() > loc.Name.size() &&
-       this->Name.substr(0, loc.Name.size()) == loc.Name &&
-       this->Name[loc.Name.size()] == '.'))
+       this->Name[loc.Name.size()] == '.' &&
+       cmHasLiteralPrefixImpl(this->Name.c_str(),
+                              loc.Name.c_str(), loc.Name.size())))
     {
     return false;
     }
 
   // Only a fixed set of extensions will be tried to match a file on
   // disk.  One of these must match if loc refers to this source file.
-  std::string ext = this->Name.substr(loc.Name.size()+1);
+  std::string const& ext = this->Name.substr(loc.Name.size()+1);
   cmMakefile const* mf = this->Makefile;
   const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
   if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
@@ -187,36 +210,34 @@
 //----------------------------------------------------------------------------
 bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
 {
-  if(this->AmbiguousExtension && loc.AmbiguousExtension)
+  assert(this->Makefile);
+  if(this->AmbiguousExtension == loc.AmbiguousExtension)
     {
-    // Both extensions are ambiguous.  Since only the old fixed set of
-    // extensions will be tried, the names must match at this point to
-    // be the same file.
-    if(this->Name != loc.Name)
-      {
-      return false;
-      }
-    }
-  else if(this->AmbiguousExtension)
-    {
-    // Only "this" extension is ambiguous.
-    if(!loc.MatchesAmbiguousExtension(*this))
-      {
-      return false;
-      }
-    }
-  else if(loc.AmbiguousExtension)
-    {
-    // Only "loc" extension is ambiguous.
-    if(!this->MatchesAmbiguousExtension(loc))
+    // Both extensions are similarly ambiguous.  Since only the old fixed set
+    // of extensions will be tried, the names must match at this point to be
+    // the same file.
+    if(this->Name.size() != loc.Name.size() || this->Name != loc.Name)
       {
       return false;
       }
     }
   else
     {
-    // Neither extension is ambiguous.
-    if(this->Name != loc.Name)
+    const cmSourceFileLocation* loc1;
+    const cmSourceFileLocation* loc2;
+    if(this->AmbiguousExtension)
+      {
+      // Only "this" extension is ambiguous.
+      loc1 = &loc;
+      loc2 = this;
+      }
+    else
+      {
+      // Only "loc" extension is ambiguous.
+      loc1 = this;
+      loc2 = &loc;
+      }
+    if(!loc1->MatchesAmbiguousExtension(*loc2))
       {
       return false;
       }
@@ -230,35 +251,37 @@
       return false;
       }
     }
-  else if(this->AmbiguousDirectory && loc.AmbiguousDirectory &&
-          this->Makefile == loc.Makefile)
-    {
-    // Both sides have directories relative to the same location.
-    if(this->Directory != loc.Directory)
-      {
-      return false;
-      }
-    }
   else if(this->AmbiguousDirectory && loc.AmbiguousDirectory)
     {
-    // Each side has a directory relative to a different location.
-    // This can occur when referencing a source file from a different
-    // directory.  This is not yet allowed.
-    this->Makefile->IssueMessage(
-      cmake::INTERNAL_ERROR,
-      "Matches error: Each side has a directory relative to a different "
-      "location. This can occur when referencing a source file from a "
-      "different directory.  This is not yet allowed."
-      );
-    return false;
+    if (this->Makefile == loc.Makefile)
+      {
+      // Both sides have directories relative to the same location.
+      if(this->Directory != loc.Directory)
+        {
+        return false;
+        }
+      }
+    else
+      {
+      // Each side has a directory relative to a different location.
+      // This can occur when referencing a source file from a different
+      // directory.  This is not yet allowed.
+      this->Makefile->IssueMessage(
+        cmake::INTERNAL_ERROR,
+        "Matches error: Each side has a directory relative to a different "
+        "location. This can occur when referencing a source file from a "
+        "different directory.  This is not yet allowed."
+        );
+      return false;
+      }
     }
   else if(this->AmbiguousDirectory)
     {
     // Compare possible directory combinations.
-    std::string srcDir =
+    std::string const& srcDir =
       cmSystemTools::CollapseFullPath(
         this->Directory.c_str(), this->Makefile->GetCurrentDirectory());
-    std::string binDir =
+    std::string const& binDir =
       cmSystemTools::CollapseFullPath(
         this->Directory.c_str(), this->Makefile->GetCurrentOutputDirectory());
     if(srcDir != loc.Directory &&
@@ -270,10 +293,10 @@
   else if(loc.AmbiguousDirectory)
     {
     // Compare possible directory combinations.
-    std::string srcDir =
+    std::string const& srcDir =
       cmSystemTools::CollapseFullPath(
         loc.Directory.c_str(), loc.Makefile->GetCurrentDirectory());
-    std::string binDir =
+    std::string const& binDir =
       cmSystemTools::CollapseFullPath(
         loc.Directory.c_str(), loc.Makefile->GetCurrentOutputDirectory());
     if(srcDir != this->Directory &&
diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h
index c03eee7..af3651a 100644
--- a/Source/cmSourceFileLocation.h
+++ b/Source/cmSourceFileLocation.h
@@ -33,7 +33,10 @@
    * Construct for a source file created in a given cmMakefile
    * instance with an initial name.
    */
-  cmSourceFileLocation(cmMakefile const* mf, const char* name);
+  cmSourceFileLocation(cmMakefile const* mf, const std::string& name);
+  cmSourceFileLocation();
+  cmSourceFileLocation(const cmSourceFileLocation& loc);
+  cmSourceFileLocation& operator=(const cmSourceFileLocation& loc);
 
   /**
    * Return whether the givne source file location could refers to the
@@ -68,7 +71,7 @@
    * Otherwise it will be a relative path (possibly empty) that is
    * either with respect to the source or build tree.
    */
-  const char* GetDirectory() const { return this->Directory.c_str(); }
+  const std::string& GetDirectory() const { return this->Directory; }
 
   /**
    * Get the file name as best is currently known.  If
@@ -76,7 +79,7 @@
    * final name (but could be).  Otherwise the returned name is the
    * final name.
    */
-  const char* GetName() const { return this->Name.c_str(); }
+  const std::string& GetName() const { return this->Name; }
 
   /**
    * Get the cmMakefile instance for which the source file was created.
@@ -93,9 +96,7 @@
 
   // Update the location with additional knowledge.
   void Update(cmSourceFileLocation const& loc);
-  void Update(const char* name);
-  void UpdateExtension(const char* name);
-  void UpdateDirectory(const char* name);
+  void UpdateExtension(const std::string& name);
 };
 
 #endif
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index d272b6c..8fed95e 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -73,7 +73,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmSourceGroup::AddGroupFile(const char* name)
+void cmSourceGroup::AddGroupFile(const std::string& name)
 {
   this->GroupFiles.insert(name);
 }
@@ -99,7 +99,7 @@
 //----------------------------------------------------------------------------
 bool cmSourceGroup::MatchesFiles(const char* name)
 {
-  std::set<cmStdString>::const_iterator i = this->GroupFiles.find(name);
+  std::set<std::string>::const_iterator i = this->GroupFiles.find(name);
   if(i != this->GroupFiles.end())
     {
     return true;
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index 3bbdef9..e8cf519 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -46,7 +46,7 @@
   /**
    * Add a file name to the explicit list of files for this group.
    */
-  void AddGroupFile(const char* name);
+  void AddGroupFile(const std::string& name);
 
   /**
    * Add child to this sourcegroup
@@ -118,7 +118,7 @@
   /**
    * Set of file names explicitly added to this group.
    */
-  std::set<cmStdString> GroupFiles;
+  std::set<std::string> GroupFiles;
 
   /**
    * Vector of all source files that have been assigned to
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 9cb80f6..edba5ba 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -78,7 +78,7 @@
     else if(doingFiles)
       {
       // Convert name to full path and add to the group's list.
-      std::string src = args[i].c_str();
+      std::string src = args[i];
       if(!cmSystemTools::FileIsFullPath(src.c_str()))
         {
         src = this->Makefile->GetCurrentDirectory();
@@ -86,14 +86,14 @@
         src += args[i];
         }
       src = cmSystemTools::CollapseFullPath(src.c_str());
-      sg->AddGroupFile(src.c_str());
+      sg->AddGroupFile(src);
       }
     else
       {
       cmOStringStream err;
-      err << "Unknown argument \"" << args[i].c_str() << "\".  "
+      err << "Unknown argument \"" << args[i] << "\".  "
           << "Perhaps the FILES keyword is missing.\n";
-      this->SetError(err.str().c_str());
+      this->SetError(err.str());
       return false;
       }
     }
diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h
index 5d8b48c..410411b 100644
--- a/Source/cmSourceGroupCommand.h
+++ b/Source/cmSourceGroupCommand.h
@@ -41,7 +41,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "source_group";}
+  virtual std::string GetName() const {return "source_group";}
 
   cmTypeMacro(cmSourceGroupCommand, cmCommand);
 };
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index b4ae657..3731502 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -241,7 +241,7 @@
 // std::string is really basic_string<....lots of stuff....>
 // when combined with a map or set, the symbols can be > 2000 chars!
 #include <cmsys/String.hxx>
-typedef cmsys::String cmStdString;
+//typedef cmsys::String std::string;
 
 // Define cmOStringStream and cmIStringStream wrappers to hide
 // differences between std::stringstream and the old strstream.
@@ -324,12 +324,12 @@
 {
   std::string Name;
   std::string Brief;
-  cmDocumentationEntry(){};
+  cmDocumentationEntry(){}
   cmDocumentationEntry(const char *doc[2])
   { if (doc[0]) this->Name = doc[0];
-  if (doc[1]) this->Brief = doc[1];};
+  if (doc[1]) this->Brief = doc[1];}
   cmDocumentationEntry(const char *n, const char *b)
-  { if (n) this->Name = n; if (b) this->Brief = b; };
+  { if (n) this->Name = n; if (b) this->Brief = b; }
 };
 
 /** Data structure to represent a single command line.  */
@@ -378,7 +378,8 @@
     return static_cast<thisClass *>(c); \
     } \
   return 0;\
-}
+} \
+class cmTypeMacro_UseTrailingSemicolon
 
 inline bool cmHasLiteralPrefixImpl(const std::string &str1,
                                  const char *str2,
@@ -449,11 +450,16 @@
 
 struct cmStrCmp {
   cmStrCmp(const char *test) : m_test(test) {}
-  cmStrCmp(std::string &test) : m_test(test.c_str()) {}
+  cmStrCmp(const std::string &test) : m_test(test) {}
+
+  bool operator()(const std::string& input) const
+  {
+    return m_test == input;
+  }
 
   bool operator()(const char * input) const
   {
-    return strcmp(input, m_test) == 0;
+    return strcmp(input, m_test.c_str()) == 0;
   }
 
   // For use with binary_search
@@ -463,7 +469,7 @@
   }
 
 private:
-  const char * const m_test;
+  const std::string m_test;
 };
 
 #endif
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index f9b69e3..65912da 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -101,9 +101,13 @@
     {
     return this->HandleMakeCIdentifierCommand(args);
     }
+  else if(subCommand == "GENEX_STRIP")
+    {
+    return this->HandleGenexStripCommand(args);
+    }
 
   std::string e = "does not recognize sub-command "+subCommand;
-  this->SetError(e.c_str());
+  this->SetError(e);
   return false;
 }
 
@@ -115,15 +119,15 @@
     {
     cmOStringStream e;
     e << args[0] << " requires an output variable and an input string";
-    this->SetError(e.str().c_str());
+    this->SetError(e.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());
+    std::string out = hash->HashString(args[2]);
+    this->Makefile->AddDefinition(args[1], out.c_str());
     return true;
     }
   return false;
@@ -158,7 +162,7 @@
     }
 
   // Store the output in the provided variable.
-  this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+  this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
@@ -185,12 +189,12 @@
       std::string error = "Character with code ";
       error += args[cc];
       error += " does not exist.";
-      this->SetError(error.c_str());
+      this->SetError(error);
       return false;
       }
     }
   // Store the output in the provided variable.
-  this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+  this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
@@ -226,7 +230,7 @@
       {
       cmOStringStream err;
       err << "Unrecognized argument \"" << args[i] << "\"";
-      this->SetError(err.str().c_str());
+      this->SetError(err.str());
       return false;
       }
     }
@@ -236,7 +240,7 @@
   this->Makefile->ConfigureString(args[1], output, atOnly, escapeQuotes);
 
   // Store the output in the provided variable.
-  this->Makefile->AddDefinition(args[2].c_str(), output.c_str());
+  this->Makefile->AddDefinition(args[2], output.c_str());
 
   return true;
 }
@@ -282,7 +286,7 @@
     }
 
   std::string e = "sub-command REGEX does not recognize mode "+mode;
-  this->SetError(e.c_str());
+  this->SetError(e);
   return false;
 }
 
@@ -301,14 +305,14 @@
     input += args[i];
     }
 
-  this->ClearMatches(this->Makefile);
+  this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
   if(!re.compile(regex.c_str()))
     {
     std::string e =
       "sub-command REGEX, mode MATCH failed to compile regex \""+regex+"\".";
-    this->SetError(e.c_str());
+    this->SetError(e);
     return false;
     }
 
@@ -316,7 +320,7 @@
   std::string output;
   if(re.find(input.c_str()))
     {
-    this->StoreMatches(this->Makefile, re);
+    this->Makefile->StoreMatches(re);
     std::string::size_type l = re.start();
     std::string::size_type r = re.end();
     if(r-l == 0)
@@ -324,14 +328,14 @@
       std::string e =
         "sub-command REGEX, mode MATCH regex \""+regex+
         "\" matched an empty string.";
-      this->SetError(e.c_str());
+      this->SetError(e);
       return false;
       }
     output = input.substr(l, r-l);
     }
 
   // Store the output in the provided variable.
-  this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+  this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
@@ -350,7 +354,7 @@
     input += args[i];
     }
 
-  this->ClearMatches(this->Makefile);
+  this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
   if(!re.compile(regex.c_str()))
@@ -358,7 +362,7 @@
     std::string e =
       "sub-command REGEX, mode MATCHALL failed to compile regex \""+
       regex+"\".";
-    this->SetError(e.c_str());
+    this->SetError(e);
     return false;
     }
 
@@ -367,14 +371,14 @@
   const char* p = input.c_str();
   while(re.find(p))
     {
-    this->StoreMatches(this->Makefile, re);
+    this->Makefile->StoreMatches(re);
     std::string::size_type l = re.start();
     std::string::size_type r = re.end();
     if(r-l == 0)
       {
       std::string e = "sub-command REGEX, mode MATCHALL regex \""+
         regex+"\" matched an empty string.";
-      this->SetError(e.c_str());
+      this->SetError(e);
       return false;
       }
     if(output.length() > 0)
@@ -386,7 +390,7 @@
     }
 
   // Store the output in the provided variable.
-  this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+  this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
@@ -439,7 +443,7 @@
         std::string e = "sub-command REGEX, mode REPLACE: Unknown escape \"";
         e += replace.substr(r, 2);
         e += "\" in replace-expression.";
-        this->SetError(e.c_str());
+        this->SetError(e);
         return false;
         }
       r += 2;
@@ -454,7 +458,7 @@
     input += args[i];
     }
 
-  this->ClearMatches(this->Makefile);
+  this->Makefile->ClearMatches();
   // Compile the regular expression.
   cmsys::RegularExpression re;
   if(!re.compile(regex.c_str()))
@@ -462,7 +466,7 @@
     std::string e =
       "sub-command REGEX, mode REPLACE failed to compile regex \""+
       regex+"\".";
-    this->SetError(e.c_str());
+    this->SetError(e);
     return false;
     }
 
@@ -471,7 +475,7 @@
   std::string::size_type base = 0;
   while(re.find(input.c_str()+base))
     {
-    this->StoreMatches(this->Makefile, re);
+    this->Makefile->StoreMatches(re);
     std::string::size_type l2 = re.start();
     std::string::size_type r = re.end();
 
@@ -483,7 +487,7 @@
       {
       std::string e = "sub-command REGEX, mode REPLACE regex \""+
         regex+"\" matched an empty string.";
-      this->SetError(e.c_str());
+      this->SetError(e);
       return false;
       }
 
@@ -513,7 +517,7 @@
             "sub-command REGEX, mode REPLACE: replace expression \""+
             replace+"\" contains an out-of-range escape for regex \""+
             regex+"\".";
-          this->SetError(e.c_str());
+          this->SetError(e);
           return false;
           }
         }
@@ -527,43 +531,11 @@
   output += input.substr(base, input.length()-base);
 
   // Store the output in the provided variable.
-  this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+  this->Makefile->AddDefinition(outvar, output.c_str());
   return true;
 }
 
 //----------------------------------------------------------------------------
-void cmStringCommand::ClearMatches(cmMakefile* mf)
-{
-  for (unsigned int i=0; i<10; i++)
-    {
-    char name[128];
-    sprintf(name, "CMAKE_MATCH_%d", i);
-    const char* s = mf->GetDefinition(name);
-    if(s && *s != 0)
-      {
-      mf->AddDefinition(name, "");
-      mf->MarkVariableAsUsed(name);
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
-void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re)
-{
-  for (unsigned int i=0; i<10; i++)
-    {
-    std::string m = re.match(i);
-    if(m.size() > 0)
-      {
-      char name[128];
-      sprintf(name, "CMAKE_MATCH_%d", i);
-      mf->AddDefinition(name, re.match(i).c_str());
-      mf->MarkVariableAsUsed(name);
-      }
-    }
-}
-
-//----------------------------------------------------------------------------
 bool cmStringCommand::HandleFindCommand(std::vector<std::string> const&
                                            args)
 {
@@ -616,12 +588,12 @@
     {
     cmOStringStream s;
     s << pos;
-    this->Makefile->AddDefinition(outvar.c_str(), s.str().c_str());
+    this->Makefile->AddDefinition(outvar, s.str().c_str());
     return true;
     }
 
   // the character was not found, but this is not really an error
-  this->Makefile->AddDefinition(outvar.c_str(), "-1");
+  this->Makefile->AddDefinition(outvar, "-1");
   return true;
 }
 
@@ -643,7 +615,7 @@
       std::string e = "sub-command COMPARE, mode ";
       e += mode;
       e += " needs at least 5 arguments total to command.";
-      this->SetError(e.c_str());
+      this->SetError(e);
       return false;
       }
 
@@ -669,16 +641,16 @@
       }
     if(result)
       {
-      this->Makefile->AddDefinition(outvar.c_str(), "1");
+      this->Makefile->AddDefinition(outvar, "1");
       }
     else
       {
-      this->Makefile->AddDefinition(outvar.c_str(), "0");
+      this->Makefile->AddDefinition(outvar, "0");
       }
     return true;
     }
   std::string e = "sub-command COMPARE does not recognize mode "+mode;
-  this->SetError(e.c_str());
+  this->SetError(e);
   return false;
 }
 
@@ -705,7 +677,7 @@
   cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(),
                                     replaceExpression.c_str());
 
-  this->Makefile->AddDefinition(variableName.c_str(), input.c_str());
+  this->Makefile->AddDefinition(variableName, input.c_str());
   return true;
 }
 
@@ -731,7 +703,7 @@
     cmOStringStream ostr;
     ostr << "begin index: " << begin << " is out of range 0 - "
          << stringLength;
-    this->SetError(ostr.str().c_str());
+    this->SetError(ostr.str());
     return false;
     }
   int leftOverLength = intStringLength - begin;
@@ -740,11 +712,11 @@
     cmOStringStream ostr;
     ostr << "end index: " << end << " is out of range -1 - "
          << leftOverLength;
-    this->SetError(ostr.str().c_str());
+    this->SetError(ostr.str());
     return false;
     }
 
-  this->Makefile->AddDefinition(variableName.c_str(),
+  this->Makefile->AddDefinition(variableName,
                                 stringValue.substr(begin, end).c_str());
   return true;
 }
@@ -766,7 +738,7 @@
   char buffer[1024];
   sprintf(buffer, "%d", static_cast<int>(length));
 
-  this->Makefile->AddDefinition(variableName.c_str(), buffer);
+  this->Makefile->AddDefinition(variableName, buffer);
   return true;
 }
 
@@ -787,7 +759,7 @@
     value += args[i];
     }
 
-  this->Makefile->AddDefinition(variableName.c_str(), value.c_str());
+  this->Makefile->AddDefinition(variableName, value.c_str());
   return true;
 }
 
@@ -804,12 +776,33 @@
   const std::string& input = args[1];
   const std::string& variableName = args[2];
 
-  this->Makefile->AddDefinition(variableName.c_str(),
+  this->Makefile->AddDefinition(variableName,
                       cmSystemTools::MakeCidentifier(input.c_str()).c_str());
   return true;
 }
 
 //----------------------------------------------------------------------------
+bool cmStringCommand
+::HandleGenexStripCommand(std::vector<std::string> const& args)
+{
+  if(args.size() != 3)
+    {
+    this->SetError("sub-command GENEX_STRIP requires two arguments.");
+    return false;
+    }
+
+  const std::string& input = args[1];
+
+  std::string result = cmGeneratorExpression::Preprocess(input,
+                        cmGeneratorExpression::StripAllGeneratorExpressions);
+
+  const std::string& variableName = args[2];
+
+  this->Makefile->AddDefinition(variableName, result.c_str());
+  return true;
+}
+
+//----------------------------------------------------------------------------
 bool cmStringCommand::HandleStripCommand(
   std::vector<std::string> const& args)
 {
@@ -853,7 +846,7 @@
     outLength=endPos - startPos + 1;
     }
 
-  this->Makefile->AddDefinition(variableName.c_str(),
+  this->Makefile->AddDefinition(variableName,
     stringValue.substr(startPos, outLength).c_str());
   return true;
 }
@@ -937,7 +930,7 @@
     }
   result.push_back(0);
 
-  this->Makefile->AddDefinition(variableName.c_str(), &*result.begin());
+  this->Makefile->AddDefinition(variableName, &*result.begin());
   return true;
 }
 
@@ -977,14 +970,14 @@
       {
       std::string e = " TIMESTAMP sub-command does not recognize option " +
           args[argsIndex] + ".";
-      this->SetError(e.c_str());
+      this->SetError(e);
       return false;
       }
     }
 
   cmTimestamp timestamp;
   std::string result = timestamp.CurrentTime(formatString, utcFlag);
-  this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str());
+  this->Makefile->AddDefinition(outputVariable, result.c_str());
 
   return true;
 }
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index 66b48e6..8292e64 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -50,11 +50,9 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "string";}
+  virtual std::string GetName() const { return "string";}
 
   cmTypeMacro(cmStringCommand, cmCommand);
-  static void ClearMatches(cmMakefile* mf);
-  static void StoreMatches(cmMakefile* mf, cmsys::RegularExpression& re);
 protected:
   bool HandleConfigureCommand(std::vector<std::string> const& args);
   bool HandleAsciiCommand(std::vector<std::string> const& args);
@@ -75,6 +73,7 @@
   bool HandleFindCommand(std::vector<std::string> const& args);
   bool HandleTimestampCommand(std::vector<std::string> const& args);
   bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
+  bool HandleGenexStripCommand(std::vector<std::string> const& args);
 
   class RegexReplacement
   {
@@ -82,7 +81,7 @@
     RegexReplacement(const char* s): number(-1), value(s) {}
     RegexReplacement(const std::string& s): number(-1), value(s) {}
     RegexReplacement(int n): number(n), value() {}
-    RegexReplacement() {};
+    RegexReplacement() {}
     int number;
     std::string value;
   };
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index e497b46..cdde916 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -47,7 +47,7 @@
       std::string binPath =
         std::string(this->Makefile->GetCurrentOutputDirectory()) +
         "/" + i->c_str();
-      this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
+      this->Makefile->AddSubDirectory(srcPath, binPath,
                                   excludeFromAll, preorder, false);
       }
     // otherwise it is a full path
@@ -57,15 +57,15 @@
       // element from the source path and use that
       std::string binPath =
         std::string(this->Makefile->GetCurrentOutputDirectory()) +
-        "/" + cmSystemTools::GetFilenameName(i->c_str());
-      this->Makefile->AddSubDirectory(i->c_str(), binPath.c_str(),
+        "/" + cmSystemTools::GetFilenameName(*i);
+      this->Makefile->AddSubDirectory(*i, binPath,
                                   excludeFromAll, preorder, false);
       }
     else
       {
       std::string error = "Incorrect SUBDIRS command. Directory: ";
       error += *i + " does not exist.";
-      this->SetError(error.c_str());
+      this->SetError(error);
       res = false;
       }
     }
diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h
index 8be8335..6addd8f 100644
--- a/Source/cmSubdirCommand.h
+++ b/Source/cmSubdirCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "subdirs";}
+  virtual std::string GetName() const { return "subdirs";}
 
   /** This command is kept for compatibility with older CMake versions. */
   virtual bool IsDiscouraged() const
diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h
index f78cfb7..75a5685 100644
--- a/Source/cmSubdirDependsCommand.h
+++ b/Source/cmSubdirDependsCommand.h
@@ -20,7 +20,7 @@
   virtual cmCommand* Clone() { return new cmSubdirDependsCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
-  virtual const char* GetName() const { return "subdir_depends";}
+  virtual std::string GetName() const { return "subdir_depends";}
   virtual bool IsDiscouraged() const { return true; }
   cmTypeMacro(cmSubdirDependsCommand, cmCommand);
 };
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index c7acfd0..2e417cb 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -121,13 +121,14 @@
 bool cmSystemTools::s_DisableMessages = false;
 bool cmSystemTools::s_ForceUnixPaths = false;
 
-void (*cmSystemTools::s_ErrorCallback)(const char*, const char*,
-                                       bool&, void*);
-void (*cmSystemTools::s_StdoutCallback)(const char*, int len, void*);
-void* cmSystemTools::s_ErrorCallbackClientData = 0;
-void* cmSystemTools::s_StdoutCallbackClientData = 0;
-bool (*cmSystemTools::s_InterruptCallback)(void*);
-void* cmSystemTools::s_InterruptCallbackClientData = 0;
+cmSystemTools::MessageCallback cmSystemTools::s_MessageCallback;
+cmSystemTools::OutputCallback cmSystemTools::s_StdoutCallback;
+cmSystemTools::OutputCallback cmSystemTools::s_StderrCallback;
+cmSystemTools::InterruptCallback cmSystemTools::s_InterruptCallback;
+void* cmSystemTools::s_MessageCallbackClientData;
+void* cmSystemTools::s_StdoutCallbackClientData;
+void* cmSystemTools::s_StderrCallbackClientData;
+void* cmSystemTools::s_InterruptCallbackClientData;
 
 // replace replace with with as many times as it shows up in source.
 // write the result into source.
@@ -179,10 +180,11 @@
 }
 #endif
 
-std::string cmSystemTools::EscapeQuotes(const char* str)
+std::string cmSystemTools::EscapeQuotes(const std::string& str)
 {
-  std::string result = "";
-  for(const char* ch = str; *ch != '\0'; ++ch)
+  std::string result;
+  result.reserve(str.size());
+  for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
     {
     if(*ch == '"')
       {
@@ -253,39 +255,48 @@
   return false;
 }
 
-void cmSystemTools::SetErrorCallback(ErrorCallback f, void* clientData)
+void cmSystemTools::SetMessageCallback(MessageCallback f, void* clientData)
 {
-  s_ErrorCallback = f;
-  s_ErrorCallbackClientData = clientData;
+  s_MessageCallback = f;
+  s_MessageCallbackClientData = clientData;
 }
 
-void cmSystemTools::SetStdoutCallback(StdoutCallback f, void* clientData)
+void cmSystemTools::SetStdoutCallback(OutputCallback f, void* clientData)
 {
   s_StdoutCallback = f;
   s_StdoutCallbackClientData = clientData;
 }
 
+void cmSystemTools::SetStderrCallback(OutputCallback f, void* clientData)
+{
+  s_StderrCallback = f;
+  s_StderrCallbackClientData = clientData;
+}
+
 void cmSystemTools::Stdout(const char* s)
 {
-  if(s_StdoutCallback)
+  cmSystemTools::Stdout(s, strlen(s));
+}
+
+void cmSystemTools::Stderr(const char* s)
+{
+  cmSystemTools::Stderr(s, strlen(s));
+}
+
+void cmSystemTools::Stderr(const char* s, size_t length)
+{
+  if(s_StderrCallback)
     {
-    (*s_StdoutCallback)(s, static_cast<int>(strlen(s)),
-                        s_StdoutCallbackClientData);
+    (*s_StderrCallback)(s, length, s_StderrCallbackClientData);
     }
   else
     {
-    std::cout << s;
-    std::cout.flush();
+    std::cerr.write(s, length);
+    std::cerr.flush();
     }
 }
 
-void cmSystemTools::Stderr(const char* s, int length)
-{
-    std::cerr.write(s, length);
-    std::cerr.flush();
-}
-
-void cmSystemTools::Stdout(const char* s, int length)
+void cmSystemTools::Stdout(const char* s, size_t length)
 {
   if(s_StdoutCallback)
     {
@@ -304,10 +315,10 @@
     {
     return;
     }
-  if(s_ErrorCallback)
+  if(s_MessageCallback)
     {
-    (*s_ErrorCallback)(m1, title, s_DisableMessages,
-                       s_ErrorCallbackClientData);
+    (*s_MessageCallback)(m1, title, s_DisableMessages,
+                         s_MessageCallbackClientData);
     return;
     }
   else
@@ -476,13 +487,6 @@
       args.push_back(*arg);
       }
     }
-  void Store(std::vector<cmStdString>& args) const
-    {
-    for(char** arg = this->ArgV; arg && *arg; ++arg)
-      {
-      args.push_back(*arg);
-      }
-    }
 };
 
 //----------------------------------------------------------------------------
@@ -494,15 +498,6 @@
   argv.Store(args);
 }
 
-//----------------------------------------------------------------------------
-void cmSystemTools::ParseUnixCommandLine(const char* command,
-                                         std::vector<cmStdString>& args)
-{
-  // Invoke the underlying parser.
-  cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0);
-  argv.Store(args);
-}
-
 std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg,
                                                       int shell_flags)
 {
@@ -522,9 +517,9 @@
   return result;
 }
 
-std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command)
+std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
 {
-  std::vector<cmStdString> args;
+  std::vector<std::string> args;
   std::string arg;
 
   bool win_path = false;
@@ -605,22 +600,6 @@
 }
 
 
-bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
-                                     std::string* output ,
-                                     int* retVal , const char* dir ,
-                                     OutputOption outputflag ,
-                                     double timeout )
-{
-  std::vector<std::string> cmd;
-  for(std::vector<cmStdString>::const_iterator i = command.begin();
-      i != command.end(); ++i)
-    {
-    cmd.push_back(*i);
-    }
-  return cmSystemTools::RunSingleCommand(cmd, output, retVal, dir,
-                                         outputflag, timeout);
-}
-
 bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
                                      std::string* output ,
                                      int* retVal , const char* dir ,
@@ -780,7 +759,7 @@
     outputflag = OUTPUT_NONE;
     }
 
-  std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+  std::vector<std::string> args = cmSystemTools::ParseArguments(command);
 
   if(args.size() < 1)
     {
@@ -946,7 +925,7 @@
 #endif
 }
 
-bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out)
+bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   cmCryptoHashMD5 md5;
@@ -961,7 +940,7 @@
 #endif
 }
 
-std::string cmSystemTools::ComputeStringMD5(const char* input)
+std::string cmSystemTools::ComputeStringMD5(const std::string& input)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   cmCryptoHashMD5 md5;
@@ -973,13 +952,14 @@
 #endif
 }
 
-void cmSystemTools::Glob(const char *directory, const char *regexp,
+void cmSystemTools::Glob(const std::string& directory,
+                         const std::string& regexp,
                          std::vector<std::string>& files)
 {
   cmsys::Directory d;
-  cmsys::RegularExpression reg(regexp);
+  cmsys::RegularExpression reg(regexp.c_str());
 
-  if (d.Load(directory))
+  if (d.Load(directory.c_str()))
     {
     size_t numf;
         unsigned int i;
@@ -996,14 +976,13 @@
 }
 
 
-void cmSystemTools::GlobDirs(const char *fullPath,
+void cmSystemTools::GlobDirs(const std::string& path,
                              std::vector<std::string>& files)
 {
-  std::string path = fullPath;
   std::string::size_type pos = path.find("/*");
   if(pos == std::string::npos)
     {
-    files.push_back(fullPath);
+    files.push_back(path);
     return;
     }
   std::string startPath = path.substr(0, pos);
@@ -1023,7 +1002,7 @@
         if(cmSystemTools::FileIsDirectory(fname.c_str()))
           {
           fname += finishPath;
-          cmSystemTools::GlobDirs(fname.c_str(), files);
+          cmSystemTools::GlobDirs(fname, files);
           }
         }
       }
@@ -1046,7 +1025,7 @@
                                        bool emptyArgs)
 {
   // If argument is empty, it is an empty list.
-  if(arg.length() == 0 && !emptyArgs)
+  if(!emptyArgs && arg.empty())
     {
     return;
     }
@@ -1056,10 +1035,11 @@
     newargs.push_back(arg);
     return;
     }
-  std::vector<char> newArgVec;
+  std::string newArg;
+  const char *last = arg.c_str();
   // Break the string at non-escaped semicolons not nested in [].
   int squareNesting = 0;
-  for(const char* c = arg.c_str(); *c; ++c)
+  for(const char* c = last; *c; ++c)
     {
     switch(*c)
       {
@@ -1067,34 +1047,21 @@
         {
         // We only want to allow escaping of semicolons.  Other
         // escapes should not be processed here.
-        ++c;
-        if(*c == ';')
+        const char* next = c + 1;
+        if(*next == ';')
           {
-          newArgVec.push_back(*c);
-          }
-        else
-          {
-          newArgVec.push_back('\\');
-          if(*c)
-            {
-            newArgVec.push_back(*c);
-            }
-          else
-            {
-            // Terminate the loop properly.
-            --c;
-            }
+          newArg.append(last, c - last);
+          // Skip over the escape character
+          last = c = next;
           }
         } break;
       case '[':
         {
         ++squareNesting;
-        newArgVec.push_back(*c);
         } break;
       case ']':
         {
         --squareNesting;
-        newArgVec.push_back(*c);
         } break;
       case ';':
         {
@@ -1102,36 +1069,33 @@
         // brackets.
         if(squareNesting == 0)
           {
-          if ( newArgVec.size() || emptyArgs )
+          newArg.append(last, c - last);
+          // Skip over the semicolon
+          last = c + 1;
+          if ( !newArg.empty() || emptyArgs )
             {
             // Add the last argument if the string is not empty.
-            newArgVec.push_back(0);
-            newargs.push_back(&*newArgVec.begin());
-            newArgVec.clear();
+            newargs.push_back(newArg);
+            newArg = "";
             }
           }
-        else
-          {
-          newArgVec.push_back(*c);
-          }
         } break;
       default:
         {
         // Just append this character.
-        newArgVec.push_back(*c);
         } break;
       }
     }
-  if ( newArgVec.size() || emptyArgs )
+  newArg.append(last);
+  if ( !newArg.empty() || emptyArgs )
     {
     // Add the last argument if the string is not empty.
-    newArgVec.push_back(0);
-    newargs.push_back(&*newArgVec.begin());
+    newargs.push_back(newArg);
     }
 }
 
-bool cmSystemTools::SimpleGlob(const cmStdString& glob,
-                               std::vector<cmStdString>& files,
+bool cmSystemTools::SimpleGlob(const std::string& glob,
+                               std::vector<std::string>& files,
                                int type /* = 0 */)
 {
   files.clear();
@@ -1249,7 +1213,7 @@
   return cmSystemTools::UNKNOWN_FILE_FORMAT;
 }
 
-bool cmSystemTools::Split(const char* s, std::vector<cmStdString>& l)
+bool cmSystemTools::Split(const char* s, std::vector<std::string>& l)
 {
   std::vector<std::string> temp;
   bool res = Superclass::Split(s, temp);
@@ -1461,7 +1425,7 @@
 }
 
 bool cmSystemTools::CreateTar(const char* outFileName,
-                              const std::vector<cmStdString>& files,
+                              const std::vector<std::string>& files,
                               bool gzip, bool bzip2, bool verbose)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -1481,7 +1445,7 @@
                            cmArchiveWrite::CompressNone)),
                            cmArchiveWrite::TypeTAR);
   a.SetVerbose(verbose);
-  for(std::vector<cmStdString>::const_iterator i = files.begin();
+  for(std::vector<std::string>::const_iterator i = files.begin();
       i != files.end(); ++i)
     {
     std::string path = *i;
@@ -1664,7 +1628,9 @@
       return (r);
       }
     }
-  return r;
+#if !defined(__clang__) && !defined(__HP_aCC)
+  return r; /* this should not happen but it quiets some compilers */
+#endif
 }
 
 bool extract_tar(const char* outFileName, bool verbose,
@@ -2153,7 +2119,7 @@
     // remove symlinks
     exe = cmSystemTools::GetRealPath(exe.c_str());
     exe_dir =
-      cmSystemTools::GetFilenamePath(exe.c_str());
+      cmSystemTools::GetFilenamePath(exe);
     }
   else
     {
@@ -2333,10 +2299,10 @@
 bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
                                        std::string& soname)
 {
-  std::vector<cmStdString> cmds;
+  std::vector<std::string> cmds;
   cmds.push_back("otool");
   cmds.push_back("-D");
-  cmds.push_back(fullPath.c_str());
+  cmds.push_back(fullPath);
 
   std::string output;
   if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE))
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 4a5d298..4455dd1 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -47,7 +47,7 @@
                                    KeyWOW64 view = KeyWOW64_Default);
 
   ///! Escape quotes in a string.
-  static std::string EscapeQuotes(const char* str);
+  static std::string EscapeQuotes(const std::string& str);
 
   /** Map help document name to file name.  */
   static std::string HelpFileName(std::string);
@@ -57,14 +57,14 @@
    */
   static std::string TrimWhitespace(const std::string& s);
 
-  typedef  void (*ErrorCallback)(const char*, const char*, bool&, void*);
+  typedef void (*MessageCallback)(const char*, const char*, bool&, void*);
   /**
    *  Set the function used by GUIs to display error messages
    *  Function gets passed: message as a const char*,
    *  title as a const char*, and a reference to bool that when
    *  set to false, will disable furthur messages (cancel).
    */
-  static void SetErrorCallback(ErrorCallback f, void* clientData=0);
+  static void SetMessageCallback(MessageCallback f, void* clientData=0);
 
   /**
    * Display an error message.
@@ -77,14 +77,17 @@
    */
   static void Message(const char* m, const char* title=0);
 
+  typedef void (*OutputCallback)(const char*, size_t length, void*);
+
   ///! Send a string to stdout
   static void Stdout(const char* s);
-  static void Stdout(const char* s, int length);
-  typedef  void (*StdoutCallback)(const char*, int length, void*);
-  static void SetStdoutCallback(StdoutCallback, void* clientData=0);
+  static void Stdout(const char* s, size_t length);
+  static void SetStdoutCallback(OutputCallback, void* clientData=0);
 
-  ///! Send a string to stderr. Stdout callbacks will not be invoced.
-  static void Stderr(const char* s, int length);
+  ///! Send a string to stderr
+  static void Stderr(const char* s);
+  static void Stderr(const char* s, size_t length);
+  static void SetStderrCallback(OutputCallback, void* clientData=0);
 
 
   typedef bool (*InterruptCallback)(void*);
@@ -158,9 +161,10 @@
   static std::string FileExistsInParentDirectories(const char* fname,
     const char* directory, const char* toplevel);
 
-  static void Glob(const char *directory, const char *regexp,
+  static void Glob(const std::string& directory, const std::string& regexp,
                    std::vector<std::string>& files);
-  static void GlobDirs(const char *fullPath, std::vector<std::string>& files);
+  static void GlobDirs(const std::string& fullPath,
+                       std::vector<std::string>& files);
 
   /**
    * Try to find a list of files that match the "simple" globbing
@@ -171,8 +175,8 @@
    * want to find. 0 means all files, -1 means directories, 1 means
    * files only. This method returns true if search was succesfull.
    */
-  static bool SimpleGlob(const cmStdString& glob,
-                         std::vector<cmStdString>& files,
+  static bool SimpleGlob(const std::string& glob,
+                         std::vector<std::string>& files,
                          int type = 0);
 
   ///! Copy a file.
@@ -185,10 +189,10 @@
   static bool RenameFile(const char* oldname, const char* newname);
 
   ///! Compute the md5sum of a file
-  static bool ComputeFileMD5(const char* source, char* md5out);
+  static bool ComputeFileMD5(const std::string& source, char* md5out);
 
   /** Compute the md5sum of a string.  */
-  static std::string ComputeStringMD5(const char* input);
+  static std::string ComputeStringMD5(const std::string& input);
 
   /**
    * Run a single executable command
@@ -233,18 +237,13 @@
                                int* retVal = 0, const char* dir = 0,
                                OutputOption outputflag = OUTPUT_MERGE,
                                double timeout = 0.0);
-  static bool RunSingleCommand(std::vector<cmStdString> const& command,
-                               std::string* output = 0,
-                               int* retVal = 0, const char* dir = 0,
-                               OutputOption outputflag = OUTPUT_MERGE,
-                               double timeout = 0.0);
 
   static std::string PrintSingleCommand(std::vector<std::string> const&);
 
   /**
    * Parse arguments out of a single string command
    */
-  static std::vector<cmStdString> ParseArguments(const char* command);
+  static std::vector<std::string> ParseArguments(const char* command);
 
   /** Parse arguments out of a windows command line string.  */
   static void ParseWindowsCommandLine(const char* command,
@@ -253,8 +252,6 @@
   /** Parse arguments out of a unix command line string.  */
   static void ParseUnixCommandLine(const char* command,
                                    std::vector<std::string>& args);
-  static void ParseUnixCommandLine(const char* command,
-                                   std::vector<cmStdString>& args);
 
   /** Compute an escaped version of the given argument for use in a
       windows shell.  See kwsys/System.h.in for details.  */
@@ -320,7 +317,7 @@
 
   /** Split a string on its newlines into multiple lines.  Returns
       false only if the last line stored had no newline.  */
-  static bool Split(const char* s, std::vector<cmStdString>& l);
+  static bool Split(const char* s, std::vector<std::string>& l);
   static void SetForceUnixPaths(bool v)
     {
       s_ForceUnixPaths = v;
@@ -389,7 +386,7 @@
   static bool ListTar(const char* outFileName,
                       bool gzip, bool verbose);
   static bool CreateTar(const char* outFileName,
-                        const std::vector<cmStdString>& files, bool gzip,
+                        const std::vector<std::string>& files, bool gzip,
                         bool bzip2, bool verbose);
   static bool ExtractTar(const char* inFileName, bool gzip,
                          bool verbose);
@@ -476,11 +473,13 @@
   static bool s_FatalErrorOccured;
   static bool s_DisableMessages;
   static bool s_DisableRunCommandOutput;
-  static ErrorCallback s_ErrorCallback;
-  static StdoutCallback s_StdoutCallback;
+  static MessageCallback s_MessageCallback;
+  static OutputCallback s_StdoutCallback;
+  static OutputCallback s_StderrCallback;
   static InterruptCallback s_InterruptCallback;
-  static void* s_ErrorCallbackClientData;
+  static void* s_MessageCallbackClientData;
   static void* s_StdoutCallbackClientData;
+  static void* s_StderrCallbackClientData;
   static void* s_InterruptCallbackClientData;
 };
 
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 63c5908..59cc14c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -71,6 +71,12 @@
   cmTarget::LinkInterface LinkInterface;
 };
 
+//----------------------------------------------------------------------------
+struct cmTarget::CompileInfo
+{
+  std::string CompilePdbDir;
+};
+
 struct TargetConfigPair : public std::pair<cmTarget const* , std::string> {
   TargetConfigPair(cmTarget const* tgt, const std::string &config)
     : std::pair<cmTarget const* , std::string>(tgt, config) {}
@@ -81,19 +87,16 @@
 {
 public:
   cmTargetInternals()
+    : Backtrace(NULL)
     {
     this->PolicyWarnedCMP0022 = false;
-    this->SourceFileFlagsConstructed = false;
     }
   cmTargetInternals(cmTargetInternals const&)
+    : Backtrace(NULL)
     {
     this->PolicyWarnedCMP0022 = false;
-    this->SourceFileFlagsConstructed = false;
     }
   ~cmTargetInternals();
-  typedef cmTarget::SourceFileFlags SourceFileFlags;
-  mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
-  mutable bool SourceFileFlagsConstructed;
 
   // The backtrace when the target was created.
   cmListFileBacktrace Backtrace;
@@ -101,21 +104,33 @@
   // Cache link interface computation from each configuration.
   struct OptionalLinkInterface: public cmTarget::LinkInterface
   {
-    OptionalLinkInterface(): Exists(false) {}
+    OptionalLinkInterface():
+      Exists(false), Complete(false), ExplicitLibraries(0) {}
     bool Exists;
+    bool Complete;
+    const char* ExplicitLibraries;
   };
+  void ComputeLinkInterface(cmTarget const* thisTarget,
+                            const std::string& config,
+                            OptionalLinkInterface& iface,
+                            cmTarget const* head,
+                            const char *explicitLibraries) const;
+
   typedef std::map<TargetConfigPair, OptionalLinkInterface>
                                                           LinkInterfaceMapType;
   LinkInterfaceMapType LinkInterfaceMap;
   bool PolicyWarnedCMP0022;
 
-  typedef std::map<cmStdString, cmTarget::OutputInfo> OutputInfoMapType;
+  typedef std::map<std::string, cmTarget::OutputInfo> OutputInfoMapType;
   OutputInfoMapType OutputInfoMap;
 
   typedef std::map<TargetConfigPair, cmTarget::ImportInfo>
                                                             ImportInfoMapType;
   ImportInfoMapType ImportInfoMap;
 
+  typedef std::map<std::string, cmTarget::CompileInfo> CompileInfoMapType;
+  CompileInfoMapType CompileInfoMap;
+
   // Cache link implementation computation from each configuration.
   typedef std::map<TargetConfigPair,
                    cmTarget::LinkImplementation> LinkImplMapType;
@@ -125,6 +140,10 @@
                                                           LinkClosureMapType;
   LinkClosureMapType LinkClosureMap;
 
+  typedef std::map<TargetConfigPair, std::vector<cmSourceFile*> >
+                                                          SourceFilesMapType;
+  SourceFilesMapType SourceFilesMap;
+
   struct TargetPropertyEntry {
     TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
       const std::string &targetName = std::string())
@@ -136,7 +155,9 @@
   };
   std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
   std::vector<TargetPropertyEntry*> CompileOptionsEntries;
+  std::vector<TargetPropertyEntry*> CompileFeaturesEntries;
   std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
+  std::vector<TargetPropertyEntry*> SourceEntries;
   std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries;
 
   mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
@@ -145,10 +166,16 @@
                                 CachedLinkInterfaceCompileOptionsEntries;
   mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
                                 CachedLinkInterfaceCompileDefinitionsEntries;
+  mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
+                                CachedLinkInterfaceSourcesEntries;
+  mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
+                                CachedLinkInterfaceCompileFeaturesEntries;
 
   mutable std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
   mutable std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
   mutable std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone;
+  mutable std::map<std::string, bool> CacheLinkInterfaceSourcesDone;
+  mutable std::map<std::string, bool> CacheLinkInterfaceCompileFeaturesDone;
 };
 
 //----------------------------------------------------------------------------
@@ -183,7 +210,9 @@
 {
   deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
   deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
+  deleteAndClear(this->CachedLinkInterfaceCompileFeaturesEntries);
   deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries);
+  deleteAndClear(this->CachedLinkInterfaceSourcesEntries);
 }
 
 //----------------------------------------------------------------------------
@@ -205,7 +234,10 @@
   this->BuildInterfaceIncludesAppended = false;
   this->DebugIncludesDone = false;
   this->DebugCompileOptionsDone = false;
+  this->DebugCompileFeaturesDone = false;
   this->DebugCompileDefinitionsDone = false;
+  this->DebugSourcesDone = false;
+  this->LinkImplementationLanguageIsContextDependent = true;
 }
 
 //----------------------------------------------------------------------------
@@ -222,7 +254,7 @@
      "", "", true);
 }
 
-void cmTarget::SetType(TargetType type, const char* name)
+void cmTarget::SetType(TargetType type, const std::string& name)
 {
   this->Name = name;
   // only add dependency information for library targets
@@ -267,6 +299,7 @@
     this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0);
     this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0);
     this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0);
+    this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", 0);
     this->SetPropertyDefault("Fortran_FORMAT", 0);
     this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0);
     this->SetPropertyDefault("GNUtoMS", 0);
@@ -283,6 +316,12 @@
     this->SetPropertyDefault("MACOSX_BUNDLE", 0);
     this->SetPropertyDefault("MACOSX_RPATH", 0);
     this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0);
+    this->SetPropertyDefault("C_STANDARD", 0);
+    this->SetPropertyDefault("C_STANDARD_REQUIRED", 0);
+    this->SetPropertyDefault("C_EXTENSIONS", 0);
+    this->SetPropertyDefault("CXX_STANDARD", 0);
+    this->SetPropertyDefault("CXX_STANDARD_REQUIRED", 0);
+    this->SetPropertyDefault("CXX_EXTENSIONS", 0);
     }
 
   // Collect the set of configuration types.
@@ -295,6 +334,7 @@
     "LIBRARY_OUTPUT_DIRECTORY_",
     "RUNTIME_OUTPUT_DIRECTORY_",
     "PDB_OUTPUT_DIRECTORY_",
+    "COMPILE_PDB_OUTPUT_DIRECTORY_",
     "MAP_IMPORTED_CONFIG_",
     0};
   for(std::vector<std::string>::iterator ci = configNames.begin();
@@ -310,7 +350,7 @@
         }
       std::string property = *p;
       property += configUpper;
-      this->SetPropertyDefault(property.c_str(), 0);
+      this->SetPropertyDefault(property, 0);
       }
 
     // Initialize per-configuration name postfix property from the
@@ -323,12 +363,12 @@
       {
       std::string property = cmSystemTools::UpperCase(*ci);
       property += "_POSTFIX";
-      this->SetPropertyDefault(property.c_str(), 0);
+      this->SetPropertyDefault(property, 0);
       }
     }
 
   // Save the backtrace of target construction.
-  this->Makefile->GetBacktrace(this->Internal->Backtrace);
+  this->Internal->Backtrace = this->Makefile->GetBacktrace();
 
   if (!this->IsImported())
     {
@@ -342,10 +382,10 @@
       {
       this->InsertInclude(*it);
       }
-    const std::set<cmStdString> parentSystemIncludes =
+    const std::set<std::string> parentSystemIncludes =
                                 this->Makefile->GetSystemIncludeDirectories();
 
-    for (std::set<cmStdString>::const_iterator it
+    for (std::set<std::string>::const_iterator it
           = parentSystemIncludes.begin();
           it != parentSystemIncludes.end(); ++it)
       {
@@ -401,18 +441,19 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::AddUtility(const char *u, cmMakefile *makefile)
+void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
 {
   if(this->Utilities.insert(u).second && makefile)
     {
-    makefile->GetBacktrace(UtilityBacktraces[u]);
+    UtilityBacktraces.insert(std::make_pair(u, makefile->GetBacktrace()));
     }
 }
 
 //----------------------------------------------------------------------------
-cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const
+cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
+    const std::string& u) const
 {
-  std::map<cmStdString, cmListFileBacktrace>::const_iterator i =
+  std::map<std::string, cmListFileBacktrace>::const_iterator i =
     this->UtilityBacktraces.find(u);
   if(i == this->UtilityBacktraces.end()) return 0;
 
@@ -435,6 +476,7 @@
 //----------------------------------------------------------------------------
 void cmTarget::ClearLinkMaps()
 {
+  this->LinkImplementationLanguageIsContextDependent = true;
   this->Internal->LinkImplMap.clear();
   this->Internal->LinkInterfaceMap.clear();
   this->Internal->LinkClosureMap.clear();
@@ -526,21 +568,283 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::FindSourceFiles()
+static bool processSources(cmTarget const* tgt,
+      const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
+      std::vector<std::string> &srcs,
+      std::set<std::string> &uniqueSrcs,
+      cmGeneratorExpressionDAGChecker *dagChecker,
+      cmTarget const* head,
+      std::string const& config, bool debugSources)
 {
-  for(std::vector<cmSourceFile*>::const_iterator
-        si = this->SourceFiles.begin();
-      si != this->SourceFiles.end(); ++si)
+  cmMakefile *mf = tgt->GetMakefile();
+
+  bool contextDependent = false;
+
+  for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
+      it = entries.begin(), end = entries.end(); it != end; ++it)
     {
-    std::string e;
-    if((*si)->GetFullPath(&e).empty())
+    bool cacheSources = false;
+    std::vector<std::string> entrySources = (*it)->CachedEntries;
+    if(entrySources.empty())
       {
-      if(!e.empty())
+      cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
+                                                config,
+                                                false,
+                                                head ? head : tgt,
+                                                tgt,
+                                                dagChecker),
+                                      entrySources);
+
+      if ((*it)->ge->GetHadContextSensitiveCondition())
         {
-        cmake* cm = this->Makefile->GetCMakeInstance();
-        cm->IssueMessage(cmake::FATAL_ERROR, e,
-                         this->GetBacktrace());
+        contextDependent = true;
         }
+      else if (mf->IsGeneratingBuildSystem())
+        {
+        cacheSources = true;
+        }
+
+      for(std::vector<std::string>::iterator i = entrySources.begin();
+          i != entrySources.end(); ++i)
+        {
+        std::string& src = *i;
+
+        cmSourceFile* sf = mf->GetOrCreateSource(src);
+        std::string e;
+        src = sf->GetFullPath(&e);
+        if(src.empty())
+          {
+          if(!e.empty())
+            {
+            cmake* cm = mf->GetCMakeInstance();
+            cm->IssueMessage(cmake::FATAL_ERROR, e,
+                            tgt->GetBacktrace());
+            }
+          return contextDependent;
+          }
+        }
+      if (cacheSources)
+        {
+        (*it)->CachedEntries = entrySources;
+        }
+      }
+    std::string usedSources;
+    for(std::vector<std::string>::iterator
+          li = entrySources.begin(); li != entrySources.end(); ++li)
+      {
+      std::string src = *li;
+
+      if(uniqueSrcs.insert(src).second)
+        {
+        srcs.push_back(src);
+        if (debugSources)
+          {
+          usedSources += " * " + src + "\n";
+          }
+        }
+      }
+    if (!usedSources.empty())
+      {
+      mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
+                            std::string("Used sources for target ")
+                            + tgt->GetName() + ":\n"
+                            + usedSources, (*it)->ge->GetBacktrace());
+      }
+    }
+  return contextDependent;
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetSourceFiles(std::vector<std::string> &files,
+                              const std::string& config,
+                              cmTarget const* head) const
+{
+  assert(this->GetType() != INTERFACE_LIBRARY);
+
+  if (this->Makefile->GetGeneratorTargets().empty())
+    {
+    // At configure-time, this method can be called as part of getting the
+    // LOCATION property or to export() a file to be include()d.  However
+    // there is no cmGeneratorTarget at configure-time, so search the SOURCES
+    // for TARGET_OBJECTS instead for backwards compatibility with OLD
+    // behavior of CMP0024 and CMP0026 only.
+
+    typedef cmTargetInternals::TargetPropertyEntry
+                                TargetPropertyEntry;
+    for(std::vector<TargetPropertyEntry*>::const_iterator
+          i = this->Internal->SourceEntries.begin();
+        i != this->Internal->SourceEntries.end(); ++i)
+      {
+      std::string entry = (*i)->ge->GetInput();
+
+      std::vector<std::string> items;
+      cmSystemTools::ExpandListArgument(entry, items);
+      for (std::vector<std::string>::const_iterator
+          li = items.begin(); li != items.end(); ++li)
+        {
+        if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
+            (*li)[li->size() - 1] == '>')
+          {
+          continue;
+          }
+        files.push_back(*li);
+        }
+      }
+    return;
+    }
+
+  std::vector<std::string> debugProperties;
+  const char *debugProp =
+              this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+  if (debugProp)
+    {
+    cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+    }
+
+  bool debugSources = !this->DebugSourcesDone
+                    && std::find(debugProperties.begin(),
+                                 debugProperties.end(),
+                                 "SOURCES")
+                        != debugProperties.end();
+
+  if (this->Makefile->IsGeneratingBuildSystem())
+    {
+    this->DebugSourcesDone = true;
+    }
+
+  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+                                             "SOURCES", 0, 0);
+
+  std::set<std::string> uniqueSrcs;
+  bool contextDependentDirectSources = processSources(this,
+                 this->Internal->SourceEntries,
+                 files,
+                 uniqueSrcs,
+                 &dagChecker,
+                 head,
+                 config,
+                 debugSources);
+
+  if (!this->Internal->CacheLinkInterfaceSourcesDone[config])
+    {
+    for (std::vector<cmValueWithOrigin>::const_iterator
+        it = this->Internal->LinkImplementationPropertyEntries.begin(),
+        end = this->Internal->LinkImplementationPropertyEntries.end();
+        it != end; ++it)
+      {
+      if (!cmGeneratorExpression::IsValidTargetName(it->Value)
+          && cmGeneratorExpression::Find(it->Value) == std::string::npos)
+        {
+        continue;
+        }
+      {
+      cmGeneratorExpression ge;
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+                                                        ge.Parse(it->Value);
+      std::string targetResult = cge->Evaluate(this->Makefile, config,
+                                        false, this, 0, &dagChecker);
+      if (!this->Makefile->FindTargetToUse(targetResult))
+        {
+        continue;
+        }
+      }
+      std::string sourceGenex = "$<TARGET_PROPERTY:" +
+                              it->Value + ",INTERFACE_SOURCES>";
+      if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
+        {
+        // Because it->Value is a generator expression, ensure that it
+        // evaluates to the non-empty string before being used in the
+        // TARGET_PROPERTY expression.
+        sourceGenex = "$<$<BOOL:" + it->Value + ">:" + sourceGenex + ">";
+        }
+      cmGeneratorExpression ge(&it->Backtrace);
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
+                                                                sourceGenex);
+
+      this->Internal
+        ->CachedLinkInterfaceSourcesEntries[config].push_back(
+                        new cmTargetInternals::TargetPropertyEntry(cge,
+                                                              it->Value));
+      }
+    }
+
+    std::vector<std::string>::size_type numFilesBefore = files.size();
+    bool contextDependentInterfaceSources = processSources(this,
+    this->Internal->CachedLinkInterfaceSourcesEntries[config],
+                            files,
+                            uniqueSrcs,
+                            &dagChecker,
+                            head,
+                            config,
+                            debugSources);
+
+  if (!contextDependentDirectSources
+      && !(contextDependentInterfaceSources && numFilesBefore < files.size()))
+    {
+    this->LinkImplementationLanguageIsContextDependent = false;
+    }
+
+  if (!this->Makefile->IsGeneratingBuildSystem())
+    {
+    deleteAndClear(this->Internal->CachedLinkInterfaceSourcesEntries);
+    }
+  else
+    {
+    this->Internal->CacheLinkInterfaceSourcesDone[config] = true;
+    }
+}
+
+//----------------------------------------------------------------------------
+bool
+cmTarget::GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const
+{
+  std::vector<std::string> configs;
+  this->Makefile->GetConfigurations(configs);
+  if (configs.empty())
+    {
+    configs.push_back("");
+    }
+
+  std::vector<std::string>::const_iterator it = configs.begin();
+  const std::string& firstConfig = *it;
+  this->GetSourceFiles(files, firstConfig);
+
+  for ( ; it != configs.end(); ++it)
+    {
+    std::vector<cmSourceFile*> configFiles;
+    this->GetSourceFiles(configFiles, *it);
+    if (configFiles != files)
+      {
+      std::string firstConfigFiles;
+      const char* sep = "";
+      for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
+           fi != files.end(); ++fi)
+        {
+        firstConfigFiles += sep;
+        firstConfigFiles += (*fi)->GetFullPath();
+        sep = "\n  ";
+        }
+
+      std::string thisConfigFiles;
+      sep = "";
+      for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
+           fi != configFiles.end(); ++fi)
+        {
+        thisConfigFiles += sep;
+        thisConfigFiles += (*fi)->GetFullPath();
+        sep = "\n  ";
+        }
+      cmOStringStream e;
+      e << "Target \"" << this->Name << "\" has source files which vary by "
+        "configuration. This is not supported by the \""
+        << this->Makefile->GetLocalGenerator()
+                         ->GetGlobalGenerator()->GetName()
+        << "\" generator.\n"
+          "Config \"" << firstConfig << "\":\n"
+          "  " << firstConfigFiles << "\n"
+          "Config \"" << *it << "\":\n"
+          "  " << thisConfigFiles << "\n";
+      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
       return false;
       }
     }
@@ -548,42 +852,111 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
+void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
+                              const std::string& config,
+                              cmTarget const* head) const
 {
-  assert(this->GetType() != INTERFACE_LIBRARY);
-  files = this->SourceFiles;
+
+  // Lookup any existing link implementation for this configuration.
+  TargetConfigPair key(head, cmSystemTools::UpperCase(config));
+
+  if(!this->LinkImplementationLanguageIsContextDependent)
+    {
+    files = this->Internal->SourceFilesMap.begin()->second;
+    return;
+    }
+
+  cmTargetInternals::SourceFilesMapType::iterator
+    it = this->Internal->SourceFilesMap.find(key);
+  if(it != this->Internal->SourceFilesMap.end())
+    {
+    files = it->second;
+    }
+  else
+    {
+    std::vector<std::string> srcs;
+    this->GetSourceFiles(srcs, config, head);
+
+    std::set<cmSourceFile*> emitted;
+
+    for(std::vector<std::string>::const_iterator i = srcs.begin();
+        i != srcs.end(); ++i)
+      {
+      cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+      if (emitted.insert(sf).second)
+        {
+        files.push_back(sf);
+        }
+      }
+    this->Internal->SourceFilesMap[key] = files;
+    }
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::AddSourceFile(cmSourceFile* sf)
+void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
 {
-  if (std::find(this->SourceFiles.begin(), this->SourceFiles.end(), sf)
-                                            == this->SourceFiles.end())
+  std::string srcFiles;
+  const char* sep = "";
+  for(std::vector<std::string>::const_iterator i = srcs.begin();
+      i != srcs.end(); ++i)
     {
-    this->SourceFiles.push_back(sf);
+    std::string filename = *i;
+    srcFiles += sep;
+    srcFiles += filename;
+    sep = ";";
+    }
+  if (!srcFiles.empty())
+    {
+    this->Internal->SourceFilesMap.clear();
+    this->LinkImplementationLanguageIsContextDependent = true;
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
+    cge->SetEvaluateForBuildsystem(true);
+    this->Internal->SourceEntries.push_back(
+                          new cmTargetInternals::TargetPropertyEntry(cge));
     }
 }
 
 //----------------------------------------------------------------------------
 void cmTarget::AddSources(std::vector<std::string> const& srcs)
 {
+  std::string srcFiles;
+  const char* sep = "";
   for(std::vector<std::string>::const_iterator i = srcs.begin();
       i != srcs.end(); ++i)
     {
-    const char* src = i->c_str();
-    if(src[0] == '$' && src[1] == '<')
+    std::string filename = *i;
+    const char* src = filename.c_str();
+
+    if(!(src[0] == '$' && src[1] == '<'))
       {
-      this->ProcessSourceExpression(*i);
+      filename = this->ProcessSourceItemCMP0049(filename);
+      if (cmSystemTools::GetErrorOccuredFlag())
+        {
+        return;
+        }
+      this->Makefile->GetOrCreateSource(filename);
       }
-    else
-      {
-      this->AddSource(src);
-      }
+    srcFiles += sep;
+    srcFiles += filename;
+    sep = ";";
+    }
+  if (!srcFiles.empty())
+    {
+    this->Internal->SourceFilesMap.clear();
+    this->LinkImplementationLanguageIsContextDependent = true;
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
+    cge->SetEvaluateForBuildsystem(true);
+    this->Internal->SourceEntries.push_back(
+                          new cmTargetInternals::TargetPropertyEntry(cge));
     }
 }
 
 //----------------------------------------------------------------------------
-cmSourceFile* cmTarget::AddSource(const char* s)
+std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
 {
   std::string src = s;
 
@@ -615,143 +988,116 @@
         << s << "\" expanded to \"" << src << "\" in target \""
         << this->GetName() << "\".  This behavior will be removed in a "
         "future version of CMake.";
-      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      this->Makefile->IssueMessage(messageType, e.str());
       if (messageType == cmake::FATAL_ERROR)
         {
-        return 0;
+        return "";
         }
       }
     }
-
-  cmSourceFile* sf = this->Makefile->GetOrCreateSource(src.c_str());
-  this->AddSourceFile(sf);
-  return sf;
+  return src;
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::ProcessSourceExpression(std::string const& expr)
+cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s)
 {
-  if(cmHasLiteralPrefix(expr.c_str(), "$<TARGET_OBJECTS:") &&
-     expr[expr.size()-1] == '>')
+  std::string src = this->ProcessSourceItemCMP0049(s);
+
+  if (cmSystemTools::GetErrorOccuredFlag())
     {
-    std::string objLibName = expr.substr(17, expr.size()-18);
-    this->ObjectLibraries.push_back(objLibName);
+    return 0;
     }
-  else
-    {
-    cmOStringStream e;
-    e << "Unrecognized generator expression:\n"
-      << "  " << expr;
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-    }
+  return this->AddSource(src);
 }
 
 //----------------------------------------------------------------------------
-struct cmTarget::SourceFileFlags
-cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
+struct CreateLocation
 {
-  struct SourceFileFlags flags;
-  this->ConstructSourceFileFlags();
-  std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
-    this->Internal->SourceFlagsMap.find(sf);
-  if(si != this->Internal->SourceFlagsMap.end())
-    {
-    flags = si->second;
-    }
-  return flags;
-}
+  cmMakefile const* Makefile;
+
+  CreateLocation(cmMakefile const* mf)
+    : Makefile(mf)
+  {
+
+  }
+
+  cmSourceFileLocation operator()(const std::string& filename)
+  {
+    return cmSourceFileLocation(this->Makefile, filename);
+  }
+};
 
 //----------------------------------------------------------------------------
-void cmTarget::ConstructSourceFileFlags() const
+struct LocationMatcher
 {
-  if(this->Internal->SourceFileFlagsConstructed)
-    {
-    return;
-    }
-  this->Internal->SourceFileFlagsConstructed = true;
+  const cmSourceFileLocation& Needle;
 
-  // Process public headers to mark the source files.
-  if(const char* files = this->GetProperty("PUBLIC_HEADER"))
-    {
-    std::vector<std::string> relFiles;
-    cmSystemTools::ExpandListArgument(files, relFiles);
-    for(std::vector<std::string>::iterator it = relFiles.begin();
-        it != relFiles.end(); ++it)
-      {
-      if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
-        {
-        SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
-        flags.MacFolder = "Headers";
-        flags.Type = cmTarget::SourceFileTypePublicHeader;
-        }
-      }
-    }
+  LocationMatcher(const cmSourceFileLocation& needle)
+    : Needle(needle)
+  {
 
-  // Process private headers after public headers so that they take
-  // precedence if a file is listed in both.
-  if(const char* files = this->GetProperty("PRIVATE_HEADER"))
-    {
-    std::vector<std::string> relFiles;
-    cmSystemTools::ExpandListArgument(files, relFiles);
-    for(std::vector<std::string>::iterator it = relFiles.begin();
-        it != relFiles.end(); ++it)
-      {
-      if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
-        {
-        SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
-        flags.MacFolder = "PrivateHeaders";
-        flags.Type = cmTarget::SourceFileTypePrivateHeader;
-        }
-      }
-    }
+  }
 
-  // Mark sources listed as resources.
-  if(const char* files = this->GetProperty("RESOURCE"))
-    {
-    std::vector<std::string> relFiles;
-    cmSystemTools::ExpandListArgument(files, relFiles);
-    for(std::vector<std::string>::iterator it = relFiles.begin();
-        it != relFiles.end(); ++it)
-      {
-      if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
-        {
-        SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
-        flags.MacFolder = "Resources";
-        flags.Type = cmTarget::SourceFileTypeResource;
-        }
-      }
-    }
+  bool operator()(cmSourceFileLocation &loc)
+  {
+    return loc.Matches(this->Needle);
+  }
+};
 
-  // Handle the MACOSX_PACKAGE_LOCATION property on source files that
-  // were not listed in one of the other lists.
-  std::vector<cmSourceFile*> sources;
-  this->GetSourceFiles(sources);
-  for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
-      si != sources.end(); ++si)
+
+//----------------------------------------------------------------------------
+struct TargetPropertyEntryFinder
+{
+private:
+  const cmSourceFileLocation& Needle;
+public:
+  TargetPropertyEntryFinder(const cmSourceFileLocation& needle)
+    : Needle(needle)
+  {
+
+  }
+
+  bool operator()(cmTargetInternals::TargetPropertyEntry* entry)
+  {
+    std::vector<std::string> files;
+    cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files);
+    std::vector<cmSourceFileLocation> locations(files.size());
+    std::transform(files.begin(), files.end(), locations.begin(),
+                   CreateLocation(this->Needle.GetMakefile()));
+
+    return std::find_if(locations.begin(), locations.end(),
+        LocationMatcher(this->Needle)) != locations.end();
+  }
+};
+
+//----------------------------------------------------------------------------
+cmSourceFile* cmTarget::AddSource(const std::string& src)
+{
+  cmSourceFileLocation sfl(this->Makefile, src);
+  if (std::find_if(this->Internal->SourceEntries.begin(),
+                   this->Internal->SourceEntries.end(),
+                   TargetPropertyEntryFinder(sfl))
+                                      == this->Internal->SourceEntries.end())
     {
-    cmSourceFile* sf = *si;
-    if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION"))
-      {
-      SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
-      if(flags.Type == cmTarget::SourceFileTypeNormal)
-        {
-        flags.MacFolder = location;
-        if(strcmp(location, "Resources") == 0)
-          {
-          flags.Type = cmTarget::SourceFileTypeResource;
-          }
-        else
-          {
-          flags.Type = cmTarget::SourceFileTypeMacContent;
-          }
-        }
-      }
+    this->Internal->SourceFilesMap.clear();
+    this->LinkImplementationLanguageIsContextDependent = true;
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
+    cge->SetEvaluateForBuildsystem(true);
+    this->Internal->SourceEntries.push_back(
+                          new cmTargetInternals::TargetPropertyEntry(cge));
     }
+  if (cmGeneratorExpression::Find(src) != std::string::npos)
+    {
+    return 0;
+    }
+  return this->Makefile->GetOrCreateSource(src);
 }
 
 //----------------------------------------------------------------------------
 void cmTarget::MergeLinkLibraries( cmMakefile& mf,
-                                   const char *selfname,
+                                   const std::string& selfname,
                                    const LinkLibraryVectorType& libs )
 {
   // Only add on libraries we haven't added on before.
@@ -761,15 +1107,15 @@
   for( ; i != libs.end(); ++i )
     {
     // This is equivalent to the target_link_libraries plain signature.
-    this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second );
+    this->AddLinkLibrary( mf, selfname, i->first, i->second );
     this->AppendProperty("INTERFACE_LINK_LIBRARIES",
-      this->GetDebugGeneratorExpressions(i->first.c_str(), i->second).c_str());
+      this->GetDebugGeneratorExpressions(i->first, i->second).c_str());
     }
   this->PrevLinkedLibraries = libs;
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::AddLinkDirectory(const char* d)
+void cmTarget::AddLinkDirectory(const std::string& d)
 {
   // Make sure we don't add unnecessary search directories.
   if(this->LinkDirectoriesEmmitted.insert(d).second)
@@ -785,10 +1131,11 @@
 }
 
 //----------------------------------------------------------------------------
-cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const
+cmTarget::LinkLibraryType cmTarget::ComputeLinkType(
+                                      const std::string& config) const
 {
   // No configuration is always optimized.
-  if(!(config && *config))
+  if(config.empty())
     {
     return cmTarget::OPTIMIZED;
     }
@@ -814,7 +1161,7 @@
 
 //----------------------------------------------------------------------------
 void cmTarget::ClearDependencyInformation( cmMakefile& mf,
-                                           const char* target )
+                                           const std::string& target )
 {
   // Clear the dependencies. The cache variable must exist iff we are
   // recording dependency information for this target.
@@ -822,12 +1169,12 @@
   depname += "_LIB_DEPENDS";
   if (this->RecordDependencies)
     {
-    mf.AddCacheDefinition(depname.c_str(), "",
+    mf.AddCacheDefinition(depname, "",
                           "Dependencies for target", cmCacheManager::STATIC);
     }
   else
     {
-    if (mf.GetDefinition( depname.c_str() ))
+    if (mf.GetDefinition( depname ))
       {
       std::string message = "Target ";
       message += target;
@@ -848,18 +1195,17 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::GetDirectLinkLibraries(const char *config,
+void cmTarget::GetDirectLinkLibraries(const std::string& config,
                             std::vector<std::string> &libs,
                             cmTarget const* head) const
 {
   const char *prop = this->GetProperty("LINK_LIBRARIES");
   if (prop)
     {
-    cmListFileBacktrace lfbt;
-    cmGeneratorExpression ge(lfbt);
+    cmGeneratorExpression ge;
     const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
 
-    cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+    cmGeneratorExpressionDAGChecker dagChecker(
                                         this->GetName(),
                                         "LINK_LIBRARIES", 0, 0);
     cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile,
@@ -869,31 +1215,31 @@
                                         &dagChecker),
                                       libs);
 
-    std::set<cmStdString> seenProps = cge->GetSeenTargetProperties();
-    for (std::set<cmStdString>::const_iterator it = seenProps.begin();
+    std::set<std::string> const& seenProps = cge->GetSeenTargetProperties();
+    for (std::set<std::string>::const_iterator it = seenProps.begin();
         it != seenProps.end(); ++it)
       {
-      if (!this->GetProperty(it->c_str()))
+      if (!this->GetProperty(*it))
         {
         this->LinkImplicitNullProperties.insert(*it);
         }
       }
+    cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards);
     }
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::GetInterfaceLinkLibraries(const char *config,
+void cmTarget::GetInterfaceLinkLibraries(const std::string& config,
                                          std::vector<std::string> &libs,
                                          cmTarget const* head) const
 {
   const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES");
   if (prop)
     {
-    cmListFileBacktrace lfbt;
-    cmGeneratorExpression ge(lfbt);
+    cmGeneratorExpression ge;
     const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
 
-    cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+    cmGeneratorExpressionDAGChecker dagChecker(
                                         this->GetName(),
                                         "INTERFACE_LINK_LIBRARIES", 0, 0);
     cmSystemTools::ExpandListArgument(cge->Evaluate(this->Makefile,
@@ -938,9 +1284,9 @@
 }
 
 //----------------------------------------------------------------------------
-static std::string targetNameGenex(const char *lib)
+static std::string targetNameGenex(const std::string& lib)
 {
-  return std::string("$<TARGET_NAME:") + lib + ">";
+  return "$<TARGET_NAME:" + lib + ">";
 }
 
 //----------------------------------------------------------------------------
@@ -954,8 +1300,7 @@
       ret = false;
       }
     }
-  cmListFileBacktrace lfbt;
-  this->Makefile->GetBacktrace(lfbt);
+  cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
   this->TLLCommands.push_back(std::make_pair(signature, lfbt));
   return ret;
 }
@@ -980,10 +1325,11 @@
                         = (sig == cmTarget::KeywordTLLSignature ? "keyword"
                                                                 : "plain");
     s << "The uses of the " << sigString << " signature are here:\n";
-    std::set<cmStdString> emitted;
-    for(std::vector<cmListFileBacktrace>::const_iterator it = sigs.begin();
+    std::set<std::string> emitted;
+    for(std::vector<cmListFileBacktrace>::iterator it = sigs.begin();
         it != sigs.end(); ++it)
       {
+      it->MakeRelative();
       cmListFileBacktrace::const_iterator i = it->begin();
       if(i != it->end())
         {
@@ -1002,7 +1348,8 @@
 
 //----------------------------------------------------------------------------
 void cmTarget::AddLinkLibrary(cmMakefile& mf,
-                              const char *target, const char* lib,
+                              const std::string& target,
+                              const std::string& lib,
                               LinkLibraryType llt)
 {
   cmTarget *tgt = this->Makefile->FindTargetToUse(lib);
@@ -1011,7 +1358,7 @@
 
   const std::string libName = (isNonImportedTarget && llt != GENERAL)
                                                         ? targetNameGenex(lib)
-                                                        : std::string(lib);
+                                                        : lib;
   this->AppendProperty("LINK_LIBRARIES",
                        this->GetDebugGeneratorExpressions(libName,
                                                           llt).c_str());
@@ -1019,7 +1366,7 @@
 
   if (cmGeneratorExpression::Find(lib) != std::string::npos
       || (tgt && tgt->GetType() == INTERFACE_LIBRARY)
-      || (strcmp( target, lib ) == 0))
+      || (target == lib ))
     {
     return;
     }
@@ -1044,7 +1391,7 @@
     std::string targetEntry = target;
     targetEntry += "_LIB_DEPENDS";
     std::string dependencies;
-    const char* old_val = mf.GetDefinition( targetEntry.c_str() );
+    const char* old_val = mf.GetDefinition( targetEntry );
     if( old_val )
       {
       dependencies += old_val;
@@ -1064,7 +1411,7 @@
     dependencies += ";";
     dependencies += lib;
     dependencies += ";";
-    mf.AddCacheDefinition( targetEntry.c_str(), dependencies.c_str(),
+    mf.AddCacheDefinition( targetEntry, dependencies.c_str(),
                            "Dependencies for the target",
                            cmCacheManager::STATIC );
     }
@@ -1073,9 +1420,9 @@
 
 //----------------------------------------------------------------------------
 void
-cmTarget::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
+cmTarget::AddSystemIncludeDirectories(const std::set<std::string> &incs)
 {
-  for(std::set<cmStdString>::const_iterator li = incs.begin();
+  for(std::set<std::string>::const_iterator li = incs.begin();
       li != incs.end(); ++li)
     {
     this->SystemIncludeDirectories.insert(*li);
@@ -1338,7 +1685,7 @@
     return;
     }
 
-  const char* deps = mf.GetDefinition( (lib.first+"_LIB_DEPENDS").c_str() );
+  const char* deps = mf.GetDefinition( lib.first+"_LIB_DEPENDS" );
   if( deps && strcmp(deps,"") != 0 )
     {
     // Make sure this library is in the map, even if it has an empty
@@ -1387,7 +1734,7 @@
 }
 
 //----------------------------------------------------------------------------
-static bool whiteListedInterfaceProperty(const char *prop)
+static bool whiteListedInterfaceProperty(const std::string& prop)
 {
   if(cmHasLiteralPrefix(prop, "INTERFACE_"))
     {
@@ -1407,7 +1754,7 @@
 
   if (std::binary_search(cmArrayBegin(builtIns),
                          cmArrayEnd(builtIns),
-                         prop,
+                         prop.c_str(),
                          cmStrCmp(prop)))
     {
     return true;
@@ -1422,156 +1769,195 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::SetProperty(const char* prop, const char* value)
+void cmTarget::SetProperty(const std::string& prop, const char* value)
 {
-  if (!prop)
-    {
-    return;
-    }
   if (this->GetType() == INTERFACE_LIBRARY
       && !whiteListedInterfaceProperty(prop))
     {
     cmOStringStream e;
     e << "INTERFACE_LIBRARY targets may only have whitelisted properties.  "
          "The property \"" << prop << "\" is not allowed.";
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
     }
 
-  if (strcmp(prop, "NAME") == 0)
+  if (prop == "NAME")
     {
     cmOStringStream e;
     e << "NAME property is read-only\n";
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
     }
-  if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
+  if(prop == "INCLUDE_DIRECTORIES")
     {
-    cmListFileBacktrace lfbt;
-    this->Makefile->GetBacktrace(lfbt);
-    cmGeneratorExpression ge(lfbt);
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
     deleteAndClear(this->Internal->IncludeDirectoriesEntries);
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
     this->Internal->IncludeDirectoriesEntries.push_back(
                           new cmTargetInternals::TargetPropertyEntry(cge));
     return;
     }
-  if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+  if(prop == "COMPILE_OPTIONS")
     {
-    cmListFileBacktrace lfbt;
-    this->Makefile->GetBacktrace(lfbt);
-    cmGeneratorExpression ge(lfbt);
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
     deleteAndClear(this->Internal->CompileOptionsEntries);
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
     this->Internal->CompileOptionsEntries.push_back(
                           new cmTargetInternals::TargetPropertyEntry(cge));
     return;
     }
-  if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
+  if(prop == "COMPILE_FEATURES")
     {
-    cmListFileBacktrace lfbt;
-    this->Makefile->GetBacktrace(lfbt);
-    cmGeneratorExpression ge(lfbt);
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
+    deleteAndClear(this->Internal->CompileFeaturesEntries);
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+    this->Internal->CompileFeaturesEntries.push_back(
+                          new cmTargetInternals::TargetPropertyEntry(cge));
+    return;
+    }
+  if(prop == "COMPILE_DEFINITIONS")
+    {
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
     deleteAndClear(this->Internal->CompileDefinitionsEntries);
     cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
     this->Internal->CompileDefinitionsEntries.push_back(
                           new cmTargetInternals::TargetPropertyEntry(cge));
     return;
     }
-  if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
+  if(prop == "EXPORT_NAME" && this->IsImported())
     {
     cmOStringStream e;
     e << "EXPORT_NAME property can't be set on imported targets (\""
           << this->Name << "\")\n";
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
     }
-  if (strcmp(prop, "LINK_LIBRARIES") == 0)
+  if (prop == "LINK_LIBRARIES")
     {
     this->Internal->LinkImplementationPropertyEntries.clear();
-    cmListFileBacktrace lfbt;
-    this->Makefile->GetBacktrace(lfbt);
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
     cmValueWithOrigin entry(value, lfbt);
     this->Internal->LinkImplementationPropertyEntries.push_back(entry);
     return;
     }
+  if (prop == "SOURCES")
+    {
+    if(this->IsImported())
+      {
+      cmOStringStream e;
+      e << "SOURCES property can't be set on imported targets (\""
+            << this->Name << "\")\n";
+      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+      return;
+      }
+    this->Internal->SourceFilesMap.clear();
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
+    this->Internal->SourceEntries.clear();
+    cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+    this->Internal->SourceEntries.push_back(
+                          new cmTargetInternals::TargetPropertyEntry(cge));
+    return;
+    }
   this->Properties.SetProperty(prop, value, cmProperty::TARGET);
   this->MaybeInvalidatePropertyCache(prop);
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::AppendProperty(const char* prop, const char* value,
+void cmTarget::AppendProperty(const std::string& prop, const char* value,
                               bool asString)
 {
-  if (!prop)
-    {
-    return;
-    }
   if (this->GetType() == INTERFACE_LIBRARY
       && !whiteListedInterfaceProperty(prop))
     {
     cmOStringStream e;
     e << "INTERFACE_LIBRARY targets may only have whitelisted properties.  "
          "The property \"" << prop << "\" is not allowed.";
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
     }
-  if (strcmp(prop, "NAME") == 0)
+  if (prop == "NAME")
     {
     cmOStringStream e;
     e << "NAME property is read-only\n";
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
     }
-  if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
+  if(prop == "INCLUDE_DIRECTORIES")
     {
-    cmListFileBacktrace lfbt;
-    this->Makefile->GetBacktrace(lfbt);
-    cmGeneratorExpression ge(lfbt);
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
     this->Internal->IncludeDirectoriesEntries.push_back(
               new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
     return;
     }
-  if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+  if(prop == "COMPILE_OPTIONS")
     {
-    cmListFileBacktrace lfbt;
-    this->Makefile->GetBacktrace(lfbt);
-    cmGeneratorExpression ge(lfbt);
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
     this->Internal->CompileOptionsEntries.push_back(
               new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
     return;
     }
-  if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
+  if(prop == "COMPILE_FEATURES")
     {
-    cmListFileBacktrace lfbt;
-    this->Makefile->GetBacktrace(lfbt);
-    cmGeneratorExpression ge(lfbt);
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
+    this->Internal->CompileFeaturesEntries.push_back(
+              new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
+    return;
+    }
+  if(prop == "COMPILE_DEFINITIONS")
+    {
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+    cmGeneratorExpression ge(&lfbt);
     this->Internal->CompileDefinitionsEntries.push_back(
               new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
     return;
     }
-  if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
+  if(prop == "EXPORT_NAME" && this->IsImported())
     {
     cmOStringStream e;
     e << "EXPORT_NAME property can't be set on imported targets (\""
           << this->Name << "\")\n";
-    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
     return;
     }
-  if (strcmp(prop, "LINK_LIBRARIES") == 0)
+  if (prop == "LINK_LIBRARIES")
     {
-    cmListFileBacktrace lfbt;
-    this->Makefile->GetBacktrace(lfbt);
+    cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
     cmValueWithOrigin entry(value, lfbt);
     this->Internal->LinkImplementationPropertyEntries.push_back(entry);
     return;
     }
+  if (prop == "SOURCES")
+    {
+    if(this->IsImported())
+      {
+      cmOStringStream e;
+      e << "SOURCES property can't be set on imported targets (\""
+            << this->Name << "\")\n";
+      this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+      return;
+      }
+      this->Internal->SourceFilesMap.clear();
+      cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+      cmGeneratorExpression ge(&lfbt);
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+      this->Internal->SourceEntries.push_back(
+                            new cmTargetInternals::TargetPropertyEntry(cge));
+    return;
+    }
   this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString);
   this->MaybeInvalidatePropertyCache(prop);
 }
 
 //----------------------------------------------------------------------------
-const char* cmTarget::GetExportName() const
+std::string cmTarget::GetExportName() const
 {
   const char *exportName = this->GetProperty("EXPORT_NAME");
 
@@ -1626,7 +2012,7 @@
 void cmTarget::InsertInclude(const cmValueWithOrigin &entry,
                      bool before)
 {
-  cmGeneratorExpression ge(entry.Backtrace);
+  cmGeneratorExpression ge(&entry.Backtrace);
 
   std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
                 = before ? this->Internal->IncludeDirectoriesEntries.begin()
@@ -1640,7 +2026,7 @@
 void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry,
                      bool before)
 {
-  cmGeneratorExpression ge(entry.Backtrace);
+  cmGeneratorExpression ge(&entry.Backtrace);
 
   std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
                 = before ? this->Internal->CompileOptionsEntries.begin()
@@ -1653,7 +2039,7 @@
 //----------------------------------------------------------------------------
 void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry)
 {
-  cmGeneratorExpression ge(entry.Backtrace);
+  cmGeneratorExpression ge(&entry.Backtrace);
 
   this->Internal->CompileDefinitionsEntries.push_back(
       new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value)));
@@ -1665,7 +2051,7 @@
       std::vector<std::string> &includes,
       std::set<std::string> &uniqueIncludes,
       cmGeneratorExpressionDAGChecker *dagChecker,
-      const char *config, bool debugIncludes)
+      const std::string& config, bool debugIncludes)
 {
   cmMakefile *mf = tgt->GetMakefile();
 
@@ -1674,7 +2060,7 @@
     {
     bool testIsOff = true;
     bool cacheIncludes = false;
-    std::vector<std::string> entryIncludes = (*it)->CachedEntries;
+    std::vector<std::string>& entryIncludes = (*it)->CachedEntries;
     if(!entryIncludes.empty())
       {
       testIsOff = false;
@@ -1694,14 +2080,13 @@
         }
       }
     std::string usedIncludes;
-    cmListFileBacktrace lfbt;
     for(std::vector<std::string>::iterator
           li = entryIncludes.begin(); li != entryIncludes.end(); ++li)
       {
       std::string targetName = (*it)->TargetName;
       std::string evaluatedTargetName;
       {
-      cmGeneratorExpression ge(lfbt);
+      cmGeneratorExpression ge;
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
                                                         ge.Parse(targetName);
       evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0);
@@ -1752,7 +2137,7 @@
              "successfully.\n"
              "* The installation package was faulty and references files it "
              "does not provide.\n";
-        tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+        tgt->GetMakefile()->IssueMessage(messageType, e.str());
         return;
         }
 
@@ -1791,7 +2176,7 @@
           }
         if (!noMessage)
           {
-          tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+          tgt->GetMakefile()->IssueMessage(messageType, e.str());
           if (messageType == cmake::FATAL_ERROR)
             {
             return;
@@ -1830,14 +2215,12 @@
 
 //----------------------------------------------------------------------------
 std::vector<std::string>
-cmTarget::GetIncludeDirectories(const char *config) const
+cmTarget::GetIncludeDirectories(const std::string& config) const
 {
   std::vector<std::string> includes;
   std::set<std::string> uniqueIncludes;
-  cmListFileBacktrace lfbt;
 
-  cmGeneratorExpressionDAGChecker dagChecker(lfbt,
-                                             this->GetName(),
+  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
                                              "INCLUDE_DIRECTORIES", 0, 0);
 
   std::vector<std::string> debugProperties;
@@ -1867,8 +2250,7 @@
                             config,
                             debugIncludes);
 
-  std::string configString = config ? config : "";
-  if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString])
+  if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config])
     {
     for (std::vector<cmValueWithOrigin>::const_iterator
         it = this->Internal->LinkImplementationPropertyEntries.begin(),
@@ -1881,7 +2263,7 @@
         continue;
         }
       {
-      cmGeneratorExpression ge(lfbt);
+      cmGeneratorExpression ge;
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
                                                         ge.Parse(it->Value);
       std::string result = cge->Evaluate(this->Makefile, config,
@@ -1900,12 +2282,12 @@
         // TARGET_PROPERTY expression.
         includeGenex = "$<$<BOOL:" + it->Value + ">:" + includeGenex + ">";
         }
-      cmGeneratorExpression ge(it->Backtrace);
+      cmGeneratorExpression ge(&it->Backtrace);
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
                                                               includeGenex);
 
       this->Internal
-        ->CachedLinkInterfaceIncludeDirectoriesEntries[configString].push_back(
+        ->CachedLinkInterfaceIncludeDirectoriesEntries[config].push_back(
                         new cmTargetInternals::TargetPropertyEntry(cge,
                                                               it->Value));
       }
@@ -1929,18 +2311,18 @@
 
         libDir = frameworkCheck.match(1);
 
-        cmGeneratorExpression ge(lfbt);
+        cmGeneratorExpression ge;
         cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
                   ge.Parse(libDir.c_str());
         this->Internal
-                ->CachedLinkInterfaceIncludeDirectoriesEntries[configString]
+                ->CachedLinkInterfaceIncludeDirectoriesEntries[config]
                 .push_back(new cmTargetInternals::TargetPropertyEntry(cge));
         }
       }
     }
 
   processIncludeDirectories(this,
-    this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[configString],
+    this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config],
                             includes,
                             uniqueIncludes,
                             &dagChecker,
@@ -1954,7 +2336,7 @@
     }
   else
     {
-    this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString]
+    this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config]
                                                                       = true;
     }
 
@@ -1967,7 +2349,7 @@
       std::vector<std::string> &options,
       std::set<std::string> &uniqueOptions,
       cmGeneratorExpressionDAGChecker *dagChecker,
-      const char *config, bool debugOptions, const char *logName)
+      const std::string& config, bool debugOptions, const char *logName)
 {
   cmMakefile *mf = tgt->GetMakefile();
 
@@ -2026,7 +2408,7 @@
       std::vector<std::string> &options,
       std::set<std::string> &uniqueOptions,
       cmGeneratorExpressionDAGChecker *dagChecker,
-      const char *config, bool debugOptions)
+      const std::string& config, bool debugOptions)
 {
   processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
                                 dagChecker, config, debugOptions, "options");
@@ -2034,7 +2416,7 @@
 
 //----------------------------------------------------------------------------
 void cmTarget::GetAutoUicOptions(std::vector<std::string> &result,
-                                 const char *config) const
+                                 const std::string& config) const
 {
   const char *prop
             = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS",
@@ -2043,10 +2425,9 @@
     {
     return;
     }
-  cmListFileBacktrace lfbt;
-  cmGeneratorExpression ge(lfbt);
+  cmGeneratorExpression ge;
 
-  cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+  cmGeneratorExpressionDAGChecker dagChecker(
                                       this->GetName(),
                                       "AUTOUIC_OPTIONS", 0, 0);
   cmSystemTools::ExpandListArgument(ge.Parse(prop)
@@ -2060,14 +2441,12 @@
 
 //----------------------------------------------------------------------------
 void cmTarget::GetCompileOptions(std::vector<std::string> &result,
-                                 const char *config) const
+                                 const std::string& config) const
 {
   std::set<std::string> uniqueOptions;
-  cmListFileBacktrace lfbt;
 
-  cmGeneratorExpressionDAGChecker dagChecker(lfbt,
-                                              this->GetName(),
-                                              "COMPILE_OPTIONS", 0, 0);
+  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+                                             "COMPILE_OPTIONS", 0, 0);
 
   std::vector<std::string> debugProperties;
   const char *debugProp =
@@ -2096,8 +2475,7 @@
                             config,
                             debugOptions);
 
-  std::string configString = config ? config : "";
-  if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString])
+  if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[config])
     {
     for (std::vector<cmValueWithOrigin>::const_iterator
         it = this->Internal->LinkImplementationPropertyEntries.begin(),
@@ -2110,7 +2488,7 @@
         continue;
         }
       {
-      cmGeneratorExpression ge(lfbt);
+      cmGeneratorExpression ge;
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
                                                         ge.Parse(it->Value);
       std::string targetResult = cge->Evaluate(this->Makefile, config,
@@ -2129,19 +2507,19 @@
         // TARGET_PROPERTY expression.
         optionGenex = "$<$<BOOL:" + it->Value + ">:" + optionGenex + ">";
         }
-      cmGeneratorExpression ge(it->Backtrace);
+      cmGeneratorExpression ge(&it->Backtrace);
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
                                                                 optionGenex);
 
       this->Internal
-        ->CachedLinkInterfaceCompileOptionsEntries[configString].push_back(
+        ->CachedLinkInterfaceCompileOptionsEntries[config].push_back(
                         new cmTargetInternals::TargetPropertyEntry(cge,
                                                               it->Value));
       }
     }
 
   processCompileOptions(this,
-    this->Internal->CachedLinkInterfaceCompileOptionsEntries[configString],
+    this->Internal->CachedLinkInterfaceCompileOptionsEntries[config],
                             result,
                             uniqueOptions,
                             &dagChecker,
@@ -2154,7 +2532,7 @@
     }
   else
     {
-    this->Internal->CacheLinkInterfaceCompileOptionsDone[configString] = true;
+    this->Internal->CacheLinkInterfaceCompileOptionsDone[config] = true;
     }
 }
 
@@ -2164,7 +2542,7 @@
       std::vector<std::string> &options,
       std::set<std::string> &uniqueOptions,
       cmGeneratorExpressionDAGChecker *dagChecker,
-      const char *config, bool debugOptions)
+      const std::string& config, bool debugOptions)
 {
   processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
                                 dagChecker, config, debugOptions,
@@ -2173,14 +2551,12 @@
 
 //----------------------------------------------------------------------------
 void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
-                                            const char *config) const
+                                            const std::string& config) const
 {
   std::set<std::string> uniqueOptions;
-  cmListFileBacktrace lfbt;
 
-  cmGeneratorExpressionDAGChecker dagChecker(lfbt,
-                                              this->GetName(),
-                                              "COMPILE_DEFINITIONS", 0, 0);
+  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+                                             "COMPILE_DEFINITIONS", 0, 0);
 
   std::vector<std::string> debugProperties;
   const char *debugProp =
@@ -2209,8 +2585,7 @@
                             config,
                             debugDefines);
 
-  std::string configString = config ? config : "";
-  if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString])
+  if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config])
     {
     for (std::vector<cmValueWithOrigin>::const_iterator
         it = this->Internal->LinkImplementationPropertyEntries.begin(),
@@ -2223,7 +2598,7 @@
         continue;
         }
       {
-      cmGeneratorExpression ge(lfbt);
+      cmGeneratorExpression ge;
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
                                                         ge.Parse(it->Value);
       std::string targetResult = cge->Evaluate(this->Makefile, config,
@@ -2242,20 +2617,20 @@
         // TARGET_PROPERTY expression.
         defsGenex = "$<$<BOOL:" + it->Value + ">:" + defsGenex + ">";
         }
-      cmGeneratorExpression ge(it->Backtrace);
+      cmGeneratorExpression ge(&it->Backtrace);
       cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
                                                                 defsGenex);
 
       this->Internal
-        ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back(
+        ->CachedLinkInterfaceCompileDefinitionsEntries[config].push_back(
                         new cmTargetInternals::TargetPropertyEntry(cge,
                                                               it->Value));
       }
-    if (config)
+    if (!config.empty())
       {
       std::string configPropName = "COMPILE_DEFINITIONS_"
                                           + cmSystemTools::UpperCase(config);
-      const char *configProp = this->GetProperty(configPropName.c_str());
+      const char *configProp = this->GetProperty(configPropName);
       if (configProp)
         {
         switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043))
@@ -2266,15 +2641,15 @@
             e << this->Makefile->GetCMakeInstance()->GetPolicies()
                      ->GetPolicyWarning(cmPolicies::CMP0043);
             this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
-                                         e.str().c_str());
+                                         e.str());
             }
           case cmPolicies::OLD:
             {
-            cmGeneratorExpression ge(lfbt);
+            cmGeneratorExpression ge;
             cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
                                                         ge.Parse(configProp);
             this->Internal
-              ->CachedLinkInterfaceCompileDefinitionsEntries[configString]
+              ->CachedLinkInterfaceCompileDefinitionsEntries[config]
                   .push_back(new cmTargetInternals::TargetPropertyEntry(cge));
             }
             break;
@@ -2289,7 +2664,7 @@
     }
 
   processCompileDefinitions(this,
-    this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[configString],
+    this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[config],
                             list,
                             uniqueOptions,
                             &dagChecker,
@@ -2303,13 +2678,123 @@
     }
   else
     {
-    this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]
+    this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config]
                                                                       = true;
     }
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
+static void processCompileFeatures(cmTarget const* tgt,
+      const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
+      std::vector<std::string> &options,
+      std::set<std::string> &uniqueOptions,
+      cmGeneratorExpressionDAGChecker *dagChecker,
+      const std::string& config, bool debugOptions)
+{
+  processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
+                                dagChecker, config, debugOptions, "features");
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
+                                  const std::string& config) const
+{
+  std::set<std::string> uniqueFeatures;
+
+  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+                                             "COMPILE_FEATURES",
+                                             0, 0);
+
+  std::vector<std::string> debugProperties;
+  const char *debugProp =
+              this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+  if (debugProp)
+    {
+    cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+    }
+
+  bool debugFeatures = !this->DebugCompileFeaturesDone
+                    && std::find(debugProperties.begin(),
+                                 debugProperties.end(),
+                                 "COMPILE_FEATURES")
+                        != debugProperties.end();
+
+  if (this->Makefile->IsGeneratingBuildSystem())
+    {
+    this->DebugCompileFeaturesDone = true;
+    }
+
+  processCompileFeatures(this,
+                            this->Internal->CompileFeaturesEntries,
+                            result,
+                            uniqueFeatures,
+                            &dagChecker,
+                            config,
+                            debugFeatures);
+
+  if (!this->Internal->CacheLinkInterfaceCompileFeaturesDone[config])
+    {
+    for (std::vector<cmValueWithOrigin>::const_iterator
+        it = this->Internal->LinkImplementationPropertyEntries.begin(),
+        end = this->Internal->LinkImplementationPropertyEntries.end();
+        it != end; ++it)
+      {
+      if (!cmGeneratorExpression::IsValidTargetName(it->Value)
+          && cmGeneratorExpression::Find(it->Value) == std::string::npos)
+        {
+        continue;
+        }
+      {
+      cmGeneratorExpression ge;
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+                                                        ge.Parse(it->Value);
+      std::string targetResult = cge->Evaluate(this->Makefile, config,
+                                        false, this, 0, 0);
+      if (!this->Makefile->FindTargetToUse(targetResult))
+        {
+        continue;
+        }
+      }
+      std::string featureGenex = "$<TARGET_PROPERTY:" +
+                              it->Value + ",INTERFACE_COMPILE_FEATURES>";
+      if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
+        {
+        // Because it->Value is a generator expression, ensure that it
+        // evaluates to the non-empty string before being used in the
+        // TARGET_PROPERTY expression.
+        featureGenex = "$<$<BOOL:" + it->Value + ">:" + featureGenex + ">";
+        }
+      cmGeneratorExpression ge(&it->Backtrace);
+      cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
+                                                                featureGenex);
+
+      this->Internal
+        ->CachedLinkInterfaceCompileFeaturesEntries[config].push_back(
+                        new cmTargetInternals::TargetPropertyEntry(cge,
+                                                              it->Value));
+      }
+    }
+
+  processCompileFeatures(this,
+    this->Internal->CachedLinkInterfaceCompileFeaturesEntries[config],
+                            result,
+                            uniqueFeatures,
+                            &dagChecker,
+                            config,
+                            debugFeatures);
+
+  if (!this->Makefile->IsGeneratingBuildSystem())
+    {
+    deleteAndClear(this->Internal->CachedLinkInterfaceCompileFeaturesEntries);
+    }
+  else
+    {
+    this->Internal->CacheLinkInterfaceCompileFeaturesDone[config] = true;
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop)
 {
   // Wipe out maps caching information affected by this property.
   if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED"))
@@ -2324,8 +2809,8 @@
 
 //----------------------------------------------------------------------------
 static void cmTargetCheckLINK_INTERFACE_LIBRARIES(
-  const char* prop, const char* value, cmMakefile* context, bool imported
-  )
+  const std::string& prop, const char* value, cmMakefile* context,
+  bool imported)
 {
   // Look for link-type keywords in the value.
   static cmsys::RegularExpression
@@ -2389,7 +2874,8 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::CheckProperty(const char* prop, cmMakefile* context) const
+void cmTarget::CheckProperty(const std::string& prop,
+                             cmMakefile* context) const
 {
   // Certain properties need checking.
   if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES"))
@@ -2432,7 +2918,8 @@
 }
 
 //----------------------------------------------------------------------------
-cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const
+cmTarget::OutputInfo const* cmTarget::GetOutputInfo(
+    const std::string& config) const
 {
   // There is no output information for imported targets.
   if(this->IsImported())
@@ -2448,13 +2935,12 @@
     msg += " which has type ";
     msg += cmTarget::GetTargetTypeName(this->GetType());
     this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
-    abort();
     return 0;
     }
 
   // Lookup/compute/cache the output information for this configuration.
   std::string config_upper;
-  if(config && *config)
+  if(!config.empty())
     {
     config_upper = cmSystemTools::UpperCase(config);
     }
@@ -2466,7 +2952,7 @@
     OutputInfo info;
     this->ComputeOutputDir(config, false, info.OutDir);
     this->ComputeOutputDir(config, true, info.ImpDir);
-    if(!this->ComputePDBOutputDir(config, info.PdbDir))
+    if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir))
       {
       info.PdbDir = info.OutDir;
       }
@@ -2477,7 +2963,47 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetDirectory(const char* config, bool implib) const
+cmTarget::CompileInfo const* cmTarget::GetCompileInfo(
+                                            const std::string& config) const
+{
+  // There is no compile information for imported targets.
+  if(this->IsImported())
+    {
+    return 0;
+    }
+
+  if(this->GetType() > cmTarget::OBJECT_LIBRARY)
+    {
+    std::string msg = "cmTarget::GetCompileInfo called for ";
+    msg += this->GetName();
+    msg += " which has type ";
+    msg += cmTarget::GetTargetTypeName(this->GetType());
+    this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
+    return 0;
+    }
+
+  // Lookup/compute/cache the compile information for this configuration.
+  std::string config_upper;
+  if(!config.empty())
+    {
+    config_upper = cmSystemTools::UpperCase(config);
+    }
+  typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType;
+  CompileInfoMapType::const_iterator i =
+    this->Internal->CompileInfoMap.find(config_upper);
+  if(i == this->Internal->CompileInfoMap.end())
+    {
+    CompileInfo info;
+    this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir);
+    CompileInfoMapType::value_type entry(config_upper, info);
+    i = this->Internal->CompileInfoMap.insert(entry).first;
+    }
+  return &i->second;
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetDirectory(const std::string& config,
+                                   bool implib) const
 {
   if (this->IsImported())
     {
@@ -2495,7 +3021,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetPDBDirectory(const char* config) const
+std::string cmTarget::GetPDBDirectory(const std::string& config) const
 {
   if(OutputInfo const* info = this->GetOutputInfo(config))
     {
@@ -2506,34 +3032,37 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmTarget::GetLocation(const char* config) const
+std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const
 {
-  if (this->IsImported())
+  if(CompileInfo const* info = this->GetCompileInfo(config))
     {
-    return this->ImportedGetLocation(config);
+    return info->CompilePdbDir;
     }
-  else
-    {
-    return this->NormalGetLocation(config);
-    }
+  return "";
 }
 
 //----------------------------------------------------------------------------
-const char* cmTarget::ImportedGetLocation(const char* config) const
+const char* cmTarget::GetLocation(const std::string& config) const
 {
   static std::string location;
-  location = this->ImportedGetFullPath(config, false);
+  if (this->IsImported())
+    {
+    location = this->ImportedGetFullPath(config, false);
+    }
+  else
+    {
+    location = this->GetFullPath(config, false);
+    }
   return location.c_str();
 }
 
 //----------------------------------------------------------------------------
-const char* cmTarget::NormalGetLocation(const char* config) const
+const char* cmTarget::GetLocationForBuild() const
 {
   static std::string location;
-  // Handle the configuration-specific case first.
-  if(config)
+  if(this->IsImported())
     {
-    location = this->GetFullPath(config, false);
+    location = this->ImportedGetFullPath("", false);
     return location.c_str();
     }
 
@@ -2553,7 +3082,7 @@
 
   if(this->IsAppBundleOnApple())
     {
-    std::string macdir = this->BuildMacContentDirectory("", config, false);
+    std::string macdir = this->BuildMacContentDirectory("", "", false);
     if(!macdir.empty())
       {
       location += "/";
@@ -2561,7 +3090,7 @@
       }
     }
   location += "/";
-  location += this->GetFullName(config, false);
+  location += this->GetFullName("", false);
   return location.c_str();
 }
 
@@ -2604,14 +3133,15 @@
 }
 
 //----------------------------------------------------------------------------
-const char* cmTarget::GetFeature(const char* feature, const char* config) const
+const char* cmTarget::GetFeature(const std::string& feature,
+                                 const std::string& config) const
 {
-  if(config && *config)
+  if(!config.empty())
     {
     std::string featureConfig = feature;
     featureConfig += "_";
     featureConfig += cmSystemTools::UpperCase(config);
-    if(const char* value = this->GetProperty(featureConfig.c_str()))
+    if(const char* value = this->GetProperty(featureConfig))
       {
       return value;
       }
@@ -2624,6 +3154,13 @@
 }
 
 //----------------------------------------------------------------------------
+bool cmTarget::GetFeatureAsBool(const std::string& feature,
+                                const std::string& config) const
+{
+  return cmSystemTools::IsOn(this->GetFeature(feature, config));
+}
+
+//----------------------------------------------------------------------------
 bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
 {
   if (this->IsImported())
@@ -2654,40 +3191,35 @@
       << this->GetName() << "\".  Use the target name directly with "
       "add_custom_command, or use the generator expression $<TARGET_FILE>, "
       "as appropriate.\n";
-    context->IssueMessage(messageType, e.str().c_str());
+    context->IssueMessage(messageType, e.str());
     }
 
   return messageType != cmake::FATAL_ERROR;
 }
 
 //----------------------------------------------------------------------------
-const char *cmTarget::GetProperty(const char* prop) const
+const char *cmTarget::GetProperty(const std::string& prop) const
 {
   return this->GetProperty(prop, this->Makefile);
 }
 
 //----------------------------------------------------------------------------
-const char *cmTarget::GetProperty(const char* prop,
+const char *cmTarget::GetProperty(const std::string& prop,
                                   cmMakefile* context) const
 {
-  if(!prop)
-    {
-    return 0;
-    }
-
   if (this->GetType() == INTERFACE_LIBRARY
       && !whiteListedInterfaceProperty(prop))
     {
     cmOStringStream e;
     e << "INTERFACE_LIBRARY targets may only have whitelisted properties.  "
          "The property \"" << prop << "\" is not allowed.";
-    context->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    context->IssueMessage(cmake::FATAL_ERROR, e.str());
     return 0;
     }
 
-  if (strcmp(prop, "NAME") == 0)
+  if (prop == "NAME")
     {
-    return this->GetName();
+    return this->GetName().c_str();
     }
 
   // Watch for special "computed" properties that are dependent on
@@ -2698,7 +3230,7 @@
      this->GetType() == cmTarget::MODULE_LIBRARY ||
      this->GetType() == cmTarget::UNKNOWN_LIBRARY)
     {
-    if(strcmp(prop,"LOCATION") == 0)
+    if(prop == "LOCATION")
       {
       if (!this->HandleLocationPropertyPolicy(context))
         {
@@ -2714,7 +3246,7 @@
       // cannot take into account the per-configuration name of the
       // target because the configuration type may not be known at
       // CMake time.
-      this->Properties.SetProperty("LOCATION", this->GetLocation(0),
+      this->Properties.SetProperty("LOCATION", this->GetLocationForBuild(),
                                    cmProperty::TARGET);
       }
 
@@ -2725,15 +3257,15 @@
         {
         return 0;
         }
-      std::string configName = prop+9;
+      const char* configName = prop.c_str() + 9;
       this->Properties.SetProperty(prop,
-                                   this->GetLocation(configName.c_str()),
+                                   this->GetLocation(configName),
                                    cmProperty::TARGET);
       }
     // Support "<CONFIG>_LOCATION".
     if(cmHasLiteralSuffix(prop, "_LOCATION"))
       {
-      std::string configName(prop, strlen(prop) - 9);
+      std::string configName(prop.c_str(), prop.size() - 9);
       if(configName != "IMPORTED")
         {
         if (!this->HandleLocationPropertyPolicy(context))
@@ -2741,12 +3273,12 @@
           return 0;
           }
         this->Properties.SetProperty(prop,
-                                     this->GetLocation(configName.c_str()),
+                                     this->GetLocation(configName),
                                      cmProperty::TARGET);
         }
       }
     }
-  if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
+  if(prop == "INCLUDE_DIRECTORIES")
     {
     static std::string output;
     output = "";
@@ -2764,7 +3296,7 @@
       }
     return output.c_str();
     }
-  if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+  if(prop == "COMPILE_OPTIONS")
     {
     static std::string output;
     output = "";
@@ -2782,7 +3314,25 @@
       }
     return output.c_str();
     }
-  if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
+  if(prop == "COMPILE_FEATURES")
+    {
+    static std::string output;
+    output = "";
+    std::string sep;
+    typedef cmTargetInternals::TargetPropertyEntry
+                                TargetPropertyEntry;
+    for (std::vector<TargetPropertyEntry*>::const_iterator
+        it = this->Internal->CompileFeaturesEntries.begin(),
+        end = this->Internal->CompileFeaturesEntries.end();
+        it != end; ++it)
+      {
+      output += sep;
+      output += (*it)->ge->GetInput();
+      sep = ";";
+      }
+    return output.c_str();
+    }
+  if(prop == "COMPILE_DEFINITIONS")
     {
     static std::string output;
     output = "";
@@ -2800,7 +3350,7 @@
       }
     return output.c_str();
     }
-  if(strcmp(prop,"LINK_LIBRARIES") == 0)
+  if(prop == "LINK_LIBRARIES")
     {
     static std::string output;
     output = "";
@@ -2817,41 +3367,106 @@
     return output.c_str();
     }
 
-  if (strcmp(prop,"IMPORTED") == 0)
+  if (prop == "IMPORTED")
     {
     return this->IsImported()?"TRUE":"FALSE";
     }
 
-  if(!strcmp(prop,"SOURCES"))
+  if(prop == "SOURCES")
     {
     cmOStringStream ss;
     const char* sep = "";
-    for(std::vector<cmSourceFile*>::const_iterator
-          i = this->SourceFiles.begin();
-        i != this->SourceFiles.end(); ++i)
+    typedef cmTargetInternals::TargetPropertyEntry
+                                TargetPropertyEntry;
+    for(std::vector<TargetPropertyEntry*>::const_iterator
+          i = this->Internal->SourceEntries.begin();
+        i != this->Internal->SourceEntries.end(); ++i)
       {
-      // Separate from the previous list entries.
-      ss << sep;
-      sep = ";";
+      std::string entry = (*i)->ge->GetInput();
 
-      // Construct what is known about this source file location.
-      cmSourceFileLocation const& location = (*i)->GetLocation();
-      std::string sname = location.GetDirectory();
-      if(!sname.empty())
+      std::vector<std::string> files;
+      cmSystemTools::ExpandListArgument(entry, files);
+      for (std::vector<std::string>::const_iterator
+          li = files.begin(); li != files.end(); ++li)
         {
-        sname += "/";
-        }
-      sname += location.GetName();
+        if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
+            (*li)[li->size() - 1] == '>')
+          {
+          std::string objLibName = li->substr(17, li->size()-18);
 
-      // Append this list entry.
-      ss << sname;
+          if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
+            {
+            ss << sep;
+            sep = ";";
+            ss << *li;
+            continue;
+            }
+
+          bool addContent = false;
+          bool noMessage = true;
+          cmOStringStream e;
+          cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+          switch(context->GetPolicyStatus(cmPolicies::CMP0051))
+            {
+            case cmPolicies::WARN:
+              e << (this->Makefile->GetPolicies()
+                    ->GetPolicyWarning(cmPolicies::CMP0051)) << "\n";
+              noMessage = false;
+            case cmPolicies::OLD:
+              break;
+            case cmPolicies::REQUIRED_ALWAYS:
+            case cmPolicies::REQUIRED_IF_USED:
+            case cmPolicies::NEW:
+              addContent = true;
+            }
+          if (!noMessage)
+            {
+            e << "Target \"" << this->Name << "\" contains $<TARGET_OBJECTS> "
+            "generator expression in its sources list.  This content was not "
+            "previously part of the SOURCES property when that property was "
+            "read at configure time.  Code reading that property needs to be "
+            "adapted to ignore the generator expression using the "
+            "string(GENEX_STRIP) command.";
+            context->IssueMessage(messageType, e.str());
+            }
+          if (addContent)
+            {
+            ss << sep;
+            sep = ";";
+            ss << *li;
+            }
+          }
+        else if (cmGeneratorExpression::Find(*li) == std::string::npos)
+          {
+          ss << sep;
+          sep = ";";
+          ss << *li;
+          }
+        else
+          {
+          cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li);
+          // Construct what is known about this source file location.
+          cmSourceFileLocation const& location = sf->GetLocation();
+          std::string sname = location.GetDirectory();
+          if(!sname.empty())
+            {
+            sname += "/";
+            }
+          sname += location.GetName();
+
+          ss << sep;
+          sep = ";";
+          // Append this list entry.
+          ss << sname;
+          }
+        }
       }
     this->Properties.SetProperty("SOURCES", ss.str().c_str(),
                                  cmProperty::TARGET);
     }
 
   // the type property returns what type the target is
-  if (!strcmp(prop,"TYPE"))
+  if (prop == "TYPE")
     {
     return cmTarget::GetTargetTypeName(this->GetType());
     }
@@ -2866,7 +3481,7 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::GetPropertyAsBool(const char* prop) const
+bool cmTarget::GetPropertyAsBool(const std::string& prop) const
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
@@ -2875,8 +3490,9 @@
 class cmTargetCollectLinkLanguages
 {
 public:
-  cmTargetCollectLinkLanguages(cmTarget const* target, const char* config,
-                               std::set<cmStdString>& languages,
+  cmTargetCollectLinkLanguages(cmTarget const* target,
+                               const std::string& config,
+                               std::set<std::string>& languages,
                                cmTarget const* head):
     Config(config), Languages(languages), HeadTarget(head),
     Makefile(target->GetMakefile()), Target(target)
@@ -2947,8 +3563,8 @@
       }
     }
 private:
-  const char* Config;
-  std::set<cmStdString>& Languages;
+  std::string Config;
+  std::set<std::string>& Languages;
   cmTarget const* HeadTarget;
   cmMakefile* Makefile;
   const cmTarget* Target;
@@ -2956,20 +3572,19 @@
 };
 
 //----------------------------------------------------------------------------
-const char* cmTarget::GetLinkerLanguage(const char* config,
+std::string cmTarget::GetLinkerLanguage(const std::string& config,
                                         cmTarget const* head) const
 {
   cmTarget const* headTarget = head ? head : this;
-  const char* lang = this->GetLinkClosure(config, headTarget)
-                                                    ->LinkerLanguage.c_str();
-  return *lang? lang : 0;
+  return this->GetLinkClosure(config, headTarget)->LinkerLanguage;
 }
 
 //----------------------------------------------------------------------------
-cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config,
+cmTarget::LinkClosure const* cmTarget::GetLinkClosure(
+                                                  const std::string& config,
                                                   cmTarget const* head) const
 {
-  TargetConfigPair key(head, cmSystemTools::UpperCase(config ? config : ""));
+  TargetConfigPair key(head, cmSystemTools::UpperCase(config));
   cmTargetInternals::LinkClosureMapType::iterator
     i = this->Internal->LinkClosureMap.find(key);
   if(i == this->Internal->LinkClosureMap.end())
@@ -2989,14 +3604,14 @@
   cmTarget const* Target;
   cmMakefile* Makefile;
   cmGlobalGenerator* GG;
-  std::set<cmStdString> Preferred;
+  std::set<std::string> Preferred;
 public:
   cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target)
     {
     this->Makefile = this->Target->GetMakefile();
     this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
     }
-  void Consider(const char* lang)
+  void Consider(const std::string& lang)
     {
     int preference = this->GG->GetLinkerPreference(lang);
     if(preference > this->Preference)
@@ -3021,7 +3636,7 @@
       e << "Target " << this->Target->GetName()
         << " contains multiple languages with the highest linker preference"
         << " (" << this->Preference << "):\n";
-      for(std::set<cmStdString>::const_iterator
+      for(std::set<std::string>::const_iterator
             li = this->Preferred.begin(); li != this->Preferred.end(); ++li)
         {
         e << "  " << *li << "\n";
@@ -3036,11 +3651,11 @@
 };
 
 //----------------------------------------------------------------------------
-void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc,
+void cmTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc,
                                   cmTarget const* head) const
 {
   // Get languages built in this target.
-  std::set<cmStdString> languages;
+  std::set<std::string> languages;
   LinkImplementation const* impl = this->GetLinkImplementation(config, head);
   for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
       li != impl->Languages.end(); ++li)
@@ -3057,7 +3672,7 @@
     }
 
   // Store the transitive closure of languages.
-  for(std::set<cmStdString>::const_iterator li = languages.begin();
+  for(std::set<std::string>::const_iterator li = languages.begin();
       li != languages.end(); ++li)
     {
     lc.Languages.push_back(*li);
@@ -3081,17 +3696,17 @@
     for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
         li != impl->Languages.end(); ++li)
       {
-      tsl.Consider(li->c_str());
+      tsl.Consider(*li);
       }
 
     // Now consider languages that propagate from linked targets.
-    for(std::set<cmStdString>::const_iterator sit = languages.begin();
+    for(std::set<std::string>::const_iterator sit = languages.begin();
         sit != languages.end(); ++sit)
       {
       std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES";
-      if(this->Makefile->IsOn(propagates.c_str()))
+      if(this->Makefile->IsOn(propagates))
         {
-        tsl.Consider(sit->c_str());
+        tsl.Consider(*sit);
         }
       }
 
@@ -3149,7 +3764,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetPDBName(const char* config) const
+std::string cmTarget::GetPDBName(const std::string& config) const
 {
   std::string prefix;
   std::string base;
@@ -3157,8 +3772,7 @@
   this->GetFullNameInternal(config, false, prefix, base, suffix);
 
   std::vector<std::string> props;
-  std::string configUpper =
-    cmSystemTools::UpperCase(config? config : "");
+  std::string configUpper = cmSystemTools::UpperCase(config);
   if(!configUpper.empty())
     {
     // PDB_NAME_<CONFIG>
@@ -3171,7 +3785,7 @@
   for(std::vector<std::string>::const_iterator i = props.begin();
       i != props.end(); ++i)
     {
-    if(const char* outName = this->GetProperty(i->c_str()))
+    if(const char* outName = this->GetProperty(*i))
       {
       base = outName;
       break;
@@ -3181,7 +3795,50 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::HasSOName(const char* config) const
+std::string cmTarget::GetCompilePDBName(const std::string& config) const
+{
+  std::string prefix;
+  std::string base;
+  std::string suffix;
+  this->GetFullNameInternal(config, false, prefix, base, suffix);
+
+  // Check for a per-configuration output directory target property.
+  std::string configUpper = cmSystemTools::UpperCase(config);
+  std::string configProp = "COMPILE_PDB_NAME_";
+  configProp += configUpper;
+  const char* config_name = this->GetProperty(configProp);
+  if(config_name && *config_name)
+    {
+    return prefix + config_name + ".pdb";
+    }
+
+  const char* name = this->GetProperty("COMPILE_PDB_NAME");
+  if(name && *name)
+    {
+    return prefix + name + ".pdb";
+    }
+
+  return "";
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetCompilePDBPath(const std::string& config) const
+{
+  std::string dir = this->GetCompilePDBDirectory(config);
+  std::string name = this->GetCompilePDBName(config);
+  if(dir.empty() && !name.empty())
+    {
+    dir = this->GetPDBDirectory(config);
+    }
+  if(!dir.empty())
+    {
+    dir += "/";
+    }
+  return dir + name;
+}
+
+//----------------------------------------------------------------------------
+bool cmTarget::HasSOName(const std::string& config) const
 {
   // soname is supported only for shared libraries and modules,
   // and then only when the platform supports an soname flag.
@@ -3193,7 +3850,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetSOName(const char* config) const
+std::string cmTarget::GetSOName(const std::string& config) const
 {
   if(this->IsImported())
     {
@@ -3235,7 +3892,7 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::HasMacOSXRpathInstallNameDir(const char* config) const
+bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const
 {
   bool install_name_is_rpath = false;
   bool macosx_rpath = false;
@@ -3347,7 +4004,8 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const
+bool cmTarget::IsImportedSharedLibWithoutSOName(
+                                          const std::string& config) const
 {
   if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY)
     {
@@ -3360,7 +4018,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::NormalGetRealName(const char* config) const
+std::string cmTarget::NormalGetRealName(const std::string& config) const
 {
   // This should not be called for imported targets.
   // TODO: Split cmTarget into a class hierarchy to get compile-time
@@ -3371,7 +4029,7 @@
     msg += this->GetName();
     this->GetMakefile()->
       IssueMessage(cmake::INTERNAL_ERROR,
-                   msg.c_str());
+                   msg);
     }
 
   if(this->GetType() == cmTarget::EXECUTABLE)
@@ -3398,7 +4056,8 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetFullName(const char* config, bool implib) const
+std::string cmTarget::GetFullName(const std::string& config,
+                                  bool implib) const
 {
   if(this->IsImported())
     {
@@ -3412,7 +4071,7 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmTarget::GetFullNameImported(const char* config, bool implib) const
+cmTarget::GetFullNameImported(const std::string& config, bool implib) const
 {
   return cmSystemTools::GetFilenameName(
     this->ImportedGetFullPath(config, implib));
@@ -3420,14 +4079,15 @@
 
 //----------------------------------------------------------------------------
 void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base,
-                                     std::string& suffix, const char* config,
+                                     std::string& suffix,
+                                     const std::string& config,
                                      bool implib) const
 {
   this->GetFullNameInternal(config, implib, prefix, base, suffix);
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetFullPath(const char* config, bool implib,
+std::string cmTarget::GetFullPath(const std::string& config, bool implib,
                                   bool realname) const
 {
   if(this->IsImported())
@@ -3441,8 +4101,8 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
-                                        bool realname) const
+std::string cmTarget::NormalGetFullPath(const std::string& config,
+                                        bool implib, bool realname) const
 {
   std::string fpath = this->GetDirectory(config, implib);
   fpath += "/";
@@ -3470,7 +4130,7 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmTarget::ImportedGetFullPath(const char* config, bool implib) const
+cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const
 {
   std::string result;
   if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this))
@@ -3487,7 +4147,7 @@
 
 //----------------------------------------------------------------------------
 std::string
-cmTarget::GetFullNameInternal(const char* config, bool implib) const
+cmTarget::GetFullNameInternal(const std::string& config, bool implib) const
 {
   std::string prefix;
   std::string base;
@@ -3497,7 +4157,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::GetFullNameInternal(const char* config,
+void cmTarget::GetFullNameInternal(const std::string& config,
                                    bool implib,
                                    std::string& outPrefix,
                                    std::string& outBase,
@@ -3543,11 +4203,11 @@
                               ? this->GetProperty("IMPORT_SUFFIX")
                               : this->GetProperty("SUFFIX"));
   const char* configPostfix = 0;
-  if(config && *config)
+  if(!config.empty())
     {
     std::string configProp = cmSystemTools::UpperCase(config);
     configProp += "_POSTFIX";
-    configPostfix = this->GetProperty(configProp.c_str());
+    configPostfix = this->GetProperty(configProp);
     // Mac application bundles and frameworks have no postfix.
     if(configPostfix &&
        (this->IsAppBundleOnApple() || this->IsFrameworkOnApple()))
@@ -3559,17 +4219,18 @@
   const char* suffixVar = this->GetSuffixVariableInternal(implib);
 
   // Check for language-specific default prefix and suffix.
-  if(const char* ll = this->GetLinkerLanguage(config, this))
+  std::string ll = this->GetLinkerLanguage(config, this);
+  if(!ll.empty())
     {
     if(!targetSuffix && suffixVar && *suffixVar)
       {
       std::string langSuff = suffixVar + std::string("_") + ll;
-      targetSuffix = this->Makefile->GetDefinition(langSuff.c_str());
+      targetSuffix = this->Makefile->GetDefinition(langSuff);
       }
     if(!targetPrefix && prefixVar && *prefixVar)
       {
       std::string langPrefix = prefixVar + std::string("_") + ll;
-      targetPrefix = this->Makefile->GetDefinition(langPrefix.c_str());
+      targetPrefix = this->Makefile->GetDefinition(langPrefix);
       }
     }
 
@@ -3639,7 +4300,7 @@
                                std::string& realName,
                                std::string& impName,
                                std::string& pdbName,
-                               const char* config) const
+                               const std::string& config) const
 {
   // This should not be called for imported targets.
   // TODO: Split cmTarget into a class hierarchy to get compile-time
@@ -3649,7 +4310,7 @@
     std::string msg =  "GetLibraryNames called on imported target: ";
     msg += this->GetName();
     this->Makefile->IssueMessage(cmake::INTERNAL_ERROR,
-                                 msg.c_str());
+                                 msg);
     return;
     }
 
@@ -3743,7 +4404,7 @@
                                   std::string& realName,
                                   std::string& impName,
                                   std::string& pdbName,
-                                  const char* config) const
+                                  const std::string& config) const
 {
   // This should not be called for imported targets.
   // TODO: Split cmTarget into a class hierarchy to get compile-time
@@ -3753,7 +4414,7 @@
     std::string msg =
       "GetExecutableNames called on imported target: ";
     msg += this->GetName();
-    this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg.c_str());
+    this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
     }
 
   // This versioning is supported only for executables and then only
@@ -3821,14 +4482,14 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::SetPropertyDefault(const char* property,
+void cmTarget::SetPropertyDefault(const std::string& property,
                                   const char* default_value)
 {
   // Compute the name of the variable holding the default value.
   std::string var = "CMAKE_";
   var += property;
 
-  if(const char* value = this->Makefile->GetDefinition(var.c_str()))
+  if(const char* value = this->Makefile->GetDefinition(var))
     {
     this->SetProperty(property, value);
     }
@@ -3839,7 +4500,7 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::HaveBuildTreeRPATH(const char *config) const
+bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const
 {
   if (this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
     {
@@ -3859,7 +4520,7 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::NeedRelinkBeforeInstall(const char* config) const
+bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const
 {
   // Only executables and shared libraries can have an rpath and may
   // need relinking.
@@ -3896,12 +4557,13 @@
     }
 
   // Check for rpath support on this platform.
-  if(const char* ll = this->GetLinkerLanguage(config, this))
+  std::string ll = this->GetLinkerLanguage(config, this);
+  if(!ll.empty())
     {
     std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
     flagVar += ll;
     flagVar += "_FLAG";
-    if(!this->Makefile->IsSet(flagVar.c_str()))
+    if(!this->Makefile->IsSet(flagVar))
       {
       // There is no rpath support on this platform so nothing needs
       // relinking.
@@ -3922,7 +4584,8 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) const
+std::string cmTarget::GetInstallNameDirForBuildTree(
+    const std::string& config) const
 {
   // If building directly for installation then the build tree install_name
   // is the same as the install tree.
@@ -4044,10 +4707,11 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::ComputeOutputDir(const char* config,
+bool cmTarget::ComputeOutputDir(const std::string& config,
                                 bool implib, std::string& out) const
 {
   bool usesDefaultOutputDir = false;
+  std::string conf = config;
 
   // Look for a target property defining the target output directory
   // based on the target type.
@@ -4061,7 +4725,7 @@
     }
 
   // Check for a per-configuration output directory target property.
-  std::string configUpper = cmSystemTools::UpperCase(config? config : "");
+  std::string configUpper = cmSystemTools::UpperCase(conf);
   const char* configProp = 0;
   std::string configPropStr = targetTypeName;
   if(!configPropStr.empty())
@@ -4078,7 +4742,7 @@
     out = config_outdir;
 
     // Skip per-configuration subdirectory.
-    config = 0;
+    conf = "";
     }
   else if(const char* outdir = this->GetProperty(propertyName))
     {
@@ -4111,37 +4775,39 @@
          (out.c_str(), this->Makefile->GetStartOutputDirectory()));
 
   // The generator may add the configuration's subdirectory.
-  if(config && *config)
+  if(!conf.empty())
     {
     const char *platforms = this->Makefile->GetDefinition(
       "CMAKE_XCODE_EFFECTIVE_PLATFORMS");
     std::string suffix =
       usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : "";
     this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
-      AppendDirectoryForConfig("/", config, suffix.c_str(), out);
+      AppendDirectoryForConfig("/", conf, suffix, out);
     }
 
   return usesDefaultOutputDir;
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const
+bool cmTarget::ComputePDBOutputDir(const std::string& kind,
+                                   const std::string& config,
+                                   std::string& out) const
 {
   // Look for a target property defining the target output directory
   // based on the target type.
-  std::string targetTypeName = "PDB";
   const char* propertyName = 0;
-  std::string propertyNameStr = targetTypeName;
+  std::string propertyNameStr = kind;
   if(!propertyNameStr.empty())
     {
     propertyNameStr += "_OUTPUT_DIRECTORY";
     propertyName = propertyNameStr.c_str();
     }
+  std::string conf = config;
 
   // Check for a per-configuration output directory target property.
-  std::string configUpper = cmSystemTools::UpperCase(config? config : "");
+  std::string configUpper = cmSystemTools::UpperCase(conf);
   const char* configProp = 0;
-  std::string configPropStr = targetTypeName;
+  std::string configPropStr = kind;
   if(!configPropStr.empty())
     {
     configPropStr += "_OUTPUT_DIRECTORY_";
@@ -4156,7 +4822,7 @@
     out = config_outdir;
 
     // Skip per-configuration subdirectory.
-    config = 0;
+    conf = "";
     }
   else if(const char* outdir = this->GetProperty(propertyName))
     {
@@ -4175,27 +4841,29 @@
          (out.c_str(), this->Makefile->GetStartOutputDirectory()));
 
   // The generator may add the configuration's subdirectory.
-  if(config && *config)
+  if(!conf.empty())
     {
     this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
-      AppendDirectoryForConfig("/", config, "", out);
+      AppendDirectoryForConfig("/", conf, "", out);
     }
   return true;
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) const
+bool cmTarget::UsesDefaultOutputDir(const std::string& config,
+                                    bool implib) const
 {
   std::string dir;
   return this->ComputeOutputDir(config, implib, dir);
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetOutputName(const char* config, bool implib) const
+std::string cmTarget::GetOutputName(const std::string& config,
+                                    bool implib) const
 {
   std::vector<std::string> props;
   std::string type = this->GetOutputTargetType(implib);
-  std::string configUpper = cmSystemTools::UpperCase(config? config : "");
+  std::string configUpper = cmSystemTools::UpperCase(config);
   if(!type.empty() && !configUpper.empty())
     {
     // <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
@@ -4219,7 +4887,7 @@
   for(std::vector<std::string>::const_iterator i = props.begin();
       i != props.end(); ++i)
     {
-    if(const char* outName = this->GetProperty(i->c_str()))
+    if(const char* outName = this->GetProperty(*i))
       {
       return outName;
       }
@@ -4487,8 +5155,7 @@
   areport += result;
   areport += "\"):\n" + report;
 
-  cmListFileBacktrace lfbt;
-  this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport, lfbt);
+  this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport);
 }
 
 //----------------------------------------------------------------------------
@@ -4529,7 +5196,7 @@
 template<typename PropertyType>
 PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
                                           const std::string &p,
-                                          const char *config,
+                                          const std::string& config,
                                           const char *defaultValue,
                                           CompatibleType t,
                                           PropertyType *)
@@ -4537,19 +5204,20 @@
   PropertyType propContent = getTypedProperty<PropertyType>(tgt, p.c_str(),
                                                             0);
   const bool explicitlySet = tgt->GetProperties()
-                                  .find(p.c_str())
+                                  .find(p)
                                   != tgt->GetProperties().end();
   const bool impliedByUse =
           tgt->IsNullImpliedByLinkLibraries(p);
   assert((impliedByUse ^ explicitlySet)
       || (!impliedByUse && !explicitlySet));
 
-  cmComputeLinkInformation *info = tgt->GetLinkInformation(config);
-  if(!info)
+  std::vector<cmTarget*> deps;
+  tgt->GetTransitiveTargetClosure(config, tgt, deps);
+
+  if(deps.empty())
     {
     return propContent;
     }
-  const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
   bool propInitialized = explicitlySet;
 
   std::string report = " * Target \"";
@@ -4569,7 +5237,7 @@
     report += "\" property not set.\n";
     }
 
-  for(cmComputeLinkInformation::ItemVector::const_iterator li =
+  for(std::vector<cmTarget*>::const_iterator li =
       deps.begin();
       li != deps.end(); ++li)
     {
@@ -4579,23 +5247,20 @@
     // target itself has a POSITION_INDEPENDENT_CODE which disagrees
     // with a dependency.
 
-    if (!li->Target)
-      {
-      continue;
-      }
+    cmTarget const* theTarget = *li;
 
-    const bool ifaceIsSet = li->Target->GetProperties()
+    const bool ifaceIsSet = theTarget->GetProperties()
                             .find("INTERFACE_" + p)
-                            != li->Target->GetProperties().end();
+                            != theTarget->GetProperties().end();
     PropertyType ifacePropContent =
-                    getTypedProperty<PropertyType>(li->Target,
+                    getTypedProperty<PropertyType>(theTarget,
                               ("INTERFACE_" + p).c_str(), 0);
 
     std::string reportEntry;
     if (ifaceIsSet)
       {
       reportEntry += " * Target \"";
-      reportEntry += li->Target->GetName();
+      reportEntry += theTarget->GetName();
       reportEntry += "\" property value \"";
       reportEntry += valueAsString<PropertyType>(ifacePropContent);
       reportEntry += "\" ";
@@ -4616,7 +5281,7 @@
           e << "Property " << p << " on target \""
             << tgt->GetName() << "\" does\nnot match the "
             "INTERFACE_" << p << " property requirement\nof "
-            "dependency \"" << li->Target->GetName() << "\".\n";
+            "dependency \"" << theTarget->GetName() << "\".\n";
           cmSystemTools::Error(e.str().c_str());
           break;
           }
@@ -4650,7 +5315,7 @@
             << tgt->GetName() << "\" is\nimplied to be " << defaultValue
             << " because it was used to determine the link libraries\n"
                "already. The INTERFACE_" << p << " property on\ndependency \""
-            << li->Target->GetName() << "\" is in conflict.\n";
+            << theTarget->GetName() << "\" is in conflict.\n";
           cmSystemTools::Error(e.str().c_str());
           break;
           }
@@ -4681,7 +5346,7 @@
             {
             cmOStringStream e;
             e << "The INTERFACE_" << p << " property of \""
-              << li->Target->GetName() << "\" does\nnot agree with the value "
+              << theTarget->GetName() << "\" does\nnot agree with the value "
                 "of " << p << " already determined\nfor \""
               << tgt->GetName() << "\".\n";
             cmSystemTools::Error(e.str().c_str());
@@ -4715,7 +5380,7 @@
 
 //----------------------------------------------------------------------------
 bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p,
-                                                     const char *config) const
+                                              const std::string& config) const
 {
   return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE",
                                                    BoolType, 0);
@@ -4723,8 +5388,8 @@
 
 //----------------------------------------------------------------------------
 const char * cmTarget::GetLinkInterfaceDependentStringProperty(
-                                                      const std::string &p,
-                                                      const char *config) const
+                                              const std::string &p,
+                                              const std::string& config) const
 {
   return checkInterfacePropertyCompatibility<const char *>(this,
                                                            p,
@@ -4735,8 +5400,8 @@
 
 //----------------------------------------------------------------------------
 const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty(
-                                                      const std::string &p,
-                                                      const char *config) const
+                                              const std::string &p,
+                                              const std::string& config) const
 {
   return checkInterfacePropertyCompatibility<const char *>(this,
                                                            p,
@@ -4747,8 +5412,8 @@
 
 //----------------------------------------------------------------------------
 const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty(
-                                                      const std::string &p,
-                                                      const char *config) const
+                                              const std::string &p,
+                                              const std::string& config) const
 {
   return checkInterfacePropertyCompatibility<const char *>(this,
                                                            p,
@@ -4759,26 +5424,22 @@
 
 //----------------------------------------------------------------------------
 bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p,
-                             const char *interfaceProperty,
-                             const char *config)
+                             const std::string& interfaceProperty,
+                             const std::string& config)
 {
-  cmComputeLinkInformation *info = tgt->GetLinkInformation(config);
-  if(!info)
+  std::vector<cmTarget*> deps;
+  tgt->GetTransitiveTargetClosure(config, tgt, deps);
+
+  if(deps.empty())
     {
     return false;
     }
 
-  const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
-
-  for(cmComputeLinkInformation::ItemVector::const_iterator li =
+  for(std::vector<cmTarget*>::const_iterator li =
       deps.begin();
       li != deps.end(); ++li)
     {
-    if (!li->Target)
-      {
-      continue;
-      }
-    const char *prop = li->Target->GetProperty(interfaceProperty);
+    const char *prop = (*li)->GetProperty(interfaceProperty);
     if (!prop)
       {
       continue;
@@ -4802,7 +5463,7 @@
 
 //----------------------------------------------------------------------------
 bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p,
-                                           const char *config) const
+                                           const std::string& config) const
 {
   if (this->TargetTypeValue == OBJECT_LIBRARY
       || this->TargetTypeValue == INTERFACE_LIBRARY)
@@ -4816,7 +5477,7 @@
 
 //----------------------------------------------------------------------------
 bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p,
-                                    const char *config) const
+                                    const std::string& config) const
 {
   if (this->TargetTypeValue == OBJECT_LIBRARY
       || this->TargetTypeValue == INTERFACE_LIBRARY)
@@ -4830,7 +5491,7 @@
 
 //----------------------------------------------------------------------------
 bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
-                                    const char *config) const
+                                    const std::string& config) const
 {
   if (this->TargetTypeValue == OBJECT_LIBRARY
       || this->TargetTypeValue == INTERFACE_LIBRARY)
@@ -4843,7 +5504,7 @@
 
 //----------------------------------------------------------------------------
 bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
-                                    const char *config) const
+                                    const std::string& config) const
 {
   if (this->TargetTypeValue == OBJECT_LIBRARY
       || this->TargetTypeValue == INTERFACE_LIBRARY)
@@ -4855,20 +5516,94 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::GetLanguages(std::set<cmStdString>& languages) const
+void
+cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const
 {
-  for(std::vector<cmSourceFile*>::const_iterator
-        i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i)
+  // At configure-time, this method can be called as part of getting the
+  // LOCATION property or to export() a file to be include()d.  However
+  // there is no cmGeneratorTarget at configure-time, so search the SOURCES
+  // for TARGET_OBJECTS instead for backwards compatibility with OLD
+  // behavior of CMP0024 and CMP0026 only.
+  typedef cmTargetInternals::TargetPropertyEntry
+                              TargetPropertyEntry;
+  for(std::vector<TargetPropertyEntry*>::const_iterator
+        i = this->Internal->SourceEntries.begin();
+      i != this->Internal->SourceEntries.end(); ++i)
     {
-    if(const char* lang = (*i)->GetLanguage())
+    std::string entry = (*i)->ge->GetInput();
+
+    std::vector<std::string> files;
+    cmSystemTools::ExpandListArgument(entry, files);
+    for (std::vector<std::string>::const_iterator
+        li = files.begin(); li != files.end(); ++li)
       {
-      languages.insert(lang);
+      if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
+          (*li)[li->size() - 1] == '>')
+        {
+        std::string objLibName = li->substr(17, li->size()-18);
+
+        if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
+          {
+          continue;
+          }
+        cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName.c_str());
+        if(objLib)
+          {
+          objlibs.push_back(objLib);
+          }
+        }
       }
     }
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::IsChrpathUsed(const char* config) const
+void cmTarget::GetLanguages(std::set<std::string>& languages,
+                            const std::string& config,
+                            cmTarget const* head) const
+{
+  std::vector<cmSourceFile*> sourceFiles;
+  this->GetSourceFiles(sourceFiles, config, head);
+  for(std::vector<cmSourceFile*>::const_iterator
+        i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
+    {
+    const std::string& lang = (*i)->GetLanguage();
+    if(!lang.empty())
+      {
+      languages.insert(lang);
+      }
+    }
+
+  std::vector<cmTarget*> objectLibraries;
+  std::vector<cmSourceFile const*> externalObjects;
+  if (this->Makefile->GetGeneratorTargets().empty())
+    {
+    this->GetObjectLibrariesCMP0026(objectLibraries);
+    }
+  else
+    {
+    cmGeneratorTarget* gt = this->Makefile->GetLocalGenerator()
+                                ->GetGlobalGenerator()
+                                ->GetGeneratorTarget(this);
+    gt->GetExternalObjects(externalObjects, config);
+    for(std::vector<cmSourceFile const*>::const_iterator
+          i = externalObjects.begin(); i != externalObjects.end(); ++i)
+      {
+      std::string objLib = (*i)->GetObjectLibrary();
+      if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
+        {
+        objectLibraries.push_back(tgt);
+        }
+      }
+    }
+  for(std::vector<cmTarget*>::const_iterator
+      i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
+    {
+    (*i)->GetLanguages(languages, config, head);
+    }
+}
+
+//----------------------------------------------------------------------------
+bool cmTarget::IsChrpathUsed(const std::string& config) const
 {
   // Only certain target types have an rpath.
   if(!(this->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -4911,12 +5646,13 @@
 #if defined(CMAKE_USE_ELF_PARSER)
   // Enable if the rpath flag uses a separator and the target uses ELF
   // binaries.
-  if(const char* ll = this->GetLinkerLanguage(config, this))
+  std::string ll = this->GetLinkerLanguage(config, this);
+  if(!ll.empty())
     {
     std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
     sepVar += ll;
     sepVar += "_FLAG_SEP";
-    const char* sep = this->Makefile->GetDefinition(sepVar.c_str());
+    const char* sep = this->Makefile->GetDefinition(sepVar);
     if(sep && *sep)
       {
       // TODO: Add ELF check to ABI detection and get rid of
@@ -4935,7 +5671,8 @@
 
 //----------------------------------------------------------------------------
 cmTarget::ImportInfo const*
-cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const
+cmTarget::GetImportInfo(const std::string& config,
+                        cmTarget const* headTarget) const
 {
   // There is no imported information for non-imported targets.
   if(!this->IsImported())
@@ -4946,7 +5683,7 @@
   // Lookup/compute/cache the import information for this
   // configuration.
   std::string config_upper;
-  if(config && *config)
+  if(!config.empty())
     {
     config_upper = cmSystemTools::UpperCase(config);
     }
@@ -5004,7 +5741,7 @@
   {
   std::string mapProp = "MAP_IMPORTED_CONFIG_";
   mapProp += desired_config;
-  if(const char* mapValue = this->GetProperty(mapProp.c_str()))
+  if(const char* mapValue = this->GetProperty(mapProp))
     {
     cmSystemTools::ExpandListArgument(mapValue, mappedConfigs);
     }
@@ -5020,15 +5757,15 @@
       !*loc && !*imp && mci != mappedConfigs.end(); ++mci)
     {
     // Look for this configuration.
-    std::string mcUpper = cmSystemTools::UpperCase(mci->c_str());
+    std::string mcUpper = cmSystemTools::UpperCase(*mci);
     std::string locProp = "IMPORTED_LOCATION_";
     locProp += mcUpper;
-    *loc = this->GetProperty(locProp.c_str());
+    *loc = this->GetProperty(locProp);
     if(allowImp)
       {
       std::string impProp = "IMPORTED_IMPLIB_";
       impProp += mcUpper;
-      *imp = this->GetProperty(impProp.c_str());
+      *imp = this->GetProperty(impProp);
       }
 
     // If it was found, use it for all properties below.
@@ -5053,12 +5790,12 @@
     {
     std::string locProp = "IMPORTED_LOCATION";
     locProp += suffix;
-    *loc = this->GetProperty(locProp.c_str());
+    *loc = this->GetProperty(locProp);
     if(allowImp)
       {
       std::string impProp = "IMPORTED_IMPLIB";
       impProp += suffix;
-      *imp = this->GetProperty(impProp.c_str());
+      *imp = this->GetProperty(impProp);
       }
     }
 
@@ -5095,12 +5832,12 @@
       suffix += cmSystemTools::UpperCase(*aci);
       std::string locProp = "IMPORTED_LOCATION";
       locProp += suffix;
-      *loc = this->GetProperty(locProp.c_str());
+      *loc = this->GetProperty(locProp);
       if(allowImp)
         {
         std::string impProp = "IMPORTED_IMPLIB";
         impProp += suffix;
-        *imp = this->GetProperty(impProp.c_str());
+        *imp = this->GetProperty(impProp);
         }
       }
     }
@@ -5136,7 +5873,7 @@
   // Get the link interface.
   {
   std::string linkProp = "INTERFACE_LINK_LIBRARIES";
-  const char *propertyLibs = this->GetProperty(linkProp.c_str());
+  const char *propertyLibs = this->GetProperty(linkProp);
 
   if (this->GetType() != INTERFACE_LIBRARY)
     {
@@ -5144,26 +5881,25 @@
       {
       linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
       linkProp += suffix;
-      propertyLibs = this->GetProperty(linkProp.c_str());
+      propertyLibs = this->GetProperty(linkProp);
       }
 
     if(!propertyLibs)
       {
       linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
-      propertyLibs = this->GetProperty(linkProp.c_str());
+      propertyLibs = this->GetProperty(linkProp);
       }
     }
   if(propertyLibs)
     {
-    cmListFileBacktrace lfbt;
-    cmGeneratorExpression ge(lfbt);
+    cmGeneratorExpression ge;
 
-    cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+    cmGeneratorExpressionDAGChecker dagChecker(
                                         this->GetName(),
                                         linkProp, 0, 0);
     cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs)
                                        ->Evaluate(this->Makefile,
-                                                  desired_config.c_str(),
+                                                  desired_config,
                                                   false,
                                                   headTarget,
                                                   this,
@@ -5188,7 +5924,7 @@
     {
     std::string impProp = "IMPORTED_LOCATION";
     impProp += suffix;
-    if(const char* config_location = this->GetProperty(impProp.c_str()))
+    if(const char* config_location = this->GetProperty(impProp))
       {
       info.Location = config_location;
       }
@@ -5203,7 +5939,7 @@
     {
     std::string soProp = "IMPORTED_SONAME";
     soProp += suffix;
-    if(const char* config_soname = this->GetProperty(soProp.c_str()))
+    if(const char* config_soname = this->GetProperty(soProp))
       {
       info.SOName = config_soname;
       }
@@ -5218,7 +5954,7 @@
     {
     std::string soProp = "IMPORTED_NO_SONAME";
     soProp += suffix;
-    if(const char* config_no_soname = this->GetProperty(soProp.c_str()))
+    if(const char* config_no_soname = this->GetProperty(soProp))
       {
       info.NoSOName = cmSystemTools::IsOn(config_no_soname);
       }
@@ -5238,7 +5974,7 @@
     {
     std::string impProp = "IMPORTED_IMPLIB";
     impProp += suffix;
-    if(const char* config_implib = this->GetProperty(impProp.c_str()))
+    if(const char* config_implib = this->GetProperty(impProp))
       {
       info.ImportLibrary = config_implib;
       }
@@ -5252,7 +5988,7 @@
   {
   std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES";
   linkProp += suffix;
-  if(const char* config_libs = this->GetProperty(linkProp.c_str()))
+  if(const char* config_libs = this->GetProperty(linkProp))
     {
     cmSystemTools::ExpandListArgument(config_libs,
                                       info.LinkInterface.SharedDeps);
@@ -5269,7 +6005,7 @@
     {
     std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
     linkProp += suffix;
-    if(const char* config_libs = this->GetProperty(linkProp.c_str()))
+    if(const char* config_libs = this->GetProperty(linkProp))
       {
       cmSystemTools::ExpandListArgument(config_libs,
                                         info.LinkInterface.Languages);
@@ -5287,7 +6023,7 @@
     {
     std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
     linkProp += suffix;
-    if(const char* config_reps = this->GetProperty(linkProp.c_str()))
+    if(const char* config_reps = this->GetProperty(linkProp))
       {
       sscanf(config_reps, "%u", &info.LinkInterface.Multiplicity);
       }
@@ -5300,7 +6036,8 @@
 }
 
 //----------------------------------------------------------------------------
-cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config,
+cmTarget::LinkInterface const* cmTarget::GetLinkInterface(
+                                                  const std::string& config,
                                                   cmTarget const* head) const
 {
   // Imported targets have their own link interface.
@@ -5322,7 +6059,7 @@
     }
 
   // Lookup any existing link interface for this configuration.
-  TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : ""));
+  TargetConfigPair key(head, cmSystemTools::UpperCase(config));
 
   cmTargetInternals::LinkInterfaceMapType::iterator
     i = this->Internal->LinkInterfaceMap.find(key);
@@ -5330,24 +6067,124 @@
     {
     // Compute the link interface for this configuration.
     cmTargetInternals::OptionalLinkInterface iface;
-    iface.Exists = this->ComputeLinkInterface(config, iface, head);
+    iface.ExplicitLibraries =
+        this->ComputeLinkInterfaceLibraries(config, iface, head, iface.Exists);
+    if (iface.Exists)
+      {
+      this->Internal->ComputeLinkInterface(this, config, iface,
+                                           head, iface.ExplicitLibraries);
+      }
+
+    // Store the information for this configuration.
+    cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface);
+    i = this->Internal->LinkInterfaceMap.insert(entry).first;
+    }
+  else if(!i->second.Complete && i->second.Exists)
+    {
+    this->Internal->ComputeLinkInterface(this, config, i->second, head,
+                                         i->second.ExplicitLibraries);
+    }
+
+  return i->second.Exists ? &i->second : 0;
+}
+
+//----------------------------------------------------------------------------
+cmTarget::LinkInterface const*
+cmTarget::GetLinkInterfaceLibraries(const std::string& config,
+                                    cmTarget const* head) const
+{
+  // Imported targets have their own link interface.
+  if(this->IsImported())
+    {
+    if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, head))
+      {
+      return &info->LinkInterface;
+      }
+    return 0;
+    }
+
+  // Link interfaces are not supported for executables that do not
+  // export symbols.
+  if(this->GetType() == cmTarget::EXECUTABLE &&
+     !this->IsExecutableWithExports())
+    {
+    return 0;
+    }
+
+  // Lookup any existing link interface for this configuration.
+  TargetConfigPair key(head, cmSystemTools::UpperCase(config));
+
+  cmTargetInternals::LinkInterfaceMapType::iterator
+    i = this->Internal->LinkInterfaceMap.find(key);
+  if(i == this->Internal->LinkInterfaceMap.end())
+    {
+    // Compute the link interface for this configuration.
+    cmTargetInternals::OptionalLinkInterface iface;
+    iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config,
+                                                                iface,
+                                                                head,
+                                                                iface.Exists);
 
     // Store the information for this configuration.
     cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface);
     i = this->Internal->LinkInterfaceMap.insert(entry).first;
     }
 
-  return i->second.Exists? &i->second : 0;
+  return i->second.Exists ? &i->second : 0;
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::GetTransitivePropertyLinkLibraries(
-                                      const char* config,
-                                      cmTarget const* headTarget,
-                                      std::vector<std::string> &libs) const
+void processILibs(const std::string& config,
+                  cmTarget const* headTarget,
+                  std::string const& name,
+                  std::vector<cmTarget*>& tgts, std::set<cmTarget*>& emitted)
 {
-  cmTarget::LinkInterface const* iface = this->GetLinkInterface(config,
-                                                                headTarget);
+  if (cmTarget* tgt = headTarget->GetMakefile()
+                                ->FindTargetToUse(name))
+    {
+    if (emitted.insert(tgt).second)
+      {
+      tgts.push_back(tgt);
+      std::vector<std::string> ilibs;
+      cmTarget::LinkInterface const* iface =
+                          tgt->GetLinkInterfaceLibraries(config, headTarget);
+      if (iface)
+        {
+        for(std::vector<std::string>::const_iterator
+            it = iface->Libraries.begin();
+            it != iface->Libraries.end(); ++it)
+          {
+          processILibs(config, headTarget, *it, tgts, emitted);
+          }
+        }
+      }
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetTransitiveTargetClosure(const std::string& config,
+                                      cmTarget const* headTarget,
+                                      std::vector<cmTarget*> &tgts) const
+{
+  std::set<cmTarget*> emitted;
+
+  cmTarget::LinkImplementation const* impl
+      = this->GetLinkImplementationLibraries(config, headTarget);
+
+  for(std::vector<std::string>::const_iterator it = impl->Libraries.begin();
+      it != impl->Libraries.end(); ++it)
+    {
+      processILibs(config, headTarget, *it, tgts, emitted);
+    }
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetTransitivePropertyTargets(const std::string& config,
+                                      cmTarget const* headTarget,
+                                      std::vector<cmTarget*> &tgts) const
+{
+  cmTarget::LinkInterface const* iface
+                        = this->GetLinkInterfaceLibraries(config, headTarget);
   if (!iface)
     {
     return;
@@ -5356,7 +6193,15 @@
       || this->GetPolicyStatusCMP0022() == cmPolicies::WARN
       || this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
     {
-    libs = iface->Libraries;
+    for(std::vector<std::string>::const_iterator it = iface->Libraries.begin();
+        it != iface->Libraries.end(); ++it)
+      {
+      if (cmTarget* tgt = headTarget->GetMakefile()
+                                    ->FindTargetToUse(*it))
+        {
+        tgts.push_back(tgt);
+        }
+      }
     return;
     }
 
@@ -5369,26 +6214,38 @@
     }
 
   // The interface libraries have been explicitly set.
-  cmListFileBacktrace lfbt;
-  cmGeneratorExpression ge(lfbt);
-  cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
-                                              linkIfaceProp, 0, 0);
+  cmGeneratorExpression ge;
+  cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+                                             linkIfaceProp, 0, 0);
   dagChecker.SetTransitivePropertiesOnly();
+  std::vector<std::string> libs;
   cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate(
                                       this->Makefile,
                                       config,
                                       false,
                                       headTarget,
                                       this, &dagChecker), libs);
+
+  for(std::vector<std::string>::const_iterator it = libs.begin();
+      it != libs.end(); ++it)
+    {
+    if (cmTarget* tgt = headTarget->GetMakefile()
+                                  ->FindTargetToUse(*it))
+      {
+      tgts.push_back(tgt);
+      }
+    }
 }
 
 //----------------------------------------------------------------------------
-bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
-                                    cmTarget const* headTarget) const
+const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config,
+                                           LinkInterface& iface,
+                                           cmTarget const* headTarget,
+                                           bool &exists) const
 {
   // Construct the property name suffix for this configuration.
   std::string suffix = "_";
-  if(config && *config)
+  if(!config.empty())
     {
     suffix += cmSystemTools::UpperCase(config);
     }
@@ -5406,7 +6263,7 @@
     {
     // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
     linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
-    explicitLibraries = this->GetProperty(linkIfaceProp.c_str());
+    explicitLibraries = this->GetProperty(linkIfaceProp);
     }
   else if(this->GetType() == cmTarget::SHARED_LIBRARY ||
           this->IsExecutableWithExports())
@@ -5417,13 +6274,13 @@
     // Lookup the per-configuration property.
     linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
     linkIfaceProp += suffix;
-    explicitLibraries = this->GetProperty(linkIfaceProp.c_str());
+    explicitLibraries = this->GetProperty(linkIfaceProp);
 
     // If not set, try the generic property.
     if(!explicitLibraries)
       {
       linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
-      explicitLibraries = this->GetProperty(linkIfaceProp.c_str());
+      explicitLibraries = this->GetProperty(linkIfaceProp);
       }
     }
 
@@ -5460,15 +6317,16 @@
      (this->GetType() == cmTarget::EXECUTABLE ||
       (this->GetType() == cmTarget::MODULE_LIBRARY)))
     {
-    return false;
+    exists = false;
+    return 0;
     }
+  exists = true;
 
   if(explicitLibraries)
     {
     // The interface libraries have been explicitly set.
-    cmListFileBacktrace lfbt;
-    cmGeneratorExpression ge(lfbt);
-    cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
+    cmGeneratorExpression ge;
+    cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
                                                linkIfaceProp, 0, 0);
     cmSystemTools::ExpandListArgument(ge.Parse(explicitLibraries)->Evaluate(
                                         this->Makefile,
@@ -5476,47 +6334,6 @@
                                         false,
                                         headTarget,
                                         this, &dagChecker), iface.Libraries);
-
-    if(this->GetType() == cmTarget::SHARED_LIBRARY
-        || this->GetType() == cmTarget::STATIC_LIBRARY
-        || this->GetType() == cmTarget::INTERFACE_LIBRARY)
-      {
-      // Shared libraries may have runtime implementation dependencies
-      // on other shared libraries that are not in the interface.
-      std::set<cmStdString> emitted;
-      for(std::vector<std::string>::const_iterator
-            li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
-        {
-        emitted.insert(*li);
-        }
-      if (this->GetType() != cmTarget::INTERFACE_LIBRARY)
-        {
-        LinkImplementation const* impl = this->GetLinkImplementation(config,
-                                                                  headTarget);
-        for(std::vector<std::string>::const_iterator
-              li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
-          {
-          if(emitted.insert(*li).second)
-            {
-            if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li))
-              {
-              // This is a runtime dependency on another shared library.
-              if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
-                {
-                iface.SharedDeps.push_back(*li);
-                }
-              }
-            else
-              {
-              // TODO: Recognize shared library file names.  Perhaps this
-              // should be moved to cmComputeLinkInformation, but that creates
-              // a chicken-and-egg problem since this list is needed for its
-              // construction.
-              }
-            }
-          }
-        }
-      }
     }
   else if (this->PolicyStatusCMP0022 == cmPolicies::WARN
         || this->PolicyStatusCMP0022 == cmPolicies::OLD)
@@ -5526,20 +6343,16 @@
     // to the link implementation.
     {
     // The link implementation is the default link interface.
-    LinkImplementation const* impl = this->GetLinkImplementation(config,
-                                                              headTarget);
-    iface.ImplementationIsInterface = true;
+    LinkImplementation const* impl =
+        this->GetLinkImplementationLibraries(config, headTarget);
     iface.Libraries = impl->Libraries;
-    iface.WrongConfigLibraries = impl->WrongConfigLibraries;
-
     if(this->PolicyStatusCMP0022 == cmPolicies::WARN &&
        !this->Internal->PolicyWarnedCMP0022)
       {
       // Compare the link implementation fallback link interface to the
       // preferred new link interface property and warn if different.
-      cmListFileBacktrace lfbt;
-      cmGeneratorExpression ge(lfbt);
-      cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
+      cmGeneratorExpression ge;
+      cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
                                       "INTERFACE_LINK_LIBRARIES", 0, 0);
       std::vector<std::string> ifaceLibs;
       const char* newExplicitLibraries =
@@ -5596,40 +6409,113 @@
         }
       }
     }
+  return explicitLibraries;
+}
 
-  if(this->LinkLanguagePropagatesToDependents())
+//----------------------------------------------------------------------------
+void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget,
+                                             const std::string& config,
+                                             OptionalLinkInterface& iface,
+                                             cmTarget const* headTarget,
+                                          const char* explicitLibraries) const
+{
+  if(explicitLibraries)
+    {
+    if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY
+        || thisTarget->GetType() == cmTarget::STATIC_LIBRARY
+        || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY)
+      {
+      // Shared libraries may have runtime implementation dependencies
+      // on other shared libraries that are not in the interface.
+      std::set<std::string> emitted;
+      for(std::vector<std::string>::const_iterator
+          li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
+        {
+        emitted.insert(*li);
+        }
+      if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY)
+        {
+        cmTarget::LinkImplementation const* impl =
+            thisTarget->GetLinkImplementation(config, headTarget);
+        for(std::vector<std::string>::const_iterator
+              li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
+          {
+          if(emitted.insert(*li).second)
+            {
+            if(cmTarget* tgt = thisTarget->Makefile->FindTargetToUse(*li))
+              {
+              // This is a runtime dependency on another shared library.
+              if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
+                {
+                iface.SharedDeps.push_back(*li);
+                }
+              }
+            else
+              {
+              // TODO: Recognize shared library file names.  Perhaps this
+              // should be moved to cmComputeLinkInformation, but that creates
+              // a chicken-and-egg problem since this list is needed for its
+              // construction.
+              }
+            }
+          }
+        }
+      }
+    }
+  else if (thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN
+        || thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD)
+    {
+    // The link implementation is the default link interface.
+    cmTarget::LinkImplementation const*
+                impl = thisTarget->GetLinkImplementation(config, headTarget);
+    iface.ImplementationIsInterface = true;
+    iface.WrongConfigLibraries = impl->WrongConfigLibraries;
+    }
+
+  if(thisTarget->LinkLanguagePropagatesToDependents())
     {
     // Targets using this archive need its language runtime libraries.
-    if(LinkImplementation const* impl =
-       this->GetLinkImplementation(config, headTarget))
+    if(cmTarget::LinkImplementation const* impl =
+       thisTarget->GetLinkImplementation(config, headTarget))
       {
       iface.Languages = impl->Languages;
       }
     }
 
-  if(this->GetType() == cmTarget::STATIC_LIBRARY)
+  if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY)
     {
+    // Construct the property name suffix for this configuration.
+    std::string suffix = "_";
+    if(!config.empty())
+      {
+      suffix += cmSystemTools::UpperCase(config);
+      }
+    else
+      {
+      suffix += "NOCONFIG";
+      }
+
     // How many repetitions are needed if this library has cyclic
     // dependencies?
     std::string propName = "LINK_INTERFACE_MULTIPLICITY";
     propName += suffix;
-    if(const char* config_reps = this->GetProperty(propName.c_str()))
+    if(const char* config_reps = thisTarget->GetProperty(propName))
       {
       sscanf(config_reps, "%u", &iface.Multiplicity);
       }
     else if(const char* reps =
-            this->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
+            thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
       {
       sscanf(reps, "%u", &iface.Multiplicity);
       }
     }
-
-  return true;
+  iface.Complete = true;
 }
 
 //----------------------------------------------------------------------------
 cmTarget::LinkImplementation const*
-cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const
+cmTarget::GetLinkImplementation(const std::string& config,
+                                cmTarget const* head) const
 {
   // There is no link implementation for imported targets.
   if(this->IsImported())
@@ -5638,7 +6524,42 @@
     }
 
   // Lookup any existing link implementation for this configuration.
-  TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : ""));
+  TargetConfigPair key(head, cmSystemTools::UpperCase(config));
+
+  cmTargetInternals::LinkImplMapType::iterator
+    i = this->Internal->LinkImplMap.find(key);
+  if(i == this->Internal->LinkImplMap.end())
+    {
+    // Compute the link implementation for this configuration.
+    LinkImplementation impl;
+    this->ComputeLinkImplementation(config, impl, head);
+    this->ComputeLinkImplementationLanguages(config, impl, head);
+
+    // Store the information for this configuration.
+    cmTargetInternals::LinkImplMapType::value_type entry(key, impl);
+    i = this->Internal->LinkImplMap.insert(entry).first;
+    }
+  else if (i->second.Languages.empty())
+    {
+    this->ComputeLinkImplementationLanguages(config, i->second, head);
+    }
+
+  return &i->second;
+}
+
+//----------------------------------------------------------------------------
+cmTarget::LinkImplementation const*
+cmTarget::GetLinkImplementationLibraries(const std::string& config,
+                                         cmTarget const* head) const
+{
+  // There is no link implementation for imported targets.
+  if(this->IsImported())
+    {
+    return 0;
+    }
+
+  // Lookup any existing link implementation for this configuration.
+  TargetConfigPair key(head, cmSystemTools::UpperCase(config));
 
   cmTargetInternals::LinkImplMapType::iterator
     i = this->Internal->LinkImplMap.find(key);
@@ -5657,7 +6578,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::ComputeLinkImplementation(const char* config,
+void cmTarget::ComputeLinkImplementation(const std::string& config,
                                          LinkImplementation& impl,
                                          cmTarget const* head) const
 {
@@ -5729,26 +6650,20 @@
       impl.WrongConfigLibraries.push_back(item);
       }
     }
+}
 
+//----------------------------------------------------------------------------
+void
+cmTarget::ComputeLinkImplementationLanguages(const std::string& config,
+                                             LinkImplementation& impl,
+                                             cmTarget const* head) const
+{
   // This target needs runtime libraries for its source languages.
-  std::set<cmStdString> languages;
+  std::set<std::string> languages;
   // Get languages used in our source files.
-  this->GetLanguages(languages);
-  // Get languages used in object library sources.
-  for(std::vector<std::string>::const_iterator
-      i = this->ObjectLibraries.begin();
-      i != this->ObjectLibraries.end(); ++i)
-    {
-    if(cmTarget* objLib = this->Makefile->FindTargetToUse(*i))
-      {
-      if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
-        {
-        objLib->GetLanguages(languages);
-        }
-      }
-    }
+  this->GetLanguages(languages, config, head);
   // Copy the set of langauges to the link implementation.
-  for(std::set<cmStdString>::iterator li = languages.begin();
+  for(std::set<std::string>::iterator li = languages.begin();
       li != languages.end(); ++li)
     {
     impl.Languages.push_back(*li);
@@ -5816,15 +6731,15 @@
 
 template<typename PropertyType>
 PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt,
-                                               const std::string prop,
-                                               const char *config,
+                                               const std::string& prop,
+                                               const std::string& config,
                                                CompatibleType,
                                                PropertyType *);
 
 template<>
 bool getLinkInterfaceDependentProperty(cmTarget const* tgt,
-                                       const std::string prop,
-                                       const char *config,
+                                       const std::string& prop,
+                                       const std::string& config,
                                        CompatibleType, bool *)
 {
   return tgt->GetLinkInterfaceDependentBoolProperty(prop, config);
@@ -5832,8 +6747,8 @@
 
 template<>
 const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
-                                               const std::string prop,
-                                               const char *config,
+                                               const std::string& prop,
+                                               const std::string& config,
                                                CompatibleType t,
                                                const char **)
 {
@@ -5857,9 +6772,9 @@
 template<typename PropertyType>
 void checkPropertyConsistency(cmTarget const* depender,
                               cmTarget const* dependee,
-                              const char *propName,
-                              std::set<cmStdString> &emitted,
-                              const char *config,
+                              const std::string& propName,
+                              std::set<std::string> &emitted,
+                              const std::string& config,
                               CompatibleType t,
                               PropertyType *)
 {
@@ -5902,10 +6817,10 @@
     }
 }
 
-static cmStdString intersect(const std::set<cmStdString> &s1,
-                             const std::set<cmStdString> &s2)
+static std::string intersect(const std::set<std::string> &s1,
+                             const std::set<std::string> &s2)
 {
-  std::set<cmStdString> intersect;
+  std::set<std::string> intersect;
   std::set_intersection(s1.begin(),s1.end(),
                         s2.begin(),s2.end(),
                       std::inserter(intersect,intersect.begin()));
@@ -5915,11 +6830,11 @@
     }
   return "";
 }
-static cmStdString intersect(const std::set<cmStdString> &s1,
-                       const std::set<cmStdString> &s2,
-                       const std::set<cmStdString> &s3)
+static std::string intersect(const std::set<std::string> &s1,
+                       const std::set<std::string> &s2,
+                       const std::set<std::string> &s3)
 {
-  cmStdString result;
+  std::string result;
   result = intersect(s1, s2);
   if (!result.empty())
     return result;
@@ -5928,12 +6843,12 @@
     return result;
   return intersect(s2, s3);
 }
-static cmStdString intersect(const std::set<cmStdString> &s1,
-                       const std::set<cmStdString> &s2,
-                       const std::set<cmStdString> &s3,
-                       const std::set<cmStdString> &s4)
+static std::string intersect(const std::set<std::string> &s1,
+                       const std::set<std::string> &s2,
+                       const std::set<std::string> &s3,
+                       const std::set<std::string> &s4)
 {
-  cmStdString result;
+  std::string result;
   result = intersect(s1, s2);
   if (!result.empty())
     return result;
@@ -5948,14 +6863,14 @@
 
 //----------------------------------------------------------------------------
 void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
-                                          const char* config) const
+                                          const std::string& config) const
 {
   const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
 
-  std::set<cmStdString> emittedBools;
-  std::set<cmStdString> emittedStrings;
-  std::set<cmStdString> emittedMinNumbers;
-  std::set<cmStdString> emittedMaxNumbers;
+  std::set<std::string> emittedBools;
+  std::set<std::string> emittedStrings;
+  std::set<std::string> emittedMinNumbers;
+  std::set<std::string> emittedMaxNumbers;
 
   for(cmComputeLinkInformation::ItemVector::const_iterator li =
       deps.begin();
@@ -5967,32 +6882,32 @@
       }
 
     checkPropertyConsistency<bool>(this, li->Target,
-                                   "COMPATIBLE_INTERFACE_BOOL",
-                                   emittedBools, config, BoolType, 0);
+                                std::string("COMPATIBLE_INTERFACE_BOOL"),
+                                emittedBools, config, BoolType, 0);
     if (cmSystemTools::GetErrorOccuredFlag())
       {
       return;
       }
     checkPropertyConsistency<const char *>(this, li->Target,
-                                           "COMPATIBLE_INTERFACE_STRING",
-                                           emittedStrings, config,
-                                           StringType, 0);
+                                std::string("COMPATIBLE_INTERFACE_STRING"),
+                                emittedStrings, config,
+                                StringType, 0);
     if (cmSystemTools::GetErrorOccuredFlag())
       {
       return;
       }
     checkPropertyConsistency<const char *>(this, li->Target,
-                                           "COMPATIBLE_INTERFACE_NUMBER_MIN",
-                                           emittedMinNumbers, config,
-                                           NumberMinType, 0);
+                                std::string("COMPATIBLE_INTERFACE_NUMBER_MIN"),
+                                emittedMinNumbers, config,
+                                NumberMinType, 0);
     if (cmSystemTools::GetErrorOccuredFlag())
       {
       return;
       }
     checkPropertyConsistency<const char *>(this, li->Target,
-                                           "COMPATIBLE_INTERFACE_NUMBER_MAX",
-                                           emittedMaxNumbers, config,
-                                           NumberMaxType, 0);
+                                std::string("COMPATIBLE_INTERFACE_NUMBER_MAX"),
+                                emittedMaxNumbers, config,
+                                NumberMaxType, 0);
     if (cmSystemTools::GetErrorOccuredFlag())
       {
       return;
@@ -6007,7 +6922,7 @@
   if (!prop.empty())
     {
     std::set<std::string> props;
-    std::set<cmStdString>::const_iterator i = emittedBools.find(prop);
+    std::set<std::string>::const_iterator i = emittedBools.find(prop);
     if (i != emittedBools.end())
       {
       props.insert("COMPATIBLE_INTERFACE_BOOL");
@@ -6052,12 +6967,12 @@
 
 //----------------------------------------------------------------------------
 cmComputeLinkInformation*
-cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const
+cmTarget::GetLinkInformation(const std::string& config,
+                             cmTarget const* head) const
 {
   cmTarget const* headTarget = head ? head : this;
   // Lookup any existing information for this configuration.
-  TargetConfigPair key(headTarget,
-                                  cmSystemTools::UpperCase(config?config:""));
+  TargetConfigPair key(headTarget, cmSystemTools::UpperCase(config));
   cmTargetLinkInformationMap::iterator
     i = this->LinkInformation.find(key);
   if(i == this->LinkInformation.end())
@@ -6084,7 +6999,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetFrameworkDirectory(const char* config,
+std::string cmTarget::GetFrameworkDirectory(const std::string& config,
                                             bool rootDir) const
 {
   std::string fpath;
@@ -6099,7 +7014,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetCFBundleDirectory(const char* config,
+std::string cmTarget::GetCFBundleDirectory(const std::string& config,
                                            bool contentOnly) const
 {
   std::string fpath;
@@ -6118,7 +7033,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetAppBundleDirectory(const char* config,
+std::string cmTarget::GetAppBundleDirectory(const std::string& config,
                                             bool contentOnly) const
 {
   std::string fpath = this->GetFullName(config, false);
@@ -6130,7 +7045,7 @@
 
 //----------------------------------------------------------------------------
 std::string cmTarget::BuildMacContentDirectory(const std::string& base,
-                                               const char* config,
+                                               const std::string& config,
                                                bool contentOnly) const
 {
   std::string fpath = base;
@@ -6150,7 +7065,7 @@
 }
 
 //----------------------------------------------------------------------------
-std::string cmTarget::GetMacContentDirectory(const char* config,
+std::string cmTarget::GetMacContentDirectory(const std::string& config,
                                              bool implib) const
 {
   // Start with the output directory for the target.
@@ -6211,7 +7126,9 @@
 {
   deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
   deleteAndClear(this->Pointer->CompileOptionsEntries);
+  deleteAndClear(this->Pointer->CompileFeaturesEntries);
   deleteAndClear(this->Pointer->CompileDefinitionsEntries);
+  deleteAndClear(this->Pointer->SourceEntries);
   delete this->Pointer;
 }
 
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a305caa..2d51835 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -30,7 +30,8 @@
   F(CMP0038) \
   F(CMP0041) \
   F(CMP0042) \
-  F(CMP0046)
+  F(CMP0046) \
+  F(CMP0052)
 
 class cmake;
 class cmMakefile;
@@ -96,17 +97,17 @@
   /**
    * Set the target type
    */
-  void SetType(TargetType f, const char* name);
+  void SetType(TargetType f, const std::string& name);
 
   void MarkAsImported();
 
   ///! Set/Get the name of the target
-  const char* GetName() const {return this->Name.c_str();}
-  const char* GetExportName() const;
+  const std::string& GetName() const {return this->Name;}
+  std::string GetExportName() const;
 
   ///! Set the cmMakefile that owns this target
   void SetMakefile(cmMakefile *mf);
-  cmMakefile *GetMakefile() const { return this->Makefile;};
+  cmMakefile *GetMakefile() const { return this->Makefile;}
 
 #define DECLARE_TARGET_POLICY(POLICY) \
   cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
@@ -135,76 +136,48 @@
   /**
    * Get the list of the source files used by this target
    */
-  void GetSourceFiles(std::vector<cmSourceFile*> &files) const;
-  void AddSourceFile(cmSourceFile* sf);
-  std::vector<std::string> const& GetObjectLibraries() const
-    {
-    return this->ObjectLibraries;
-    }
-
-  /**
-   * Flags for a given source file as used in this target. Typically assigned
-   * via SET_TARGET_PROPERTIES when the property is a list of source files.
-   */
-  enum SourceFileType
-  {
-    SourceFileTypeNormal,
-    SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
-    SourceFileTypePublicHeader,  // is in "PUBLIC_HEADER" target property
-    SourceFileTypeResource,      // is in "RESOURCE" target property *or*
-                                 // has MACOSX_PACKAGE_LOCATION=="Resources"
-    SourceFileTypeMacContent     // has MACOSX_PACKAGE_LOCATION!="Resources"
-  };
-  struct SourceFileFlags
-  {
-    SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
-    SourceFileFlags(SourceFileFlags const& r):
-      Type(r.Type), MacFolder(r.MacFolder) {}
-    SourceFileType Type;
-    const char* MacFolder; // location inside Mac content folders
-  };
-
-  /**
-   * Get the flags for a given source file as used in this target
-   */
-  struct SourceFileFlags
-  GetTargetSourceFileFlags(const cmSourceFile* sf) const;
+  void GetSourceFiles(std::vector<cmSourceFile*> &files,
+                      const std::string& config,
+                      cmTarget const* head = 0) const;
+  bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
 
   /**
    * Add sources to the target.
    */
   void AddSources(std::vector<std::string> const& srcs);
-  cmSourceFile* AddSource(const char* src);
+  void AddTracedSources(std::vector<std::string> const& srcs);
+  cmSourceFile* AddSourceCMP0049(const std::string& src);
+  cmSourceFile* AddSource(const std::string& src);
 
   enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
 
   //* how we identify a library, by name and type
-  typedef std::pair<cmStdString, LinkLibraryType> LibraryID;
+  typedef std::pair<std::string, LinkLibraryType> LibraryID;
 
   typedef std::vector<LibraryID > LinkLibraryVectorType;
   const LinkLibraryVectorType &GetLinkLibraries() const {
   return this->LinkLibraries;}
   const LinkLibraryVectorType &GetOriginalLinkLibraries() const
     {return this->OriginalLinkLibraries;}
-  void GetDirectLinkLibraries(const char *config,
+  void GetDirectLinkLibraries(const std::string& config,
                               std::vector<std::string> &,
                               cmTarget const* head) const;
-  void GetInterfaceLinkLibraries(const char *config,
+  void GetInterfaceLinkLibraries(const std::string& config,
                               std::vector<std::string> &,
                               cmTarget const* head) const;
 
   /** Compute the link type to use for the given configuration.  */
-  LinkLibraryType ComputeLinkType(const char* config) const;
+  LinkLibraryType ComputeLinkType(const std::string& config) const;
 
   /**
    * Clear the dependency information recorded for this target, if any.
    */
-  void ClearDependencyInformation(cmMakefile& mf, const char* target);
+  void ClearDependencyInformation(cmMakefile& mf, const std::string& target);
 
   // Check to see if a library is a framework and treat it different on Mac
   bool NameResolvesToFramework(const std::string& libname) const;
   void AddLinkLibrary(cmMakefile& mf,
-                      const char *target, const char* lib,
+                      const std::string& target, const std::string& lib,
                       LinkLibraryType llt);
   enum TLLSignature {
     KeywordTLLSignature,
@@ -213,12 +186,12 @@
   bool PushTLLCommandTrace(TLLSignature signature);
   void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const;
 
-  void MergeLinkLibraries( cmMakefile& mf, const char* selfname,
+  void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname,
                            const LinkLibraryVectorType& libs );
 
   const std::vector<std::string>& GetLinkDirectories() const;
 
-  void AddLinkDirectory(const char* d);
+  void AddLinkDirectory(const std::string& d);
 
   /**
    * Set the path where this target should be installed. This is relative to
@@ -245,26 +218,32 @@
    * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
    * commands. It is not a full path nor does it have an extension.
    */
-  void AddUtility(const char* u, cmMakefile *makefile = 0);
+  void AddUtility(const std::string& u, cmMakefile *makefile = 0);
   ///! Get the utilities used by this target
-  std::set<cmStdString>const& GetUtilities() const { return this->Utilities; }
-  cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const;
+  std::set<std::string>const& GetUtilities() const { return this->Utilities; }
+  cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
 
   /** Finalize the target at the end of the Configure step.  */
   void FinishConfigure();
 
   ///! Set/Get a property of this target file
-  void SetProperty(const char *prop, const char *value);
-  void AppendProperty(const char* prop, const char* value,bool asString=false);
-  const char *GetProperty(const char *prop) const;
-  const char *GetProperty(const char *prop, cmMakefile* context) const;
-  bool GetPropertyAsBool(const char *prop) const;
-  void CheckProperty(const char* prop, cmMakefile* context) const;
+  void SetProperty(const std::string& prop, const char *value);
+  void AppendProperty(const std::string&  prop, const char* value,
+          bool asString=false);
+  const char *GetProperty(const std::string& prop) const;
+  const char *GetProperty(const std::string& prop, cmMakefile* context) const;
+  bool GetPropertyAsBool(const std::string& prop) const;
+  void CheckProperty(const std::string& prop, cmMakefile* context) const;
 
-  const char* GetFeature(const char* feature, const char* config) const;
+  const char* GetFeature(const std::string& feature,
+                         const std::string& config) const;
+  bool GetFeatureAsBool(const std::string& feature,
+                        const std::string& config) const;
 
   bool IsImported() const {return this->IsImportedTarget;}
 
+  void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const;
+
   /** The link interface specifies transitive library dependencies and
       other information needed by targets that link to this target.  */
   struct LinkInterface
@@ -293,11 +272,16 @@
 
   /** Get the link interface for the given configuration.  Returns 0
       if the target cannot be linked.  */
-  LinkInterface const* GetLinkInterface(const char* config,
+  LinkInterface const* GetLinkInterface(const std::string& config,
                                         cmTarget const* headTarget) const;
-  void GetTransitivePropertyLinkLibraries(const char* config,
+  LinkInterface const* GetLinkInterfaceLibraries(const std::string& config,
+                                        cmTarget const* headTarget) const;
+  void GetTransitivePropertyTargets(const std::string& config,
                                         cmTarget const* headTarget,
-                                        std::vector<std::string> &libs) const;
+                                        std::vector<cmTarget*> &libs) const;
+  void GetTransitiveTargetClosure(const std::string& config,
+                                        cmTarget const* headTarget,
+                                        std::vector<cmTarget*> &libs) const;
 
   /** The link implementation specifies the direct library
       dependencies needed by the object files of the target.  */
@@ -313,7 +297,11 @@
     // Needed only for OLD behavior of CMP0003.
     std::vector<std::string> WrongConfigLibraries;
   };
-  LinkImplementation const* GetLinkImplementation(const char* config,
+  LinkImplementation const* GetLinkImplementation(const std::string& config,
+                                                  cmTarget const* head) const;
+
+  LinkImplementation const* GetLinkImplementationLibraries(
+                                                  const std::string& config,
                                                   cmTarget const* head) const;
 
   /** Link information from the transitive closure of the link
@@ -326,7 +314,7 @@
     // Languages whose runtime libraries must be linked.
     std::vector<std::string> Languages;
   };
-  LinkClosure const* GetLinkClosure(const char* config,
+  LinkClosure const* GetLinkClosure(const std::string& config,
                                     cmTarget const* head) const;
 
   /** Strip off leading and trailing whitespace from an item named in
@@ -337,18 +325,29 @@
       configuration name is given then the generator will add its
       subdirectory for that configuration.  Otherwise just the canonical
       output directory is given.  */
-  std::string GetDirectory(const char* config = 0, bool implib = false) const;
+  std::string GetDirectory(const std::string& config = "",
+                           bool implib = false) const;
 
   /** Get the directory in which this targets .pdb files will be placed.
       If the configuration name is given then the generator will add its
       subdirectory for that configuration.  Otherwise just the canonical
       pdb output directory is given.  */
-  std::string GetPDBDirectory(const char* config = 0) const;
+  std::string GetPDBDirectory(const std::string& config) const;
+
+  /** Get the directory in which to place the target compiler .pdb file.
+      If the configuration name is given then the generator will add its
+      subdirectory for that configuration.  Otherwise just the canonical
+      compiler pdb output directory is given.  */
+  std::string GetCompilePDBDirectory(const std::string& config = "") const;
 
   /** Get the location of the target in the build tree for the given
-      configuration.  This location is suitable for use as the LOCATION
-      target property.  */
-  const char* GetLocation(const char* config) const;
+      configuration.  */
+  const char* GetLocation(const std::string& config) const;
+
+  /** Get the location of the target in the build tree with a placeholder
+      referencing the configuration in the native build system.  This
+      location is suitable for use as the LOCATION target property.  */
+  const char* GetLocationForBuild() const;
 
   /** Get the target major and minor version numbers interpreted from
       the VERSION property.  Version 0 is returned if the property is
@@ -361,44 +360,47 @@
   void
   GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
 
-  /**
-   * Make sure the full path to all source files is known.
-   */
-  bool FindSourceFiles();
-
   ///! Return the preferred linker language for this target
-  const char* GetLinkerLanguage(const char* config = 0,
+  std::string GetLinkerLanguage(const std::string& config = "",
                                 cmTarget const* head = 0) const;
 
   /** Get the full name of the target according to the settings in its
       makefile.  */
-  std::string GetFullName(const char* config=0, bool implib = false) const;
+  std::string GetFullName(const std::string& config="",
+                          bool implib = false) const;
   void GetFullNameComponents(std::string& prefix,
                              std::string& base, std::string& suffix,
-                             const char* config=0, bool implib = false) const;
+                             const std::string& config="",
+                             bool implib = false) const;
 
   /** Get the name of the pdb file for the target.  */
-  std::string GetPDBName(const char* config=0) const;
+  std::string GetPDBName(const std::string& config) const;
+
+  /** Get the name of the compiler pdb file for the target.  */
+  std::string GetCompilePDBName(const std::string& config="") const;
+
+  /** Get the path for the MSVC /Fd option for this target.  */
+  std::string GetCompilePDBPath(const std::string& config="") const;
 
   /** Whether this library has soname enabled and platform supports it.  */
-  bool HasSOName(const char* config) const;
+  bool HasSOName(const std::string& config) const;
 
   /** Get the soname of the target.  Allowed only for a shared library.  */
-  std::string GetSOName(const char* config) const;
+  std::string GetSOName(const std::string& config) const;
 
   /** Whether this library has \@rpath and platform supports it.  */
-  bool HasMacOSXRpathInstallNameDir(const char* config) const;
+  bool HasMacOSXRpathInstallNameDir(const std::string& config) const;
 
   /** Whether this library defaults to \@rpath.  */
   bool MacOSXRpathInstallNameDirDefault() const;
 
   /** Test for special case of a third-party shared library that has
       no soname at all.  */
-  bool IsImportedSharedLibWithoutSOName(const char* config) const;
+  bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
 
   /** Get the full path to the target according to the settings in its
       makefile and the configuration type.  */
-  std::string GetFullPath(const char* config=0, bool implib = false,
+  std::string GetFullPath(const std::string& config="", bool implib = false,
                           bool realname = false) const;
 
   /** Get the names of the library needed to generate a build rule
@@ -406,14 +408,15 @@
       should be called only on a library target.  */
   void GetLibraryNames(std::string& name, std::string& soName,
                        std::string& realName, std::string& impName,
-                       std::string& pdbName, const char* config) const;
+                       std::string& pdbName, const std::string& config) const;
 
   /** Get the names of the executable needed to generate a build rule
       that takes into account executable version numbers.  This should
       be called only on an executable target.  */
   void GetExecutableNames(std::string& name, std::string& realName,
                           std::string& impName,
-                          std::string& pdbName, const char* config) const;
+                          std::string& pdbName,
+                          const std::string& config) const;
 
   /** Does this target have a GNU implib to convert to MS format?  */
   bool HasImplibGNUtoMS() const;
@@ -426,28 +429,28 @@
   /**
    * Compute whether this target must be relinked before installing.
    */
-  bool NeedRelinkBeforeInstall(const char* config) const;
+  bool NeedRelinkBeforeInstall(const std::string& config) const;
 
-  bool HaveBuildTreeRPATH(const char *config) const;
+  bool HaveBuildTreeRPATH(const std::string& config) const;
   bool HaveInstallTreeRPATH() const;
 
   /** Return true if builtin chrpath will work for this target */
-  bool IsChrpathUsed(const char* config) const;
+  bool IsChrpathUsed(const std::string& config) const;
 
   /** Return the install name directory for the target in the
     * build tree.  For example: "\@rpath/", "\@loader_path/",
     * or "/full/path/to/library".  */
-  std::string GetInstallNameDirForBuildTree(const char* config) const;
+  std::string GetInstallNameDirForBuildTree(const std::string& config) const;
 
   /** Return the install name directory for the target in the
     * install tree.  For example: "\@rpath/" or "\@loader_path/". */
   std::string GetInstallNameDirForInstallTree() const;
 
-  cmComputeLinkInformation* GetLinkInformation(const char* config,
+  cmComputeLinkInformation* GetLinkInformation(const std::string& config,
                                                cmTarget const* head = 0) const;
 
   // Get the properties
-  cmPropertyMap &GetProperties() const { return this->Properties; };
+  cmPropertyMap &GetProperties() const { return this->Properties; }
 
   bool GetMappedConfig(std::string const& desired_config,
                        const char** loc,
@@ -462,14 +465,16 @@
   const char* GetExportMacro() const;
 
   void GetCompileDefinitions(std::vector<std::string> &result,
-                             const char *config) const;
+                             const std::string& config) const;
 
   // Compute the set of languages compiled by the target.  This is
   // computed every time it is called because the languages can change
   // when source file properties are changed and we do not have enough
   // information to forward these property changes to the targets
   // until we have per-target object file properties.
-  void GetLanguages(std::set<cmStdString>& languages) const;
+  void GetLanguages(std::set<std::string>& languages,
+                    std::string const& config,
+                    cmTarget const* head = 0) const;
 
   /** Return whether this target is an executable with symbol exports
       enabled.  */
@@ -510,26 +515,29 @@
 
   /** Return whether this target uses the default value for its output
       directory.  */
-  bool UsesDefaultOutputDir(const char* config, bool implib) const;
+  bool UsesDefaultOutputDir(const std::string& config, bool implib) const;
 
   /** @return the mac content directory for this target. */
-  std::string GetMacContentDirectory(const char* config,
+  std::string GetMacContentDirectory(const std::string& config,
                                      bool implib) const;
 
   /** @return whether this target have a well defined output file name. */
   bool HaveWellDefinedOutputFiles() const;
 
   /** @return the Mac framework directory without the base. */
-  std::string GetFrameworkDirectory(const char* config, bool rootDir) const;
+  std::string GetFrameworkDirectory(const std::string& config,
+                                    bool rootDir) const;
 
   /** @return the Mac CFBundle directory without the base */
-  std::string GetCFBundleDirectory(const char* config, bool contentOnly) const;
+  std::string GetCFBundleDirectory(const std::string& config,
+                                   bool contentOnly) const;
 
   /** @return the Mac App directory without the base */
-  std::string GetAppBundleDirectory(const char* config,
+  std::string GetAppBundleDirectory(const std::string& config,
                                     bool contentOnly) const;
 
-  std::vector<std::string> GetIncludeDirectories(const char *config) const;
+  std::vector<std::string> GetIncludeDirectories(
+                     const std::string& config) const;
   void InsertInclude(const cmValueWithOrigin &entry,
                      bool before = false);
   void InsertCompileOption(const cmValueWithOrigin &entry,
@@ -539,36 +547,38 @@
   void AppendBuildInterfaceIncludes();
 
   void GetCompileOptions(std::vector<std::string> &result,
-                         const char *config) const;
+                         const std::string& config) const;
   void GetAutoUicOptions(std::vector<std::string> &result,
-                         const char *config) const;
+                         const std::string& config) const;
+  void GetCompileFeatures(std::vector<std::string> &features,
+                          const std::string& config) const;
 
   bool IsNullImpliedByLinkLibraries(const std::string &p) const;
   bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
-                                            const char *config) const;
+                         const std::string& config) const;
   bool IsLinkInterfaceDependentStringProperty(const std::string &p,
-                                              const char *config) const;
+                         const std::string& config) const;
   bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
-                                                 const char *config) const;
+                         const std::string& config) const;
   bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
-                                                 const char *config) const;
+                         const std::string& config) const;
 
   bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
-                                             const char *config) const;
+                                             const std::string& config) const;
 
   const char *GetLinkInterfaceDependentStringProperty(const std::string &p,
-                                                    const char *config) const;
+                         const std::string& config) const;
   const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p,
-                                                    const char *config) const;
+                         const std::string& config) const;
   const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
-                                                    const char *config) const;
+                         const std::string& config) const;
 
   std::string GetDebugGeneratorExpressions(const std::string &value,
                                   cmTarget::LinkLibraryType llt) const;
 
-  void AddSystemIncludeDirectories(const std::set<cmStdString> &incs);
+  void AddSystemIncludeDirectories(const std::set<std::string> &incs);
   void AddSystemIncludeDirectories(const std::vector<std::string> &incs);
-  std::set<cmStdString> const & GetSystemIncludeDirectories() const
+  std::set<std::string> const & GetSystemIncludeDirectories() const
     { return this->SystemIncludeDirectories; }
 
   bool LinkLanguagePropagatesToDependents() const
@@ -579,12 +589,18 @@
                             const std::string &report,
                             const std::string &compatibilityType) const;
 
+  std::map<std::string, std::string> const&
+  GetMaxLanguageStandards() const
+  {
+    return this->MaxLanguageStandards;
+  }
+
 private:
   bool HandleLocationPropertyPolicy(cmMakefile* context) const;
 
   // The set of include directories that are marked as system include
   // directories.
-  std::set<cmStdString> SystemIncludeDirectories;
+  std::set<std::string> SystemIncludeDirectories;
 
   std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands;
 
@@ -641,60 +657,62 @@
 
   const char* GetSuffixVariableInternal(bool implib) const;
   const char* GetPrefixVariableInternal(bool implib) const;
-  std::string GetFullNameInternal(const char* config, bool implib) const;
-  void GetFullNameInternal(const char* config, bool implib,
+  std::string GetFullNameInternal(const std::string& config,
+                                  bool implib) const;
+  void GetFullNameInternal(const std::string& config, bool implib,
                            std::string& outPrefix, std::string& outBase,
                            std::string& outSuffix) const;
 
   // Use a makefile variable to set a default for the given property.
   // If the variable is not defined use the given default instead.
-  void SetPropertyDefault(const char* property, const char* default_value);
+  void SetPropertyDefault(const std::string& property,
+                          const char* default_value);
 
   // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
   const char* GetOutputTargetType(bool implib) const;
 
   // Get the target base name.
-  std::string GetOutputName(const char* config, bool implib) const;
+  std::string GetOutputName(const std::string& config, bool implib) const;
 
-  const char* ImportedGetLocation(const char* config) const;
-  const char* NormalGetLocation(const char* config) const;
+  std::string GetFullNameImported(const std::string& config,
+                                  bool implib) const;
 
-  std::string GetFullNameImported(const char* config, bool implib) const;
-
-  std::string ImportedGetFullPath(const char* config, bool implib) const;
-  std::string NormalGetFullPath(const char* config, bool implib,
+  std::string ImportedGetFullPath(const std::string& config,
+                                  bool implib) const;
+  std::string NormalGetFullPath(const std::string& config, bool implib,
                                 bool realname) const;
 
   /** Get the real name of the target.  Allowed only for non-imported
       targets.  When a library or executable file is versioned this is
       the full versioned name.  If the target is not versioned this is
       the same as GetFullName.  */
-  std::string NormalGetRealName(const char* config) const;
+  std::string NormalGetRealName(const std::string& config) const;
 
   /** Append to @a base the mac content directory and return it. */
   std::string BuildMacContentDirectory(const std::string& base,
-                                       const char* config,
+                                       const std::string& config,
                                        bool contentOnly) const;
 
+  void GetSourceFiles(std::vector<std::string> &files,
+                      const std::string& config,
+                      cmTarget const* head = 0) const;
 private:
   std::string Name;
   std::vector<cmCustomCommand> PreBuildCommands;
   std::vector<cmCustomCommand> PreLinkCommands;
   std::vector<cmCustomCommand> PostBuildCommands;
   TargetType TargetTypeValue;
-  std::vector<cmSourceFile*> SourceFiles;
-  std::vector<std::string> ObjectLibraries;
   LinkLibraryVectorType LinkLibraries;
   LinkLibraryVectorType PrevLinkedLibraries;
   bool LinkLibrariesAnalyzed;
   std::vector<std::string> LinkDirectories;
-  std::set<cmStdString> LinkDirectoriesEmmitted;
+  std::set<std::string> LinkDirectoriesEmmitted;
   bool HaveInstallRule;
   std::string InstallPath;
   std::string RuntimeInstallPath;
   mutable std::string ExportMacro;
-  std::set<cmStdString> Utilities;
-  std::map<cmStdString, cmListFileBacktrace> UtilityBacktraces;
+  std::set<std::string> Utilities;
+  std::map<std::string, cmListFileBacktrace> UtilityBacktraces;
   bool RecordDependencies;
   mutable cmPropertyMap Properties;
   LinkLibraryVectorType OriginalLinkLibraries;
@@ -705,39 +723,55 @@
   mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
   mutable bool DebugCompileOptionsDone;
   mutable bool DebugCompileDefinitionsDone;
+  mutable bool DebugSourcesDone;
+  mutable bool DebugCompileFeaturesDone;
   mutable std::set<std::string> LinkImplicitNullProperties;
+  mutable std::map<std::string, std::string> MaxLanguageStandards;
   bool BuildInterfaceIncludesAppended;
 
   // Cache target output paths for each configuration.
   struct OutputInfo;
-  OutputInfo const* GetOutputInfo(const char* config) const;
+  OutputInfo const* GetOutputInfo(const std::string& config) const;
   bool
-  ComputeOutputDir(const char* config, bool implib, std::string& out) const;
-  bool ComputePDBOutputDir(const char* config, std::string& out) const;
+  ComputeOutputDir(const std::string& config,
+                   bool implib, std::string& out) const;
+  bool ComputePDBOutputDir(const std::string& kind, const std::string& config,
+                           std::string& out) const;
 
   // Cache import information from properties for each configuration.
   struct ImportInfo;
-  ImportInfo const* GetImportInfo(const char* config,
+  ImportInfo const* GetImportInfo(const std::string& config,
                                         cmTarget const* workingTarget) const;
   void ComputeImportInfo(std::string const& desired_config, ImportInfo& info,
                                         cmTarget const* head) const;
 
+  // Cache target compile paths for each configuration.
+  struct CompileInfo;
+  CompileInfo const* GetCompileInfo(const std::string& config) const;
+
   mutable cmTargetLinkInformationMap LinkInformation;
   void CheckPropertyCompatibility(cmComputeLinkInformation *info,
-                                  const char* config) const;
+                                  const std::string& config) const;
 
-  bool ComputeLinkInterface(const char* config, LinkInterface& iface,
-                                        cmTarget const* head) const;
+  const char* ComputeLinkInterfaceLibraries(const std::string& config,
+                                            LinkInterface& iface,
+                                            cmTarget const* head,
+                                            bool &exists) const;
 
-  void ComputeLinkImplementation(const char* config,
+  void ComputeLinkImplementation(const std::string& config,
                                  LinkImplementation& impl,
                                  cmTarget const* head) const;
-  void ComputeLinkClosure(const char* config, LinkClosure& lc,
+  void ComputeLinkImplementationLanguages(const std::string& config,
+                                          LinkImplementation& impl,
+                                          cmTarget const* head) const;
+  void ComputeLinkClosure(const std::string& config, LinkClosure& lc,
                           cmTarget const* head) const;
 
+  std::string ProcessSourceItemCMP0049(const std::string& s);
+
   void ClearLinkMaps();
 
-  void MaybeInvalidatePropertyCache(const char* prop);
+  void MaybeInvalidatePropertyCache(const std::string& prop);
 
   void ProcessSourceExpression(std::string const& expr);
 
@@ -759,18 +793,19 @@
   friend class cmTargetTraceDependencies;
   cmTargetInternalPointer Internal;
 
-  void ConstructSourceFileFlags() const;
   void ComputeVersionedName(std::string& vName,
                             std::string const& prefix,
                             std::string const& base,
                             std::string const& suffix,
                             std::string const& name,
                             const char* version) const;
+
+  mutable bool LinkImplementationLanguageIsContextDependent;
 };
 
-typedef std::map<cmStdString,cmTarget> cmTargets;
+typedef std::map<std::string,cmTarget> cmTargets;
 
-class cmTargetSet: public std::set<cmStdString> {};
-class cmTargetManifest: public std::map<cmStdString, cmTargetSet> {};
+class cmTargetSet: public std::set<std::string> {};
+class cmTargetManifest: public std::map<std::string, cmTargetSet> {};
 
 #endif
diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index b567252..66d8ad3 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -58,9 +58,10 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTargetCompileDefinitionsCommand
+bool cmTargetCompileDefinitionsCommand
 ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
                                    bool, bool)
 {
   tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
+  return true;
 }
diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h
index 7405e90..b548c70 100644
--- a/Source/cmTargetCompileDefinitionsCommand.h
+++ b/Source/cmTargetCompileDefinitionsCommand.h
@@ -36,7 +36,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "target_compile_definitions";}
+  virtual std::string GetName() const { return "target_compile_definitions";}
 
   cmTypeMacro(cmTargetCompileDefinitionsCommand, cmTargetPropCommandBase);
 
@@ -44,7 +44,7 @@
   virtual void HandleImportedTarget(const std::string &tgt);
   virtual void HandleMissingTarget(const std::string &name);
 
-  virtual void HandleDirectContent(cmTarget *tgt,
+  virtual bool HandleDirectContent(cmTarget *tgt,
                                    const std::vector<std::string> &content,
                                    bool prepend, bool system);
   virtual std::string Join(const std::vector<std::string> &content);
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
new file mode 100644
index 0000000..10daad4
--- /dev/null
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -0,0 +1,70 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2013 Stephen Kelly <steveire@gmail.com>
+
+  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 "cmTargetCompileFeaturesCommand.h"
+
+bool cmTargetCompileFeaturesCommand::InitialPass(
+  std::vector<std::string> const& args,
+  cmExecutionStatus &)
+{
+  return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS);
+}
+
+void cmTargetCompileFeaturesCommand
+::HandleImportedTarget(const std::string &tgt)
+{
+  cmOStringStream e;
+  e << "Cannot specify compile features for imported target \""
+    << tgt << "\".";
+  this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+void cmTargetCompileFeaturesCommand
+::HandleMissingTarget(const std::string &name)
+{
+  cmOStringStream e;
+  e << "Cannot specify compile features for target \"" << name << "\" "
+       "which is not built by this project.";
+  this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+//----------------------------------------------------------------------------
+std::string cmTargetCompileFeaturesCommand
+::Join(const std::vector<std::string> &content)
+{
+  std::string defs;
+  std::string sep;
+  for(std::vector<std::string>::const_iterator it = content.begin();
+    it != content.end(); ++it)
+    {
+    defs += sep + *it;
+    sep = ";";
+    }
+  return defs;
+}
+
+//----------------------------------------------------------------------------
+bool cmTargetCompileFeaturesCommand
+::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
+                                   bool, bool)
+{
+  for(std::vector<std::string>::const_iterator it = content.begin();
+    it != content.end(); ++it)
+    {
+    std::string error;
+    if(!this->Makefile->AddRequiredTargetFeature(tgt, *it, &error))
+      {
+      this->SetError(error);
+      return false;
+      }
+    }
+  return true;
+}
diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h
new file mode 100644
index 0000000..fa7ae8d
--- /dev/null
+++ b/Source/cmTargetCompileFeaturesCommand.h
@@ -0,0 +1,41 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2013 Stephen Kelly <steveire@gmail.com>
+
+  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 cmTargetCompileFeaturesCommand_h
+#define cmTargetCompileFeaturesCommand_h
+
+#include "cmTargetPropCommandBase.h"
+
+class cmTargetCompileFeaturesCommand : public cmTargetPropCommandBase
+{
+  virtual cmCommand* Clone()
+    {
+    return new cmTargetCompileFeaturesCommand;
+    }
+
+  virtual bool InitialPass(std::vector<std::string> const& args,
+                           cmExecutionStatus &status);
+
+  virtual std::string GetName() const { return "target_compile_features";}
+
+  cmTypeMacro(cmTargetCompileFeaturesCommand, cmTargetPropCommandBase);
+
+private:
+  virtual void HandleImportedTarget(const std::string &tgt);
+  virtual void HandleMissingTarget(const std::string &name);
+
+  virtual bool HandleDirectContent(cmTarget *tgt,
+                                   const std::vector<std::string> &content,
+                                   bool prepend, bool system);
+  virtual std::string Join(const std::vector<std::string> &content);
+};
+
+#endif
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
index 254acc7..3fb76a6 100644
--- a/Source/cmTargetCompileOptionsCommand.cxx
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -51,12 +51,12 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTargetCompileOptionsCommand
+bool cmTargetCompileOptionsCommand
 ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
                                    bool, bool)
 {
-  cmListFileBacktrace lfbt;
-  this->Makefile->GetBacktrace(lfbt);
+  cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
   cmValueWithOrigin entry(this->Join(content), lfbt);
   tgt->InsertCompileOption(entry);
+  return true;
 }
diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h
index 3713e5a..d43534d 100644
--- a/Source/cmTargetCompileOptionsCommand.h
+++ b/Source/cmTargetCompileOptionsCommand.h
@@ -36,7 +36,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "target_compile_options";}
+  virtual std::string GetName() const { return "target_compile_options";}
 
   cmTypeMacro(cmTargetCompileOptionsCommand, cmTargetPropCommandBase);
 
@@ -44,7 +44,7 @@
   virtual void HandleImportedTarget(const std::string &tgt);
   virtual void HandleMissingTarget(const std::string &name);
 
-  virtual void HandleDirectContent(cmTarget *tgt,
+  virtual bool HandleDirectContent(cmTarget *tgt,
                                    const std::vector<std::string> &content,
                                    bool prepend, bool system);
   virtual std::string Join(const std::vector<std::string> &content);
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index f8e1188..e9f0e04 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -66,18 +66,18 @@
 }
 
 //----------------------------------------------------------------------------
-void cmTargetIncludeDirectoriesCommand
+bool cmTargetIncludeDirectoriesCommand
 ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
                       bool prepend, bool system)
 {
-  cmListFileBacktrace lfbt;
-  this->Makefile->GetBacktrace(lfbt);
+  cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
   cmValueWithOrigin entry(this->Join(content), lfbt);
   tgt->InsertInclude(entry, prepend);
   if (system)
     {
     tgt->AddSystemIncludeDirectories(content);
     }
+  return true;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h
index 6863ee5..2a7814e 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.h
+++ b/Source/cmTargetIncludeDirectoriesCommand.h
@@ -37,7 +37,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "target_include_directories";}
+  virtual std::string GetName() const { return "target_include_directories";}
 
   cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmTargetPropCommandBase);
 
@@ -45,7 +45,7 @@
   virtual void HandleImportedTarget(const std::string &tgt);
   virtual void HandleMissingTarget(const std::string &name);
 
-  virtual void HandleDirectContent(cmTarget *tgt,
+  virtual bool HandleDirectContent(cmTarget *tgt,
                                    const std::vector<std::string> &content,
                                    bool prepend, bool system);
   virtual void HandleInterfaceContent(cmTarget *tgt,
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 95a2cba..56e1338 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -39,7 +39,7 @@
   // Lookup the target for which libraries are specified.
   this->Target =
     this->Makefile->GetCMakeInstance()
-    ->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
+    ->GetGlobalGenerator()->FindTarget(args[0]);
   if(!this->Target)
     {
     cmake::MessageType t = cmake::FATAL_ERROR;  // fail by default
@@ -70,7 +70,6 @@
                                   GetRequiredPolicyError(cmPolicies::CMP0016);
           break;
         case cmPolicies::NEW:  // NEW behavior prints the error.
-        default:
           break;
         }
       }
@@ -125,7 +124,7 @@
       e <<
         "Utility target \"" << this->Target->GetName() << "\" " << modal
         << " not be used as the target of a target_link_libraries call.";
-      this->Makefile->IssueMessage(messageType, e.str().c_str());
+      this->Makefile->IssueMessage(messageType, e.str());
       if(messageType == cmake::FATAL_ERROR)
         {
         return false;
@@ -273,7 +272,7 @@
       {
       // The link type was specified by the previous argument.
       haveLLT = false;
-      if (!this->HandleLibrary(args[i].c_str(), llt))
+      if (!this->HandleLibrary(args[i], llt))
         {
         return false;
         }
@@ -290,7 +289,7 @@
       std::string linkType = args[0];
       linkType += "_LINK_TYPE";
       const char* linkTypeString =
-        this->Makefile->GetDefinition( linkType.c_str() );
+        this->Makefile->GetDefinition( linkType );
       if(linkTypeString)
         {
         if(strcmp(linkTypeString, "debug") == 0)
@@ -302,7 +301,7 @@
           llt = cmTarget::OPTIMIZED;
           }
         }
-      if (!this->HandleLibrary(args[i].c_str(), llt))
+      if (!this->HandleLibrary(args[i], llt))
         {
         return false;
         }
@@ -353,7 +352,7 @@
 
 //----------------------------------------------------------------------------
 bool
-cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
+cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
                                             cmTarget::LinkLibraryType llt)
 {
   if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY
@@ -409,7 +408,7 @@
                                           sig == cmTarget::KeywordTLLSignature
                                             ? cmTarget::PlainTLLSignature
                                             : cmTarget::KeywordTLLSignature);
-        this->Makefile->IssueMessage(messageType, e.str().c_str());
+        this->Makefile->IssueMessage(messageType, e.str());
         if(messageType == cmake::FATAL_ERROR)
           {
           return false;
@@ -481,13 +480,13 @@
       {
       prop = "LINK_INTERFACE_LIBRARIES_";
       prop += *i;
-      this->Target->AppendProperty(prop.c_str(), lib);
+      this->Target->AppendProperty(prop, lib.c_str());
       }
     }
   if(llt == cmTarget::OPTIMIZED || llt == cmTarget::GENERAL)
     {
     // Put in the non-DEBUG configuration interfaces.
-    this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib);
+    this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib.c_str());
 
     // Make sure the DEBUG configuration interfaces exist so that the
     // general one will not be used as a fall-back.
@@ -496,9 +495,9 @@
       {
       prop = "LINK_INTERFACE_LIBRARIES_";
       prop += *i;
-      if(!this->Target->GetProperty(prop.c_str()))
+      if(!this->Target->GetProperty(prop))
         {
-        this->Target->SetProperty(prop.c_str(), "");
+        this->Target->SetProperty(prop, "");
         }
       }
     }
diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h
index 6fbf722..47dd8bd 100644
--- a/Source/cmTargetLinkLibrariesCommand.h
+++ b/Source/cmTargetLinkLibrariesCommand.h
@@ -42,7 +42,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "target_link_libraries";}
+  virtual std::string GetName() const { return "target_link_libraries";}
 
   cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand);
 private:
@@ -62,7 +62,7 @@
 
   ProcessingState CurrentProcessingState;
 
-  bool HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt);
+  bool HandleLibrary(const std::string& lib, cmTarget::LinkLibraryType llt);
 };
 
 
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 195690e..4696de4 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -16,8 +16,9 @@
 
 //----------------------------------------------------------------------------
 bool cmTargetPropCommandBase
-::HandleArguments(std::vector<std::string> const& args, const char *prop,
-                 ArgumentFlags flags)
+::HandleArguments(std::vector<std::string> const& args,
+                  const std::string& prop,
+                  ArgumentFlags flags)
 {
   if(args.size() < 2)
     {
@@ -33,7 +34,7 @@
     }
   this->Target =
     this->Makefile->GetCMakeInstance()
-    ->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
+    ->GetGlobalGenerator()->FindTarget(args[0]);
   if(!this->Target)
     {
     this->Target = this->Makefile->FindTargetToUse(args[0]);
@@ -131,29 +132,31 @@
         || args[i] == "PRIVATE"
         || args[i] == "INTERFACE" )
       {
-      this->PopulateTargetProperies(scope, content, prepend, system);
-      return true;
+      return this->PopulateTargetProperies(scope, content, prepend, system);
       }
     content.push_back(args[i]);
     }
-  this->PopulateTargetProperies(scope, content, prepend, system);
-  return true;
+  return this->PopulateTargetProperies(scope, content, prepend, system);
 }
 
 //----------------------------------------------------------------------------
-void cmTargetPropCommandBase
+bool cmTargetPropCommandBase
 ::PopulateTargetProperies(const std::string &scope,
                           const std::vector<std::string> &content,
                           bool prepend, bool system)
 {
   if (scope == "PRIVATE" || scope == "PUBLIC")
     {
-    this->HandleDirectContent(this->Target, content, prepend, system);
+    if (!this->HandleDirectContent(this->Target, content, prepend, system))
+      {
+      return false;
+      }
     }
   if (scope == "INTERFACE" || scope == "PUBLIC")
     {
     this->HandleInterfaceContent(this->Target, content, prepend, system);
     }
+  return true;
 }
 
 //----------------------------------------------------------------------------
@@ -164,15 +167,15 @@
   if (prepend)
     {
     const std::string propName = std::string("INTERFACE_") + this->Property;
-    const char *propValue = tgt->GetProperty(propName.c_str());
+    const char *propValue = tgt->GetProperty(propName);
     const std::string totalContent = this->Join(content) + (propValue
                                               ? std::string(";") + propValue
                                               : std::string());
-    tgt->SetProperty(propName.c_str(), totalContent.c_str());
+    tgt->SetProperty(propName, totalContent.c_str());
     }
   else
     {
-    tgt->AppendProperty(("INTERFACE_" + this->Property).c_str(),
+    tgt->AppendProperty("INTERFACE_" + this->Property,
                           this->Join(content).c_str());
     }
 }
diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h
index c402836..d42b588 100644
--- a/Source/cmTargetPropCommandBase.h
+++ b/Source/cmTargetPropCommandBase.h
@@ -29,7 +29,8 @@
   };
 
   bool HandleArguments(std::vector<std::string> const& args,
-                           const char *prop, ArgumentFlags flags = NO_FLAGS);
+                       const std::string& prop,
+                       ArgumentFlags flags = NO_FLAGS);
 
   cmTypeMacro(cmTargetPropCommandBase, cmCommand);
 protected:
@@ -43,7 +44,7 @@
   virtual void HandleImportedTarget(const std::string &tgt) = 0;
   virtual void HandleMissingTarget(const std::string &name) = 0;
 
-  virtual void HandleDirectContent(cmTarget *tgt,
+  virtual bool HandleDirectContent(cmTarget *tgt,
                                    const std::vector<std::string> &content,
                                    bool prepend, bool system) = 0;
 
@@ -51,7 +52,7 @@
 
   bool ProcessContentArgs(std::vector<std::string> const& args,
                           unsigned int &argIndex, bool prepend, bool system);
-  void PopulateTargetProperies(const std::string &scope,
+  bool PopulateTargetProperies(const std::string &scope,
                                const std::vector<std::string> &content,
                                bool prepend, bool system);
 };
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
new file mode 100644
index 0000000..ce3b11e
--- /dev/null
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -0,0 +1,65 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Stephen Kelly <steveire@gmail.com>
+
+  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 "cmTargetSourcesCommand.h"
+
+#include "cmGeneratorExpression.h"
+
+//----------------------------------------------------------------------------
+bool cmTargetSourcesCommand
+::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+{
+  return this->HandleArguments(args, "SOURCES");
+}
+
+//----------------------------------------------------------------------------
+void cmTargetSourcesCommand
+::HandleImportedTarget(const std::string &tgt)
+{
+  cmOStringStream e;
+  e << "Cannot specify sources for imported target \""
+    << tgt << "\".";
+  this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+//----------------------------------------------------------------------------
+void cmTargetSourcesCommand
+::HandleMissingTarget(const std::string &name)
+{
+  cmOStringStream e;
+  e << "Cannot specify sources for target \"" << name << "\" "
+       "which is not built by this project.";
+  this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+//----------------------------------------------------------------------------
+std::string cmTargetSourcesCommand
+::Join(const std::vector<std::string> &content)
+{
+  std::string srcs;
+  std::string sep;
+  for(std::vector<std::string>::const_iterator it = content.begin();
+    it != content.end(); ++it)
+    {
+    srcs += sep + *it;
+    sep = ";";
+    }
+  return srcs;
+}
+
+//----------------------------------------------------------------------------
+bool cmTargetSourcesCommand
+::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
+                      bool, bool)
+{
+  tgt->AppendProperty("SOURCES", this->Join(content).c_str());
+  return true;
+}
diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h
new file mode 100644
index 0000000..a170e36
--- /dev/null
+++ b/Source/cmTargetSourcesCommand.h
@@ -0,0 +1,55 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2014 Stephen Kelly <steveire@gmail.com>
+
+  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 cmTargetSourcesCommand_h
+#define cmTargetSourcesCommand_h
+
+#include "cmTargetPropCommandBase.h"
+
+//----------------------------------------------------------------------------
+class cmTargetSourcesCommand : public cmTargetPropCommandBase
+{
+public:
+  /**
+   * This is a virtual constructor for the command.
+   */
+  virtual cmCommand* Clone()
+    {
+    return new cmTargetSourcesCommand;
+    }
+
+  /**
+   * This is called when the command is first encountered in
+   * the CMakeLists.txt file.
+   */
+  virtual bool InitialPass(std::vector<std::string> const& args,
+                           cmExecutionStatus &status);
+
+  /**
+   * The name of the command as specified in CMakeList.txt.
+   */
+  virtual std::string GetName() const { return "target_sources";}
+
+  cmTypeMacro(cmTargetSourcesCommand, cmTargetPropCommandBase);
+
+private:
+  virtual void HandleImportedTarget(const std::string &tgt);
+  virtual void HandleMissingTarget(const std::string &name);
+
+  virtual bool HandleDirectContent(cmTarget *tgt,
+                                   const std::vector<std::string> &content,
+                                   bool prepend, bool system);
+
+  virtual std::string Join(const std::vector<std::string> &content);
+};
+
+#endif
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 9cda978..ff5d411 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -17,33 +17,27 @@
 
 //----------------------------------------------------------------------------
 cmTest::cmTest(cmMakefile* mf)
+  : Backtrace(mf->GetBacktrace())
 {
   this->Makefile = mf;
   this->OldStyle = true;
   this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
-  this->Backtrace = new cmListFileBacktrace;
-  this->Makefile->GetBacktrace(*this->Backtrace);
 }
 
 //----------------------------------------------------------------------------
 cmTest::~cmTest()
 {
-  delete this->Backtrace;
 }
 
 //----------------------------------------------------------------------------
 cmListFileBacktrace const& cmTest::GetBacktrace() const
 {
-  return *this->Backtrace;
+  return this->Backtrace;
 }
 
 //----------------------------------------------------------------------------
-void cmTest::SetName(const char* name)
+void cmTest::SetName(const std::string& name)
 {
-  if ( !name )
-    {
-    name = "";
-    }
   this->Name = name;
 }
 
@@ -54,7 +48,7 @@
 }
 
 //----------------------------------------------------------------------------
-const char *cmTest::GetProperty(const char* prop) const
+const char *cmTest::GetProperty(const std::string& prop) const
 {
   bool chain = false;
   const char *retVal =
@@ -67,28 +61,20 @@
 }
 
 //----------------------------------------------------------------------------
-bool cmTest::GetPropertyAsBool(const char* prop) const
+bool cmTest::GetPropertyAsBool(const std::string& prop) const
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
 
 //----------------------------------------------------------------------------
-void cmTest::SetProperty(const char* prop, const char* value)
+void cmTest::SetProperty(const std::string& prop, const char* value)
 {
-  if (!prop)
-    {
-    return;
-    }
-
   this->Properties.SetProperty(prop, value, cmProperty::TEST);
 }
 
 //----------------------------------------------------------------------------
-void cmTest::AppendProperty(const char* prop, const char* value, bool asString)
+void cmTest::AppendProperty(const std::string& prop,
+                            const char* value, bool asString)
 {
-  if (!prop)
-    {
-    return;
-    }
   this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString);
 }
diff --git a/Source/cmTest.h b/Source/cmTest.h
index 1fe8fc0..c6e7e42 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -14,8 +14,8 @@
 
 #include "cmCustomCommand.h"
 #include "cmPropertyMap.h"
+#include "cmListFileCache.h"
 class cmMakefile;
-class cmListFileBacktrace;
 
 /** \class cmTest
  * \brief Represent a test
@@ -31,8 +31,8 @@
   ~cmTest();
 
   ///! Set the test name
-  void SetName(const char* name);
-  const char* GetName() const { return this->Name.c_str(); }
+  void SetName(const std::string& name);
+  std::string GetName() const { return this->Name; }
 
   void SetCommand(std::vector<std::string> const& command);
   std::vector<std::string> const& GetCommand() const
@@ -46,14 +46,15 @@
   void Print() const;
 
   ///! Set/Get a property of this source file
-  void SetProperty(const char *prop, const char *value);
-  void AppendProperty(const char* prop, const char* value,bool asString=false);
-  const char *GetProperty(const char *prop) const;
-  bool GetPropertyAsBool(const char *prop) const;
-  cmPropertyMap &GetProperties() { return this->Properties; };
+  void SetProperty(const std::string& prop, const char *value);
+  void AppendProperty(const std::string& prop,
+                      const char* value,bool asString=false);
+  const char *GetProperty(const std::string& prop) const;
+  bool GetPropertyAsBool(const std::string& prop) const;
+  cmPropertyMap &GetProperties() { return this->Properties; }
 
   /** Get the cmMakefile instance that owns this test.  */
-  cmMakefile *GetMakefile() { return this->Makefile;};
+  cmMakefile *GetMakefile() { return this->Makefile;}
 
   /** Get the backtrace of the command that created this test.  */
   cmListFileBacktrace const& GetBacktrace() const;
@@ -64,13 +65,13 @@
 
 private:
   cmPropertyMap Properties;
-  cmStdString Name;
+  std::string Name;
   std::vector<std::string> Command;
 
   bool OldStyle;
 
   cmMakefile* Makefile;
-  cmListFileBacktrace* Backtrace;
+  cmListFileBacktrace Backtrace;
 };
 
 #endif
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index 5dc3e60..f87a535 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -64,13 +64,13 @@
 
 //----------------------------------------------------------------------------
 void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
-                                              const char* config,
+                                              const std::string& config,
                                               Indent const& indent)
 {
   this->TestGenerated = true;
 
   // Set up generator expression evaluation context.
-  cmGeneratorExpression ge(this->Test->GetBacktrace());
+  cmGeneratorExpression ge(&this->Test->GetBacktrace());
 
   // Start the test command.
   os << indent << "add_test(" << this->Test->GetName() << " ";
@@ -97,7 +97,7 @@
 
   // Generate the command line with full escapes.
   cmLocalGenerator* lg = mf->GetLocalGenerator();
-  os << lg->EscapeForCMake(exe.c_str());
+  os << lg->EscapeForCMake(exe);
   for(std::vector<std::string>::const_iterator ci = command.begin()+1;
       ci != command.end(); ++ci)
     {
diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h
index 2c69fc3..5446553 100644
--- a/Source/cmTestGenerator.h
+++ b/Source/cmTestGenerator.h
@@ -32,7 +32,7 @@
   virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
   virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
   virtual void GenerateScriptForConfig(std::ostream& os,
-                                       const char* config,
+                                       const std::string& config,
                                        Indent const& indent);
   virtual void GenerateScriptNoConfig(std::ostream& os, Indent const& indent);
   virtual bool NeedsScriptNoConfig() const;
diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h
index 8e6bbc1..a09c47f 100644
--- a/Source/cmTryCompileCommand.h
+++ b/Source/cmTryCompileCommand.h
@@ -40,7 +40,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "try_compile";}
+  virtual std::string GetName() const { return "try_compile";}
 
   cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile);
 
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index cfedaa5..cc6e139 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -162,7 +162,7 @@
       // now put the output into the variables
       if(this->RunOutputVariable.size())
         {
-        this->Makefile->AddDefinition(this->RunOutputVariable.c_str(),
+        this->Makefile->AddDefinition(this->RunOutputVariable,
                                       runOutputContents.c_str());
         }
 
@@ -171,12 +171,12 @@
         // if the TryCompileCore saved output in this outputVariable then
         // prepend that output to this output
         const char* compileOutput
-                 = this->Makefile->GetDefinition(this->OutputVariable.c_str());
+                 = this->Makefile->GetDefinition(this->OutputVariable);
         if (compileOutput)
           {
           runOutputContents = std::string(compileOutput) + runOutputContents;
           }
-        this->Makefile->AddDefinition(this->OutputVariable.c_str(),
+        this->Makefile->AddDefinition(this->OutputVariable,
                                       runOutputContents.c_str());
         }
       }
@@ -214,7 +214,7 @@
     {
     strcpy(retChar, "FAILED_TO_RUN");
     }
-  this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), retChar,
+  this->Makefile->AddCacheDefinition(this->RunResultVariable, retChar,
                                      "Result of TRY_RUN",
                                      cmCacheManager::INTERNAL);
 }
@@ -235,10 +235,10 @@
   copyDest += cmake::GetCMakeFilesDirectory();
   copyDest += "/";
   copyDest += cmSystemTools::GetFilenameWithoutExtension(
-                                                     this->OutputFile.c_str());
+                                                     this->OutputFile);
   copyDest += "-";
   copyDest += this->RunResultVariable;
-  copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile.c_str());
+  copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile);
   cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), copyDest.c_str());
 
   std::string resultFileName =  this->Makefile->GetHomeOutputDirectory();
@@ -250,7 +250,7 @@
   std::string internalRunOutputName=this->RunResultVariable+"__TRYRUN_OUTPUT";
   bool error = false;
 
-  if (this->Makefile->GetDefinition(this->RunResultVariable.c_str()) == 0)
+  if (this->Makefile->GetDefinition(this->RunResultVariable) == 0)
     {
     // if the variables doesn't exist, create it with a helpful error text
     // and mark it as advanced
@@ -258,7 +258,7 @@
     comment += "Run result of TRY_RUN(), indicates whether the executable "
                "would have been able to run on its target platform.\n";
     comment += detailsString;
-    this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(),
+    this->Makefile->AddCacheDefinition(this->RunResultVariable,
                                        "PLEASE_FILL_OUT-FAILED_TO_RUN",
                                        comment.c_str(),
                                        cmCacheManager::STRING);
@@ -276,7 +276,7 @@
   // is the output from the executable used ?
   if (out!=0)
     {
-    if (this->Makefile->GetDefinition(internalRunOutputName.c_str()) == 0)
+    if (this->Makefile->GetDefinition(internalRunOutputName) == 0)
       {
       // if the variables doesn't exist, create it with a helpful error text
       // and mark it as advanced
@@ -285,7 +285,7 @@
            "would have printed on stdout and stderr on its target platform.\n";
       comment += detailsString;
 
-      this->Makefile->AddCacheDefinition(internalRunOutputName.c_str(),
+      this->Makefile->AddCacheDefinition(internalRunOutputName,
                                          "PLEASE_FILL_OUT-NOTFOUND",
                                          comment.c_str(),
                                          cmCacheManager::STRING);
@@ -355,13 +355,13 @@
       file << comment << "\n\n";
 
       file << "set( " << this->RunResultVariable << " \n     \""
-           << this->Makefile->GetDefinition(this->RunResultVariable.c_str())
+           << this->Makefile->GetDefinition(this->RunResultVariable)
            << "\"\n     CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n";
 
       if (out!=0)
         {
         file << "set( " << internalRunOutputName << " \n     \""
-             << this->Makefile->GetDefinition(internalRunOutputName.c_str())
+             << this->Makefile->GetDefinition(internalRunOutputName)
              << "\"\n     CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n";
         }
       file.close();
@@ -383,6 +383,6 @@
 
   if (out!=0)
     {
-    (*out) = this->Makefile->GetDefinition(internalRunOutputName.c_str());
+    (*out) = this->Makefile->GetDefinition(internalRunOutputName);
     }
 }
diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h
index d0bf9ce..9b97b16 100644
--- a/Source/cmTryRunCommand.h
+++ b/Source/cmTryRunCommand.h
@@ -40,7 +40,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "try_run";}
+  virtual std::string GetName() const { return "try_run";}
 
   cmTypeMacro(cmTryRunCommand, cmCoreTryCompile);
 private:
diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h
index 2308139..62c2bd3 100644
--- a/Source/cmUnsetCommand.h
+++ b/Source/cmUnsetCommand.h
@@ -45,7 +45,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const {return "unset";}
+  virtual std::string GetName() const {return "unset";}
 
   cmTypeMacro(cmUnsetCommand, cmCommand);
 };
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index d4ec20f..8d26f86 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -38,7 +38,7 @@
     std::string e = "Bad path to Mesa, could not find: ";
     e += glh;
     e += " ";
-    this->SetError(e.c_str());
+    this->SetError(e);
     return false;
     }
   const char* destDir = args[1].c_str();
@@ -107,12 +107,12 @@
       if(glDirLine.find(includeFile.c_str()))
         {
         std::string gfile = glDirLine.match(3);
-        fout << "#include \"" << outdir << "/" << gfile.c_str() << "\"\n";
+        fout << "#include \"" << outdir << "/" << gfile << "\"\n";
         }
       else if(glLine.find(includeFile.c_str()))
         {
         fout << "#include \"" << outdir << "/" <<
-          includeLine.match(1).c_str() << "\"\n";
+          includeLine.match(1) << "\"\n";
         }
       else
         {
diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h
index dca75a5..da927c7 100644
--- a/Source/cmUseMangledMesaCommand.h
+++ b/Source/cmUseMangledMesaCommand.h
@@ -21,7 +21,7 @@
   virtual cmCommand* Clone() { return new cmUseMangledMesaCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
-  virtual const char* GetName() const { return "use_mangled_mesa";}
+  virtual std::string GetName() const { return "use_mangled_mesa";}
   virtual bool IsScriptable() const { return true; }
   virtual bool IsDiscouraged() const { return true; }
 protected:
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index 11e5108..ba6b4ac 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -29,7 +29,7 @@
   // The first argument is the cache entry name.
   std::string cacheEntry = *arg++;
   const char* cacheValue =
-    this->Makefile->GetDefinition(cacheEntry.c_str());
+    this->Makefile->GetDefinition(cacheEntry);
   // If it exists already and appears up to date then we are done.  If
   // the string contains "(IntDir)" but that is not the
   // CMAKE_CFG_INTDIR setting then the value is out of date.
@@ -113,14 +113,14 @@
   cmSystemTools::ReplaceString(utilityExecutable, "/./", "/");
 
   // Enter the value into the cache.
-  this->Makefile->AddCacheDefinition(cacheEntry.c_str(),
+  this->Makefile->AddCacheDefinition(cacheEntry,
                                  utilityExecutable.c_str(),
                                  "Path to an internal program.",
                                  cmCacheManager::FILEPATH);
   // add a value into the cache that maps from the
   // full path to the name of the project
   cmSystemTools::ConvertToUnixSlashes(utilityExecutable);
-  this->Makefile->AddCacheDefinition(utilityExecutable.c_str(),
+  this->Makefile->AddCacheDefinition(utilityExecutable,
                                  utilityName.c_str(),
                                  "Executable to project name.",
                                  cmCacheManager::INTERNAL);
diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h
index 83d115c..23afdbe 100644
--- a/Source/cmUtilitySourceCommand.h
+++ b/Source/cmUtilitySourceCommand.h
@@ -21,7 +21,7 @@
   virtual cmCommand* Clone() { return new cmUtilitySourceCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
-  virtual const char* GetName() const { return "utility_source";}
+  virtual std::string GetName() const { return "utility_source";}
   virtual bool IsDiscouraged() const { return true; }
 };
 
diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h
index 5ab8ebb..a61ab16 100644
--- a/Source/cmVS11CLFlagTable.h
+++ b/Source/cmVS11CLFlagTable.h
@@ -248,9 +248,9 @@
   {"ForcedUsingFiles", "FU",
    "Forced #using File",
    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PREfastAdditionalOptions", "analyze:",
-   "Additional Code Analysis Native options",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  {"PREfastLog", "analyze:log",
+   "Code Analysis Log",
+   "", cmVS7FlagTable::UserFollowing},
   {"PREfastAdditionalPlugins", "analyze:plugin",
    "Additional Code Analysis Native plugins",
    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
@@ -283,9 +283,6 @@
    "", cmVS7FlagTable::UserValue},
   // Skip [XMLDocumentationFileName] - no command line Switch.
   // Skip [BrowseInformationFile] - no command line Switch.
-  {"PREfastLog", "analyze:log ",
-   "Code Analysis Log",
-   "", cmVS7FlagTable::UserValue},
   // Skip [AdditionalOptions] - no command line Switch.
   {0,0,0,0,0}
 };
diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h
index 8f51319..0a7916f 100644
--- a/Source/cmVS12CLFlagTable.h
+++ b/Source/cmVS12CLFlagTable.h
@@ -254,9 +254,9 @@
   {"ForcedUsingFiles", "FU",
    "Forced #using File",
    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
-  {"PREfastAdditionalOptions", "analyze:",
-   "Additional Code Analysis Native options",
-   "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+  {"PREfastLog", "analyze:log",
+   "Code Analysis Log",
+   "", cmVS7FlagTable::UserFollowing},
   {"PREfastAdditionalPlugins", "analyze:plugin",
    "Additional Code Analysis Native plugins",
    "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
@@ -289,9 +289,6 @@
    "", cmVS7FlagTable::UserValue},
   // Skip [XMLDocumentationFileName] - no command line Switch.
   // Skip [BrowseInformationFile] - no command line Switch.
-  {"PREfastLog", "analyze:log ",
-   "Code Analysis Log",
-   "", cmVS7FlagTable::UserValue},
   // Skip [AdditionalOptions] - no command line Switch.
   {0,0,0,0,0}
 };
diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx
index ddb4003..80c1286 100644
--- a/Source/cmVariableRequiresCommand.cxx
+++ b/Source/cmVariableRequiresCommand.cxx
@@ -26,7 +26,7 @@
     }
 
   std::string testVariable = args[0];
-  if(!this->Makefile->IsOn(testVariable.c_str()))
+  if(!this->Makefile->IsOn(testVariable))
     {
     return true;
     }
@@ -36,7 +36,7 @@
   bool hasAdvanced = false;
   for(unsigned int i = 2; i < args.size(); ++i)
     {
-    if(!this->Makefile->IsOn(args[i].c_str()))
+    if(!this->Makefile->IsOn(args[i]))
       {
       requirementsMet = false;
       notSet += args[i];
@@ -49,13 +49,13 @@
         }
       }
     }
-  const char* reqVar = this->Makefile->GetDefinition(resultVariable.c_str());
+  const char* reqVar = this->Makefile->GetDefinition(resultVariable);
   // if reqVar is unset, then set it to requirementsMet
   // if reqVar is set to true, but requirementsMet is false , then
   // set reqVar to false.
   if(!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar)))
     {
-    this->Makefile->AddDefinition(resultVariable.c_str(), requirementsMet);
+    this->Makefile->AddDefinition(resultVariable, requirementsMet);
     }
 
   if(!requirementsMet)
diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h
index 881b149..7e68de1 100644
--- a/Source/cmVariableRequiresCommand.h
+++ b/Source/cmVariableRequiresCommand.h
@@ -21,7 +21,7 @@
   virtual cmCommand* Clone() { return new cmVariableRequiresCommand; }
   virtual bool InitialPass(std::vector<std::string> const& args,
                            cmExecutionStatus &status);
-  virtual const char* GetName() const { return "variable_requires";}
+  virtual std::string GetName() const { return "variable_requires";}
   virtual bool IsDiscouraged() const { return true; }
 };
 
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 8ad6fce..cb6cb12 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -16,7 +16,6 @@
     "READ_ACCESS",
     "UNKNOWN_READ_ACCESS",
     "UNKNOWN_DEFINED_ACCESS",
-    "ALLOWED_UNKNOWN_READ_ACCESS",
     "MODIFIED_ACCESS",
     "REMOVED_ACCESS",
     "NO_ACCESS"
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index 790c75a..0ca4a55 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -53,7 +53,6 @@
     VARIABLE_READ_ACCESS = 0,
     UNKNOWN_VARIABLE_READ_ACCESS,
     UNKNOWN_VARIABLE_DEFINED_ACCESS,
-    ALLOWED_UNKNOWN_VARIABLE_READ_ACCESS,
     VARIABLE_MODIFIED_ACCESS,
     VARIABLE_REMOVED_ACCESS,
     NO_ACCESS
@@ -81,7 +80,7 @@
   };
 
   typedef std::vector< Pair* > VectorOfPairs;
-  typedef std::map<cmStdString, VectorOfPairs > StringToVectorOfPairs;
+  typedef std::map<std::string, VectorOfPairs > StringToVectorOfPairs;
 
   StringToVectorOfPairs WatchMap;
 };
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 33e159b..debe243 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -84,7 +84,7 @@
   if ( !processed )
     {
     cmOStringStream msg;
-    msg << "Variable \"" << variable.c_str() << "\" was accessed using "
+    msg << "Variable \"" << variable << "\" was accessed using "
         << accessString << " with value \"" << (newValue?newValue:"") << "\".";
     makefile->IssueMessage(cmake::LOG, msg.str());
     }
@@ -136,8 +136,8 @@
   if ( variable == "CMAKE_CURRENT_LIST_FILE" )
     {
     cmOStringStream ostr;
-    ostr << "cannot be set on the variable: " << variable.c_str();
-    this->SetError(ostr.str().c_str());
+    ostr << "cannot be set on the variable: " << variable;
+    this->SetError(ostr.str());
     return false;
     }
 
diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h
index fb6062c..c1ee9b1 100644
--- a/Source/cmVariableWatchCommand.h
+++ b/Source/cmVariableWatchCommand.h
@@ -54,7 +54,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "variable_watch";}
+  virtual std::string GetName() const { return "variable_watch";}
 
   cmTypeMacro(cmVariableWatchCommand, cmCommand);
 
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ed7e243..72bb020 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -19,6 +19,7 @@
 #include "cmSourceFile.h"
 #include "cmVisualStudioGeneratorOptions.h"
 #include "cmLocalVisualStudio7Generator.h"
+#include "cmCustomCommandGenerator.h"
 #include "cmVS10CLFlagTable.h"
 #include "cmVS10LinkFlagTable.h"
 #include "cmVS10LibFlagTable.h"
@@ -140,7 +141,7 @@
 
 void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
   const char* tag,
-  const char* config,
+  const std::string& config,
   int indentLevel,
   const char* attribute,
   const char* end,
@@ -221,7 +222,8 @@
   //get the tools version to use
   const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
   std::string project_defaults=
-    "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n";
+    "<?xml version=\"1.0\" encoding=\"" +
+    this->GlobalGenerator->Encoding() + "\"?>\n";
   project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\"");
   project_defaults.append(toolsVer +"\" ");
   project_defaults.append(
@@ -376,12 +378,12 @@
 
 void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
 {
-  std::vector<cmSourceFile*> resxObjs;
-    this->GeneratorTarget->GetResxSources(resxObjs);
+  std::vector<cmSourceFile const*> resxObjs;
+    this->GeneratorTarget->GetResxSources(resxObjs, "");
   if(!resxObjs.empty())
     {
     this->WriteString("<ItemGroup>\n", 1);
-    for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin();
+    for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
         oi != resxObjs.end(); ++oi)
       {
       std::string obj = (*oi)->GetFullPath();
@@ -550,9 +552,9 @@
 void cmVisualStudio10TargetGenerator::WriteCustomCommands()
 {
   this->SourcesVisited.clear();
-  std::vector<cmSourceFile*> customCommands;
-  this->GeneratorTarget->GetCustomCommands(customCommands);
-  for(std::vector<cmSourceFile*>::const_iterator
+  std::vector<cmSourceFile const*> customCommands;
+  this->GeneratorTarget->GetCustomCommands(customCommands, "");
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = customCommands.begin();
       si != customCommands.end(); ++si)
     {
@@ -561,7 +563,8 @@
 }
 
 //----------------------------------------------------------------------------
-void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf)
+void cmVisualStudio10TargetGenerator
+::WriteCustomCommand(cmSourceFile const* sf)
 {
   if(this->SourcesVisited.insert(sf).second)
     {
@@ -584,7 +587,7 @@
 }
 
 void
-cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
+cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
                                                  cmCustomCommand const &
                                                  command)
 {
@@ -616,8 +619,6 @@
       }
     }
   cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
-  std::string comment = lg->ConstructComment(command);
-  comment = cmVS10EscapeComment(comment);
   std::vector<std::string> *configs =
     static_cast<cmGlobalVisualStudio7Generator *>
     (this->GlobalGenerator)->GetConfigurations();
@@ -627,8 +628,11 @@
   for(std::vector<std::string>::iterator i = configs->begin();
       i != configs->end(); ++i)
     {
+    cmCustomCommandGenerator ccg(command, *i, this->Makefile);
+    std::string comment = lg->ConstructComment(ccg);
+    comment = cmVS10EscapeComment(comment);
     std::string script =
-      cmVS10EscapeXML(lg->ConstructScript(command, i->c_str()));
+      cmVS10EscapeXML(lg->ConstructScript(ccg));
     this->WritePlatformConfigTag("Message",i->c_str(), 3);
     (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
     this->WritePlatformConfigTag("Command", i->c_str(), 3);
@@ -637,8 +641,8 @@
 
     (*this->BuildFileStream ) << source->GetFullPath();
     for(std::vector<std::string>::const_iterator d =
-          command.GetDepends().begin();
-        d != command.GetDepends().end();
+          ccg.GetDepends().begin();
+        d != ccg.GetDepends().end();
         ++d)
       {
       std::string dep;
@@ -652,8 +656,8 @@
     this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
     const char* sep = "";
     for(std::vector<std::string>::const_iterator o =
-          command.GetOutputs().begin();
-        o != command.GetOutputs().end();
+          ccg.GetOutputs().begin();
+        o != ccg.GetOutputs().end();
         ++o)
       {
       std::string out = *o;
@@ -681,7 +685,8 @@
       this->Makefile->GetCurrentOutputDirectory(), path.c_str())
     : this->LocalGenerator->Convert(path.c_str(),
                                     cmLocalGenerator::START_OUTPUT,
-                                    cmLocalGenerator::UNCHANGED);
+                                    cmLocalGenerator::UNCHANGED,
+                                    /* optional = */ true);
 }
 
 void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s)
@@ -700,7 +705,10 @@
   std::vector<cmSourceGroup> sourceGroups =
     this->Makefile->GetSourceGroups();
   std::vector<cmSourceFile*> classes;
-  this->Target->GetSourceFiles(classes);
+  if (!this->Target->GetConfigCommonSourceFiles(classes))
+    {
+    return;
+    }
 
   std::set<cmSourceGroup*> groupsUsed;
   for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
@@ -730,7 +738,8 @@
   //get the tools version to use
   const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
   std::string project_defaults=
-    "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n";
+    "<?xml version=\"1.0\" encoding=\"" +
+    this->GlobalGenerator->Encoding() + "\"?>\n";
   project_defaults.append("<Project ToolsVersion=\"");
   project_defaults.append(toolsVer +"\" ");
   project_defaults.append(
@@ -743,12 +752,12 @@
     this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups);
     }
 
-  std::vector<cmSourceFile*> resxObjs;
-    this->GeneratorTarget->GetResxSources(resxObjs);
+  std::vector<cmSourceFile const*> resxObjs;
+    this->GeneratorTarget->GetResxSources(resxObjs, "");
   if(!resxObjs.empty())
     {
     this->WriteString("<ItemGroup>\n", 1);
-    for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin();
+    for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
         oi != resxObjs.end(); ++oi)
       {
       std::string obj = (*oi)->GetFullPath();
@@ -763,7 +772,7 @@
 
   // Add object library contents as external objects.
   std::vector<std::string> objs;
-  this->GeneratorTarget->UseObjectLibraries(objs);
+  this->GeneratorTarget->UseObjectLibraries(objs, "");
   if(!objs.empty())
     {
     this->WriteString("<ItemGroup>\n", 1);
@@ -899,7 +908,7 @@
   for(ToolSources::const_iterator s = sources.begin();
       s != sources.end(); ++s)
     {
-    cmSourceFile* sf = s->SourceFile;
+    cmSourceFile const* sf = s->SourceFile;
     std::string const& source = sf->GetFullPath();
     cmSourceGroup* sourceGroup =
       this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
@@ -926,14 +935,14 @@
 }
 
 void cmVisualStudio10TargetGenerator::WriteSource(
-  const char* tool, cmSourceFile* sf, const char* end)
+  const char* tool, cmSourceFile const* sf, const char* end)
 {
   // Visual Studio tools append relative paths to the current dir, as in:
   //
   //  c:\path\to\current\dir\..\..\..\relative\path\to\source.c
   //
   // and fail if this exceeds the maximum allowed path length.  Our path
-  // conversion uses full paths outside the build tree to allow deeper trees.
+  // conversion uses full paths when possible to allow deeper trees.
   bool forceRelative = false;
   std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false);
   if(this->LocalGenerator->GetVersion() == cmLocalVisualStudioGenerator::VS10
@@ -982,9 +991,9 @@
 }
 
 void cmVisualStudio10TargetGenerator::WriteSources(
-  const char* tool, std::vector<cmSourceFile*> const& sources)
+  const char* tool, std::vector<cmSourceFile const*> const& sources)
 {
-  for(std::vector<cmSourceFile*>::const_iterator
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = sources.begin(); si != sources.end(); ++si)
     {
     this->WriteSource(tool, *si);
@@ -999,31 +1008,31 @@
     }
   this->WriteString("<ItemGroup>\n", 1);
 
-  std::vector<cmSourceFile*> headerSources;
-  this->GeneratorTarget->GetHeaderSources(headerSources);
+  std::vector<cmSourceFile const*> headerSources;
+  this->GeneratorTarget->GetHeaderSources(headerSources, "");
   this->WriteSources("ClInclude", headerSources);
-  std::vector<cmSourceFile*> idlSources;
-  this->GeneratorTarget->GetIDLSources(idlSources);
+  std::vector<cmSourceFile const*> idlSources;
+  this->GeneratorTarget->GetIDLSources(idlSources, "");
   this->WriteSources("Midl", idlSources);
 
-  std::vector<cmSourceFile*> objectSources;
-  this->GeneratorTarget->GetObjectSources(objectSources);
-  for(std::vector<cmSourceFile*>::const_iterator
+  std::vector<cmSourceFile const*> objectSources;
+  this->GeneratorTarget->GetObjectSources(objectSources, "");
+  for(std::vector<cmSourceFile const*>::const_iterator
         si = objectSources.begin();
       si != objectSources.end(); ++si)
     {
-    const char* lang = (*si)->GetLanguage();
+    const std::string& lang = (*si)->GetLanguage();
     const char* tool = NULL;
-    if (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") == 0)
+    if (lang == "C"|| lang == "CXX")
       {
       tool = "ClCompile";
       }
-    else if (strcmp(lang, "ASM_MASM") == 0 &&
+    else if (lang == "ASM_NASM" &&
              this->GlobalGenerator->IsMasmEnabled())
       {
       tool = "MASM";
       }
-    else if (strcmp(lang, "RC") == 0)
+    else if (lang == "RC")
       {
       tool = "ResourceCompile";
       }
@@ -1047,8 +1056,21 @@
       }
     }
 
-  std::vector<cmSourceFile*> externalObjects;
-  this->GeneratorTarget->GetExternalObjects(externalObjects);
+  std::vector<cmSourceFile const*> externalObjects;
+  this->GeneratorTarget->GetExternalObjects(externalObjects, "");
+  for(std::vector<cmSourceFile const*>::iterator
+        si = externalObjects.begin();
+      si != externalObjects.end(); )
+    {
+    if (!(*si)->GetObjectLibrary().empty())
+      {
+      si = externalObjects.erase(si);
+      }
+    else
+      {
+      ++si;
+      }
+    }
   if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
     {
     // For VS >= 11 we use LinkObjects to avoid linking custom command
@@ -1059,7 +1081,7 @@
     {
     // If an object file is generated in this target, then vs10 will use
     // it in the build, and we have to list it as None instead of Object.
-    for(std::vector<cmSourceFile*>::const_iterator
+    for(std::vector<cmSourceFile const*>::const_iterator
           si = externalObjects.begin();
         si != externalObjects.end(); ++si)
       {
@@ -1069,13 +1091,13 @@
       }
     }
 
-  std::vector<cmSourceFile*> extraSources;
-  this->GeneratorTarget->GetExtraSources(extraSources);
+  std::vector<cmSourceFile const*> extraSources;
+  this->GeneratorTarget->GetExtraSources(extraSources, "");
   this->WriteSources("None", extraSources);
 
   // Add object library contents as external objects.
   std::vector<std::string> objs;
-  this->GeneratorTarget->UseObjectLibraries(objs);
+  this->GeneratorTarget->UseObjectLibraries(objs, "");
   for(std::vector<std::string>::const_iterator
         oi = objs.begin(); oi != objs.end(); ++oi)
     {
@@ -1089,9 +1111,9 @@
 }
 
 bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
-  cmSourceFile* source)
+  cmSourceFile const* source)
 {
-  cmSourceFile& sf = *source;
+  cmSourceFile const& sf = *source;
 
   std::string objectName;
   if(this->GeneratorTarget->HasExplicitObjectName(&sf))
@@ -1108,29 +1130,28 @@
     {
     defines += cdefs;
     }
-  const char* lang =
+  std::string lang =
     this->GlobalGenerator->GetLanguageFromExtension
     (sf.GetExtension().c_str());
-  const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
-  const char* linkLanguage = this->Target->GetLinkerLanguage();
+  std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
+  const std::string& linkLanguage = this->Target->GetLinkerLanguage();
   bool needForceLang = false;
   // source file does not match its extension language
-  if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
+  if(lang != sourceLang)
     {
     needForceLang = true;
     lang = sourceLang;
     }
   // if the source file does not match the linker language
   // then force c or c++
-  if(needForceLang || (linkLanguage && lang
-                       && strcmp(lang, linkLanguage) != 0))
+  if(needForceLang || (linkLanguage != lang))
     {
-    if(strcmp(lang, "CXX") == 0)
+    if(lang == "CXX")
       {
       // force a C++ file type
       flags += " /TP ";
       }
-    else if(strcmp(lang, "C") == 0)
+    else if(lang == "C")
       {
       // force to c
       flags += " /TC ";
@@ -1341,17 +1362,17 @@
   // collect up flags for
   if(this->Target->GetType() < cmTarget::UTILITY)
     {
-    const char* linkLanguage =
+    const std::string& linkLanguage =
       this->Target->GetLinkerLanguage(configName.c_str());
-    if(!linkLanguage)
+    if(linkLanguage.empty())
       {
       cmSystemTools::Error
         ("CMake can not determine linker language for target: ",
          this->Name.c_str());
       return false;
       }
-    if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
-       || strcmp(linkLanguage, "Fortran") == 0)
+    if(linkLanguage == "C" || linkLanguage == "CXX"
+       || linkLanguage == "Fortran")
       {
       std::string baseFlagVar = "CMAKE_";
       baseFlagVar += linkLanguage;
@@ -1365,11 +1386,11 @@
         Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
       }
     // set the correct language
-    if(strcmp(linkLanguage, "C") == 0)
+    if(linkLanguage == "C")
       {
       flags += " /TC ";
       }
-    if(strcmp(linkLanguage, "CXX") == 0)
+    if(linkLanguage == "CXX")
       {
       flags += " /TP ";
       }
@@ -1427,6 +1448,17 @@
   clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, "      ",
                                           "\n", "CXX");
   this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
+
+  // Specify the compiler program database file if configured.
+  std::string pdb = this->Target->GetCompilePDBPath(configName.c_str());
+  if(!pdb.empty())
+    {
+    this->ConvertToWindowsSlash(pdb);
+    this->WriteString("<ProgramDataBaseFileName>", 3);
+    *this->BuildFileStream << cmVS10EscapeXML(pdb)
+                           << "</ProgramDataBaseFileName>\n";
+    }
+
   this->WriteString("</ClCompile>\n", 2);
 }
 
@@ -1514,9 +1546,9 @@
                 cmVSGetLinkFlagTable(this->LocalGenerator), 0, this));
   Options& linkOptions = *pOptions;
 
-  const char* linkLanguage =
+  const std::string& linkLanguage =
     this->Target->GetLinkerLanguage(config.c_str());
-  if(!linkLanguage)
+  if(linkLanguage.empty())
     {
     cmSystemTools::Error
       ("CMake can not determine linker language for target: ",
@@ -1666,10 +1698,10 @@
   linkOptions.AddFlag("ImportLibrary", imLib.c_str());
   linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
   linkOptions.Parse(flags.c_str());
-  if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+  std::string def = this->GeneratorTarget->GetModuleDefinitionFile("");
+  if(!def.empty())
     {
-    linkOptions.AddFlag("ModuleDefinitionFile",
-                        this->GeneratorTarget->ModuleDefinitionFile.c_str());
+    linkOptions.AddFlag("ModuleDefinitionFile", def.c_str());
     }
 
   this->LinkOptions[config] = pOptions.release();
@@ -1825,13 +1857,12 @@
   for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
       i != commands.end(); ++i)
     {
-    const cmCustomCommand& command = *i;
+    cmCustomCommandGenerator ccg(*i, configName, this->Makefile);
     comment += pre;
-    comment += lg->ConstructComment(command);
+    comment += lg->ConstructComment(ccg);
     script += pre;
     pre = "\n";
-    script +=
-      cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str()));
+    script += cmVS10EscapeXML(lg->ConstructScript(ccg));
     }
   comment = cmVS10EscapeComment(comment);
   this->WriteString("<Message>",3);
@@ -1897,7 +1928,7 @@
   IsResxHeader(const std::string& headerFile)
 {
   std::set<std::string> expectedResxHeaders;
-  this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders);
+  this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders, "");
 
   std::set<std::string>::const_iterator it =
                                         expectedResxHeaders.find(headerFile);
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index d1f3d19..d72c6fd 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -35,7 +35,7 @@
   // used by cmVisualStudioGeneratorOptions
   void WritePlatformConfigTag(
     const char* tag,
-    const char* config,
+    const std::string& config,
     int indentLevel,
     const char* attribute = 0,
     const char* end = 0,
@@ -45,7 +45,7 @@
 private:
   struct ToolSource
   {
-    cmSourceFile* SourceFile;
+    cmSourceFile const* SourceFile;
     bool RelativePath;
   };
   struct ToolSources: public std::vector<ToolSource> {};
@@ -55,8 +55,10 @@
   void WriteString(const char* line, int indentLevel);
   void WriteProjectConfigurations();
   void WriteProjectConfigurationValues();
-  void WriteSource(const char* tool, cmSourceFile* sf, const char* end = 0);
-  void WriteSources(const char* tool, std::vector<cmSourceFile*> const&);
+  void WriteSource(const char* tool, cmSourceFile const* sf,
+                   const char* end = 0);
+  void WriteSources(const char* tool,
+                    std::vector<cmSourceFile const*> const&);
   void WriteAllSources();
   void WriteDotNetReferences();
   void WriteEmbeddedResourceGroup();
@@ -77,13 +79,13 @@
                         std::vector<std::string> const & includes);
   void OutputIncludes(std::vector<std::string> const & includes);
   void OutputLinkIncremental(std::string const& configName);
-  void WriteCustomRule(cmSourceFile* source,
+  void WriteCustomRule(cmSourceFile const* source,
                        cmCustomCommand const & command);
   void WriteCustomCommands();
-  void WriteCustomCommand(cmSourceFile* sf);
+  void WriteCustomCommand(cmSourceFile const* sf);
   void WriteGroups();
   void WriteProjectReferences();
-  bool OutputSourceSpecificFlags(cmSourceFile* source);
+  bool OutputSourceSpecificFlags(cmSourceFile const* source);
   void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring);
   void WriteLibOptions(std::string const& config);
   void WriteEvents(std::string const& configName);
@@ -98,7 +100,7 @@
 
 private:
   typedef cmVisualStudioGeneratorOptions Options;
-  typedef std::map<cmStdString, Options*> OptionsMap;
+  typedef std::map<std::string, Options*> OptionsMap;
   OptionsMap ClOptions;
   OptionsMap LinkOptions;
   std::string PathToVcxproj;
@@ -111,9 +113,9 @@
   cmGlobalVisualStudio10Generator* GlobalGenerator;
   cmGeneratedFileStream* BuildFileStream;
   cmLocalVisualStudio7Generator* LocalGenerator;
-  std::set<cmSourceFile*> SourcesVisited;
+  std::set<cmSourceFile const*> SourcesVisited;
 
-  typedef std::map<cmStdString, ToolSources> ToolSourceMap;
+  typedef std::map<std::string, ToolSources> ToolSourceMap;
   ToolSourceMap Tools;
 };
 
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 6aca787..81adb56 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -222,7 +222,7 @@
 ::OutputPreprocessorDefinitions(std::ostream& fout,
                                 const char* prefix,
                                 const char* suffix,
-                                const char* lang)
+                                const std::string& lang)
 {
   if(this->Defines.empty())
     {
@@ -270,7 +270,7 @@
       {
       define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str());
 
-      if(0 == strcmp(lang, "RC"))
+      if(lang == "RC")
         {
         cmSystemTools::ReplaceString(define, "\"", "\\\"");
         }
@@ -300,7 +300,7 @@
 {
   if(this->Version >= cmLocalVisualStudioGenerator::VS10)
     {
-    for(std::map<cmStdString, cmStdString>::iterator m = this->FlagMap.begin();
+    for(std::map<std::string, std::string>::iterator m = this->FlagMap.begin();
         m != this->FlagMap.end(); ++m)
       {
       fout << indent;
@@ -326,7 +326,7 @@
     }
   else
     {
-    for(std::map<cmStdString, cmStdString>::iterator m = this->FlagMap.begin();
+    for(std::map<std::string, std::string>::iterator m = this->FlagMap.begin();
         m != this->FlagMap.end(); ++m)
       {
       fout << indent << m->first << "=\"" << m->second << "\"\n";
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 90f7667..214b893 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -55,7 +55,7 @@
   void OutputPreprocessorDefinitions(std::ostream& fout,
                                      const char* prefix,
                                      const char* suffix,
-                                     const char* lang);
+                                     const std::string& lang);
   void OutputFlagMap(std::ostream& fout, const char* indent);
   void OutputAdditionalOptions(std::ostream& fout,
                                const char* prefix,
diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx
index 219a5eb..ca226fb 100644
--- a/Source/cmVisualStudioWCEPlatformParser.cxx
+++ b/Source/cmVisualStudioWCEPlatformParser.cxx
@@ -62,7 +62,7 @@
   return 0;
 }
 
-void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
+void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
                                                    const char** attributes)
 {
   if(this->FoundRequiredName)
@@ -72,7 +72,7 @@
 
   this->CharacterData = "";
 
-  if(strcmp(name, "PlatformData") == 0)
+  if(name == "PlatformData")
     {
     this->PlatformName = "";
     this->OSMajorVersion = "";
@@ -80,7 +80,7 @@
     this->Macros.clear();
     }
 
-  if(strcmp(name, "Macro") == 0)
+  if(name == "Macro")
     {
     std::string macroName;
     std::string macroValue;
@@ -102,7 +102,7 @@
       this->Macros[macroName] = macroValue;
       }
     }
-  else if(strcmp(name, "Directories") == 0)
+  else if(name == "Directories")
     {
     for(const char** attr = attributes; *attr; attr += 2)
       {
@@ -122,11 +122,11 @@
     }
 }
 
-void cmVisualStudioWCEPlatformParser::EndElement(const char* name)
+void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name)
 {
   if(!this->RequiredName)
     {
-    if(strcmp(name, "PlatformName") == 0)
+    if(name == "PlatformName")
       {
       this->AvailablePlatforms.push_back(this->CharacterData);
       }
@@ -138,19 +138,19 @@
     return;
     }
 
-  if(strcmp(name, "PlatformName") == 0)
+  if(name == "PlatformName")
     {
     this->PlatformName = this->CharacterData;
     }
-  else if(strcmp(name, "OSMajorVersion") == 0)
+  else if(name == "OSMajorVersion")
     {
     this->OSMajorVersion = this->CharacterData;
     }
-  else if(strcmp(name, "OSMinorVersion") == 0)
+  else if(name == "OSMinorVersion")
    {
    this->OSMinorVersion = this->CharacterData;
    }
-  else if(strcmp(name, "Platform") == 0)
+  else if(name == "Platform")
     {
     if(this->PlatformName == this->RequiredName)
       {
diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h
index 466e1dd..042df01 100644
--- a/Source/cmVisualStudioWCEPlatformParser.h
+++ b/Source/cmVisualStudioWCEPlatformParser.h
@@ -41,8 +41,8 @@
     return this->AvailablePlatforms; }
 
 protected:
-  virtual void StartElement(const char* name, const char** attributes);
-  void EndElement(const char* name);
+  virtual void StartElement(const std::string& name, const char** attributes);
+  void EndElement(const std::string& name);
   void CharacterDataHandler(const char* data, int length);
 
 private:
diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h
index 45badd0..9fafffc 100644
--- a/Source/cmWhileCommand.h
+++ b/Source/cmWhileCommand.h
@@ -66,7 +66,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "while";}
+  virtual std::string GetName() const { return "while";}
 
   cmTypeMacro(cmWhileCommand, cmCommand);
 };
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
index aa6b9f8..af955ec 100644
--- a/Source/cmWriteFileCommand.cxx
+++ b/Source/cmWriteFileCommand.cxx
@@ -47,7 +47,7 @@
     {
     std::string e = "attempted to write a file: " + fileName
       + " into a source directory.";
-    this->SetError(e.c_str());
+    this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
     }
@@ -79,7 +79,7 @@
     std::string error = "Internal CMake error when trying to open file: ";
     error += fileName.c_str();
     error += " for writing.";
-    this->SetError(error.c_str());
+    this->SetError(error);
     return false;
     }
   file << message << std::endl;
diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h
index 84a38fc..0d06878 100644
--- a/Source/cmWriteFileCommand.h
+++ b/Source/cmWriteFileCommand.h
@@ -44,7 +44,7 @@
   /**
    * The name of the command as specified in CMakeList.txt.
    */
-  virtual const char* GetName() const { return "write_file";}
+  virtual std::string GetName() const { return "write_file";}
 
   /** This command is kept for compatibility with older CMake versions. */
   virtual bool IsDiscouraged() const
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index 6abf6bf..3302a8d 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -108,7 +108,7 @@
     {
     out << separator;
     }
-  std::map<cmStdString, cmXCodeObject*>::iterator i;
+  std::map<std::string, cmXCodeObject*>::iterator i;
   cmXCodeObject::Indent(3*indentFactor, out);
   out << "isa = " << PBXTypeNames[this->IsA]  << ";" << separator;
   for(i = this->ObjectAttributes.begin();
@@ -138,7 +138,7 @@
       }
     else if(object->TypeValue == ATTRIBUTE_GROUP)
       {
-      std::map<cmStdString, cmXCodeObject*>::iterator j;
+      std::map<std::string, cmXCodeObject*>::iterator j;
       out << i->first << " = {" << separator;
       for(j = object->ObjectAttributes.begin(); j !=
             object->ObjectAttributes.end(); ++j)
@@ -236,7 +236,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmXCodeObject::PrintString(std::ostream& os,cmStdString String)
+void cmXCodeObject::PrintString(std::ostream& os,std::string String)
 {
   // The string needs to be quoted if it contains any characters
   // considered special by the Xcode project file parser.
@@ -266,7 +266,7 @@
 }
 
 //----------------------------------------------------------------------------
-void cmXCodeObject::SetString(const char* s)
+void cmXCodeObject::SetString(const std::string& s)
 {
   this->String = s;
 }
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index b89f78c..ed2940a 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -30,20 +30,20 @@
                  PBXCopyFilesBuildPhase,
                  None
   };
-  class StringVec: public std::vector<cmStdString> {};
+  class StringVec: public std::vector<std::string> {};
   static const char* PBXTypeNames[];
   virtual ~cmXCodeObject();
   cmXCodeObject(PBXType ptype, Type type);
   Type GetType() { return this->TypeValue;}
   PBXType GetIsA() { return this->IsA;}
 
-  void SetString(const char* s);
-  const char* GetString()
+  void SetString(const std::string& s);
+  const std::string& GetString()
     {
-      return this->String.c_str();
+      return this->String;
     }
 
-  void AddAttribute(const char* name, cmXCodeObject* value)
+  void AddAttribute(const std::string& name, cmXCodeObject* value)
     {
       this->ObjectAttributes[name] = value;
     }
@@ -79,11 +79,11 @@
 
   static void PrintList(std::vector<cmXCodeObject*> const&,
                         std::ostream& out);
-  const char* GetId()
+  const std::string& GetId()
     {
-      return this->Id.c_str();
+      return this->Id;
     }
-  void SetId(const char* id)
+  void SetId(const std::string& id)
     {
       this->Id = id;
     }
@@ -95,8 +95,8 @@
     {
       this->Target = t;
     }
-  const char* GetComment() {return this->Comment.c_str();}
-  bool HasComment() { return (this->Comment.size() !=  0);}
+  const std::string& GetComment() {return this->Comment;}
+  bool HasComment() { return (!this->Comment.empty());}
   cmXCodeObject* GetObject(const char* name)
     {
       if(this->ObjectAttributes.count(name))
@@ -122,49 +122,41 @@
 
   void CopyAttributes(cmXCodeObject* );
 
-  void AddDependLibrary(const char* configName,
-                        const char* l)
+  void AddDependLibrary(const std::string& configName,
+                        const std::string& l)
     {
-      if(!configName)
-        {
-        configName = "";
-        }
       this->DependLibraries[configName].push_back(l);
     }
-  std::map<cmStdString, StringVec> const& GetDependLibraries()
+  std::map<std::string, StringVec> const& GetDependLibraries()
     {
       return this->DependLibraries;
     }
-  void AddDependTarget(const char* configName,
-                       const char* tName)
+  void AddDependTarget(const std::string& configName,
+                       const std::string& tName)
     {
-      if(!configName)
-        {
-        configName = "";
-        }
       this->DependTargets[configName].push_back(tName);
     }
-  std::map<cmStdString, StringVec> const& GetDependTargets()
+  std::map<std::string, StringVec> const& GetDependTargets()
     {
     return this->DependTargets;
     }
   std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;}
-  void SetComment(const char* c) { this->Comment = c;}
-  static void PrintString(std::ostream& os,cmStdString String);
+  void SetComment(const std::string& c) { this->Comment = c;}
+  static void PrintString(std::ostream& os,std::string String);
 protected:
   void PrintString(std::ostream& os) const;
 
   cmTarget* Target;
   Type TypeValue;
-  cmStdString Id;
+  std::string Id;
   PBXType IsA;
   int Version;
-  cmStdString Comment;
-  cmStdString String;
+  std::string Comment;
+  std::string String;
   cmXCodeObject* Object;
   std::vector<cmXCodeObject*> List;
-  std::map<cmStdString, StringVec> DependLibraries;
-  std::map<cmStdString, StringVec> DependTargets;
-  std::map<cmStdString, cmXCodeObject*> ObjectAttributes;
+  std::map<std::string, StringVec> DependLibraries;
+  std::map<std::string, StringVec> DependTargets;
+  std::map<std::string, cmXCodeObject*> ObjectAttributes;
 };
 #endif
diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx
index 0c53440..a73fd70 100644
--- a/Source/cmXMLParser.cxx
+++ b/Source/cmXMLParser.cxx
@@ -152,14 +152,14 @@
 }
 
 //----------------------------------------------------------------------------
-void cmXMLParser::StartElement(const char * name,
+void cmXMLParser::StartElement(const std::string& name,
   const char ** /*atts*/)
 {
   std::cout << "Start element: " << name << std::endl;
 }
 
 //----------------------------------------------------------------------------
-void cmXMLParser::EndElement(const char * name)
+void cmXMLParser::EndElement(const std::string& name)
 {
   std::cout << "End element: " << name << std::endl;
 }
diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h
index d916075..84a5a7d 100644
--- a/Source/cmXMLParser.h
+++ b/Source/cmXMLParser.h
@@ -74,11 +74,11 @@
    * element.  atts = Null-terminated array of attribute name/value pairs.
    * Even indices are attribute names, and odd indices are values.
    */
-  virtual void StartElement(const char* name, const char** atts);
+  virtual void StartElement(const std::string& name, const char** atts);
 
   //! Called at the end of an element in the XML source opened when
   //StartElement was called.
-  virtual void EndElement(const char* name);
+  virtual void EndElement(const std::string& name);
 
   //! Called when there is character data to handle.
   virtual void CharacterDataHandler(const char* data, int length);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 7cbc1da..e3bebbd 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -24,6 +24,7 @@
 #if defined(CMAKE_BUILD_WITH_CMAKE)
 # include "cmGraphVizWriter.h"
 # include "cmVariableWatch.h"
+# include <cmsys/SystemInformation.hxx>
 #endif
 
 #include <cmsys/Glob.hxx>
@@ -60,13 +61,15 @@
 #    include "cmGlobalBorlandMakefileGenerator.h"
 #    include "cmGlobalNMakeMakefileGenerator.h"
 #    include "cmGlobalJOMMakefileGenerator.h"
-#    include "cmGlobalWatcomWMakeGenerator.h"
 #    define CMAKE_HAVE_VS_GENERATORS
 #  endif
 #  include "cmGlobalMSYSMakefileGenerator.h"
 #  include "cmGlobalMinGWMakefileGenerator.h"
 #else
 #endif
+#if defined(CMAKE_USE_WMAKE)
+# include "cmGlobalWatcomWMakeGenerator.h"
+#endif
 #include "cmGlobalUnixMakefileGenerator3.h"
 #include "cmGlobalNinjaGenerator.h"
 #include "cmExtraCodeLiteGenerator.h"
@@ -221,13 +224,13 @@
     }
 }
 
-bool cmake::CommandExists(const char* name) const
+bool cmake::CommandExists(const std::string& name) const
 {
   std::string sName = cmSystemTools::LowerCase(name);
   return (this->Commands.find(sName) != this->Commands.end());
 }
 
-cmCommand *cmake::GetCommand(const char *name)
+cmCommand *cmake::GetCommand(const std::string& name)
 {
   cmCommand* rm = 0;
   std::string sName = cmSystemTools::LowerCase(name);
@@ -239,7 +242,8 @@
   return rm;
 }
 
-void cmake::RenameCommand(const char*oldName, const char* newName)
+void cmake::RenameCommand(const std::string& oldName,
+                          const std::string& newName)
 {
   // if the command already exists, free the old one
   std::string sOldName = cmSystemTools::LowerCase(oldName);
@@ -262,7 +266,7 @@
   this->Commands.erase(pos);
 }
 
-void cmake::RemoveCommand(const char* name)
+void cmake::RemoveCommand(const std::string& name)
 {
   std::string sName = cmSystemTools::LowerCase(name);
   RegisteredCommandsMap::iterator pos = this->Commands.find(sName);
@@ -305,7 +309,7 @@
       it != unscriptableCommands.end();
       ++it)
     {
-    this->RemoveCommand(it->c_str());
+    this->RemoveCommand(*it);
     }
 }
 
@@ -334,23 +338,23 @@
         }
       std::string var, value;
       cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
-      if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type))
+      if(cmCacheManager::ParseEntry(entry, var, value, type))
         {
         // The value is transformed if it is a filepath for example, so
         // we can't compare whether the value is already in the cache until
         // after we call AddCacheEntry.
         const char *cachedValue =
-                              this->CacheManager->GetCacheValue(var.c_str());
+                              this->CacheManager->GetCacheValue(var);
 
-        this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
+        this->CacheManager->AddCacheEntry(var, value.c_str(),
           "No help, variable specified on the command line.", type);
         if(this->WarnUnusedCli)
           {
           if (!cachedValue
-              || strcmp(this->CacheManager->GetCacheValue(var.c_str()),
+              || strcmp(this->CacheManager->GetCacheValue(var),
                         cachedValue) != 0)
             {
-            this->WatchUnusedCli(var.c_str());
+            this->WatchUnusedCli(var);
             }
           }
         }
@@ -389,7 +393,7 @@
           }
         }
       cmsys::RegularExpression regex(
-        cmsys::Glob::PatternToRegex(entryPattern.c_str(), true, true).c_str());
+        cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str());
       //go through all cache entries and collect the vars which will be removed
       std::vector<std::string> entriesToDelete;
       cmCacheManager::CacheIterator it =
@@ -413,7 +417,7 @@
           currentEntry != entriesToDelete.end();
           ++currentEntry)
         {
-        this->CacheManager->RemoveCacheEntry(currentEntry->c_str());
+        this->CacheManager->RemoveCacheEntry(*currentEntry);
         }
       }
     else if(arg.find("-C",0) == 0)
@@ -432,7 +436,7 @@
           return false;
           }
         }
-      std::cerr << "loading initial cache file " << path.c_str() << "\n";
+      std::cerr << "loading initial cache file " << path << "\n";
       this->ReadListFile(args, path.c_str());
       }
     else if(arg.find("-P",0) == 0)
@@ -485,13 +489,13 @@
     {
     cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
     lg->GetMakefile()->SetHomeOutputDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+      (cmSystemTools::GetCurrentWorkingDirectory());
     lg->GetMakefile()->SetStartOutputDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+      (cmSystemTools::GetCurrentWorkingDirectory());
     lg->GetMakefile()->SetHomeDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+      (cmSystemTools::GetCurrentWorkingDirectory());
     lg->GetMakefile()->SetStartDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+      (cmSystemTools::GetCurrentWorkingDirectory());
     if (this->GetWorkingMode() != NORMAL_MODE)
       {
       std::string file(cmSystemTools::CollapseFullPath(path));
@@ -525,13 +529,13 @@
   cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
   cmMakefile* mf = lg->GetMakefile();
   mf->SetHomeOutputDirectory
-    (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+    (cmSystemTools::GetCurrentWorkingDirectory());
   mf->SetStartOutputDirectory
-    (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+    (cmSystemTools::GetCurrentWorkingDirectory());
   mf->SetHomeDirectory
-    (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+    (cmSystemTools::GetCurrentWorkingDirectory());
   mf->SetStartDirectory
-    (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+    (cmSystemTools::GetCurrentWorkingDirectory());
 
   mf->SetArgcArgv(args);
 
@@ -565,7 +569,7 @@
     cmSystemTools::ExpandListArgument(includes, includeDirs);
 
     std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0,
-                                                   language.c_str(), false);
+                                                   language, false);
 
     std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
     printf("%s %s\n", includeFlags.c_str(), definitions.c_str());
@@ -584,7 +588,7 @@
             libIt != libList.end();
             ++libIt)
       {
-      mf->AddLinkLibraryForTarget(targetName, libIt->c_str(),
+      mf->AddLinkLibraryForTarget(targetName, *libIt,
                                   cmTarget::GENERAL);
       }
 
@@ -597,7 +601,7 @@
     gg->CreateGeneratorTargets(mf);
     cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
     lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
-                       gtgt);
+                       gtgt, false);
     linkLibs = frameworkPath + linkPath + linkLibs;
 
     printf("%s\n", linkLibs.c_str() );
@@ -635,7 +639,7 @@
       std::string path = arg.substr(2);
       path = cmSystemTools::CollapseFullPath(path.c_str());
       cmSystemTools::ConvertToUnixSlashes(path);
-      this->SetHomeDirectory(path.c_str());
+      this->SetHomeDirectory(path);
       }
     else if(arg.find("-S",0) == 0)
       {
@@ -651,7 +655,7 @@
       std::string path = arg.substr(2);
       path = cmSystemTools::CollapseFullPath(path.c_str());
       cmSystemTools::ConvertToUnixSlashes(path);
-      this->SetHomeOutputDirectory(path.c_str());
+      this->SetHomeOutputDirectory(path);
       }
     else if((i < args.size()-2) && (arg.find("--check-build-system",0) == 0))
       {
@@ -789,7 +793,7 @@
         value = args[i];
         }
       cmGlobalGenerator* gen =
-        this->CreateGlobalGenerator(value.c_str());
+        this->CreateGlobalGenerator(value);
       if(!gen)
         {
         cmSystemTools::Error("Could not create named generator ",
@@ -810,13 +814,13 @@
   if(!directoriesSet)
     {
     this->SetHomeOutputDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+      (cmSystemTools::GetCurrentWorkingDirectory());
     this->SetStartOutputDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+      (cmSystemTools::GetCurrentWorkingDirectory());
     this->SetHomeDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+      (cmSystemTools::GetCurrentWorkingDirectory());
     this->SetStartDirectory
-      (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+      (cmSystemTools::GetCurrentWorkingDirectory());
     }
 
   this->SetStartDirectory(this->GetHomeDirectory());
@@ -852,15 +856,15 @@
     {
     argIsFile = true;
     std::string fullPath = cmSystemTools::CollapseFullPath(arg);
-    std::string name = cmSystemTools::GetFilenameName(fullPath.c_str());
+    std::string name = cmSystemTools::GetFilenameName(fullPath);
     name = cmSystemTools::LowerCase(name);
     if(name == "cmakecache.txt")
       {
-      cachePath = cmSystemTools::GetFilenamePath(fullPath.c_str());
+      cachePath = cmSystemTools::GetFilenamePath(fullPath);
       }
     else if(name == "cmakelists.txt")
       {
-      listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
+      listPath = cmSystemTools::GetFilenamePath(fullPath);
       }
     }
   else
@@ -868,12 +872,12 @@
     // Specified file or directory does not exist.  Try to set things
     // up to produce a meaningful error message.
     std::string fullPath = cmSystemTools::CollapseFullPath(arg);
-    std::string name = cmSystemTools::GetFilenameName(fullPath.c_str());
+    std::string name = cmSystemTools::GetFilenameName(fullPath);
     name = cmSystemTools::LowerCase(name);
     if(name == "cmakecache.txt" || name == "cmakelists.txt")
       {
       argIsFile = true;
-      listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
+      listPath = cmSystemTools::GetFilenamePath(fullPath);
       }
     else
       {
@@ -886,11 +890,11 @@
     {
     cmCacheManager* cachem = this->GetCacheManager();
     cmCacheManager::CacheIterator it = cachem->NewIterator();
-    if(cachem->LoadCache(cachePath.c_str()) &&
+    if(cachem->LoadCache(cachePath) &&
       it.Find("CMAKE_HOME_DIRECTORY"))
       {
-      this->SetHomeOutputDirectory(cachePath.c_str());
-      this->SetStartOutputDirectory(cachePath.c_str());
+      this->SetHomeOutputDirectory(cachePath);
+      this->SetStartOutputDirectory(cachePath);
       this->SetHomeDirectory(it.GetValue());
       this->SetStartDirectory(it.GetValue());
       return;
@@ -900,23 +904,23 @@
   // If there is a CMakeLists.txt file, use it as the source tree.
   if(listPath.length() > 0)
     {
-    this->SetHomeDirectory(listPath.c_str());
-    this->SetStartDirectory(listPath.c_str());
+    this->SetHomeDirectory(listPath);
+    this->SetStartDirectory(listPath);
 
     if(argIsFile)
       {
       // Source CMakeLists.txt file given.  It was probably dropped
       // onto the executable in a GUI.  Default to an in-source build.
-      this->SetHomeOutputDirectory(listPath.c_str());
-      this->SetStartOutputDirectory(listPath.c_str());
+      this->SetHomeOutputDirectory(listPath);
+      this->SetStartOutputDirectory(listPath);
       }
     else
       {
       // Source directory given on command line.  Use current working
       // directory as build tree.
       std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-      this->SetHomeOutputDirectory(cwd.c_str());
-      this->SetStartOutputDirectory(cwd.c_str());
+      this->SetHomeOutputDirectory(cwd);
+      this->SetStartOutputDirectory(cwd);
       }
     return;
     }
@@ -926,10 +930,10 @@
   // current working directory as the build tree.
   std::string full = cmSystemTools::CollapseFullPath(arg);
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  this->SetHomeDirectory(full.c_str());
-  this->SetStartDirectory(full.c_str());
-  this->SetHomeOutputDirectory(cwd.c_str());
-  this->SetStartOutputDirectory(cwd.c_str());
+  this->SetHomeDirectory(full);
+  this->SetStartDirectory(full);
+  this->SetHomeOutputDirectory(cwd);
+  this->SetStartOutputDirectory(cwd);
 }
 
 // at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the
@@ -965,7 +969,7 @@
   return 1;
 }
 
-void cmake::AddExtraGenerator(const char* name,
+void cmake::AddExtraGenerator(const std::string& name,
                               CreateExtraGeneratorFunctionType newFunction)
 {
   cmExternalMakefileProjectGenerator* extraGenerator = newFunction();
@@ -978,8 +982,8 @@
       ++it )
     {
     std::string fullName = cmExternalMakefileProjectGenerator::
-                                    CreateFullGeneratorName(it->c_str(), name);
-    this->ExtraGenerators[fullName.c_str()] = newFunction;
+                                    CreateFullGeneratorName(*it, name);
+    this->ExtraGenerators[fullName] = newFunction;
     }
   delete extraGenerator;
 }
@@ -1034,9 +1038,10 @@
     }
 }
 
-cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
+cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
 {
   cmExternalMakefileProjectGenerator* extraGenerator = 0;
+  std::string name = gname;
   RegisteredExtraGeneratorsMap::const_iterator extraGenIt =
                                             this->ExtraGenerators.find(name);
   if (extraGenIt != this->ExtraGenerators.end())
@@ -1069,13 +1074,13 @@
   return generator;
 }
 
-void cmake::SetHomeDirectory(const char* dir)
+void cmake::SetHomeDirectory(const std::string& dir)
 {
   this->cmHomeDirectory = dir;
   cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory);
 }
 
-void cmake::SetHomeOutputDirectory(const char* lib)
+void cmake::SetHomeOutputDirectory(const std::string& lib)
 {
   this->HomeOutputDirectory = lib;
   cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory);
@@ -1202,7 +1207,7 @@
   cmCacheManager::CacheEntryType type;
 };
 
-int cmake::HandleDeleteCacheVariables(const char* var)
+int cmake::HandleDeleteCacheVariables(const std::string& var)
 {
   std::vector<std::string> argsSplit;
   cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true);
@@ -1228,7 +1233,7 @@
     i++;
     save.value = *i;
     warning << *i << "\n";
-    if(ci.Find(save.key.c_str()))
+    if(ci.Find(save.key))
       {
       save.type = ci.GetType();
       if(const char* help = ci.GetProperty("HELPSTRING"))
@@ -1247,7 +1252,7 @@
   for(std::vector<SaveCacheEntry>::iterator i = saved.begin();
       i != saved.end(); ++i)
     {
-    this->AddCacheEntry(i->key.c_str(), i->value.c_str(),
+    this->AddCacheEntry(i->key, i->value.c_str(),
                         i->help.c_str(), i->type);
     }
   cmSystemTools::Message(warning.str().c_str());
@@ -1327,8 +1332,9 @@
     if(genName)
       {
       std::string fullName = cmExternalMakefileProjectGenerator::
-                                CreateFullGeneratorName(genName, extraGenName);
-      this->GlobalGenerator = this->CreateGlobalGenerator(fullName.c_str());
+                                CreateFullGeneratorName(genName,
+                                    extraGenName ? extraGenName : "");
+      this->GlobalGenerator = this->CreateGlobalGenerator(fullName);
       }
     if(this->GlobalGenerator)
       {
@@ -1411,8 +1417,8 @@
       message += "\nDoes not match the generator used previously: ";
       message += genName;
       message +=
-        "\nEither remove the CMakeCache.txt file or choose a different"
-        " binary directory.";
+        "\nEither remove the CMakeCache.txt file and CMakeFiles "
+        "directory or choose a different binary directory.";
       cmSystemTools::Error(message.c_str());
       return -2;
       }
@@ -1420,13 +1426,13 @@
   if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR"))
     {
     this->CacheManager->AddCacheEntry("CMAKE_GENERATOR",
-                                      this->GlobalGenerator->GetName(),
+                                      this->GlobalGenerator->GetName().c_str(),
                                       "Name of generator.",
                                       cmCacheManager::INTERNAL);
     this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR",
-                                this->GlobalGenerator->GetExtraGeneratorName(),
-                                "Name of external makefile project generator.",
-                                cmCacheManager::INTERNAL);
+                        this->GlobalGenerator->GetExtraGeneratorName().c_str(),
+                        "Name of external makefile project generator.",
+                        cmCacheManager::INTERNAL);
     }
 
   if(const char* tsName =
@@ -1443,8 +1449,8 @@
       message += "\nDoes not match the toolset used previously: ";
       message += tsName;
       message +=
-        "\nEither remove the CMakeCache.txt file or choose a different"
-        " binary directory.";
+        "\nEither remove the CMakeCache.txt file and CMakeFiles "
+        "directory or choose a different binary directory.";
       cmSystemTools::Error(message.c_str());
       return -2;
       }
@@ -1456,11 +1462,6 @@
                                       "Name of generator toolset.",
                                       cmCacheManager::INTERNAL);
     }
-  if(!this->GeneratorToolset.empty() &&
-     !this->GlobalGenerator->SetGeneratorToolset(this->GeneratorToolset))
-    {
-    return -2;
-    }
 
   // reset any system configuration information, except for when we are
   // InTryCompile. With TryCompile the system info is taken from the parent's
@@ -1692,8 +1693,8 @@
     {
     return ret;
     }
-  this->SetStartDirectory(oldstartdir.c_str());
-  this->SetStartOutputDirectory(oldstartoutputdir.c_str());
+  this->SetStartDirectory(oldstartdir);
+  this->SetStartOutputDirectory(oldstartoutputdir);
 
   return ret;
 }
@@ -1728,7 +1729,7 @@
   return 0;
 }
 
-void cmake::AddCacheEntry(const char* key, const char* value,
+void cmake::AddCacheEntry(const std::string& key, const char* value,
                           const char* helpString,
                           int type)
 {
@@ -1737,7 +1738,7 @@
                                     cmCacheManager::CacheEntryType(type));
 }
 
-const char* cmake::GetCacheDefinition(const char* name) const
+const char* cmake::GetCacheDefinition(const std::string& name) const
 {
   return this->CacheManager->GetCacheValue(name);
 }
@@ -1781,8 +1782,6 @@
     cmGlobalNMakeMakefileGenerator::NewFactory());
   this->Generators.push_back(
     cmGlobalJOMMakefileGenerator::NewFactory());
-  this->Generators.push_back(
-    cmGlobalWatcomWMakeGenerator::NewFactory());
 # endif
   this->Generators.push_back(
     cmGlobalMSYSMakefileGenerator::NewFactory());
@@ -1793,6 +1792,10 @@
     cmGlobalUnixMakefileGenerator3::NewFactory());
   this->Generators.push_back(
     cmGlobalNinjaGenerator::NewFactory());
+#if defined(CMAKE_USE_WMAKE)
+  this->Generators.push_back(
+    cmGlobalWatcomWMakeGenerator::NewFactory());
+#endif
 #ifdef CMAKE_USE_XCODE
   this->Generators.push_back(
     cmGlobalXCodeGenerator::NewFactory());
@@ -1854,7 +1857,7 @@
     {
     cmDocumentationEntry e;
     cmExternalMakefileProjectGenerator* generator = (i->second)();
-    generator->GetDocumentation(e, i->first.c_str());
+    generator->GetDocumentation(e, i->first);
     e.Name = i->first;
     delete generator;
     v.push_back(e);
@@ -1922,7 +1925,7 @@
       {
       cmOStringStream msg;
       msg << "Re-run cmake missing file: "
-          << this->CheckBuildSystemArgument.c_str() << "\n";
+          << this->CheckBuildSystemArgument << "\n";
       cmSystemTools::Stdout(msg.str().c_str());
       }
     return 1;
@@ -1942,7 +1945,7 @@
       {
       cmOStringStream msg;
       msg << "Re-run cmake error reading : "
-          << this->CheckBuildSystemArgument.c_str() << "\n";
+          << this->CheckBuildSystemArgument << "\n";
       cmSystemTools::Stdout(msg.str().c_str());
       }
     // There was an error reading the file.  Just rerun.
@@ -2076,8 +2079,8 @@
     if(verbose)
       {
       cmOStringStream msg;
-      msg << "Re-run cmake file: " << out_oldest.c_str()
-          << " older than: " << dep_newest.c_str() << "\n";
+      msg << "Re-run cmake file: " << out_oldest
+          << " older than: " << dep_newest << "\n";
       cmSystemTools::Stdout(msg.str().c_str());
       }
     return 1;
@@ -2147,7 +2150,8 @@
 #endif
 }
 
-void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope,
+void cmake::DefineProperty(const std::string& name,
+                           cmProperty::ScopeType scope,
                            const char *ShortDescription,
                            const char *FullDescription,
                            bool chained)
@@ -2158,7 +2162,7 @@
 }
 
 cmPropertyDefinition *cmake
-::GetPropertyDefinition(const char *name,
+::GetPropertyDefinition(const std::string& name,
                         cmProperty::ScopeType scope)
 {
   if (this->IsPropertyDefined(name,scope))
@@ -2168,25 +2172,22 @@
   return 0;
 }
 
-bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope)
+bool cmake::IsPropertyDefined(const std::string& name,
+                              cmProperty::ScopeType scope)
 {
   return this->PropertyDefinitions[scope].IsPropertyDefined(name);
 }
 
-bool cmake::IsPropertyChained(const char *name, cmProperty::ScopeType scope)
+bool cmake::IsPropertyChained(const std::string& name,
+                              cmProperty::ScopeType scope)
 {
   return this->PropertyDefinitions[scope].IsPropertyChained(name);
 }
 
-void cmake::SetProperty(const char* prop, const char* value)
+void cmake::SetProperty(const std::string& prop, const char* value)
 {
-  if (!prop)
-    {
-    return;
-    }
-
   // Special hook to invalidate cached value.
-  if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0)
+  if(prop == "DEBUG_CONFIGURATIONS")
     {
     this->DebugConfigs.clear();
     }
@@ -2194,15 +2195,11 @@
   this->Properties.SetProperty(prop, value, cmProperty::GLOBAL);
 }
 
-void cmake::AppendProperty(const char* prop, const char* value, bool asString)
+void cmake::AppendProperty(const std::string& prop,
+                           const char* value, bool asString)
 {
-  if (!prop)
-    {
-    return;
-    }
-
   // Special hook to invalidate cached value.
-  if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0)
+  if(prop == "DEBUG_CONFIGURATIONS")
     {
     this->DebugConfigs.clear();
     }
@@ -2210,23 +2207,19 @@
   this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString);
 }
 
-const char *cmake::GetProperty(const char* prop)
+const char *cmake::GetProperty(const std::string& prop)
 {
   return this->GetProperty(prop, cmProperty::GLOBAL);
 }
 
-const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
+const char *cmake::GetProperty(const std::string& prop,
+                               cmProperty::ScopeType scope)
 {
-  if(!prop)
-    {
-    return 0;
-    }
   bool chain = false;
 
   // watch for special properties
-  std::string propname = prop;
   std::string output = "";
-  if ( propname == "CACHE_VARIABLES" )
+  if ( prop == "CACHE_VARIABLES" )
     {
     cmCacheManager::CacheIterator cit =
       this->GetCacheManager()->GetCacheIterator();
@@ -2240,7 +2233,7 @@
       }
     this->SetProperty("CACHE_VARIABLES", output.c_str());
     }
-  else if ( propname == "COMMANDS" )
+  else if ( prop == "COMMANDS" )
     {
     cmake::RegisteredCommandsMap::iterator cmds
         = this->GetCommands()->begin();
@@ -2255,12 +2248,12 @@
       }
     this->SetProperty("COMMANDS",output.c_str());
     }
-  else if ( propname == "IN_TRY_COMPILE" )
+  else if ( prop == "IN_TRY_COMPILE" )
     {
     this->SetProperty("IN_TRY_COMPILE",
                       this->GetIsInTryCompile()? "1":"0");
     }
-  else if ( propname == "ENABLED_LANGUAGES" )
+  else if ( prop == "ENABLED_LANGUAGES" )
     {
     std::string lang;
     if(this->GlobalGenerator)
@@ -2278,14 +2271,59 @@
       }
     this->SetProperty("ENABLED_LANGUAGES", lang.c_str());
     }
+#define STRING_LIST_ELEMENT(F) ";" #F
+  if (prop == "CMAKE_C_KNOWN_FEATURES")
+    {
+    return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
+    }
+  if (prop == "CMAKE_CXX_KNOWN_FEATURES")
+    {
+    return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
+    }
+#undef STRING_LIST_ELEMENT
   return this->Properties.GetPropertyValue(prop, scope, chain);
 }
 
-bool cmake::GetPropertyAsBool(const char* prop)
+bool cmake::GetPropertyAsBool(const std::string& prop)
 {
   return cmSystemTools::IsOn(this->GetProperty(prop));
 }
 
+cmInstalledFile *cmake::GetOrCreateInstalledFile(
+  cmMakefile* mf, const std::string& name)
+{
+  std::map<std::string, cmInstalledFile>::iterator i =
+    this->InstalledFiles.find(name);
+
+  if(i != this->InstalledFiles.end())
+    {
+    cmInstalledFile &file = i->second;
+    return &file;
+    }
+  else
+    {
+    cmInstalledFile &file = this->InstalledFiles[name];
+    file.SetName(mf, name);
+    return &file;
+    }
+}
+
+cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const
+{
+  std::map<std::string, cmInstalledFile>::const_iterator i =
+    this->InstalledFiles.find(name);
+
+  if(i != this->InstalledFiles.end())
+    {
+    cmInstalledFile const& file = i->second;
+    return &file;
+    }
+  else
+    {
+    return 0;
+    }
+}
+
 int cmake::GetSystemInformation(std::vector<std::string>& args)
 {
   // so create the directory
@@ -2323,7 +2361,7 @@
         value = args[i];
         }
       cmGlobalGenerator* gen =
-        this->CreateGlobalGenerator(value.c_str());
+        this->CreateGlobalGenerator(value);
       if(!gen)
         {
         cmSystemTools::Error("Could not create named generator ",
@@ -2361,8 +2399,8 @@
   // Copy file
   if(!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str()))
     {
-    std::cerr << "Error copying file \"" << inFile.c_str()
-              << "\" to \"" << outFile.c_str() << "\".\n";
+    std::cerr << "Error copying file \"" << inFile
+              << "\" to \"" << outFile << "\".\n";
     return 1;
     }
 
@@ -2524,8 +2562,11 @@
 
 //----------------------------------------------------------------------------
 void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
-                         cmListFileBacktrace const& backtrace)
+                         cmListFileBacktrace const& bt)
 {
+  cmListFileBacktrace backtrace = bt;
+  backtrace.MakeRelative();
+
   cmOStringStream msg;
   bool isError = false;
   // Construct the message header.
@@ -2607,6 +2648,22 @@
   // Add a terminating blank line.
   msg << "\n";
 
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+  // Add a C++ stack trace to internal errors.
+  if(t == cmake::INTERNAL_ERROR)
+    {
+    std::string stack = cmsys::SystemInformation::GetProgramStack(0,0);
+    if(!stack.empty())
+      {
+      if(cmHasLiteralPrefix(stack, "WARNING:"))
+        {
+        stack = "Note:" + stack.substr(8);
+        }
+      msg << stack << "\n";
+      }
+    }
+#endif
+
   // Output the message.
   if(isError)
     {
@@ -2660,7 +2717,7 @@
   cmSystemTools::ConvertToUnixSlashes(cachePath);
   cmCacheManager* cachem = this->GetCacheManager();
   cmCacheManager::CacheIterator it = cachem->NewIterator();
-  if(!cachem->LoadCache(cachePath.c_str()))
+  if(!cachem->LoadCache(cachePath))
     {
     std::cerr << "Error: could not load cache\n";
     return 1;
@@ -2686,16 +2743,16 @@
     return 1;
     }
   projName = it.GetValue();
-  return gen->Build(0, dir.c_str(),
-                    projName.c_str(), target.c_str(),
+  return gen->Build("", dir,
+                    projName, target,
                     &output,
-                    0,
-                    config.c_str(), clean, false, 0,
+                    "",
+                    config, clean, false, 0,
                     cmSystemTools::OUTPUT_PASSTHROUGH,
                     nativeOptions);
 }
 
-void cmake::WatchUnusedCli(const char* var)
+void cmake::WatchUnusedCli(const std::string& var)
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
   this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
@@ -2706,7 +2763,7 @@
 #endif
 }
 
-void cmake::UnwatchUnusedCli(const char* var)
+void cmake::UnwatchUnusedCli(const std::string& var)
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
   this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning);
@@ -2720,7 +2777,7 @@
   bool haveUnused = false;
   cmOStringStream msg;
   msg << "Manually-specified variables were not used by the project:";
-  for(std::map<cmStdString, bool>::const_iterator
+  for(std::map<std::string, bool>::const_iterator
         it = this->UsedCliVariables.begin();
       it != this->UsedCliVariables.end(); ++it)
     {
@@ -2732,7 +2789,7 @@
     }
   if(haveUnused)
     {
-    this->IssueMessage(cmake::WARNING, msg.str(), cmListFileBacktrace());
+    this->IssueMessage(cmake::WARNING, msg.str());
     }
 #endif
 }
diff --git a/Source/cmake.h b/Source/cmake.h
index dfec55c..2d04902 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -13,9 +13,11 @@
 #ifndef cmake_h
 #define cmake_h
 
+#include "cmListFileCache.h"
 #include "cmSystemTools.h"
 #include "cmPropertyDefinitionMap.h"
 #include "cmPropertyMap.h"
+#include "cmInstalledFile.h"
 
 class cmGlobalGeneratorFactory;
 class cmGlobalGenerator;
@@ -28,7 +30,6 @@
 class cmExternalMakefileProjectGenerator;
 class cmDocumentationSection;
 class cmPolicies;
-class cmListFileBacktrace;
 class cmTarget;
 class cmGeneratedFileStream;
 
@@ -91,16 +92,17 @@
      */
     FIND_PACKAGE_MODE
   };
-  typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
+  typedef std::map<std::string, cmCommand*> RegisteredCommandsMap;
+  typedef std::map<std::string, cmInstalledFile> InstalledFilesMap;
 
   /// Default constructor
   cmake();
   /// Destructor
   ~cmake();
 
-  static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";};
+  static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";}
   static const char *GetCMakeFilesDirectoryPostSlash() {
-    return "CMakeFiles/";};
+    return "CMakeFiles/";}
 
   //@{
   /**
@@ -110,12 +112,12 @@
    * CMakeLists files by recursing up the tree starting at the StartDirectory
    * and going up until it reaches the HomeDirectory.
    */
-  void SetHomeDirectory(const char* dir);
+  void SetHomeDirectory(const std::string& dir);
   const char* GetHomeDirectory() const
     {
     return this->cmHomeDirectory.c_str();
     }
-  void SetHomeOutputDirectory(const char* lib);
+  void SetHomeOutputDirectory(const std::string& lib);
   const char* GetHomeOutputDirectory() const
     {
     return this->HomeOutputDirectory.c_str();
@@ -130,7 +132,7 @@
    * recursing up the tree starting at the StartDirectory and going up until
    * it reaches the HomeDirectory.
    */
-  void SetStartDirectory(const char* dir)
+  void SetStartDirectory(const std::string& dir)
     {
       this->cmStartDirectory = dir;
       cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
@@ -139,7 +141,7 @@
     {
       return this->cmStartDirectory.c_str();
     }
-  void SetStartOutputDirectory(const char* lib)
+  void SetStartOutputDirectory(const std::string& lib)
     {
       this->StartOutputDirectory = lib;
       cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
@@ -175,7 +177,7 @@
   void PreLoadCMakeFiles();
 
   ///! Create a GlobalGenerator
-  cmGlobalGenerator* CreateGlobalGenerator(const char* name);
+  cmGlobalGenerator* CreateGlobalGenerator(const std::string& name);
 
   ///! Return the global generator assigned to this instance of cmake
   cmGlobalGenerator* GetGlobalGenerator()     { return this->GlobalGenerator; }
@@ -203,9 +205,9 @@
   /**
    * Given a variable name, return its value (as a string).
    */
-  const char* GetCacheDefinition(const char*) const;
+  const char* GetCacheDefinition(const std::string&) const;
   ///! Add an entry into the cache
-  void AddCacheEntry(const char* key, const char* value,
+  void AddCacheEntry(const std::string& key, const char* value,
                      const char* helpString,
                      int type);
 
@@ -218,20 +220,20 @@
    * Add a command to this cmake instance
    */
   void AddCommand(cmCommand* );
-  void RenameCommand(const char* oldName, const char* newName);
-  void RemoveCommand(const char* name);
+  void RenameCommand(const std::string& oldName, const std::string& newName);
+  void RemoveCommand(const std::string& name);
   void RemoveUnscriptableCommands();
 
   /**
    * Get a command by its name
    */
-  cmCommand *GetCommand(const char *name);
+  cmCommand *GetCommand(const std::string& name);
 
   /** Get list of all commands */
   RegisteredCommandsMap* GetCommands() { return &this->Commands; }
 
   /** Check if a command exists. */
-  bool CommandExists(const char* name) const;
+  bool CommandExists(const std::string& name) const;
 
   ///! Parse command line arguments
   void SetArgs(const std::vector<std::string>&,
@@ -261,7 +263,7 @@
   void UpdateProgress(const char *msg, float prog);
 
   ///!  get the cmake policies instance
-  cmPolicies *GetPolicies() {return this->Policies;} ;
+  cmPolicies *GetPolicies() {return this->Policies;}
 
   ///! Get the variable watch object
   cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
@@ -269,14 +271,25 @@
   void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
 
   ///! Set/Get a property of this target file
-  void SetProperty(const char *prop, const char *value);
-  void AppendProperty(const char *prop, const char *value,bool asString=false);
-  const char *GetProperty(const char *prop);
-  const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
-  bool GetPropertyAsBool(const char *prop);
+  void SetProperty(const std::string& prop, const char *value);
+  void AppendProperty(const std::string& prop,
+                      const char *value,bool asString=false);
+  const char *GetProperty(const std::string& prop);
+  const char *GetProperty(const std::string& prop,
+                          cmProperty::ScopeType scope);
+  bool GetPropertyAsBool(const std::string& prop);
 
   // Get the properties
-  cmPropertyMap &GetProperties() { return this->Properties; };
+  cmPropertyMap &GetProperties() { return this->Properties; }
+
+  ///! Get or create an cmInstalledFile instance and return a pointer to it
+  cmInstalledFile *GetOrCreateInstalledFile(
+    cmMakefile* mf, const std::string& name);
+
+  cmInstalledFile const* GetInstalledFile(const std::string& name) const;
+
+  InstalledFilesMap const& GetInstalledFiles() const
+    { return this->InstalledFiles; }
 
   ///! Do all the checks before running configure
   int DoPreConfigureChecks();
@@ -317,18 +330,18 @@
   void MarkCliAsUsed(const std::string& variable);
 
   // Define a property
-  void DefineProperty(const char *name, cmProperty::ScopeType scope,
+  void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
                       const char *ShortDescription,
                       const char *FullDescription,
                       bool chain = false);
 
   // get property definition
   cmPropertyDefinition *GetPropertyDefinition
-  (const char *name, cmProperty::ScopeType scope);
+  (const std::string& name, cmProperty::ScopeType scope);
 
   // Is a property defined?
-  bool IsPropertyDefined(const char *name, cmProperty::ScopeType scope);
-  bool IsPropertyChained(const char *name, cmProperty::ScopeType scope);
+  bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope);
+  bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope);
 
   /** Get the list of configurations (in upper case) considered to be
       debugging configurations.*/
@@ -347,7 +360,7 @@
 
   /** Display a message to the user.  */
   void IssueMessage(cmake::MessageType t, std::string const& text,
-                    cmListFileBacktrace const& backtrace);
+        cmListFileBacktrace const& backtrace = cmListFileBacktrace(NULL));
   ///! run the --build option
   int Build(const std::string& dir,
             const std::string& target,
@@ -355,21 +368,21 @@
             const std::vector<std::string>& nativeOptions,
             bool clean);
 
-  void UnwatchUnusedCli(const char* var);
-  void WatchUnusedCli(const char* var);
+  void UnwatchUnusedCli(const std::string& var);
+  void WatchUnusedCli(const std::string& var);
 protected:
   void RunCheckForUnusedVariables();
   void InitializeProperties();
-  int HandleDeleteCacheVariables(const char* var);
+  int HandleDeleteCacheVariables(const std::string& var);
   cmPropertyMap Properties;
-  std::set<std::pair<cmStdString,cmProperty::ScopeType> > AccessedProperties;
+  std::set<std::pair<std::string,cmProperty::ScopeType> > AccessedProperties;
 
   std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>
   PropertyDefinitions;
 
   typedef
      cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
-  typedef std::map<cmStdString,
+  typedef std::map<std::string,
                 CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap;
   typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector;
   RegisteredCommandsMap Commands;
@@ -378,7 +391,7 @@
   void AddDefaultCommands();
   void AddDefaultGenerators();
   void AddDefaultExtraGenerators();
-  void AddExtraGenerator(const char* name,
+  void AddExtraGenerator(const std::string& name,
                          CreateExtraGeneratorFunctionType newFunction);
 
   cmPolicies *Policies;
@@ -430,7 +443,7 @@
   bool WarnUnused;
   bool WarnUnusedCli;
   bool CheckSystemVars;
-  std::map<cmStdString, bool> UsedCliVariables;
+  std::map<std::string, bool> UsedCliVariables;
   std::string CMakeEditCommand;
   std::string CXXEnvironment;
   std::string CCEnvironment;
@@ -443,6 +456,7 @@
   cmFileTimeComparison* FileComparison;
   std::string GraphVizFile;
   std::vector<std::string> DebugConfigs;
+  InstalledFilesMap InstalledFiles;
 
   void UpdateConversionPathTable();
 };
@@ -456,4 +470,69 @@
   {"-Wno-dev", "Suppress developer warnings."},\
   {"-Wdev", "Enable developer warnings."}
 
+#define FOR_EACH_C_FEATURE(F) \
+  F(c_function_prototypes) \
+  F(c_restrict) \
+  F(c_static_assert) \
+  F(c_variadic_macros)
+
+#define FOR_EACH_CXX_FEATURE(F) \
+  F(cxx_aggregate_default_initializers) \
+  F(cxx_alias_templates) \
+  F(cxx_alignas) \
+  F(cxx_alignof) \
+  F(cxx_attributes) \
+  F(cxx_attribute_deprecated) \
+  F(cxx_auto_type) \
+  F(cxx_binary_literals) \
+  F(cxx_constexpr) \
+  F(cxx_contextual_conversions) \
+  F(cxx_decltype) \
+  F(cxx_decltype_auto) \
+  F(cxx_decltype_incomplete_return_types) \
+  F(cxx_default_function_template_args) \
+  F(cxx_defaulted_functions) \
+  F(cxx_defaulted_move_initializers) \
+  F(cxx_delegating_constructors) \
+  F(cxx_deleted_functions) \
+  F(cxx_digit_separators) \
+  F(cxx_enum_forward_declarations) \
+  F(cxx_explicit_conversions) \
+  F(cxx_extended_friend_declarations) \
+  F(cxx_extern_templates) \
+  F(cxx_final) \
+  F(cxx_func_identifier) \
+  F(cxx_generalized_initializers) \
+  F(cxx_generic_lambdas) \
+  F(cxx_inheriting_constructors) \
+  F(cxx_inline_namespaces) \
+  F(cxx_lambdas) \
+  F(cxx_lambda_init_captures) \
+  F(cxx_local_type_template_args) \
+  F(cxx_long_long_type) \
+  F(cxx_noexcept) \
+  F(cxx_nonstatic_member_init) \
+  F(cxx_nullptr) \
+  F(cxx_override) \
+  F(cxx_range_for) \
+  F(cxx_raw_string_literals) \
+  F(cxx_reference_qualified_functions) \
+  F(cxx_relaxed_constexpr) \
+  F(cxx_return_type_deduction) \
+  F(cxx_right_angle_brackets) \
+  F(cxx_rvalue_references) \
+  F(cxx_sizeof_member) \
+  F(cxx_static_assert) \
+  F(cxx_strong_enums) \
+  F(cxx_template_template_parameters) \
+  F(cxx_thread_local) \
+  F(cxx_trailing_return_types) \
+  F(cxx_unicode_literals) \
+  F(cxx_uniform_initialization) \
+  F(cxx_unrestricted_unions) \
+  F(cxx_user_literals) \
+  F(cxx_variable_templates) \
+  F(cxx_variadic_macros) \
+  F(cxx_variadic_templates)
+
 #endif
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index fcaa127..9f9f6bb 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -25,6 +25,7 @@
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include <cmsys/Encoding.hxx>
+#include <locale.h>
 
 #ifdef CMAKE_BUILD_WITH_CMAKE
 //----------------------------------------------------------------------------
@@ -129,8 +130,8 @@
   return msg;
 }
 
-static void cmakemainErrorCallback(const char* m, const char*, bool&,
-                                   void *clientdata)
+static void cmakemainMessageCallback(const char* m, const char*, bool&,
+                                     void *clientdata)
 {
   std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
 }
@@ -162,6 +163,7 @@
 
 int main(int ac, char const* const* av)
 {
+  setlocale(LC_ALL, "");
   cmsys::Encoding::CommandLineArguments args =
     cmsys::Encoding::CommandLineArguments::Main(ac, av);
   ac = args.argc();
@@ -310,7 +312,7 @@
     return ret;
     }
   cmake cm;
-  cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm);
+  cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void *)&cm);
   cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
   cm.SetWorkingMode(workingMode);
 
diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index faa5fa7..55fc633 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -198,7 +198,7 @@
   std::vector<std::string> args;
   cmSystemTools::ParseWindowsCommandLine(cmd.c_str(), args);
   // convert to correct vector type for RunSingleCommand
-  std::vector<cmStdString> command;
+  std::vector<std::string> command;
   for(std::vector<std::string>::iterator i = args.begin();
       i != args.end(); ++i)
     {
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 4ac1986..9aee975 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -102,8 +102,8 @@
       {
       if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str()))
         {
-        std::cerr << "Error copying file \"" << args[2].c_str()
-                  << "\" to \"" << args[3].c_str() << "\".\n";
+        std::cerr << "Error copying file \"" << args[2]
+                  << "\" to \"" << args[3] << "\".\n";
         return 1;
         }
       return 0;
@@ -116,7 +116,7 @@
           args[3].c_str()))
         {
         std::cerr << "Error copying file (if different) from \""
-                  << args[2].c_str() << "\" to \"" << args[3].c_str()
+                  << args[2] << "\" to \"" << args[3]
                   << "\".\n";
         return 1;
         }
@@ -129,7 +129,7 @@
       if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str()))
         {
         std::cerr << "Error copying directory from \""
-                  << args[2].c_str() << "\" to \"" << args[3].c_str()
+                  << args[2] << "\" to \"" << args[3]
                   << "\".\n";
         return 1;
         }
@@ -143,7 +143,7 @@
         {
         std::string e = cmSystemTools::GetLastSystemError();
         std::cerr << "Error renaming from \""
-                  << args[2].c_str() << "\" to \"" << args[3].c_str()
+                  << args[2] << "\" to \"" << args[3]
                   << "\": " << e << "\n";
         return 1;
         }
@@ -156,7 +156,7 @@
       if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str()))
         {
         std::cerr << "Files \""
-                  << args[2].c_str() << "\" to \"" << args[3].c_str()
+                  << args[2] << "\" to \"" << args[3]
                   << "\" are different.\n";
         return 1;
         }
@@ -199,7 +199,7 @@
       std::vector<std::string>::iterator it;
       for ( it = env.begin(); it != env.end(); ++ it )
         {
-        std::cout << it->c_str() << std::endl;
+        std::cout << *it << std::endl;
         }
       return 0;
       }
@@ -209,7 +209,7 @@
       {
       if(!cmSystemTools::MakeDirectory(args[2].c_str()))
         {
-        std::cerr << "Error making directory \"" << args[2].c_str()
+        std::cerr << "Error making directory \"" << args[2]
                   << "\".\n";
         return 1;
         }
@@ -221,7 +221,7 @@
       if(cmSystemTools::FileIsDirectory(args[2].c_str()) &&
          !cmSystemTools::RemoveADirectory(args[2].c_str()))
         {
-        std::cerr << "Error removing directory \"" << args[2].c_str()
+        std::cerr << "Error removing directory \"" << args[2]
                   << "\".\n";
         return 1;
         }
@@ -613,16 +613,16 @@
       startDir = cmSystemTools::CollapseFullPath(startDir.c_str());
       homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str());
       startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str());
-      cm.SetHomeDirectory(homeDir.c_str());
-      cm.SetStartDirectory(startDir.c_str());
-      cm.SetHomeOutputDirectory(homeOutDir.c_str());
-      cm.SetStartOutputDirectory(startOutDir.c_str());
-      if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen.c_str()))
+      cm.SetHomeDirectory(homeDir);
+      cm.SetStartDirectory(startDir);
+      cm.SetHomeOutputDirectory(homeOutDir);
+      cm.SetStartOutputDirectory(startOutDir);
+      if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen))
         {
         cm.SetGlobalGenerator(ggd);
         cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
-        lgd->GetMakefile()->SetStartDirectory(startDir.c_str());
-        lgd->GetMakefile()->SetStartOutputDirectory(startOutDir.c_str());
+        lgd->GetMakefile()->SetStartDirectory(startDir);
+        lgd->GetMakefile()->SetStartOutputDirectory(startOutDir);
         lgd->GetMakefile()->MakeStartDirectoriesCurrent();
 
         // Actually scan dependencies.
@@ -666,8 +666,8 @@
     else if (args[1] == "cmake_autogen" && args.size() >= 4)
       {
         cmQtAutoGenerators autogen;
-        const char *config = args[3].empty() ? 0 : args[3].c_str();
-        bool autogenSuccess = autogen.Run(args[2].c_str(), config);
+        std::string const& config = args[3];
+        bool autogenSuccess = autogen.Run(args[2], config);
         return autogenSuccess ? 0 : 1;
       }
 #endif
@@ -677,7 +677,7 @@
       {
       std::string flags = args[2];
       std::string outFile = args[3];
-      std::vector<cmStdString> files;
+      std::vector<std::string> files;
       for (std::string::size_type cc = 4; cc < args.size(); cc ++)
         {
         files.push_back(args[cc]);
@@ -1143,7 +1143,7 @@
 }
 
 int cmcmd::ParseVisualStudioLinkCommand(std::vector<std::string>& args,
-                                        std::vector<cmStdString>& command,
+                                        std::vector<std::string>& command,
                                         std::string& targetName)
 {
   std::vector<std::string>::iterator i = args.begin();
@@ -1171,17 +1171,17 @@
 }
 
 bool cmcmd::RunCommand(const char* comment,
-                       std::vector<cmStdString>& command,
+                       std::vector<std::string>& command,
                        bool verbose,
                        int* retCodeOut)
 {
   if(verbose)
     {
     std::cout << comment << ":\n";
-    for(std::vector<cmStdString>::iterator i = command.begin();
+    for(std::vector<std::string>::iterator i = command.begin();
         i != command.end(); ++i)
       {
-      std::cout << i->c_str() << " ";
+      std::cout << *i << " ";
       }
     std::cout << "\n";
     }
@@ -1239,16 +1239,16 @@
   //    7.  Finally, the Linker does another incremental link, but since the
   //    only thing that has changed is the *.res file that contains the
   //    manifest it is a short link.
-  std::vector<cmStdString> linkCommand;
+  std::vector<std::string> linkCommand;
   std::string targetName;
   if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1)
     {
     return -1;
     }
   std::string manifestArg = "/MANIFESTFILE:";
-  std::vector<cmStdString> rcCommand;
+  std::vector<std::string> rcCommand;
   rcCommand.push_back(cmSystemTools::FindProgram("rc.exe"));
-  std::vector<cmStdString> mtCommand;
+  std::vector<std::string> mtCommand;
   mtCommand.push_back(cmSystemTools::FindProgram("mt.exe"));
   std::string tempManifest;
   tempManifest = targetName;
@@ -1257,7 +1257,7 @@
   resourceInputFile += ".resource.txt";
   if(verbose)
     {
-    std::cout << "Create " << resourceInputFile.c_str() << "\n";
+    std::cout << "Create " << resourceInputFile << "\n";
     }
   // Create input file for rc command
   cmsys::ofstream fout(resourceInputFile.c_str());
@@ -1269,7 +1269,7 @@
   manifestFile += ".embed.manifest";
   std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str());
   fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID "
-    "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath.c_str() << "\"";
+    "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath << "\"";
   fout.close();
   manifestArg += tempManifest;
   // add the manifest arg to the linkCommand
@@ -1281,7 +1281,7 @@
     {
     if(verbose)
       {
-      std::cout << "Create empty: " << manifestFile.c_str() << "\n";
+      std::cout << "Create empty: " << manifestFile << "\n";
       }
     cmsys::ofstream foutTmp(manifestFile.c_str());
     }
@@ -1349,7 +1349,7 @@
                                           bool hasManifest,
                                           bool verbose)
 {
-  std::vector<cmStdString> linkCommand;
+  std::vector<std::string> linkCommand;
   std::string targetName;
   if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1)
     {
@@ -1368,7 +1368,7 @@
     {
     return 0;
     }
-  std::vector<cmStdString> mtCommand;
+  std::vector<std::string> mtCommand;
   mtCommand.push_back(cmSystemTools::FindProgram("mt.exe"));
   mtCommand.push_back("/nologo");
   mtCommand.push_back("/manifest");
diff --git a/Source/cmcmd.h b/Source/cmcmd.h
index 4517ebf..2bfbae7 100644
--- a/Source/cmcmd.h
+++ b/Source/cmcmd.h
@@ -43,10 +43,10 @@
                                             bool hasManifest,
                                             bool verbose);
   static int ParseVisualStudioLinkCommand(std::vector<std::string>& args,
-                                          std::vector<cmStdString>& command,
+                                          std::vector<std::string>& command,
                                           std::string& targetName);
   static bool RunCommand(const char* comment,
-                         std::vector<cmStdString>& command,
+                         std::vector<std::string>& command,
                          bool verbose,
                          int* retCodeOut = 0);
 };
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index b6b3d31..167e348 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -19,6 +19,7 @@
 #include "CTest/cmCTestScriptHandler.h"
 #include "CTest/cmCTestLaunch.h"
 #include "cmsys/Encoding.hxx"
+#include <locale.h>
 
 //----------------------------------------------------------------------------
 static const char * cmDocumentationName[][2] =
@@ -115,6 +116,8 @@
 // this is a test driver program for cmCTest.
 int main (int argc, char const* const* argv)
 {
+  setlocale(LC_ALL, "");
+
   cmsys::Encoding::CommandLineArguments encoding_args =
     cmsys::Encoding::CommandLineArguments::Main(argc, argv);
   argc = encoding_args.argc();
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 24ea518..5e6a226 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -299,6 +299,13 @@
   ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
   IF(CMAKE_SYSTEM MATCHES "HP-UX")
     SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
+    IF(CMAKE_CXX_COMPILER_ID MATCHES "HP")
+      # it is known that version 3.85 fails and 6.25 works without these flags
+      IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4)
+        # use new C++ library and improved template support
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
+      ENDIF()
+    ENDIF()
   ENDIF(CMAKE_SYSTEM MATCHES "HP-UX")
 ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
 
@@ -685,6 +692,7 @@
     # usually it's in libc but on FreeBSD
     # it's in libexecinfo
     FIND_LIBRARY(EXECINFO_LIB "execinfo")
+    MARK_AS_ADVANCED(EXECINFO_LIB)
     IF (NOT EXECINFO_LIB)
       SET(EXECINFO_LIB "")
     ENDIF()
@@ -1076,6 +1084,11 @@
     )
 ENDIF()
 
+IF(WIN32)
+  # Help enforce the use of wide Windows apis.
+  ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
+ENDIF()
+
 IF(KWSYS_USE_String)
   # Activate code in "String.c".  See the comment in the source.
   SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
@@ -1222,6 +1235,9 @@
     # Some Apple compilers produce bad optimizations in this source.
     IF(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|LLVM)$")
       SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0)
+    ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL")
+      # Tell IBM XL not to warn about our test infinite loop
+      SET_PROPERTY(SOURCE testProcess.c PROPERTY COMPILE_FLAGS -qsuppress=1500-010)
     ENDIF()
 
     # Test SharedForward
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx
index ece88ae..9fa9802 100644
--- a/Source/kwsys/CommandLineArguments.cxx
+++ b/Source/kwsys/CommandLineArguments.cxx
@@ -178,7 +178,7 @@
       matches->push_back(parg);
       }
     }
-  return matches->size() > 0;
+  return !matches->empty();
 }
 
 //----------------------------------------------------------------------------
@@ -235,7 +235,7 @@
           return 0;
           }
         CommandLineArguments_DEBUG("This is a space argument: " << arg
-          << " value: " << this->Internals->Argv[cc+1].c_str());
+          << " value: " << this->Internals->Argv[cc+1]);
         // Value is the next argument
         if ( !this->PopulateVariable(cs, this->Internals->Argv[cc+1].c_str()) )
           {
@@ -244,7 +244,7 @@
         cc ++;
         break;
       case EQUAL_ARGUMENT:
-        if ( arg.size() == sarg.size() || *(arg.c_str() + sarg.size()) != '=' )
+        if ( arg.size() == sarg.size() || arg.at(sarg.size()) != '=' )
           {
           this->Internals->LastArgument --;
           return 0;
@@ -309,11 +309,11 @@
       else if ( this->StoreUnusedArgumentsFlag )
         {
         CommandLineArguments_DEBUG("Store unused argument " << arg);
-        this->Internals->UnusedArguments.push_back(arg.c_str());
+        this->Internals->UnusedArguments.push_back(arg);
         }
       else
         {
-        kwsys_ios::cerr << "Got unknown argument: \"" << arg.c_str() << "\"" << kwsys_ios::endl;
+        kwsys_ios::cerr << "Got unknown argument: \"" << arg << "\"" << kwsys_ios::endl;
         this->Internals->LastArgument --;
         return 0;
         }
diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx
index f76deb5..251a56d 100644
--- a/Source/kwsys/EncodingCXX.cxx
+++ b/Source/kwsys/EncodingCXX.cxx
@@ -110,16 +110,19 @@
 Encoding::CommandLineArguments&
 Encoding::CommandLineArguments::operator=(const CommandLineArguments& other)
 {
-  size_t i;
-  for(i=0; i<this->argv_.size(); i++)
+  if(this != &other)
     {
-    free(this->argv_[i]);
-    }
+    size_t i;
+    for(i=0; i<this->argv_.size(); i++)
+      {
+      free(this->argv_[i]);
+      }
 
-  this->argv_.resize(other.argv_.size());
-  for(i=0; i<this->argv_.size(); i++)
-    {
-    this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
+    this->argv_.resize(other.argv_.size());
+    for(i=0; i<this->argv_.size(); i++)
+      {
+      this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
+      }
     }
 
   return *this;
diff --git a/Source/kwsys/FStream.cxx b/Source/kwsys/FStream.cxx
new file mode 100644
index 0000000..018652c
--- /dev/null
+++ b/Source/kwsys/FStream.cxx
@@ -0,0 +1,76 @@
+/*============================================================================
+  KWSys - Kitware System Library
+  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 "kwsysPrivate.h"
+#include KWSYS_HEADER(FStream.hxx)
+
+// Work-around CMake dependency scanning limitation.  This must
+// duplicate the above list of headers.
+#if 0
+# include "FStream.hxx.in"
+#endif
+
+namespace KWSYS_NAMESPACE
+{
+namespace FStream
+{
+
+BOM ReadBOM(std::istream& in)
+{
+  if(!in.good())
+    {
+    return BOM_None;
+    }
+  unsigned long orig = in.tellg();
+  unsigned char bom[4];
+  in.read(reinterpret_cast<char*>(bom), 2);
+  if(!in.good())
+    {
+    in.seekg(orig);
+    return BOM_None;
+    }
+  if(bom[0] == 0xEF && bom[1] == 0xBB)
+    {
+    in.read(reinterpret_cast<char*>(bom+2), 1);
+    if(in.good() && bom[2] == 0xBF)
+      {
+      return BOM_UTF8;
+      }
+    }
+  else if(bom[0] == 0xFE && bom[1] == 0xFF)
+    {
+    return BOM_UTF16BE;
+    }
+  else if(bom[0] == 0x00 && bom[1] == 0x00)
+    {
+    in.read(reinterpret_cast<char*>(bom+2), 2);
+    if(in.good() && bom[2] == 0xFE && bom[3] == 0xFF)
+      {
+      return BOM_UTF32BE;
+      }
+    }
+  else if(bom[0] == 0xFF && bom[1] == 0xFE)
+    {
+    unsigned long p = in.tellg();
+    in.read(reinterpret_cast<char*>(bom+2), 2);
+    if(in.good() && bom[2] == 0x00 && bom[3] == 0x00)
+      {
+      return BOM_UTF32LE;
+      }
+    in.seekg(p);
+    return BOM_UTF16LE;
+    }
+  in.seekg(orig);
+  return BOM_None;
+}
+
+} // FStream namespace
+} //KWSYS_NAMESPACE
diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in
index 916a93e..45425ff 100644
--- a/Source/kwsys/FStream.hxx.in
+++ b/Source/kwsys/FStream.hxx.in
@@ -161,13 +161,28 @@
   typedef basic_ofstream<char> ofstream;
 
 #else
-  using @KWSYS_NAMESPACE@_ios_namespace::basic_filebuf;
   using @KWSYS_NAMESPACE@_ios_namespace::ofstream;
   using @KWSYS_NAMESPACE@_ios_namespace::ifstream;
 #endif
 
+  namespace FStream
+  {
+    enum BOM
+    {
+      BOM_None,
+      BOM_UTF8,
+      BOM_UTF16BE,
+      BOM_UTF16LE,
+      BOM_UTF32BE,
+      BOM_UTF32LE
+    };
+
+    // Read a BOM, if one exists.
+    // If a BOM exists, the stream is advanced to after the BOM.
+    // This function requires a seekable stream (but not a relative
+    // seekable stream).
+    BOM ReadBOM(std::istream& in);
+  }
 }
 
-
-
 #endif
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index 46a7e4f..8569b0e 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -229,8 +229,7 @@
   for ( cc = 0; cc < d.GetNumberOfFiles(); cc ++ )
     {
     fname = d.GetFile(cc);
-    if ( strcmp(fname.c_str(), ".") == 0 ||
-      strcmp(fname.c_str(), "..") == 0  )
+    if ( fname == "." || fname == ".." )
       {
       continue;
       }
@@ -271,11 +270,10 @@
       }
     else
       {
-      if ( (this->Internals->Expressions.size() > 0) &&
-           this->Internals->Expressions[
-             this->Internals->Expressions.size()-1].find(fname.c_str()) )
+      if ( !this->Internals->Expressions.empty() &&
+           this->Internals->Expressions.rbegin()->find(fname) )
         {
-        this->AddFile(this->Internals->Files, realname.c_str());
+        this->AddFile(this->Internals->Files, realname);
         }
       }
     }
@@ -310,8 +308,7 @@
   for ( cc = 0; cc < d.GetNumberOfFiles(); cc ++ )
     {
     fname = d.GetFile(cc);
-    if ( strcmp(fname.c_str(), ".") == 0 ||
-      strcmp(fname.c_str(), "..") == 0  )
+    if ( fname == "." || fname == ".." )
       {
       continue;
       }
@@ -354,7 +351,7 @@
       {
       if ( last )
         {
-        this->AddFile(this->Internals->Files, realname.c_str());
+        this->AddFile(this->Internals->Files, realname);
         }
       else
         {
@@ -442,9 +439,9 @@
     int ch = expr[cc];
     if ( ch == '/' )
       {
-      if ( cexpr.size() > 0 )
+      if ( !cexpr.empty() )
         {
-        this->AddExpression(cexpr.c_str());
+        this->AddExpression(cexpr);
         }
       cexpr = "";
       }
@@ -453,9 +450,9 @@
       cexpr.append(1, static_cast<char>(ch));
       }
     }
-  if ( cexpr.size() > 0 )
+  if ( !cexpr.empty() )
     {
-    this->AddExpression(cexpr.c_str());
+    this->AddExpression(cexpr);
     }
 
   // Handle network paths
@@ -471,11 +468,11 @@
 }
 
 //----------------------------------------------------------------------------
-void Glob::AddExpression(const char* expr)
+void Glob::AddExpression(const kwsys_stl::string& expr)
 {
   this->Internals->Expressions.push_back(
     kwsys::RegularExpression(
-      this->PatternToRegex(expr).c_str()));
+      this->PatternToRegex(expr)));
 }
 
 //----------------------------------------------------------------------------
@@ -500,11 +497,11 @@
 }
 
 //----------------------------------------------------------------------------
-void Glob::AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const char* file)
+void Glob::AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const kwsys_stl::string& file)
 {
   if ( !this->Relative.empty() )
     {
-    files.push_back(kwsys::SystemTools::RelativePath(this->Relative.c_str(), file));
+    files.push_back(kwsys::SystemTools::RelativePath(this->Relative.c_str(), file.c_str()));
     }
   else
     {
diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in
index 88c343c..d8b8491 100644
--- a/Source/kwsys/Glob.hxx.in
+++ b/Source/kwsys/Glob.hxx.in
@@ -91,10 +91,10 @@
     const kwsys_stl::string& dir);
 
   //! Add regular expression
-  void AddExpression(const char* expr);
+  void AddExpression(const kwsys_stl::string& expr);
 
   //! Add a file to the list
-  void AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const char* file);
+  void AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const kwsys_stl::string& file);
 
   GlobInternals* Internals;
   bool Recurse;
diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c
index 56776a3..a147057 100644
--- a/Source/kwsys/MD5.c
+++ b/Source/kwsys/MD5.c
@@ -478,11 +478,16 @@
 /*--------------------------------------------------------------------------*/
 void kwsysMD5_Append(kwsysMD5* md5, unsigned char const* data, int length)
 {
+  size_t dlen;
   if(length < 0)
     {
-    length = (int)strlen((char const*)data);
+    dlen = strlen((char const*)data);
     }
-  md5_append(&md5->md5_state, (md5_byte_t const*)data, (size_t)length);
+  else
+    {
+    dlen = (size_t)length;
+    }
+  md5_append(&md5->md5_state, (md5_byte_t const*)data, dlen);
 }
 
 /*--------------------------------------------------------------------------*/
diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx
index c829787..598e7ca 100644
--- a/Source/kwsys/RegularExpression.cxx
+++ b/Source/kwsys/RegularExpression.cxx
@@ -882,13 +882,6 @@
 static char* regprop ();
 #endif
 
-bool RegularExpression::find (kwsys_stl::string const& s) 
-{
-  return find(s.c_str());
-}
-
-
-
 // find -- Matches the regular expression to the given string.
 // Returns true if found, and sets start and end indexes accordingly.
 
diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in
index 62e9cad..502fbe2 100644
--- a/Source/kwsys/RegularExpression.hxx.in
+++ b/Source/kwsys/RegularExpression.hxx.in
@@ -198,13 +198,18 @@
    * Instantiate RegularExpression with compiled char*.
    */
   inline RegularExpression (char const*);
-  
+
   /**
    * Instantiate RegularExpression as a copy of another regular expression.
    */
   RegularExpression (RegularExpression const&);
 
   /**
+   * Instantiate RegularExpression with compiled string.
+   */
+  inline RegularExpression (kwsys_stl::string const&);
+
+  /**
    * Destructor.
    */
   inline ~RegularExpression();
@@ -216,6 +221,12 @@
   bool compile (char const*);
 
   /**
+   * Compile a regular expression into internal code
+   * for later pattern matching.
+   */
+  inline bool compile (kwsys_stl::string const&);
+
+  /**
    * Matches the regular expression to the given string.
    * Returns true if found, and sets start and end indexes accordingly.
    */
@@ -225,7 +236,7 @@
    * Matches the regular expression to the given std string.
    * Returns true if found, and sets start and end indexes accordingly.
    */
-  bool find (kwsys_stl::string const&);               
+  inline bool find (kwsys_stl::string const&);
 
   /**
    * Index to start of first find.
@@ -313,6 +324,16 @@
 }
 
 /**
+ * Creates a regular expression from string s, and
+ * compiles s.
+ */
+inline RegularExpression::RegularExpression (const kwsys_stl::string& s)
+{
+  this->program = 0;
+  this->compile(s);
+}
+
+/**
  * Destroys and frees space allocated for the regular expression.
  */
 inline RegularExpression::~RegularExpression () 
@@ -323,6 +344,24 @@
 }
 
 /**
+ * Compile a regular expression into internal code
+ * for later pattern matching.
+ */
+inline bool RegularExpression::compile (kwsys_stl::string const& s)
+{
+  return this->compile(s.c_str());
+}
+
+/**
+ * Matches the regular expression to the given std string.
+ * Returns true if found, and sets start and end indexes accordingly.
+ */
+inline bool RegularExpression::find (kwsys_stl::string const& s)
+{
+  return this->find(s.c_str());
+}
+
+/**
  * Set the start position for the regular expression.
  */
 inline kwsys_stl::string::size_type RegularExpression::start () const 
diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in
index 8bbc74a..dd4d462 100644
--- a/Source/kwsys/SharedForward.h.in
+++ b/Source/kwsys/SharedForward.h.in
@@ -415,7 +415,7 @@
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
   /* Implementation for Windows.  */
-  DWORD n = GetFullPathName(in_path, KWSYS_SHARED_FORWARD_MAXPATH,
+  DWORD n = GetFullPathNameA(in_path, KWSYS_SHARED_FORWARD_MAXPATH,
                             out_path, 0);
   return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH;
 #else
@@ -429,9 +429,9 @@
 {
 #if defined(_WIN32)
   int result = 0;
-  HANDLE h1 = CreateFile(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
+  HANDLE h1 = CreateFileA(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
                          OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
-  HANDLE h2 = CreateFile(file2, GENERIC_READ, FILE_SHARE_READ, NULL,
+  HANDLE h2 = CreateFileA(file2, GENERIC_READ, FILE_SHARE_READ, NULL,
                          OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
   if(h1 != INVALID_HANDLE_VALUE && h2 != INVALID_HANDLE_VALUE)
     {
@@ -462,7 +462,7 @@
 #if defined(_WIN32) && !defined(__CYGWIN__)
   /* Implementation for Windows.  */
   DWORD original = GetLastError();
-  DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+  DWORD length = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
                                FORMAT_MESSAGE_IGNORE_INSERTS, 0, original,
                                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                                message, KWSYS_SHARED_FORWARD_MAXPATH, 0);
diff --git a/Source/kwsys/System.c b/Source/kwsys/System.c
index 5d178bf..1ee26fa 100644
--- a/Source/kwsys/System.c
+++ b/Source/kwsys/System.c
@@ -353,6 +353,10 @@
   if(kwsysSystem_Shell__ArgumentNeedsQuotes(in, isUnix, flags))
     {
     /* Surrounding quotes are needed.  Allocate space for them.  */
+    if((flags & kwsysSystem_Shell_Flag_WatcomQuote) && (isUnix))
+      {
+        size += 2;
+      }
     size += 2;
 
     /* We must escape all ending backslashes when quoting on windows.  */
@@ -377,7 +381,18 @@
   if(needQuotes)
     {
     /* Add the opening quote for this argument.  */
-    *out++ = '"';
+    if(flags & kwsysSystem_Shell_Flag_WatcomQuote)
+      {
+      if(isUnix)
+        {
+        *out++ = '"';
+        }
+      *out++ = '\'';
+      }
+    else
+      {
+      *out++ = '"';
+      }
     }
 
   /* Scan the string for characters that require escaping or quoting.  */
@@ -549,7 +564,18 @@
       }
 
     /* Add the closing quote for this argument.  */
-    *out++ = '"';
+    if(flags & kwsysSystem_Shell_Flag_WatcomQuote)
+      {
+      *out++ = '\'';
+      if(isUnix)
+        {
+        *out++ = '"';
+        }
+      }
+    else
+      {
+      *out++ = '"';
+      }
     }
 
   /* Store a terminating null without incrementing.  */
diff --git a/Source/kwsys/System.h.in b/Source/kwsys/System.h.in
index 549db90..f21bf0d 100644
--- a/Source/kwsys/System.h.in
+++ b/Source/kwsys/System.h.in
@@ -36,6 +36,7 @@
 # define kwsysSystem_Shell_Flag_MinGWMake             kwsys_ns(System_Shell_Flag_MinGWMake)
 # define kwsysSystem_Shell_Flag_NMake                 kwsys_ns(System_Shell_Flag_NMake)
 # define kwsysSystem_Shell_Flag_AllowMakeVariables    kwsys_ns(System_Shell_Flag_AllowMakeVariables)
+# define kwsysSystem_Shell_Flag_WatcomQuote           kwsys_ns(System_Shell_Flag_WatcomQuote)
 #endif
 
 #ifdef __VMS
@@ -102,14 +103,17 @@
   kwsysSystem_Shell_Flag_MinGWMake          = (1<<4),
 
   /** The target shell is in a NMake makefile.  */
-  kwsysSystem_Shell_Flag_NMake              = (1<<6),
+  kwsysSystem_Shell_Flag_NMake              = (1<<5),
 
   /** Make variable reference syntax $(MAKEVAR) should not be escaped
       to allow a build tool to replace it.  Replacement values
       containing spaces, quotes, backslashes, or other
       non-alphanumeric characters that have significance to some makes
       or shells produce undefined behavior.  */
-  kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<5)
+  kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<6),
+
+  /** The target shell quoting uses extra single Quotes for Watcom tools.  */
+  kwsysSystem_Shell_Flag_WatcomQuote        = (1<<7)
 };
 
 /**
@@ -156,6 +160,7 @@
 #  undef kwsysSystem_Shell_Flag_MinGWMake
 #  undef kwsysSystem_Shell_Flag_NMake
 #  undef kwsysSystem_Shell_Flag_AllowMakeVariables
+#  undef kwsysSystem_Shell_Flag_WatcomQuote
 # endif
 #endif
 
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index ec3a133..6544098 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -4685,11 +4685,28 @@
 {
 #if defined(__HAIKU__)
 
+  // CPU count
   system_info info;
   get_system_info(&info);
-
   this->NumberOfPhysicalCPU = info.cpu_count;
-  this->CPUSpeedInMHz = info.cpu_clock_speed / 1000000.0F;
+
+  // CPU speed
+  uint32 topologyNodeCount = 0;
+  cpu_topology_node_info* topology = 0;
+  get_cpu_topology_info(0, &topologyNodeCount);
+  if (topologyNodeCount != 0)
+    topology = new cpu_topology_node_info[topologyNodeCount];
+  get_cpu_topology_info(topology, &topologyNodeCount);
+
+  for (uint32 i = 0; i < topologyNodeCount; i++) {
+    if (topology[i].type == B_TOPOLOGY_CORE) {
+      this->CPUSpeedInMHz = topology[i].data.core.default_frequency /
+        1000000.0f;
+      break;
+    }
+  }
+
+  delete[] topology;
 
   // Physical Memory
   this->TotalPhysicalMemory = (info.max_pages * B_PAGE_SIZE) / (1024 * 1024) ;
@@ -4993,21 +5010,26 @@
     case CPU_PA_RISC1_0:
       this->ChipID.Vendor = "Hewlett-Packard";
       this->ChipID.Family = 0x100;
+      break;
     case CPU_PA_RISC1_1:
       this->ChipID.Vendor = "Hewlett-Packard";
       this->ChipID.Family = 0x110;
+      break;
     case CPU_PA_RISC2_0:
       this->ChipID.Vendor = "Hewlett-Packard";
       this->ChipID.Family = 0x200;
-#  ifdef CPU_HP_INTEL_EM_1_0
+      break;
+#  if defined(CPU_HP_INTEL_EM_1_0) || defined(CPU_IA64_ARCHREV_0)
+#   ifdef CPU_HP_INTEL_EM_1_0
     case CPU_HP_INTEL_EM_1_0:
-#  endif
-#  ifdef CPU_IA64_ARCHREV_0
+#   endif
+#   ifdef CPU_IA64_ARCHREV_0
     case CPU_IA64_ARCHREV_0:
-#  endif
+#   endif
       this->ChipID.Vendor = "GenuineIntel";
       this->Features.HasIA64 = true;
       break;
+#  endif
     default:
       return false;
     }
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index e5d8bde..704cbbc 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -188,6 +188,9 @@
 #endif
 
 #if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
+
+#include <wctype.h>
+
 inline int Mkdir(const char* dir)
 {
   return _wmkdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str());
@@ -624,7 +627,7 @@
     return SystemTools::FileIsDirectory(path);
     }
   kwsys_stl::string dir = path;
-  if(dir.size() == 0)
+  if(dir.empty())
     {
     return false;
     }
@@ -1262,7 +1265,7 @@
 kwsys_stl::string SystemTools::Capitalized(const kwsys_stl::string& s)
 {
   kwsys_stl::string n;
-  if(s.size() == 0)
+  if(s.empty())
     {
     return n;
     }
@@ -1322,7 +1325,7 @@
   const kwsys_stl::string& s)
 {
   kwsys_stl::string n;
-  if (s.size())
+  if (!s.empty())
     {
     n.reserve(s.size());
     n += s[0];
@@ -1815,12 +1818,13 @@
     // remove trailing slash if the path is more than
     // a single /
     pathCString = path.c_str();
-    if(path.size() > 1 && *(pathCString+(path.size()-1)) == '/')
+    size_t size = path.size();
+    if(size > 1 && *path.rbegin() == '/')
       {
       // if it is c:/ then do not remove the trailing slash
-      if(!((path.size() == 3 && pathCString[1] == ':')))
+      if(!((size == 3 && pathCString[1] == ':')))
         {
-        path = path.substr(0, path.size()-1);
+        path.resize(size - 1);
         }
       }
     }
@@ -2500,7 +2504,7 @@
       i != path.end(); ++i)
     {
     kwsys_stl::string& p = *i;
-    if(p.empty() || p[p.size()-1] != '/')
+    if(p.empty() || *p.rbegin() != '/')
       {
       p += "/";
       }
@@ -2535,7 +2539,7 @@
   kwsys_stl::string tryPath = SystemTools::FindName(name, userPaths, no_system_path);
   if(tryPath != "" && !SystemTools::FileIsDirectory(tryPath.c_str()))
     {
-    return SystemTools::CollapseFullPath(tryPath.c_str());
+    return SystemTools::CollapseFullPath(tryPath);
     }
   // Couldn't find the file.
   return "";
@@ -2554,7 +2558,7 @@
   kwsys_stl::string tryPath = SystemTools::FindName(name, userPaths, no_system_path);
   if(tryPath != "" && SystemTools::FileIsDirectory(tryPath.c_str()))
     {
-    return SystemTools::CollapseFullPath(tryPath.c_str());
+    return SystemTools::CollapseFullPath(tryPath);
     }
   // Couldn't find the file.
   return "";
@@ -2594,18 +2598,15 @@
   kwsys_stl::string tryPath;
 
   // first try with extensions if the os supports them
-  if(extensions.size())
+  for(kwsys_stl::vector<kwsys_stl::string>::iterator i =
+        extensions.begin(); i != extensions.end(); ++i)
     {
-    for(kwsys_stl::vector<kwsys_stl::string>::iterator i =
-          extensions.begin(); i != extensions.end(); ++i)
+    tryPath = name;
+    tryPath += *i;
+    if(SystemTools::FileExists(tryPath.c_str()) &&
+        !SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      tryPath = name;
-      tryPath += *i;
-      if(SystemTools::FileExists(tryPath.c_str()) &&
-         !SystemTools::FileIsDirectory(tryPath.c_str()))
-        {
-        return SystemTools::CollapseFullPath(tryPath.c_str());
-        }
+      return SystemTools::CollapseFullPath(tryPath);
       }
     }
   // now try just the name
@@ -2613,7 +2614,7 @@
   if(SystemTools::FileExists(tryPath.c_str()) &&
      !SystemTools::FileIsDirectory(tryPath.c_str()))
     {
-    return SystemTools::CollapseFullPath(tryPath.c_str());
+    return SystemTools::CollapseFullPath(tryPath);
     }
   // now construct the path
   kwsys_stl::vector<kwsys_stl::string> path;
@@ -2636,7 +2637,7 @@
       i != path.end(); ++i)
     {
     kwsys_stl::string& p = *i;
-    if(p.empty() || p[p.size()-1] != '/')
+    if(p.empty() || *p.rbegin() != '/')
       {
       p += "/";
       }
@@ -2651,19 +2652,16 @@
     SystemTools::ReplaceString(*p, "\"", "");
 #endif
     // first try with extensions
-    if(extensions.size())
+    for(kwsys_stl::vector<kwsys_stl::string>::iterator ext
+          = extensions.begin(); ext != extensions.end(); ++ext)
       {
-      for(kwsys_stl::vector<kwsys_stl::string>::iterator ext
-            = extensions.begin(); ext != extensions.end(); ++ext)
+      tryPath = *p;
+      tryPath += name;
+      tryPath += *ext;
+      if(SystemTools::FileExists(tryPath.c_str()) &&
+          !SystemTools::FileIsDirectory(tryPath.c_str()))
         {
-        tryPath = *p;
-        tryPath += name;
-        tryPath += *ext;
-        if(SystemTools::FileExists(tryPath.c_str()) &&
-           !SystemTools::FileIsDirectory(tryPath.c_str()))
-          {
-          return SystemTools::CollapseFullPath(tryPath.c_str());
-          }
+        return SystemTools::CollapseFullPath(tryPath);
         }
       }
     // now try it without them
@@ -2672,7 +2670,7 @@
     if(SystemTools::FileExists(tryPath.c_str()) &&
        !SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      return SystemTools::CollapseFullPath(tryPath.c_str());
+      return SystemTools::CollapseFullPath(tryPath);
       }
     }
   // Couldn't find the program.
@@ -2732,7 +2730,7 @@
       i != path.end(); ++i)
     {
     kwsys_stl::string& p = *i;
-    if(p.empty() || p[p.size()-1] != '/')
+    if(p.empty() || *p.rbegin() != '/')
       {
       p += "/";
       }
@@ -2749,7 +2747,7 @@
     if(SystemTools::FileExists(tryPath.c_str())
        && SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      return SystemTools::CollapseFullPath(tryPath.c_str());
+      return SystemTools::CollapseFullPath(tryPath);
       }
 #endif
 #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
@@ -2759,7 +2757,7 @@
     if(SystemTools::FileExists(tryPath.c_str())
        && !SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      return SystemTools::CollapseFullPath(tryPath.c_str());
+      return SystemTools::CollapseFullPath(tryPath);
       }
 #else
     tryPath = *p;
@@ -2769,7 +2767,7 @@
     if(SystemTools::FileExists(tryPath.c_str())
        && !SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      return SystemTools::CollapseFullPath(tryPath.c_str());
+      return SystemTools::CollapseFullPath(tryPath);
       }
     tryPath = *p;
     tryPath += "lib";
@@ -2778,7 +2776,7 @@
     if(SystemTools::FileExists(tryPath.c_str())
        && !SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      return SystemTools::CollapseFullPath(tryPath.c_str());
+      return SystemTools::CollapseFullPath(tryPath);
       }
     tryPath = *p;
     tryPath += "lib";
@@ -2787,7 +2785,7 @@
     if(SystemTools::FileExists(tryPath.c_str())
        && !SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      return SystemTools::CollapseFullPath(tryPath.c_str());
+      return SystemTools::CollapseFullPath(tryPath);
       }
     tryPath = *p;
     tryPath += "lib";
@@ -2796,7 +2794,7 @@
     if(SystemTools::FileExists(tryPath.c_str())
        && !SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      return SystemTools::CollapseFullPath(tryPath.c_str());
+      return SystemTools::CollapseFullPath(tryPath);
       }
     tryPath = *p;
     tryPath += "lib";
@@ -2805,7 +2803,7 @@
     if(SystemTools::FileExists(tryPath.c_str())
        && !SystemTools::FileIsDirectory(tryPath.c_str()))
       {
-      return SystemTools::CollapseFullPath(tryPath.c_str());
+      return SystemTools::CollapseFullPath(tryPath);
       }
 #endif
     }
@@ -2823,11 +2821,11 @@
 
 bool SystemTools::FileIsDirectory(const char* name)
 {
-  size_t length = strlen(name);
-  if (length == 0)
+  if (!*name)
     {
     return false;
     }
+  size_t length = strlen(name);
 
   // Remove any trailing slash from the name except in a root component.
   char local_buffer[KWSYS_SYSTEMTOOLS_MAXPATH];
@@ -2940,7 +2938,7 @@
     }
   if(collapse)
     {
-    return SystemTools::CollapseFullPath(path.c_str());
+    return SystemTools::CollapseFullPath(path);
     }
   return path;
 }
@@ -3041,7 +3039,7 @@
     kwsys_stl::vector<kwsys_stl::string>::iterator i;
     for(i=failures.begin(); i != failures.end(); ++i)
       {
-      msg << "    \"" << i->c_str() << "\"\n";
+      msg << "    \"" << *i << "\"\n";
       }
     errorMsg = msg.str();
     return false;
@@ -3051,12 +3049,12 @@
 }
 
 
-kwsys_stl::string SystemTools::CollapseFullPath(const char* in_relative)
+kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_relative)
 {
   return SystemTools::CollapseFullPath(in_relative, 0);
 }
 
-void SystemTools::AddTranslationPath(const char * a, const char * b)
+void SystemTools::AddTranslationPath(const kwsys_stl::string& a, const kwsys_stl::string& b)
 {
   kwsys_stl::string path_a = a;
   kwsys_stl::string path_b = b;
@@ -3073,11 +3071,11 @@
         == kwsys_stl::string::npos )
       {
       // Before inserting make sure path ends with '/'
-      if(path_a.size() && path_a[path_a.size() -1] != '/')
+      if(!path_a.empty() && *path_a.rbegin() != '/')
         {
         path_a += '/';
         }
-      if(path_b.size() && path_b[path_b.size() -1] != '/')
+      if(!path_b.empty() && *path_b.rbegin() != '/')
         {
         path_b += '/';
         }
@@ -3090,11 +3088,11 @@
     }
 }
 
-void SystemTools::AddKeepPath(const char* dir)
+void SystemTools::AddKeepPath(const kwsys_stl::string& dir)
 {
   kwsys_stl::string cdir;
   Realpath(SystemTools::CollapseFullPath(dir).c_str(), cdir);
-  SystemTools::AddTranslationPath(cdir.c_str(), dir);
+  SystemTools::AddTranslationPath(cdir, dir);
 }
 
 void SystemTools::CheckTranslationPath(kwsys_stl::string & path)
@@ -3135,24 +3133,26 @@
   kwsys_stl::vector<kwsys_stl::string>::const_iterator first,
   kwsys_stl::vector<kwsys_stl::string>::const_iterator last)
 {
+  static const kwsys_stl::string up = "..";
+  static const kwsys_stl::string cur = ".";
   for(kwsys_stl::vector<kwsys_stl::string>::const_iterator i = first;
       i != last; ++i)
     {
-    if(*i == "..")
+    if(*i == up)
       {
       if(out_components.size() > 1)
         {
-        out_components.erase(out_components.end()-1, out_components.end());
+        out_components.resize(out_components.size()-1);
         }
       }
-    else if(!(*i == ".") && !(*i == ""))
+    else if(!i->empty() && *i != cur)
       {
       out_components.push_back(*i);
       }
     }
 }
 
-kwsys_stl::string SystemTools::CollapseFullPath(const char* in_path,
+kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_path,
                                                 const char* in_base)
 {
   // Collect the output path components.
@@ -3212,7 +3212,7 @@
   // collapsed, so I am going to try to comment it out, and see what hits the
   // fan, hopefully quickly.
   // Commented out line below:
-  //SystemTools::AddTranslationPath(newPath.c_str(), in_path);
+  //SystemTools::AddTranslationPath(newPath, in_path);
 
   SystemTools::CheckTranslationPath(newPath);
 #ifdef _WIN32
@@ -3277,7 +3277,7 @@
   // path into the remote dir
   for(unsigned int i = 0; i < localSplit.size(); ++i)
     {
-    if(localSplit[i].size())
+    if(!localSplit[i].empty())
       {
       finalPath.push_back("../");
       }
@@ -3287,7 +3287,7 @@
   for(kwsys_stl::vector<String>::iterator vit = remoteSplit.begin();
       vit != remoteSplit.end(); ++vit)
     {
-    if(vit->size())
+    if(!vit->empty())
       {
       finalPath.push_back(*vit);
       }
@@ -3298,7 +3298,7 @@
   for(kwsys_stl::vector<String>::iterator vit1 = finalPath.begin();
       vit1 != finalPath.end(); ++vit1)
     {
-    if(relativePath.size() && relativePath[relativePath.size()-1] != '/')
+    if(!relativePath.empty() && *relativePath.rbegin() != '/')
       {
       relativePath += "/";
       }
@@ -3312,7 +3312,7 @@
                             kwsys_stl::string & casePath)
 {
   kwsys_stl::vector<kwsys_stl::string> path_components;
-  SystemTools::SplitPath(pathIn.c_str(), path_components);
+  SystemTools::SplitPath(pathIn, path_components);
   if(path_components[0].empty()) // First component always exists.
     {
     // Relative paths cannot be converted.
@@ -3394,11 +3394,11 @@
 }
 
 //----------------------------------------------------------------------------
-const char* SystemTools::SplitPathRootComponent(const char* p,
+const char* SystemTools::SplitPathRootComponent(const std::string& p,
                                                 kwsys_stl::string* root)
 {
   // Identify the root component.
-  const char* c = p;
+  const char* c = p.c_str();
   if((c[0] == '/' && c[1] == '/') || (c[0] == '\\' && c[1] == '\\'))
     {
     // Network path.
@@ -3480,17 +3480,17 @@
 }
 
 //----------------------------------------------------------------------------
-void SystemTools::SplitPath(const char* p,
+void SystemTools::SplitPath(const std::string& p,
                             kwsys_stl::vector<kwsys_stl::string>& components,
                             bool expand_home_dir)
 {
-  const char* c = p;
+  const char* c;
   components.clear();
 
   // Identify the root component.
   {
   kwsys_stl::string root;
-  c = SystemTools::SplitPathRootComponent(c, &root);
+  c = SystemTools::SplitPathRootComponent(p, &root);
 
   // Expand home directory references if requested.
   if(expand_home_dir && !root.empty() && root[0] == '~')
@@ -3520,12 +3520,12 @@
         }
       }
 #endif
-    if(!homedir.empty() && (homedir[homedir.size()-1] == '/' ||
-                            homedir[homedir.size()-1] == '\\'))
+    if(!homedir.empty() && (*homedir.rbegin() == '/' ||
+                            *homedir.rbegin() == '\\'))
       {
-      homedir = homedir.substr(0, homedir.size()-1);
+      homedir.resize(homedir.size() - 1);
       }
-    SystemTools::SplitPath(homedir.c_str(), components);
+    SystemTools::SplitPath(homedir, components);
     }
   else
     {
@@ -3541,9 +3541,7 @@
     if(*last == '/' || *last == '\\')
       {
       // End of a component.  Save it.
-      components.push_back(
-        kwsys_stl::string(first,static_cast<kwsys_stl::string::size_type>(
-                            last-first)));
+      components.push_back(kwsys_stl::string(first, last));
       first = last+1;
       }
     }
@@ -3551,9 +3549,7 @@
   // Save the last component unless there were no components.
   if(last != c)
     {
-    components.push_back(
-      kwsys_stl::string(first,static_cast<kwsys_stl::string::size_type>(
-                          last-first)));
+    components.push_back(kwsys_stl::string(first, last));
     }
 }
 
@@ -3572,6 +3568,13 @@
 {
   // Construct result in a single string.
   kwsys_stl::string result;
+  size_t len = 0;
+  kwsys_stl::vector<kwsys_stl::string>::const_iterator i;
+  for(i = first; i != last; ++i)
+    {
+    len += 1 + i->size();
+    }
+  result.reserve(len);
 
   // The first two components do not add a slash.
   if(first != last)
@@ -3595,18 +3598,18 @@
 }
 
 //----------------------------------------------------------------------------
-bool SystemTools::ComparePath(const char* c1, const char* c2)
+bool SystemTools::ComparePath(const kwsys_stl::string& c1, const kwsys_stl::string& c2)
 {
 #if defined(_WIN32) || defined(__APPLE__)
 # ifdef _MSC_VER
-  return _stricmp(c1, c2) == 0;
+  return _stricmp(c1.c_str(), c2.c_str()) == 0;
 # elif defined(__APPLE__) || defined(__GNUC__)
-  return strcasecmp(c1, c2) == 0;
+  return strcasecmp(c1.c_str(), c2.c_str()) == 0;
 #else
-  return SystemTools::Strucmp(c1, c2) == 0;
+  return SystemTools::Strucmp(c1.c_str(), c2.c_str()) == 0;
 # endif
 #else
-  return strcmp(c1, c2) == 0;
+  return c1 == c2;
 #endif
 }
 
@@ -3680,7 +3683,7 @@
       {
       return ret + '/';
       }
-    if(ret.size() == 0)
+    if(ret.empty())
       {
       return "/";
       }
@@ -3701,7 +3704,7 @@
 #if defined(_WIN32)
   kwsys_stl::string::size_type slash_pos = filename.find_last_of("/\\");
 #else
-  kwsys_stl::string::size_type slash_pos = filename.find_last_of("/");
+  kwsys_stl::string::size_type slash_pos = filename.rfind('/');
 #endif
   if(slash_pos != kwsys_stl::string::npos)
     {
@@ -3915,7 +3918,7 @@
   // Try to find the file in 'dir'
 
   bool res = false;
-  if (filename_base.size() && dir)
+  if (!filename_base.empty() && dir)
     {
     size_t dir_len = strlen(dir);
     int need_slash =
@@ -3949,10 +3952,10 @@
         filename_dir = SystemTools::GetFilenamePath(filename_dir);
         filename_dir_base = SystemTools::GetFilenameName(filename_dir);
 #if defined( _WIN32 )
-        if (!filename_dir_base.size() ||
-            filename_dir_base[filename_dir_base.size() - 1] == ':')
+        if (filename_dir_base.empty() ||
+            *filename_dir_base.rbegin() == ':')
 #else
-        if (!filename_dir_base.size())
+        if (filename_dir_base.empty())
 #endif
           {
           break;
@@ -3970,7 +3973,7 @@
         res = SystemTools::LocateFileInDir(
           filename_base.c_str(), temp.c_str(), filename_found, 0);
 
-        } while (!res && filename_dir_base.size());
+        } while (!res && !filename_dir_base.empty());
       }
     }
 
@@ -3979,30 +3982,30 @@
 
 bool SystemTools::FileIsFullPath(const char* in_name)
 {
-  kwsys_stl::string name = in_name;
+  size_t len = strlen(in_name);
 #if defined(_WIN32) || defined(__CYGWIN__)
   // On Windows, the name must be at least two characters long.
-  if(name.length() < 2)
+  if(len < 2)
     {
     return false;
     }
-  if(name[1] == ':')
+  if(in_name[1] == ':')
     {
     return true;
     }
-  if(name[0] == '\\')
+  if(in_name[0] == '\\')
     {
     return true;
     }
 #else
   // On UNIX, the name must be at least one character long.
-  if(name.length() < 1)
+  if(len < 1)
     {
     return false;
     }
 #endif
 #if !defined(_WIN32)
-  if(name[0] == '~')
+  if(in_name[0] == '~')
     {
     return true;
     }
@@ -4010,29 +4013,29 @@
   // On UNIX, the name must begin in a '/'.
   // On Windows, if the name begins in a '/', then it is a full
   // network path.
-  if(name[0] == '/')
+  if(in_name[0] == '/')
     {
     return true;
     }
   return false;
 }
 
-bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath)
+bool SystemTools::GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& shortPath)
 {
 #if defined(WIN32) && !defined(__CYGWIN__)
-  const int size = int(strlen(path)) +1; // size of return
+  const int size = int(path.size()) +1; // size of return
   char *tempPath = new char[size];  // create a buffer
   DWORD ret;
 
   // if the path passed in has quotes around it, first remove the quotes
-  if (path[0] == '"' && path[strlen(path)-1] == '"')
+  if (!path.empty() && path[0] == '"' && *path.rbegin() == '"')
     {
-    strcpy(tempPath,path+1);
-    tempPath[strlen(tempPath)-1] = '\0';
+    strcpy(tempPath,path.c_str()+1);
+    tempPath[size-2] = '\0';
     }
   else
     {
-    strcpy(tempPath,path);
+    strcpy(tempPath,path.c_str());
     }
 
   kwsys_stl::wstring wtempPath = Encoding::ToWide(tempPath);
@@ -4073,7 +4076,7 @@
   // may have spaces in its name so we have to look for it
   kwsys_stl::vector<kwsys_stl::string> e;
   kwsys_stl::string findProg = SystemTools::FindProgram(path, e);
-  if(findProg.size())
+  if(!findProg.empty())
     {
     program = findProg;
     args = "";
@@ -4103,7 +4106,7 @@
       }
     // Now try and find the program in the path
     findProg = SystemTools::FindProgram(tryProg.c_str(), e);
-    if(findProg.size())
+    if(!findProg.empty())
       {
       program = findProg;
       // remove trailing spaces from program
@@ -4344,9 +4347,9 @@
   return SystemTools::GetFilenamePath(fileOrDir);
 }
 
-bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir)
+bool SystemTools::IsSubDirectory(const kwsys_stl::string& cSubdir, const kwsys_stl::string& cDir)
 {
-  if(!*cDir)
+  if(cDir.empty())
     {
     return false;
     }
@@ -4357,7 +4360,7 @@
   if(subdir.size() > dir.size() && subdir[dir.size()] == '/')
     {
     std::string s = subdir.substr(0, dir.size());
-    return SystemTools::ComparePath(s.c_str(), dir.c_str());
+    return SystemTools::ComparePath(s, dir);
     }
   return false;
 }
@@ -4918,16 +4921,16 @@
 
         // Strip off one directory level and see if the logical
         // mapping still works.
-        pwd_str = SystemTools::GetFilenamePath(pwd_str.c_str());
-        cwd_str = SystemTools::GetFilenamePath(cwd_str.c_str());
+        pwd_str = SystemTools::GetFilenamePath(pwd_str);
+        cwd_str = SystemTools::GetFilenamePath(cwd_str);
         Realpath(pwd_str.c_str(), pwd_path);
         }
 
       // Add the translation to keep the logical path name.
       if(!cwd_changed.empty() && !pwd_changed.empty())
         {
-        SystemTools::AddTranslationPath(cwd_changed.c_str(),
-                                        pwd_changed.c_str());
+        SystemTools::AddTranslationPath(cwd_changed,
+                                        pwd_changed);
         }
       }
     }
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 9457a4e..fb55848 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -357,8 +357,8 @@
    * (which defaults to the current working directory).  The full path
    * is returned.
    */
-  static kwsys_stl::string CollapseFullPath(const char* in_relative);
-  static kwsys_stl::string CollapseFullPath(const char* in_relative,
+  static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative);
+  static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative,
                                             const char* in_base);
 
   /** 
@@ -383,7 +383,7 @@
    * returned.  The root component is stored in the "root" string if
    * given.
    */
-  static const char* SplitPathRootComponent(const char* p,
+  static const char* SplitPathRootComponent(const std::string& p,
                                             kwsys_stl::string* root=0);
 
   /**
@@ -396,7 +396,7 @@
    * automatically expanded if expand_home_dir is true and this
    * platform supports them.
    */
-  static void SplitPath(const char* p,
+  static void SplitPath(const std::string& p,
                         kwsys_stl::vector<kwsys_stl::string>& components,
                         bool expand_home_dir = true);
 
@@ -413,7 +413,7 @@
   /**
    * Compare a path or components of a path.
    */
-  static bool ComparePath(const char* c1, const char* c2);
+  static bool ComparePath(const kwsys_stl::string& c1, const kwsys_stl::string& c2);
 
 
   /**
@@ -465,7 +465,7 @@
    * For windows return the short path for the given path,
    * Unix just a pass through
    */
-  static bool GetShortPath(const char* path, kwsys_stl::string& result);
+  static bool GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& result);
   
   /**
    * Read line from file. Make sure to get everything. Due to a buggy stream
@@ -487,7 +487,7 @@
   /**
    * Check if the given file or directory is in subdirectory of dir
    */
-  static bool IsSubDirectory(const char* fileOrDir, const char* dir);
+  static bool IsSubDirectory(const kwsys_stl::string& fileOrDir, const kwsys_stl::string& dir);
 
   /** -----------------------------------------------------------------
    *               File Manipulation Routines
@@ -806,13 +806,13 @@
   /**
    * Add an entry in the path translation table.
    */
-  static void AddTranslationPath(const char * dir, const char * refdir);
+  static void AddTranslationPath(const kwsys_stl::string& dir, const kwsys_stl::string& refdir);
 
   /**
    * If dir is different after CollapseFullPath is called,
    * Then insert it into the path translation table
    */
-  static void AddKeepPath(const char* dir);
+  static void AddKeepPath(const kwsys_stl::string& dir);
 
   /**
    * Update path by going through the Path Translation table;
diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in
index 651de82..307f6bc 100644
--- a/Source/kwsys/hashtable.hxx.in
+++ b/Source/kwsys/hashtable.hxx.in
@@ -310,6 +310,9 @@
 {
   _Hashtable_node* _M_next;
   _Val _M_val;
+  void public_method_to_quiet_warning_about_all_methods_private();
+private:
+  void operator=(_Hashtable_node<_Val> const&); // poison node assignment
 };
 
 template <class _Val, class _Key, class _HashFcn,
diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx
index 72e6544..6a03c0f 100644
--- a/Source/kwsys/testCommandLineArguments.cxx
+++ b/Source/kwsys/testCommandLineArguments.cxx
@@ -171,7 +171,7 @@
   CompareTwoLists(strings_argument, valid_strings, 4);
   CompareTwoLists(stl_strings_argument, valid_stl_strings, 4);
 
-  kwsys_ios::cout << "Some STL String variable was set to: " << some_stl_string_variable.c_str() << kwsys_ios::endl;
+  kwsys_ios::cout << "Some STL String variable was set to: " << some_stl_string_variable << kwsys_ios::endl;
   kwsys_ios::cout << "Some bool variable was set to: " << some_bool_variable << kwsys_ios::endl;
   kwsys_ios::cout << "Some bool variable was set to: " << some_bool_variable1 << kwsys_ios::endl;
   kwsys_ios::cout << "bool_arg1 variable was set to: " << bool_arg1 << kwsys_ios::endl;
diff --git a/Source/kwsys/testCommandLineArguments1.cxx b/Source/kwsys/testCommandLineArguments1.cxx
index 0860c2a..3b84c38 100644
--- a/Source/kwsys/testCommandLineArguments1.cxx
+++ b/Source/kwsys/testCommandLineArguments1.cxx
@@ -57,12 +57,12 @@
     }
   if ( p != "1" )
     {
-    kwsys_ios::cout << "Problem setting P. Value of P: " << p.c_str() << kwsys_ios::endl;
+    kwsys_ios::cout << "Problem setting P. Value of P: " << p << kwsys_ios::endl;
     res = 1;
     }
   kwsys_ios::cout << "Value of N: " << n << kwsys_ios::endl;
   kwsys_ios::cout << "Value of M: " << m << kwsys_ios::endl;
-  kwsys_ios::cout << "Value of P: " << p.c_str() << kwsys_ios::endl;
+  kwsys_ios::cout << "Value of P: " << p << kwsys_ios::endl;
   if ( m )
     {
     delete [] m;
diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx
index 8942549..9abfd4c 100644
--- a/Source/kwsys/testFStream.cxx
+++ b/Source/kwsys/testFStream.cxx
@@ -16,11 +16,17 @@
 #endif
 
 #include KWSYS_HEADER(FStream.hxx)
+#include KWSYS_HEADER(ios/iostream)
+#include <string.h>
+#ifdef __BORLANDC__
+# include <mem.h> /* memcmp */
+#endif
 
 // Work-around CMake dependency scanning limitation.  This must
 // duplicate the above list of headers.
 #if 0
 # include "FStream.hxx.in"
+# include "kwsys_ios_iostream.h.in"
 #endif
 
 
@@ -36,6 +42,141 @@
   return 0;
 }
 
+static kwsys::FStream::BOM expected_bom[5] =
+{
+  kwsys::FStream::BOM_UTF8,
+  kwsys::FStream::BOM_UTF16LE,
+  kwsys::FStream::BOM_UTF16BE,
+  kwsys::FStream::BOM_UTF32LE,
+  kwsys::FStream::BOM_UTF32BE
+};
+
+static unsigned char expected_bom_data[5][5] =
+{
+    {3, 0xEF, 0xBB, 0xBF},
+    {2, 0xFF, 0xFE},
+    {2, 0xFE, 0xFF},
+    {4, 0xFF, 0xFE, 0x00, 0x00},
+    {4, 0x00, 0x00, 0xFE, 0xFF},
+};
+
+static unsigned char file_data[5][45] =
+{
+    {11, 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'},
+    {22, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20, 0x00,
+    0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64, 0x00},
+    {22, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20,
+    0x00, 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64},
+    {44, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00,
+    0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+    0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00,
+    0x6C, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00},
+    {44, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C,
+    0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20,
+    0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72,
+    0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x64},
+};
+
+//----------------------------------------------------------------------------
+static int testBOM()
+{
+  // test various encodings in binary mode
+  for(int i=0; i<5; i++)
+    {
+      {
+      kwsys::ofstream out("bom.txt", kwsys::ofstream::binary);
+      out.write(reinterpret_cast<const char*>(expected_bom_data[i]+1),
+                *expected_bom_data[i]);
+      out.write(reinterpret_cast<const char*>(file_data[i]+1),
+                file_data[i][0]);
+      }
+
+    kwsys::ifstream in("bom.txt", kwsys::ofstream::binary);
+    kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+    if(bom != expected_bom[i])
+      {
+      kwsys_ios::cout << "Unexpected BOM " << i << std::endl;
+      return 1;
+      }
+    char data[45];
+    in.read(data, file_data[i][0]);
+    if(!in.good())
+      {
+      kwsys_ios::cout << "Unable to read data " << i << std::endl;
+      return 1;
+      }
+
+    if(memcmp(data, file_data[i]+1, file_data[i][0]) != 0)
+      {
+      kwsys_ios::cout << "Incorrect read data " << i << std::endl;
+      return 1;
+      }
+
+    }
+
+  // test text file without bom
+  {
+    {
+    kwsys::ofstream out("bom.txt");
+    out << "Hello World";
+    }
+
+    kwsys::ifstream in("bom.txt");
+    kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+    if(bom != kwsys::FStream::BOM_None)
+      {
+      kwsys_ios::cout << "Unexpected BOM for none case" << std::endl;
+      return 1;
+      }
+    char data[45];
+    in.read(data, file_data[0][0]);
+    if(!in.good())
+      {
+      kwsys_ios::cout << "Unable to read data for none case" << std::endl;
+      return 1;
+      }
+
+    if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0)
+      {
+      kwsys_ios::cout << "Incorrect read data for none case" << std::endl;
+      return 1;
+      }
+  }
+
+  // test text file with utf-8 bom
+  {
+    {
+    kwsys::ofstream out("bom.txt");
+    out.write(reinterpret_cast<const char*>(expected_bom_data[0]+1),
+              *expected_bom_data[0]);
+    out << "Hello World";
+    }
+
+    kwsys::ifstream in("bom.txt");
+    kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+    if(bom != kwsys::FStream::BOM_UTF8)
+      {
+      kwsys_ios::cout << "Unexpected BOM for utf-8 case" << std::endl;
+      return 1;
+      }
+    char data[45];
+    in.read(data, file_data[0][0]);
+    if(!in.good())
+      {
+      kwsys_ios::cout << "Unable to read data for utf-8 case" << std::endl;
+      return 1;
+      }
+
+    if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0)
+      {
+      kwsys_ios::cout << "Incorrect read data for utf-8 case" << std::endl;
+      return 1;
+      }
+  }
+
+  return 0;
+}
+
 
 //----------------------------------------------------------------------------
 int testFStream(int, char*[])
@@ -43,6 +184,7 @@
   int ret = 0;
 
   ret |= testNoFile();
+  ret |= testBOM();
 
   return ret;
 }
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 1690fd5..69825a8 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -60,8 +60,8 @@
   if ( result != output )
     {
     kwsys_ios::cerr
-      << "Problem with ConvertToUnixSlashes - input: " << input.c_str()
-      << " output: " << result.c_str() << " expected: " << output.c_str()
+      << "Problem with ConvertToUnixSlashes - input: " << input
+      << " output: " << result << " expected: " << output
       << kwsys_ios::endl;
     return false;
     }
@@ -86,8 +86,8 @@
   if (result != output)
     {
     kwsys_ios::cerr
-      << "Problem with CheckEscapeChars - input: " << input.c_str()
-      << " output: " << result.c_str() << " expected: " << output.c_str()
+      << "Problem with CheckEscapeChars - input: " << input
+      << " output: " << result << " expected: " << output
       << kwsys_ios::endl;
     return false;
     }
diff --git a/Templates/CPackConfig.cmake.in b/Templates/CPackConfig.cmake.in
index 79b8d93..c00ea2a 100644
--- a/Templates/CPackConfig.cmake.in
+++ b/Templates/CPackConfig.cmake.in
@@ -10,3 +10,11 @@
 # usually begin with CPACK_<GENNAME>_xxxx.
 
 @_CPACK_OTHER_VARIABLES_@
+
+if(NOT CPACK_PROPERTIES_FILE)
+  set(CPACK_PROPERTIES_FILE "@CMAKE_BINARY_DIR@/CPackProperties.cmake")
+endif()
+
+if(EXISTS ${CPACK_PROPERTIES_FILE})
+  include(${CPACK_PROPERTIES_FILE})
+endif()
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
index 9467fae..c50b4e6 100644
--- a/Tests/AliasTarget/CMakeLists.txt
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -1,7 +1,15 @@
-
 cmake_minimum_required(VERSION 2.8.11)
 project(AliasTarget)
 
+set(CMAKE_CXX_STANDARD 98)
+
+# Those versions of the HP compiler that need a flag to get proper C++98
+# template support also need a flag to use the newer C++ library.
+if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
+    CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
+endif ()
+
 add_library(foo SHARED empty.cpp)
 add_library(PREFIX::Foo ALIAS foo)
 add_library(Another::Alias ALIAS foo)
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 9727930..8df331e 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -68,6 +68,8 @@
   "#define link_depends_no_shared_exe_value 0\n")
 set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt)
 
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external original\n")
+
 help_xcode_depends()
 
 message("Building project first time")
@@ -166,9 +168,21 @@
     "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
 endif()
 
+if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out)
+  file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
+  if("${external_out}" STREQUAL "external original")
+    message(STATUS "external.out contains '${external_out}'")
+  else()
+    message(SEND_ERROR "Project did not initially build properly: "
+      "external.out contains '${external_out}'")
+  endif()
+else()
+  message(SEND_ERROR "Project did not initially build properly: "
+    "external.out is missing")
+endif()
+
 message("Waiting 3 seconds...")
-# any additional argument will cause ${bar} to wait forever
-execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out)
+execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 3)
 
 message("Modifying Project/foo.cxx")
 write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
@@ -191,6 +205,8 @@
   file(WRITE ${TEST_LINK_DEPENDS} "2")
 endif()
 
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external changed\n")
+
 help_xcode_depends()
 
 message("Building project second time")
@@ -294,3 +310,16 @@
   message(SEND_ERROR "Project did not rebuild properly.  "
     "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
 endif()
+
+if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out)
+  file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
+  if("${external_out}" STREQUAL "external changed")
+    message(STATUS "external.out contains '${external_out}'")
+  else()
+    message(SEND_ERROR "Project did not rebuild properly: "
+      "external.out contains '${external_out}'")
+  endif()
+else()
+  message(SEND_ERROR "Project did not rebuild properly: "
+    "external.out is missing")
+endif()
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index 8806ecd..9ee4a43 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -139,3 +139,15 @@
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 add_executable(ninjadep ninjadep.cpp)
 add_dependencies(ninjadep header_tgt)
+
+include(ExternalProject)
+ExternalProject_Add(ExternalBuild
+  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/External
+  BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/External
+  STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/External/Stamp
+  BUILD_ALWAYS 1
+  CMAKE_ARGS
+    -Dexternal_in=${CMAKE_CURRENT_BINARY_DIR}/external.in
+    -Dexternal_out=${CMAKE_CURRENT_BINARY_DIR}/external.out
+  INSTALL_COMMAND ""
+  )
diff --git a/Tests/BuildDepends/Project/External/CMakeLists.txt b/Tests/BuildDepends/Project/External/CMakeLists.txt
new file mode 100644
index 0000000..c6015b6
--- /dev/null
+++ b/Tests/BuildDepends/Project/External/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.0)
+project(BuildDependsExternal NONE)
+if(NOT DEFINED external_in)
+  message(FATAL_ERROR "Define external_in")
+endif()
+if(NOT DEFINED external_out)
+  message(FATAL_ERROR "Define external_out")
+endif()
+add_custom_command(
+  OUTPUT ${external_out}
+  COMMAND ${CMAKE_COMMAND} -E copy ${external_in} ${external_out}
+  DEPENDS ${external_in}
+  )
+add_custom_target(drive ALL DEPENDS ${external_out})
diff --git a/Tests/BuildDepends/Project/bar.cxx b/Tests/BuildDepends/Project/bar.cxx
index 25d8bd2..dadf93d 100644
--- a/Tests/BuildDepends/Project/bar.cxx
+++ b/Tests/BuildDepends/Project/bar.cxx
@@ -15,11 +15,5 @@
   /* Print out the string that should have been regenerated.  */
   printf("%s\n", regen_string);
   fflush(stdout);
-  // if any argument is used, wait forever
-  if (argc>1)
-    {
-    // wait that we get killed...
-    for(;;);
-    }
   return 0;
 }
diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in
index 0f7074b..aaefe43 100644
--- a/Tests/CMakeBuildTest.cmake.in
+++ b/Tests/CMakeBuildTest.cmake.in
@@ -11,8 +11,8 @@
 message("running: ${CMAKE_COMMAND}")
 execute_process(COMMAND "${CMAKE_COMMAND}"
   "@CMAKE_BUILD_TEST_SOURCE_DIR@"
-  "-G@CMAKE_TEST_GENERATOR@"
-  -T "@CMAKE_TEST_GENERATOR_TOOLSET@"
+  "-G@CMAKE_GENERATOR@"
+  -T "@CMAKE_GENERATOR_TOOLSET@"
   WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@"
   RESULT_VARIABLE RESULT)
 if(RESULT)
diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
new file mode 100644
index 0000000..9b35f27
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.0)
+project(target_compile_features)
+
+if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES)
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_dummy.cpp"
+    "int main(int,char**) { return 0; }\n"
+  )
+  add_executable(target_compile_features "${CMAKE_CURRENT_BINARY_DIR}/test_dummy.cpp")
+  return()
+endif()
+
+set(CMAKE_VERBOSE_MAKEFILE ON)
+
+if (CMAKE_C_COMPILE_FEATURES)
+  add_executable(target_compile_features main.c)
+  target_compile_features(target_compile_features
+    PRIVATE c_restrict
+  )
+
+  add_library(lib_restrict lib_restrict.c)
+  target_compile_features(lib_restrict
+    PUBLIC c_restrict
+  )
+
+  add_executable(restrict_user restrict_user.c)
+  target_link_libraries(restrict_user lib_restrict)
+endif()
+
+if (CMAKE_CXX_COMPILE_FEATURES)
+  if (CMAKE_C_COMPILE_FEATURES)
+    set(target_suffix _cxx)
+  endif()
+  add_executable(target_compile_features${target_suffix} main.cpp)
+  target_compile_features(target_compile_features${target_suffix}
+    PRIVATE cxx_auto_type
+  )
+
+  add_library(lib_auto_type lib_auto_type.cpp)
+  target_compile_features(lib_auto_type
+    PUBLIC cxx_auto_type
+  )
+
+  add_executable(lib_user lib_user.cpp)
+  target_link_libraries(lib_user lib_auto_type)
+endif()
diff --git a/Tests/CMakeCommands/target_compile_features/dummy.cpp b/Tests/CMakeCommands/target_compile_features/dummy.cpp
new file mode 100644
index 0000000..341aaaf
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int, char **)
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp b/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp
new file mode 100644
index 0000000..71b2215
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp
@@ -0,0 +1,6 @@
+
+int getAutoTypeImpl()
+{
+  auto i = 0;
+  return i;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/lib_auto_type.h b/Tests/CMakeCommands/target_compile_features/lib_auto_type.h
new file mode 100644
index 0000000..c825b10
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/lib_auto_type.h
@@ -0,0 +1,8 @@
+
+int getAutoTypeImpl();
+
+int getAutoType()
+{
+  auto i = getAutoTypeImpl();
+  return i;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/lib_restrict.c b/Tests/CMakeCommands/target_compile_features/lib_restrict.c
new file mode 100644
index 0000000..049c1b0
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/lib_restrict.c
@@ -0,0 +1,9 @@
+
+#include "lib_restrict.h"
+
+int foo(int * restrict a, int * restrict b)
+{
+  (void)a;
+  (void)b;
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/lib_restrict.h b/Tests/CMakeCommands/target_compile_features/lib_restrict.h
new file mode 100644
index 0000000..eca22be
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/lib_restrict.h
@@ -0,0 +1,7 @@
+
+#ifndef LIB_RESTRICT_H
+#define LIB_RESTRICT_H
+
+int foo(int * restrict a, int * restrict b);
+
+#endif
diff --git a/Tests/CMakeCommands/target_compile_features/lib_user.cpp b/Tests/CMakeCommands/target_compile_features/lib_user.cpp
new file mode 100644
index 0000000..976068a
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/lib_user.cpp
@@ -0,0 +1,7 @@
+
+#include "lib_auto_type.h"
+
+int main(int argc, char **argv)
+{
+  return getAutoType();
+}
diff --git a/Tests/CMakeCommands/target_compile_features/main.c b/Tests/CMakeCommands/target_compile_features/main.c
new file mode 100644
index 0000000..831c5eb2
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/main.c
@@ -0,0 +1,12 @@
+
+int foo(int * restrict a, int * restrict b)
+{
+  (void)a;
+  (void)b;
+  return 0;
+}
+
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/main.cpp b/Tests/CMakeCommands/target_compile_features/main.cpp
new file mode 100644
index 0000000..fe29b04
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/main.cpp
@@ -0,0 +1,6 @@
+
+int main(int, char **)
+{
+  auto i = 0;
+  return i;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/restrict_user.c b/Tests/CMakeCommands/target_compile_features/restrict_user.c
new file mode 100644
index 0000000..d47b847
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/restrict_user.c
@@ -0,0 +1,14 @@
+
+#include "lib_restrict.h"
+
+int bar(int * restrict a, int * restrict b)
+{
+  (void)a;
+  (void)b;
+  return foo(a, b);
+}
+
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt
index 0e1fe8d..8c99f64 100644
--- a/Tests/CMakeLib/CMakeLists.txt
+++ b/Tests/CMakeLib/CMakeLists.txt
@@ -13,6 +13,8 @@
   testXMLSafe
   )
 
+set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
+
 if(WIN32)
   list(APPEND CMakeLib_TESTS
     testVisualStudioSlnParser
@@ -39,7 +41,7 @@
 endif()
 
 foreach(test ${CMakeLib_TESTS})
-  add_test(CMakeLib.${test} CMakeLibTests ${test})
+  add_test(CMakeLib.${test} CMakeLibTests ${test} ${${test}_ARGS})
 endforeach()
 
 if(TEST_CompileCommandOutput)
diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
index dc1ce24..279bcd5 100644
--- a/Tests/CMakeLib/run_compile_commands.cxx
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -2,14 +2,14 @@
 
 class CompileCommandParser {
 public:
-  class CommandType: public std::map<cmStdString, cmStdString>
+  class CommandType: public std::map<std::string, std::string>
   {
   public:
-    cmStdString const& at(cmStdString const& k) const
+    std::string const& at(std::string const& k) const
       {
       const_iterator i = this->find(k);
       if(i != this->end()) { return i->second; }
-      static cmStdString emptyString;
+      static std::string emptyString;
       return emptyString;
       }
   };
@@ -127,7 +127,7 @@
       it = parser.GetTranslationUnits().begin(),
       end = parser.GetTranslationUnits().end(); it != end; ++it)
     {
-    std::vector<cmStdString> command;
+    std::vector<std::string> command;
     cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command);
     if (!cmSystemTools::RunSingleCommand(
             command, 0, 0, it->at("directory").c_str()))
diff --git a/Tests/CMakeLib/testRST.cxx b/Tests/CMakeLib/testRST.cxx
index bad9560..37cb3fa 100644
--- a/Tests/CMakeLib/testRST.cxx
+++ b/Tests/CMakeLib/testRST.cxx
@@ -25,9 +25,14 @@
     }
 }
 
-int testRST(int, char*[])
+int testRST(int argc, char* argv[])
 {
-  std::string dir = cmSystemTools::GetFilenamePath(__FILE__);
+  if(argc != 2)
+    {
+    std::cerr << "Usage: testRST <dir>" << std::endl;
+    return 1;
+    }
+  std::string dir = argv[1];
   if(dir.empty())
     {
     dir = ".";
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index c903103..3e69f93 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -45,26 +45,27 @@
 
 # Testing
 if(BUILD_TESTING)
-  set(CMAKE_TEST_DEVENV "")
-  if(NOT CMAKE_TEST_DIFFERENT_GENERATOR)
-    if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio")
-      set(CMAKE_TEST_MAKEPROGRAM "")
-    else()
-      set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
-    endif()
-    if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND
-        NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
-      set(CMAKE_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
-    endif()
+  set(CMake_TEST_DEVENV "")
+  if(CMAKE_GENERATOR MATCHES "Visual Studio [7-9] " AND
+      NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
+    set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
   endif()
 
-  if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32))
-    set(TEST_CompileCommandOutput 1)
+  if(CMAKE_GENERATOR MATCHES "Visual Studio")
+    set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "")
+  else()
+    set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
+  endif()
+
+  if(NOT CMake_TEST_EXTERNAL_CMAKE)
+    if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32))
+      set(TEST_CompileCommandOutput 1)
+    endif()
   endif()
 
   set(MAKE_IS_GNU )
-  if(CMAKE_TEST_MAKEPROGRAM MATCHES make)
-    execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version
+  if(CMAKE_MAKE_PROGRAM MATCHES make)
+    execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version
       RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out)
     if("${res}" STREQUAL "0")
       if("${out}" MATCHES "GNU")
@@ -75,34 +76,38 @@
 
   # some old versions of make simply cannot handle spaces in paths
   if (MAKE_IS_GNU OR
-      CMAKE_TEST_MAKEPROGRAM MATCHES "nmake|gmake|wmake" OR
-      CMAKE_TEST_GENERATOR MATCHES "Visual Studio|XCode|Borland")
+      CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR
+      CMAKE_GENERATOR MATCHES "Visual Studio|XCode|Borland")
     set(MAKE_SUPPORTS_SPACES 1)
   else()
     set(MAKE_SUPPORTS_SPACES 0)
   endif()
 
   set(build_generator_args
-    --build-generator ${CMAKE_TEST_GENERATOR}
+    --build-generator ${CMAKE_GENERATOR}
     )
-  if(CMAKE_TEST_GENERATOR_TOOLSET)
+  if(CMAKE_GENERATOR_TOOLSET)
     list(APPEND build_generator_args
-      --build-generator-toolset ${CMAKE_TEST_GENERATOR_TOOLSET}
+      --build-generator-toolset ${CMAKE_GENERATOR_TOOLSET}
       )
   endif()
 
   set(build_options)
-  if(CMAKE_TEST_MAKEPROGRAM)
-    list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
+  if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
+    list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
   endif()
 
-  add_subdirectory(CMakeLib)
+  if(NOT CMake_TEST_EXTERNAL_CMAKE)
+    add_subdirectory(CMakeLib)
+  endif()
   add_subdirectory(CMakeOnly)
   add_subdirectory(RunCMake)
 
   add_subdirectory(FindPackageModeMakefileTest)
 
-  add_subdirectory(CTestTestMemcheck)
+  if(NOT CMake_TEST_EXTERNAL_CMAKE)
+    add_subdirectory(CTestTestMemcheck)
+  endif()
 
   # Collect a list of all test build directories.
   set(TEST_BUILD_DIRS)
@@ -192,6 +197,9 @@
   ADD_TEST_MACRO(TarTest TarTest)
   ADD_TEST_MACRO(SystemInformation SystemInformation)
   ADD_TEST_MACRO(MathTest MathTest)
+  ADD_TEST_MACRO(CompileFeatures CompileFeatures)
+  ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features)
+
   # assume no resources building to test
   set(TEST_RESOURCES FALSE)
   # for windows and cygwin assume we have resources
@@ -199,8 +207,8 @@
     set(TEST_RESOURCES TRUE)
   endif()
   # for borland and watcom there is no resource support
-  if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake" OR
-      "${CMAKE_TEST_GENERATOR}" MATCHES "Borland")
+  if("${CMAKE_GENERATOR}" MATCHES "WMake" OR
+      "${CMAKE_GENERATOR}" MATCHES "Borland")
     set(TEST_RESOURCES FALSE)
   endif()
   if(TEST_RESOURCES)
@@ -249,7 +257,9 @@
   ADD_TEST_MACRO(SetLang SetLang)
   ADD_TEST_MACRO(EmptyProperty EmptyProperty)
   ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
-  ADD_TEST_MACRO(LoadCommand LoadedCommand)
+  if(NOT CMake_TEST_EXTERNAL_CMAKE)
+    ADD_TEST_MACRO(LoadCommand LoadedCommand)
+  endif()
   ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
   ADD_TEST_MACRO(LinkLanguage LinkLanguage)
   ADD_TEST_MACRO(LinkLine LinkLine)
@@ -260,7 +270,7 @@
   ADD_TEST_MACRO(Assembler HelloAsm)
   ADD_TEST_MACRO(SourceGroups SourceGroups)
   ADD_TEST_MACRO(Preprocess Preprocess)
-  set(ExportImport_BUILD_OPTIONS -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
+  set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
   ADD_TEST_MACRO(ExportImport ExportImport)
   ADD_TEST_MACRO(Unset Unset)
   ADD_TEST_MACRO(PolicyScope PolicyScope)
@@ -271,12 +281,30 @@
   ADD_TEST_MACRO(AliasTarget AliasTarget)
   ADD_TEST_MACRO(StagingPrefix StagingPrefix)
   ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
+  if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
+    set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+    ADD_TEST_MACRO(ConfigSources ConfigSources)
+  endif()
+  ADD_TEST_MACRO(SourcesProperty SourcesProperty)
+  if(CMAKE_CXX_COMPILER_ID STREQUAL GNU
+      AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
+    set(runCxxDialectTest 1)
+  endif()
+  if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
+        AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.9)
+    if(NOT APPLE OR POLICY CMP0025)
+      set(runCxxDialectTest 1)
+    endif()
+  endif()
+  if(runCxxDialectTest)
+    ADD_TEST_MACRO(CxxDialect CxxDialect)
+  endif()
   set_tests_properties(EmptyLibrary PROPERTIES
     PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
   ADD_TEST_MACRO(CrossCompile CrossCompile)
   set_tests_properties(CrossCompile PROPERTIES
     PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode")
-  if("${CMAKE_TEST_GENERATOR}" MATCHES "Make")
+  if("${CMAKE_GENERATOR}" MATCHES "Make")
     ADD_TEST_MACRO(Policy0002 Policy0002)
   endif()
   if(CTEST_TEST_OSX_ARCH)
@@ -315,7 +343,7 @@
      MINGW OR
      CMAKE_SYSTEM_NAME MATCHES "Linux" OR
      CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake")
+  if(NOT "${CMAKE_GENERATOR}" STREQUAL "Watcom WMake")
 
     add_test(BundleUtilities ${CMAKE_CTEST_COMMAND}
       --build-and-test
@@ -381,6 +409,9 @@
   list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
 
   ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader)
+  ADD_TEST_MACRO(Module.FindDependency FindDependency)
+
+  ADD_TEST_MACRO(Module.WriteCompilerDetectionHeader WriteCompilerDetectionHeader)
 
   if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
     include(CheckCXXCompilerFlag)
@@ -465,7 +496,7 @@
   # build the "Simple" test with the ExtraGenerators, if available
   # This doesn't test whether the generated project files work (unfortunately),
   # mainly it tests that cmake doesn't crash when generating these project files.
-  if(${CMAKE_TEST_GENERATOR} MATCHES "Unix Makefiles"  OR  ${CMAKE_TEST_GENERATOR} MATCHES "KDevelop")
+  if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles"  OR  ${CMAKE_GENERATOR} MATCHES "KDevelop")
     # check which generators we have
     execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help
       OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput)
@@ -477,7 +508,7 @@
          "${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator"
          --build-two-config
          --build-generator "Eclipse CDT4 - Unix Makefiles"
-         --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+         --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
          --build-project Simple
          --build-options ${build_options}
          --test-command Simple)
@@ -492,7 +523,7 @@
          "${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator"
          --build-two-config
          --build-generator "CodeBlocks - Unix Makefiles"
-         --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+         --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
          --build-project Simple
          --build-options ${build_options}
          --test-command Simple)
@@ -506,7 +537,7 @@
          "${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator"
          --build-two-config
          --build-generator "KDevelop3 - Unix Makefiles"
-         --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+         --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
          --build-project Simple
          --build-options ${build_options}
          --test-command Simple)
@@ -517,7 +548,7 @@
 
   # test for correct sub-project generation
   # not implemented in VS 6, VS 7.0, Xcode, or Ninja
-  if(NOT CMAKE_TEST_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja")
+  if(NOT CMAKE_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja")
     # run cmake and configure all of SubProject
     # but only build the independent executable car
     add_test(SubProject ${CMAKE_CTEST_COMMAND}
@@ -536,17 +567,17 @@
     # the bar library which should be referenced because
     # foo links to the static library bar, but bar is not
     # directly in the foo sub project
-    if(CMAKE_TEST_MAKEPROGRAM)
+    if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
       set(SubProject-Stage2_BUILD_MAKEPROGRAM
-        --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+        --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
         )
     endif()
     add_test(SubProject-Stage2  ${CMAKE_CTEST_COMMAND}
       --build-and-test
       "${CMake_SOURCE_DIR}/Tests/SubProject/foo"
       "${CMake_BINARY_DIR}/Tests/SubProject/foo"
-      --build-generator ${CMAKE_TEST_GENERATOR}
-      --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+      --build-generator ${CMAKE_GENERATOR}
+      --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
       ${SubProject-Stage2_BUILD_MAKEPROGRAM}
       --build-nocmake
       --build-project foo
@@ -567,7 +598,7 @@
     file(WRITE "${_TEST_DIR}/nightly-cmake.sh"
       "cd ${_TEST_DIR}
 ${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
-${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
+${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
     ")
     add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh)
     if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY)
@@ -785,7 +816,7 @@
   set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK})
   set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK})
 
-  if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*")
+  if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
     find_program(RPMBUILD NAMES rpmbuild)
   endif()
   # Do not try to build RPM
@@ -821,6 +852,7 @@
 
     if(WIX_LIGHT_EXECUTABLE)
       add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND}
+        -C \${CTEST_CONFIGURATION_TYPE}
         --build-and-test
         "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator"
         "${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
@@ -829,6 +861,7 @@
         --build-options ${build_options}
         --test-command ${CMAKE_CMAKE_COMMAND}
           "-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
+          "-Dconfig=\${CTEST_CONFIGURATION_TYPE}"
           -P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake")
     endif()
   endif()
@@ -884,7 +917,7 @@
     if(APPLE)
       list(APPEND GENLST "DragNDrop")
     endif()
-    if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*")
+    if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
       list(FIND ACTIVE_CPACK_GENERATORS "RPM" RPM_ACTIVE)
       if (NOT ${RPM_ACTIVE} EQUAL -1)
         list(APPEND GENLST "RPM")
@@ -995,7 +1028,7 @@
   if(CTEST_RUN_CMakeTestBadCommandLines)
     add_test(CMakeTestBadCommandLines ${CMAKE_CMAKE_COMMAND}
         -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines
-        -D gen=${CMAKE_TEST_GENERATOR}
+        -D gen=${CMAKE_GENERATOR}
         -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
         -P ${CMake_SOURCE_DIR}/Tests/CMakeTestBadCommandLines/RunCMake.cmake
       )
@@ -1010,7 +1043,7 @@
   if(CTEST_RUN_CMakeTestMultipleConfigures)
     add_test(CMakeTestMultipleConfigures ${CMAKE_CMAKE_COMMAND}
         -D dir=${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures
-        -D gen=${CMAKE_TEST_GENERATOR}
+        -D gen=${CMAKE_GENERATOR}
         -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
         -P ${CMake_SOURCE_DIR}/Tests/CMakeTestMultipleConfigures/RunCMake.cmake
       )
@@ -1018,16 +1051,18 @@
       "${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures")
   endif()
 
-  add_test(LoadedCommandOneConfig  ${CMAKE_CTEST_COMMAND}
-    --build-and-test
-    "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig"
-    "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
-    ${build_generator_args}
-    --build-project LoadCommand
-    --build-options ${build_options}
-    --test-command  LoadedCommand
-    )
-  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
+  if(NOT CMake_TEST_EXTERNAL_CMAKE)
+    add_test(LoadedCommandOneConfig  ${CMAKE_CTEST_COMMAND}
+      --build-and-test
+      "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig"
+      "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
+      ${build_generator_args}
+      --build-project LoadCommand
+      --build-options ${build_options}
+      --test-command  LoadedCommand
+      )
+    list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
+  endif()
 
   add_test(complex  ${CMAKE_CTEST_COMMAND}
     --build-and-test
@@ -1233,8 +1268,8 @@
     COMMAND ${CMAKE_CMAKE_COMMAND}
     -DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
     -DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate
-    -DCMAKE_TEST_GENERATOR=${CMAKE_TEST_GENERATOR}
-    -DCMAKE_TEST_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET}
+    -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+    -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
     -DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
     -P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
     )
@@ -1405,7 +1440,7 @@
       ${build_generator_args}
       --build-project MacRuntimePath
       --build-options ${build_options}
-        -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}
+        -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
       )
   endif()
 
@@ -1452,19 +1487,6 @@
       )
   endif()
 
-  if(NOT CMAKE_TEST_DIFFERENT_GENERATOR)
-    add_test(kwsys ${CMAKE_CTEST_COMMAND}
-      --build-and-test
-      "${CMake_SOURCE_DIR}/Source/kwsys"
-      "${CMake_BINARY_DIR}/Tests/kwsys"
-      ${build_generator_args}
-      --build-project kwsys
-      --build-options ${build_options}
-      --test-command kwsysTestsCxx testIOS
-      )
-    list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys")
-  endif()
-
   if(MAKE_SUPPORTS_SPACES)
     add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
       --build-and-test
@@ -1511,19 +1533,19 @@
   endif ()
   list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir")
 
-  if(CMAKE_TEST_MSVC)
+  if(MSVC)
     ADD_TEST_MACRO(ForceInclude foo)
     ADD_TEST_MACRO(PDBDirectoryAndName myexe)
     ADD_TEST_MACRO(PrecompiledHeader foo)
   endif()
-  if(CMAKE_TEST_MSVC OR
-      "${CMAKE_TEST_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
+  if(MSVC OR
+      "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
     ADD_TEST_MACRO(ModuleDefinition example_exe)
   endif()
 
   ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
 
-  if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile")
+  if("${CMAKE_GENERATOR}" MATCHES "Makefile")
     add_test(MakeClean ${CMAKE_CTEST_COMMAND}
       --build-and-test
       "${CMake_SOURCE_DIR}/Tests/MakeClean"
@@ -1545,10 +1567,10 @@
 
       # Look for evidence that this is a VCExpress build. If so, avoid
       # the MFC test by default.
-      string(TOLOWER "${CMAKE_MAKE_PROGRAM};${CMAKE_TEST_MAKEPROGRAM}" mkprog)
+      string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog)
       if(mkprog MATCHES "vcexpress")
         message(STATUS
-          "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test")
+          "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test")
         set(CTEST_RUN_MFC OFF)
       endif()
 
@@ -1569,7 +1591,7 @@
 
       # For the Watcom WMake generator, avoid the MFC test by default.
       if(CTEST_RUN_MFC)
-        if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake")
+        if("${CMAKE_GENERATOR}" MATCHES "WMake")
           message(STATUS
             "using the Watcom WMake generator, avoiding MFC test")
           set(CTEST_RUN_MFC OFF)
@@ -1642,13 +1664,13 @@
     list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC")
   endif()
 
-  if(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio")
+  if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
     if(NOT MSVC60)
       ADD_TEST_MACRO(SBCS SBCS)
     endif()
 
-    if(NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [6789]( |$)"
-        AND NOT CMAKE_TEST_GENERATOR_TOOLSET)
+    if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [6789]( |$)"
+        AND NOT CMAKE_GENERATOR_TOOLSET)
       ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
     endif()
 
@@ -1674,7 +1696,7 @@
       --test-command VSMidl)
     list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
 
-    if(CMAKE_TEST_DEVENV)
+    if(CMake_TEST_DEVENV)
       # The test (and tested property) works with .sln files, so it's skipped when:
       # * Using VS6, which doesn't use .sln files
       # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file
@@ -1686,9 +1708,9 @@
           "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
           --build-config ${config}
           --build-two-config
-          --build-generator ${CMAKE_TEST_GENERATOR}
-          --build-makeprogram ${CMAKE_TEST_DEVENV}
-          --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+          --build-generator ${CMAKE_GENERATOR}
+          --build-makeprogram ${CMake_TEST_DEVENV}
+          --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
           --build-project VSExcludeFromDefaultBuild
           --test-command ${CMAKE_COMMAND}
              -D "activeConfig=${config}"
@@ -1704,15 +1726,15 @@
       list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild")
     endif()
 
-    if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
+    if(CMAKE_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
       # This is Visual Studio 10 or above, so the default build tool is MSBuild.
       add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND}
         --build-and-test
         "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir"
         "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir"
         --build-two-config
-        --build-generator ${CMAKE_TEST_GENERATOR}
-        --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+        --build-generator ${CMAKE_GENERATOR}
+        --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
         --build-project VSProjectInSubdir
         --build-target test)
       list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir")
@@ -1750,7 +1772,7 @@
         --test-command
         ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE}
         -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
-        -Dgen=${CMAKE_TEST_GENERATOR}
+        -Dgen=${CMAKE_GENERATOR}
         -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
       list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
 
@@ -1798,12 +1820,12 @@
     --build-options ${build_options}
       "--warn-unused-vars")
   set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
-    PASS_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:7 \\(set\\):")
+    PASS_REGULAR_EXPRESSION "CMake Warning \\(dev\\) at CMakeLists.txt:7 \\(set\\):")
   set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
-    FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):")
+    FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):")
   list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
 
-  if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
+  if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
     # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
     # this test. (See #13371)
     # Apparently Visual Studio does not support it either. As the MakeClean
@@ -1876,11 +1898,11 @@
 
   # A test for ctest_build() with targets in subdirectories
   set(ctest_configure_options)
-  if(CMAKE_TEST_GENERATOR_TOOLSET)
-    list(APPEND ctest_configure_options -T ${CMAKE_TEST_GENERATOR_TOOLSET})
+  if(CMAKE_GENERATOR_TOOLSET)
+    list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
   endif()
-  if(CMAKE_TEST_MAKEPROGRAM)
-    list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
+  if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
+    list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
   endif()
   configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
                  "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
@@ -2114,6 +2136,7 @@
   configure_file(
      "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/gtm_coverage.mcov.in"
      "${CMake_BINARY_DIR}/Testing/MumpsCoverage/gtm_coverage.mcov")
+  file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCoverage/VistA-FOIA")
   file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
     DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage")
   add_test(NAME CTestGTMCoverage
@@ -2122,7 +2145,7 @@
     $<TARGET_FILE:ctest> -T Coverage --debug)
   set_tests_properties(CTestGTMCoverage PROPERTIES
       PASS_REGULAR_EXPRESSION
-      "Process file.*XINDEX.m.*Total LOC:.*127.*Percentage Coverage: 85.83.*"
+      "Process file.*ZZCOVTST.m.*Total LOC:.*23.*Percentage Coverage: 82.61*"
       ENVIRONMENT COVFILE=)
 
   configure_file(
@@ -2131,6 +2154,7 @@
   configure_file(
     "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/cache_coverage.cmcov.in"
     "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/cache_coverage.cmcov")
+  file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage/VistA-FOIA")
   file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
     DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage")
   add_test(NAME CTestCacheCoverage
@@ -2139,7 +2163,7 @@
     $<TARGET_FILE:ctest> -T Coverage --debug)
   set_tests_properties(CTestCacheCoverage PROPERTIES
       PASS_REGULAR_EXPRESSION
-      "Process file.*XINDEX.m.*Total LOC:.*125.*Percentage Coverage: 85.60.*"
+      "Process file.*ZZCOVTST.m.*Total LOC:.*22.*Percentage Coverage: 86.36.*"
       ENVIRONMENT COVFILE=)
 
   # Adding a test case for Python Coverage
@@ -2160,6 +2184,24 @@
       "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*"
       ENVIRONMENT COVFILE=)
 
+  # Adding a test case for non-python Cobertura Coverage
+  configure_file(
+     "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/DartConfiguration.tcl.in"
+     "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/DartConfiguration.tcl")
+  configure_file(
+     "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/coverage.xml.in"
+     "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/coverage.xml")
+  file(COPY "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/src"
+    DESTINATION "${CMake_BINARY_DIR}/Testing/CoberturaCoverage")
+  add_test(NAME CTestCoberturaCoverage
+    COMMAND cmake -E chdir
+    ${CMake_BINARY_DIR}/Testing/CoberturaCoverage
+    $<TARGET_FILE:ctest> -T Coverage --debug)
+  set_tests_properties(CTestCoberturaCoverage PROPERTIES
+      PASS_REGULAR_EXPRESSION
+      "Process file.*CoverageTest.java.*Total LOC:.*18.*Percentage Coverage: 72.22.*"
+      ENVIRONMENT COVFILE=)
+
   function(add_config_tests cfg)
     set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
 
@@ -2219,7 +2261,7 @@
     --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log"
     )
   # with watcom the SEGFAULT is not found, it just fails
-  if(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake")
+  if(CMAKE_GENERATOR MATCHES "Watcom WMake")
     set_tests_properties(CTestTestCrash PROPERTIES
       PASS_REGULAR_EXPRESSION "Failed")
   else()
@@ -2301,6 +2343,17 @@
     "All Labels:.*  Label1.*  Label2")
 
   configure_file(
+    "${CMake_SOURCE_DIR}/Tests/CTestTestLabelRegExp/test.cmake.in"
+    "${CMake_BINARY_DIR}/Tests/CTestTestLabelRegExp/test.cmake"
+    @ONLY ESCAPE_QUOTES)
+  add_test(NAME CTestTestLabelRegExp
+    COMMAND ${CMAKE_CMAKE_COMMAND}
+      -DSOURCE_DIR=${CMAKE_SOURCE_DIR}/Tests/CTestTestLabelRegExp
+      -P ${CMAKE_BINARY_DIR}/Tests/CTestTestLabelRegExp/test.cmake
+    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Tests/CTestTestLabelRegExp
+  )
+
+  configure_file(
     "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in"
     "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake"
     @ONLY ESCAPE_QUOTES)
@@ -2370,7 +2423,7 @@
     --output-log "${CMake_BINARY_DIR}/Tests/CTestTestTimeout/testOutput.log"
     )
   set_tests_properties(CTestTestTimeout PROPERTIES
-    PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed")
+    PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*TestSleep *\\.+ *Passed.*timeout correctly killed child")
 
   add_test(
     NAME CTestTestRerunFailed
@@ -2448,6 +2501,7 @@
   set(regex "${regex}|Error message was: ")
   set(regex "${regex}([Cc]ould *n.t resolve host")
   set(regex "${regex}|[Cc]ould *n.t connect to host")
+  set(regex "${regex}|Failed connect to")
   set(regex "${regex}|Empty reply from server")
   set(regex "${regex}|The requested URL returned error")
   set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)")
@@ -2510,7 +2564,7 @@
       --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
       )
 
-    if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_TEST_GENERATOR}" MATCHES "Ninja")
+    if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
       configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
         "${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES)
       add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND}
@@ -2547,7 +2601,7 @@
     endif ()
   endif ()
 
-  if("${CMAKE_TEST_GENERATOR}" MATCHES Xcode)
+  if("${CMAKE_GENERATOR}" MATCHES Xcode)
     set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
   endif()
   if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
@@ -2592,7 +2646,7 @@
       --build-project testf
       --build-two-config
       --build-options ${build_options}
-        -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}
+        -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
       --test-command testf)
     list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran")
 
@@ -2619,7 +2673,7 @@
 
   find_package(Java COMPONENTS Development QUIET)
   if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW
-      AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode")
+      AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
     get_filename_component(JNIPATH ${JAVA_COMPILE} PATH)
     find_file(JNI_H jni.h
       "${JNIPATH}/../include"
@@ -2643,7 +2697,7 @@
   endif()
 
   # add some cross compiler tests, for now only with makefile based generators
-  if(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop")
+  if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop")
 
     # if sdcc is found, build the SimpleCOnly project with sdcc
     find_program(SDCC_EXECUTABLE sdcc)
@@ -2796,5 +2850,7 @@
       WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle)
   endif()
 
-  add_subdirectory(CMakeTests)
+  if(NOT CMake_TEST_EXTERNAL_CMAKE)
+    add_subdirectory(CMakeTests)
+  endif()
 endif()
diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
index 691728a..15493be 100644
--- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
+++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
@@ -8,11 +8,14 @@
 # Avoid ctest truncation of output
 message(STATUS "CTEST_FULL_OUTPUT")
 
+set(ORIGINAL_MODULE_PATH "${CMAKE_MODULE_PATH}")
+
 file(GLOB FIND_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/Find*.cmake" )
 
 macro(do_find MODULE_NAME)
     message(STATUS "   Checking Find${MODULE_NAME}")
     find_package(${MODULE_NAME})
+    set(CMAKE_MODULE_PATH "${ORIGINAL_MODULE_PATH}")
 endmacro()
 
 # It is only possible to use either Qt3 or Qt4 in one project.
diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in
index a266415..285643a 100644
--- a/Tests/CMakeOnly/Test.cmake.in
+++ b/Tests/CMakeOnly/Test.cmake.in
@@ -8,8 +8,8 @@
 file(MAKE_DIRECTORY "${binary_dir}")
 execute_process(
   COMMAND  ${CMAKE_COMMAND} ${CMAKE_ARGS}
-  "${source_dir}" -G "@CMAKE_TEST_GENERATOR@"
-  -T "@CMAKE_TEST_GENERATOR_TOOLSET@"
+  "${source_dir}" -G "@CMAKE_GENERATOR@"
+  -T "@CMAKE_GENERATOR_TOOLSET@"
   WORKING_DIRECTORY "${binary_dir}"
   RESULT_VARIABLE result
   )
diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake
index 7be7b30..1565394 100644
--- a/Tests/CMakeTests/CheckCMakeTest.cmake
+++ b/Tests/CMakeTests/CheckCMakeTest.cmake
@@ -9,8 +9,8 @@
     ERROR_VARIABLE stderr
     RESULT_VARIABLE result
     )
-  string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}")
-  string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}")
+  string(REPLACE "\n" "\n out> " out " out> ${stdout}")
+  string(REPLACE "\n" "\n err> " err " err> ${stderr}")
   if(NOT "${result}" STREQUAL "${${test}-RESULT}")
     message(FATAL_ERROR
       "Test ${test} result is [${result}], not [${${test}-RESULT}].\n"
diff --git a/Tests/CMakeTests/ExecuteScriptTests.cmake b/Tests/CMakeTests/ExecuteScriptTests.cmake
index c71585a..bceac33 100644
--- a/Tests/CMakeTests/ExecuteScriptTests.cmake
+++ b/Tests/CMakeTests/ExecuteScriptTests.cmake
@@ -52,9 +52,9 @@
 
   foreach(line ${script})
     if(line MATCHES "${regex}")
+      set(testname "${CMAKE_MATCH_2}")
+      set(expected_result "${CMAKE_MATCH_3}")
       math(EXPR count "${count} + 1")
-      string(REGEX REPLACE "${regex}" "\\2" testname "${line}")
-      string(REGEX REPLACE "${regex}" "\\3" expected_result "${line}")
       execute_one_script_test(${scriptname} ${testname} ${expected_result})
     endif()
   endforeach()
diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt
index d673d14..638e788 100644
--- a/Tests/CPackWiXGenerator/CMakeLists.txt
+++ b/Tests/CPackWiXGenerator/CMakeLists.txt
@@ -9,6 +9,11 @@
 
 add_executable(my-other-app myotherapp.cpp)
 
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty)
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty
+  DESTINATION extras
+  COMPONENT extras)
+
 install(TARGETS mylib
   ARCHIVE
   DESTINATION lib
@@ -58,6 +63,9 @@
 
 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt")
 
+set(CPACK_WIX_PROPERTY_ARPCOMMENTS "My Custom ARPCOMMENTS")
+set(CPACK_WIX_PROPERTY_ARPHELPLINK "http://www.cmake.org")
+
 include(CPack)
 
 cpack_add_install_type(Full DISPLAY_NAME "Everything")
@@ -69,6 +77,12 @@
   EXPANDED
   DESCRIPTION "All of the tools you'll ever need to develop software")
 
+cpack_add_component(extras
+  DISPLAY_NAME "Extras"
+  DESCRIPTION "Extras"
+  GROUP Runtime
+  INSTALL_TYPES Full)
+
 cpack_add_component(applications
   REQUIRED
   DISPLAY_NAME "MyLib Application"
diff --git a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake
index 30e33cf2..ca9fd90 100644
--- a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake
+++ b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake
@@ -10,7 +10,12 @@
 message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}")
 message(STATUS "CPackWiXGenerator_BINARY_DIR: ${CPackWiXGenerator_BINARY_DIR}")
 
+if(config)
+  set(_C_config -C ${config})
+endif()
+
 execute_process(COMMAND "${CMAKE_CPACK_COMMAND}"
+                        ${_C_config}
   RESULT_VARIABLE CPack_result
   OUTPUT_VARIABLE CPack_output
   ERROR_VARIABLE CPack_error
diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
index abf010b..670a874 100644
--- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
+++ b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
@@ -2,7 +2,7 @@
 
 set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir")
 set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
 set(CTEST_PROJECT_NAME "VSProjectInSubdir")
 set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@")
 
diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in
index 0bba6d6..608501c 100644
--- a/Tests/CTestConfig/dashboard.cmake.in
+++ b/Tests/CTestConfig/dashboard.cmake.in
@@ -18,8 +18,8 @@
 message("cmake initial configure")
 execute_process(COMMAND ${CMAKE_COMMAND}
    ${arg}
-   -G "@CMAKE_TEST_GENERATOR@"
-   -T "@CMAKE_TEST_GENERATOR_TOOLSET@"
+   -G "@CMAKE_GENERATOR@"
+   -T "@CMAKE_GENERATOR_TOOLSET@"
    ${CTEST_SOURCE_DIRECTORY}
   WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY}
   RESULT_VARIABLE rv)
diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in
index 83267a4..166de3b 100644
--- a/Tests/CTestConfig/script.cmake.in
+++ b/Tests/CTestConfig/script.cmake.in
@@ -1,5 +1,5 @@
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_PROJECT_NAME "CTestConfig")
 set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig")
 set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script")
diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in
index a7420fc..601aab4 100644
--- a/Tests/CTestTestBadExe/test.cmake.in
+++ b/Tests/CTestTestBadExe/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestBadExe")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestBadExe")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in
index b18cdf3..8413443 100644
--- a/Tests/CTestTestChecksum/test.cmake.in
+++ b/Tests/CTestTestChecksum/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestParallel")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestParallel")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in
index 42225d3..d3510bb 100644
--- a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in
+++ b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir1")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in
index 010fe1c..99b002c 100644
--- a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in
+++ b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir2")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestCostSerial/test.cmake.in b/Tests/CTestTestCostSerial/test.cmake.in
index e2dda95..ce8720c 100644
--- a/Tests/CTestTestCostSerial/test.cmake.in
+++ b/Tests/CTestTestCostSerial/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestCostSerial")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestCostSerial")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in
index 7ac1bb9..5906d12 100644
--- a/Tests/CTestTestCrash/test.cmake.in
+++ b/Tests/CTestTestCrash/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestCrash")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestCrash")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in
index 94b9cac..478badb 100644
--- a/Tests/CTestTestCycle/test.cmake.in
+++ b/Tests/CTestTestCycle/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestCycle")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestCycle")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in
index 98b2a27..a7de8cc 100644
--- a/Tests/CTestTestDepends/test.cmake.in
+++ b/Tests/CTestTestDepends/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestDepends")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestDepends")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in
index 1dee1ae..143daf8 100644
--- a/Tests/CTestTestFailure/testNoBuild.cmake.in
+++ b/Tests/CTestTestFailure/testNoBuild.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestFailure")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestFailure")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in
index 04e444d..11a1930 100644
--- a/Tests/CTestTestFailure/testNoExe.cmake.in
+++ b/Tests/CTestTestFailure/testNoExe.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestFailure")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestFailure")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestFdSetSize/test.cmake.in b/Tests/CTestTestFdSetSize/test.cmake.in
index c24f505..fbe0e82 100644
--- a/Tests/CTestTestFdSetSize/test.cmake.in
+++ b/Tests/CTestTestFdSetSize/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestFdSetSize")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestFdSetSize")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestLabelRegExp/CTestTestfile.cmake.in b/Tests/CTestTestLabelRegExp/CTestTestfile.cmake.in
new file mode 100644
index 0000000..657f382
--- /dev/null
+++ b/Tests/CTestTestLabelRegExp/CTestTestfile.cmake.in
@@ -0,0 +1,8 @@
+add_test(test1 ${CMAKE_COMMAND} -E echo test1)
+set_tests_properties(test1 PROPERTIES LABELS "foo")
+
+add_test(test2 ${CMAKE_COMMAND} -E echo test2)
+set_tests_properties(test2 PROPERTIES LABELS "bar")
+
+add_test(test3 ${CMAKE_COMMAND} -E echo test3)
+set_tests_properties(test3 PROPERTIES LABELS "foo;bar")
diff --git a/Tests/CTestTestLabelRegExp/test.cmake.in b/Tests/CTestTestLabelRegExp/test.cmake.in
new file mode 100644
index 0000000..5c0c9d7
--- /dev/null
+++ b/Tests/CTestTestLabelRegExp/test.cmake.in
@@ -0,0 +1,37 @@
+configure_file(${SOURCE_DIR}/CTestTestfile.cmake.in CTestTestfile.cmake)
+
+function(get_test_list TEST_LIST)
+  set(QUERY_COMMAND ${CMAKE_CTEST_COMMAND} -N ${ARGN})
+
+  execute_process(COMMAND ${QUERY_COMMAND}
+    RESULT_VARIABLE RESULT
+	OUTPUT_VARIABLE OUTPUT
+	ERROR_VARIABLE ERROR)
+
+  if(NOT ${RESULT} STREQUAL "0")
+    message(FATAL_ERROR "command [${QUERY_COMMAND}] failed: RESULT[${RESULT}] OUTPUT[${OUTPUT}] ERROR[${ERROR}]")
+  endif()
+
+  set(${TEST_LIST} "${OUTPUT}" PARENT_SCOPE)
+endfunction()
+
+function(expect_test_list EXPECTED_OUTPUT)
+  get_test_list(TEST_LIST ${ARGN})
+
+  if(NOT "${TEST_LIST}" MATCHES "${EXPECTED_OUTPUT}")
+    message(FATAL_ERROR "actual output [${TEST_LIST}] does not match expected output [${EXPECTED_OUTPUT}] for given arguments [${ARGN}]")
+  endif()
+endfunction()
+
+expect_test_list("test1.*test3.*Total Tests: 2" --label-regex foo)
+expect_test_list("test2.*test3.*Total Tests: 2" --label-regex bar)
+expect_test_list("test1.*test2.*test3.*Total Tests: 3" --label-regex foo|bar)
+expect_test_list("Total Tests: 0" --label-regex baz)
+
+expect_test_list("test2.*Total Tests: 1" --label-exclude foo)
+expect_test_list("test1.*Total Tests: 1" --label-exclude bar)
+expect_test_list("Total Tests: 0" --label-exclude foo|bar)
+expect_test_list("test1.*test2.*test3.*Total Tests: 3" --label-exclude baz)
+
+expect_test_list("test1.*Total Tests: 1" --label-regex foo --label-exclude bar)
+expect_test_list("test2.*Total Tests: 1" --label-regex bar --label-exclude foo)
diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt
index 9bd7249..8984463 100644
--- a/Tests/CTestTestMemcheck/CMakeLists.txt
+++ b/Tests/CTestTestMemcheck/CMakeLists.txt
@@ -19,14 +19,6 @@
 set_target_properties(pseudo_valgrind PROPERTIES OUTPUT_NAME valgrind)
 target_link_libraries(pseudo_valgrind CMakeLib)
 
-# Xcode 2.x forgets to create the output directory before linking
-# the individual architectures.
-if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
-    add_custom_command(TARGET pseudo_valgrind
-                       PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
-    )
-endif()
-
 add_executable(pseudo_purify "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx")
 set_target_properties(pseudo_purify PROPERTIES OUTPUT_NAME purify)
 target_link_libraries(pseudo_purify CMakeLib)
@@ -196,3 +188,18 @@
 set_tests_properties(CTestTestMemcheckDummyValgrindTwoTargets PROPERTIES
     PASS_REGULAR_EXPRESSION
     "\nMemory check project ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets\n.*\n *Start 1: RunCMake\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.1.log\" \"-q\".*\n *Start 2: RunCMakeAgain\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.2.log\" \"-q\".*\n")
+
+# Xcode 2.x forgets to create the output directory before linking
+# the individual architectures.
+if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
+  foreach(t
+      memcheck_fail
+      pseudo_BC
+      pseudo_purify
+      pseudo_valgrind
+      )
+    add_custom_command(TARGET ${t}
+      PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
+      )
+  endforeach()
+endif()
diff --git a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt
index c5aa2cd..3a45bfe 100644
--- a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt
+++ b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt
@@ -1,17 +1,22 @@
 # A dummy checker implementation that does not write the requested output file
 # so it triggers an error for every checker.
 
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c" "int main(){return 0;}\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in" "int main(){return 0;}\n")
+
+configure_file(
+  "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/ret0.c"
+  )
 
 foreach(_pseudo IN ITEMS valgrind purify BC)
   add_executable(pseudonl_${_pseudo} "${CMAKE_CURRENT_BINARY_DIR}/ret0.c")
   set_target_properties(pseudonl_${_pseudo} PROPERTIES OUTPUT_NAME ${_pseudo})
-endforeach()
 
-# Xcode 2.x forgets to create the output directory before linking
-# the individual architectures.
-if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
-    add_custom_command(TARGET pseudonl_valgrind
+  # Xcode 2.x forgets to create the output directory before linking
+  # the individual architectures.
+  if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
+    add_custom_command(TARGET pseudonl_${_pseudo}
                        PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
     )
-endif()
+  endif()
+endforeach()
diff --git a/Tests/CTestTestMemcheck/test.cmake.in b/Tests/CTestTestMemcheck/test.cmake.in
index 6c388c5..471e5a5 100644
--- a/Tests/CTestTestMemcheck/test.cmake.in
+++ b/Tests/CTestTestMemcheck/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@")
 set(CTEST_BINARY_DIRECTORY              "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in
index 5826342..48631ca 100644
--- a/Tests/CTestTestParallel/test.cmake.in
+++ b/Tests/CTestTestParallel/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestParallel")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestParallel")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestResourceLock/test.cmake.in b/Tests/CTestTestResourceLock/test.cmake.in
index f69b519..6ec6dfe 100644
--- a/Tests/CTestTestResourceLock/test.cmake.in
+++ b/Tests/CTestTestResourceLock/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestResourceLock")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestResourceLock")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestScheduler/test.cmake.in b/Tests/CTestTestScheduler/test.cmake.in
index 26d8058..06ba33e 100644
--- a/Tests/CTestTestScheduler/test.cmake.in
+++ b/Tests/CTestTestScheduler/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestScheduler")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestScheduler")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestSkipReturnCode/test.cmake.in b/Tests/CTestTestSkipReturnCode/test.cmake.in
index ebee01b..d3c44f5 100644
--- a/Tests/CTestTestSkipReturnCode/test.cmake.in
+++ b/Tests/CTestTestSkipReturnCode/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestSkipReturnCode")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestSkipReturnCode")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in
index d4e5a25..8adf941 100644
--- a/Tests/CTestTestStopTime/test.cmake.in
+++ b/Tests/CTestTestStopTime/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestStopTime")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestStopTime")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in
index 2b4ef4f..5a6caf1 100644
--- a/Tests/CTestTestSubdir/test.cmake.in
+++ b/Tests/CTestTestSubdir/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestSubdir")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestSubdir")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestTimeout/CMakeLists.txt b/Tests/CTestTestTimeout/CMakeLists.txt
index 476d0a5..2e3bd6a 100644
--- a/Tests/CTestTestTimeout/CMakeLists.txt
+++ b/Tests/CTestTestTimeout/CMakeLists.txt
@@ -11,18 +11,14 @@
 endif()
 
 add_definitions(-DTIMEOUT=${TIMEOUT})
-add_executable (Timeout timeout.c)
+add_executable (Sleep sleep.c)
 
 add_test(NAME TestTimeout
-  COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout>
+  COMMAND ${CMAKE_COMMAND} -D Sleep=$<TARGET_FILE:Sleep>
                            -D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log
                            -P ${CMAKE_CURRENT_SOURCE_DIR}/timeout.cmake
   )
 set_tests_properties(TestTimeout PROPERTIES TIMEOUT ${TIMEOUT})
 
-add_test(NAME CheckChild
-  COMMAND ${CMAKE_COMMAND} -D Timeout=$<TARGET_FILE:Timeout>
-                           -D Log=${CMAKE_CURRENT_BINARY_DIR}/timeout.log
-                           -P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake
-  )
-set_tests_properties(CheckChild PROPERTIES DEPENDS TestTimeout)
+add_test(NAME TestSleep COMMAND Sleep)
+set_tests_properties(TestSleep PROPERTIES DEPENDS TestTimeout)
diff --git a/Tests/CTestTestTimeout/check.cmake b/Tests/CTestTestTimeout/check.cmake
deleted file mode 100644
index b16f2aa..0000000
--- a/Tests/CTestTestTimeout/check.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-# Block just as long as timeout.cmake would if it were not killed.
-execute_process(COMMAND ${Timeout})
-
-# Verify that the log is empty, which indicates that the grandchild
-# was killed before it finished sleeping.
-file(READ "${Log}" LOG)
-if(NOT "${LOG}" STREQUAL "")
-  message(FATAL_ERROR "${LOG}")
-endif()
diff --git a/Tests/CTestTestTimeout/sleep.c b/Tests/CTestTestTimeout/sleep.c
new file mode 100644
index 0000000..33ce307
--- /dev/null
+++ b/Tests/CTestTestTimeout/sleep.c
@@ -0,0 +1,21 @@
+#if defined(_WIN32)
+# include <windows.h>
+#else
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+
+int main(void)
+{
+  fprintf(stderr, "before sleep\n");
+  fflush(stderr); /* should not be needed, but just in case */
+#if defined(_WIN32)
+  Sleep((TIMEOUT+4)*1000);
+#else
+  sleep((TIMEOUT+4));
+#endif
+  fprintf(stderr, "after sleep\n");
+  fflush(stderr); /* should not be needed, but just in case */
+  return 0;
+}
diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in
index d3d0888..68c74d8 100644
--- a/Tests/CTestTestTimeout/test.cmake.in
+++ b/Tests/CTestTestTimeout/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestTimeout")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestTimeout")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
@@ -24,3 +24,16 @@
 CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
 CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
 CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
+
+set(log ${CTEST_BINARY_DIRECTORY}/timeout.log)
+if(EXISTS "${log}")
+  # Verify that the timeout test did not finish sleeping.
+  file(STRINGS "${log}" after_sleep REGEX "after sleep")
+  if(after_sleep)
+    message(FATAL_ERROR "Log indicates timeout did not kill child.")
+  else()
+    message("Log indicates timeout correctly killed child.")
+  endif()
+else()
+  message(FATAL_ERROR "Log does not exist:\n  ${log}")
+endif()
diff --git a/Tests/CTestTestTimeout/timeout.c b/Tests/CTestTestTimeout/timeout.c
deleted file mode 100644
index 370ab22..0000000
--- a/Tests/CTestTestTimeout/timeout.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#if defined(_WIN32)
-# include <windows.h>
-#else
-# include <unistd.h>
-#endif
-
-#include <stdio.h>
-
-int main(void)
-{
-#if defined(_WIN32)
-  Sleep((TIMEOUT+4)*1000);
-#else
-  sleep((TIMEOUT+4));
-#endif
-  printf("timeout process finished sleeping!\n");
-  return -1;
-}
diff --git a/Tests/CTestTestTimeout/timeout.cmake b/Tests/CTestTestTimeout/timeout.cmake
index 198cc97..0989b65 100644
--- a/Tests/CTestTestTimeout/timeout.cmake
+++ b/Tests/CTestTestTimeout/timeout.cmake
@@ -3,4 +3,4 @@
 
 # Run a child that sleeps longer than the timout of this test.
 # Log its output so check.cmake can verify it dies.
-execute_process(COMMAND ${Timeout} OUTPUT_FILE ${Log})
+execute_process(COMMAND ${Sleep} ERROR_FILE ${Log})
diff --git a/Tests/CTestTestUpload/test.cmake.in b/Tests/CTestTestUpload/test.cmake.in
index 340877f..bb6ba25 100644
--- a/Tests/CTestTestUpload/test.cmake.in
+++ b/Tests/CTestTestUpload/test.cmake.in
@@ -7,8 +7,8 @@
 
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestUpload")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestUpload")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 
 CTEST_START(Experimental)
diff --git a/Tests/CTestTestZeroTimeout/test.cmake.in b/Tests/CTestTestZeroTimeout/test.cmake.in
index 3252754..beb6d90 100644
--- a/Tests/CTestTestZeroTimeout/test.cmake.in
+++ b/Tests/CTestTestZeroTimeout/test.cmake.in
@@ -8,8 +8,8 @@
 set(CTEST_SOURCE_DIRECTORY              "@CMake_SOURCE_DIR@/Tests/CTestTestZeroTimeout")
 set(CTEST_BINARY_DIRECTORY              "@CMake_BINARY_DIR@/Tests/CTestTestZeroTimeout")
 set(CTEST_CVS_COMMAND                   "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR               "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR               "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET       "@CMAKE_GENERATOR_TOOLSET@")
 set(CTEST_BUILD_CONFIGURATION           "$ENV{CMAKE_CONFIG_TYPE}")
 set(CTEST_COVERAGE_COMMAND              "@COVERAGE_COMMAND@")
 set(CTEST_NOTES_FILES                   "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake
index 642a618..857c6f5 100644
--- a/Tests/CTestUpdateCommon.cmake
+++ b/Tests/CTestUpdateCommon.cmake
@@ -9,7 +9,7 @@
     ERROR_STRIP_TRAILING_WHITESPACE
     )
   if(FAILED)
-    string(REGEX REPLACE "\n" "\n  " OUTPUT "${OUTPUT}")
+    string(REPLACE "\n" "\n  " OUTPUT "${OUTPUT}")
     message(FATAL_ERROR "Child failed (${FAILED}), output is\n  ${OUTPUT}\n"
       "Command = [${ARGN}]\n")
   endif()
@@ -108,7 +108,7 @@
       ${TOP}/${build}/Testing/Temporary/LastUpdate*.log)
     if(UPDATE_LOG_FILE)
       file(READ ${UPDATE_LOG_FILE} UPDATE_LOG LIMIT ${max_update_xml_size})
-      string(REGEX REPLACE "\n" "\n  " UPDATE_LOG "${UPDATE_LOG}")
+      string(REPLACE "\n" "\n  " UPDATE_LOG "${UPDATE_LOG}")
       set(MSG "${MSG}Update log:\n  ${UPDATE_LOG}")
     else()
       set(MSG "${MSG}No update log found!")
diff --git a/Tests/CoberturaCoverage/DartConfiguration.tcl.in b/Tests/CoberturaCoverage/DartConfiguration.tcl.in
new file mode 100644
index 0000000..954f59a
--- /dev/null
+++ b/Tests/CoberturaCoverage/DartConfiguration.tcl.in
@@ -0,0 +1,8 @@
+# This file is configured by CMake automatically as DartConfiguration.tcl
+# If you choose not to use CMake, this file may be hand configured, by
+# filling in the required variables.
+
+
+# Configuration directories and files
+SourceDirectory: ${CMake_SOURCE_DIR}/Testing/CoberturaCoverage
+BuildDirectory: ${CMake_BINARY_DIR}/Testing/CoberturaCoverage
diff --git a/Tests/CoberturaCoverage/coverage.xml.in b/Tests/CoberturaCoverage/coverage.xml.in
new file mode 100644
index 0000000..b3f6691
--- /dev/null
+++ b/Tests/CoberturaCoverage/coverage.xml.in
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
+
+<coverage line-rate="0.7222222222222222" branch-rate="0.875" lines-covered="13" lines-valid="18" branches-covered="7" branches-valid="8" complexity="0.0" version="1.9.4.1" timestamp="1401890139281">
+	<sources>
+		<source>${CMake_BINARY_DIR}/Testing/CoberturaCoverage/src/main/java/</source>
+	</sources>
+	<packages>
+		<package name="org.cmake.Coverage" line-rate="0.7222222222222222" branch-rate="0.875" complexity="0.0">
+			<classes>
+				<class name="org.cmake.Coverage.CoverageTest" filename="org/cmake/CoverageTest.java" line-rate="0.7222222222222222" branch-rate="0.875" complexity="0.0">
+					<methods>
+						<method name="&lt;clinit&gt;" signature="()V" line-rate="1.0" branch-rate="1.0">
+							<lines>
+								<line number="10" hits="2" branch="false"/>
+								<line number="11" hits="2" branch="false"/>
+							</lines>
+						</method>
+						<method name="&lt;init&gt;" signature="()V" line-rate="0.0" branch-rate="1.0">
+							<lines>
+								<line number="8" hits="0" branch="false"/>
+								<line number="12" hits="0" branch="false"/>
+							</lines>
+						</method>
+						<method name="equalsVarOne" signature="(Ljava/lang/String;)Ljava/lang/Boolean;" line-rate="0.6666666666666666" branch-rate="0.5">
+							<lines>
+								<line number="16" hits="2" branch="true" condition-coverage="50% (1/2)">
+									<conditions>
+										<condition number="0" type="jump" coverage="50%"/>
+									</conditions>
+								</line>
+								<line number="17" hits="2" branch="false"/>
+								<line number="20" hits="0" branch="false"/>
+							</lines>
+						</method>
+						<method name="equalsVarTwo" signature="(Ljava/lang/String;)Z" line-rate="1.0" branch-rate="1.0">
+							<lines>
+								<line number="26" hits="4" branch="true" condition-coverage="100% (2/2)">
+									<conditions>
+										<condition number="0" type="jump" coverage="100%"/>
+									</conditions>
+								</line>
+								<line number="27" hits="2" branch="false"/>
+								<line number="30" hits="2" branch="false"/>
+							</lines>
+						</method>
+						<method name="timesIntOne" signature="(Ljava/lang/Integer;)Ljava/lang/Integer;" line-rate="0.0" branch-rate="1.0">
+							<lines>
+								<line number="35" hits="0" branch="false"/>
+								<line number="36" hits="0" branch="false"/>
+							</lines>
+						</method>
+						<method name="whileLoop" signature="(Ljava/lang/Integer;)Z" line-rate="1.0" branch-rate="1.0">
+							<lines>
+								<line number="41" hits="2" branch="false"/>
+								<line number="42" hits="10" branch="true" condition-coverage="100% (2/2)">
+									<conditions>
+										<condition number="0" type="jump" coverage="100%"/>
+									</conditions>
+								</line>
+								<line number="43" hits="8" branch="false"/>
+								<line number="45" hits="2" branch="true" condition-coverage="100% (2/2)">
+									<conditions>
+										<condition number="0" type="jump" coverage="100%"/>
+									</conditions>
+								</line>
+								<line number="46" hits="1" branch="false"/>
+								<line number="49" hits="1" branch="false"/>
+							</lines>
+						</method>
+					</methods>
+					<lines>
+						<line number="8" hits="0" branch="false"/>
+						<line number="10" hits="2" branch="false"/>
+						<line number="11" hits="2" branch="false"/>
+						<line number="12" hits="0" branch="false"/>
+						<line number="16" hits="2" branch="true" condition-coverage="50% (1/2)">
+							<conditions>
+								<condition number="0" type="jump" coverage="50%"/>
+							</conditions>
+						</line>
+						<line number="17" hits="2" branch="false"/>
+						<line number="20" hits="0" branch="false"/>
+						<line number="26" hits="4" branch="true" condition-coverage="100% (2/2)">
+							<conditions>
+								<condition number="0" type="jump" coverage="100%"/>
+							</conditions>
+						</line>
+						<line number="27" hits="2" branch="false"/>
+						<line number="30" hits="2" branch="false"/>
+						<line number="35" hits="0" branch="false"/>
+						<line number="36" hits="0" branch="false"/>
+						<line number="41" hits="2" branch="false"/>
+						<line number="42" hits="10" branch="true" condition-coverage="100% (2/2)">
+							<conditions>
+								<condition number="0" type="jump" coverage="100%"/>
+							</conditions>
+						</line>
+						<line number="43" hits="8" branch="false"/>
+						<line number="45" hits="2" branch="true" condition-coverage="100% (2/2)">
+							<conditions>
+								<condition number="0" type="jump" coverage="100%"/>
+							</conditions>
+						</line>
+						<line number="46" hits="1" branch="false"/>
+						<line number="49" hits="1" branch="false"/>
+					</lines>
+				</class>
+			</classes>
+		</package>
+	</packages>
+</coverage>
diff --git a/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java b/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java
new file mode 100644
index 0000000..4fb43c6
--- /dev/null
+++ b/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java
@@ -0,0 +1,52 @@
+package org.cmake.Coverage;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.List;
+import java.awt.*;
+
+public class CoverageTest {
+
+  public static String VarOne = "test1";
+  public static String VarTwo = "test2";
+  private Integer IntOne = 4;
+
+  public static Boolean equalsVarOne(String inString) {
+
+    if(VarOne.equals(inString)){
+      return true;
+    }
+    else {
+      return false;
+    }
+  }
+
+  public static boolean equalsVarTwo(String inString){
+
+    if(VarTwo.equals(inString)){
+      return true;
+    }
+    else {
+      return false;
+    }
+  }
+
+  private Integer timesIntOne(Integer inVal){
+
+    return inVal * IntOne;
+  }
+
+  public static boolean whileLoop(Integer StopInt){
+
+    Integer i = 0;
+    while(i < StopInt){
+      i=i+1;
+    }
+    if (i.equals(5)){
+     return true;
+    }
+    else {
+     return false;
+    }
+  }
+}
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
new file mode 100644
index 0000000..d02ddaf
--- /dev/null
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -0,0 +1,112 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(CompileFeatures)
+
+if (NOT CMAKE_C_COMPILE_FEATURES AND NOT CMAKE_CXX_COMPILE_FEATURES)
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp"
+    "int main(int,char**) { return 0; }\n"
+  )
+  add_executable(CompileFeatures "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp")
+  return()
+endif()
+
+macro(run_test feature lang)
+  if (";${CMAKE_${lang}_COMPILE_FEATURES};" MATCHES ${feature})
+    add_library(test_${feature} OBJECT ${feature})
+    set_property(TARGET test_${feature}
+      PROPERTY COMPILE_FEATURES "${feature}"
+    )
+  else()
+    list(APPEND ${lang}_non_features ${feature})
+  endif()
+endmacro()
+
+get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
+foreach(feature ${c_features})
+  run_test(${feature} C)
+endforeach()
+get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
+foreach(feature ${cxx_features})
+  run_test(${feature} CXX)
+endforeach()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL GNU
+    AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
+  list(REMOVE_ITEM CXX_non_features
+    cxx_alignof
+  )
+endif()
+if (CMAKE_CXX_COMPILER_ID STREQUAL GNU
+    AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
+  # GNU prior to 4.9 does not set any preprocessor define to distinguish
+  # c++1y from c++11, so CMake does not support c++1y features before GNU 4.9.
+  list(REMOVE_ITEM CXX_non_features
+    # GNU 4.8 knows cxx_attributes, but doesn't know [[deprecated]]
+    # and warns that it is unknown and ignored.
+    cxx_attribute_deprecated
+    cxx_binary_literals
+    cxx_lambda_init_captures
+    cxx_return_type_deduction
+  )
+endif()
+
+set(C_ext c)
+set(C_standard_flag 11)
+set(CXX_ext cpp)
+set(CXX_standard_flag 14)
+foreach(lang CXX C)
+  if (CMAKE_${lang}_COMPILE_FEATURES)
+    foreach(feature ${${lang}_non_features})
+      message("Testing feature : ${feature}")
+      try_compile(${feature}_works
+        "${CMAKE_CURRENT_BINARY_DIR}/${feature}_test"
+        "${CMAKE_CURRENT_SOURCE_DIR}/feature_test.${${lang}_ext}"
+        COMPILE_DEFINITIONS "-DTEST=${CMAKE_CURRENT_SOURCE_DIR}/${feature}.${${lang}_ext}"
+        CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD=${${lang}_standard_flag}"
+        OUTPUT_VARIABLE OUTPUT
+      )
+      if (${feature}_works)
+        message(SEND_ERROR
+          "Feature ${feature} expected not to work for ${lang} ${CMAKE_${lang}_COMPILER_ID}-${CMAKE_${lang}_COMPILER_VERSION}.
+  Update the supported features or blacklist it.\n${OUTPUT}")
+      else()
+        message("Testing feature : ${feature} -- Fails, as expected.")
+      endif()
+    endforeach()
+  endif()
+endforeach()
+
+add_executable(CompileFeatures main.cpp)
+set_property(TARGET CompileFeatures
+  PROPERTY COMPILE_FEATURES "cxx_auto_type"
+)
+set_property(TARGET CompileFeatures
+  PROPERTY CXX_STANDARD_REQUIRED TRUE
+)
+
+add_executable(GenexCompileFeatures main.cpp)
+set_property(TARGET GenexCompileFeatures
+  PROPERTY COMPILE_FEATURES "$<1:cxx_auto_type>;$<0:not_a_feature>"
+)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface
+  PROPERTY INTERFACE_COMPILE_FEATURES "cxx_auto_type"
+)
+add_executable(IfaceCompileFeatures main.cpp)
+target_link_libraries(IfaceCompileFeatures iface)
+
+add_executable(CompileFeaturesGenex genex_test.cpp)
+set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11)
+target_compile_definitions(CompileFeaturesGenex PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
+
+add_executable(CompileFeaturesGenex2 genex_test.cpp)
+target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_constexpr)
+target_compile_definitions(CompileFeaturesGenex2 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
+
+add_library(noexcept_iface INTERFACE)
+target_compile_features(noexcept_iface INTERFACE cxx_noexcept)
+add_executable(CompileFeaturesGenex3 genex_test.cpp)
+target_link_libraries(CompileFeaturesGenex3 PRIVATE noexcept_iface)
+target_compile_definitions(CompileFeaturesGenex3 PRIVATE HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>)
diff --git a/Tests/CompileFeatures/c_function_prototypes.c b/Tests/CompileFeatures/c_function_prototypes.c
new file mode 100644
index 0000000..ab3c948
--- /dev/null
+++ b/Tests/CompileFeatures/c_function_prototypes.c
@@ -0,0 +1,9 @@
+
+int someFunc(int a, int b);
+
+int someFunc(int a, int b)
+{
+  (void)a;
+  (void)b;
+  return 0;
+}
diff --git a/Tests/CompileFeatures/c_restrict.c b/Tests/CompileFeatures/c_restrict.c
new file mode 100644
index 0000000..7bc7566
--- /dev/null
+++ b/Tests/CompileFeatures/c_restrict.c
@@ -0,0 +1,7 @@
+
+int f (int * restrict a, int * restrict b)
+{
+  (void)a;
+  (void)b;
+  return 0;
+}
diff --git a/Tests/CompileFeatures/c_static_assert.c b/Tests/CompileFeatures/c_static_assert.c
new file mode 100644
index 0000000..afab504
--- /dev/null
+++ b/Tests/CompileFeatures/c_static_assert.c
@@ -0,0 +1,2 @@
+
+_Static_assert(1, "Static assert test");
diff --git a/Tests/CompileFeatures/c_variadic_macros.c b/Tests/CompileFeatures/c_variadic_macros.c
new file mode 100644
index 0000000..4da111e
--- /dev/null
+++ b/Tests/CompileFeatures/c_variadic_macros.c
@@ -0,0 +1,15 @@
+
+int someFunc(int i1, char c, int i2)
+{
+  (void)i1;
+  (void)c;
+  (void)i2;
+  return 0;
+}
+
+#define FUNC_WRAPPER(...) someFunc(__VA_ARGS__)
+
+void otherFunc()
+{
+  FUNC_WRAPPER(42, 'a', 7);
+}
diff --git a/Tests/CompileFeatures/cxx_aggregate_default_initializers.cpp b/Tests/CompileFeatures/cxx_aggregate_default_initializers.cpp
new file mode 100644
index 0000000..63a3713
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_aggregate_default_initializers.cpp
@@ -0,0 +1,9 @@
+
+struct X { int i, j, k = 42; };
+
+int someFunc()
+{
+  X a[] = { 1, 2, 3, 4, 5, 6 };
+  X b[2] = { { 1, 2, 3 }, { 4, 5, 6 } };
+  return a[0].k == b[0].k && a[1].k == b[1].k ? 0 : 1;
+}
diff --git a/Tests/CompileFeatures/cxx_alias_templates.cpp b/Tests/CompileFeatures/cxx_alias_templates.cpp
new file mode 100644
index 0000000..a47e27d
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_alias_templates.cpp
@@ -0,0 +1,11 @@
+
+template <typename T1, typename T2>
+struct A
+{
+  typedef T1 MyT1;
+  using MyT2 = T2;
+};
+
+using B = A<int, char>;
+template<typename T>
+using C = A<int, T>;
diff --git a/Tests/CompileFeatures/cxx_alignas.cpp b/Tests/CompileFeatures/cxx_alignas.cpp
new file mode 100644
index 0000000..35b7c82
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_alignas.cpp
@@ -0,0 +1,4 @@
+
+struct S1 {
+  alignas(8) int n;
+};
diff --git a/Tests/CompileFeatures/cxx_alignof.cpp b/Tests/CompileFeatures/cxx_alignof.cpp
new file mode 100644
index 0000000..63b14fe
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_alignof.cpp
@@ -0,0 +1,5 @@
+
+int someFunc()
+{
+  return alignof(int);
+}
diff --git a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp
new file mode 100644
index 0000000..b6f307d
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp
@@ -0,0 +1,11 @@
+
+[[deprecated]]
+int foo()
+{
+  return 0;
+}
+
+int someFunc()
+{
+  return foo();
+}
diff --git a/Tests/CompileFeatures/cxx_attributes.cpp b/Tests/CompileFeatures/cxx_attributes.cpp
new file mode 100644
index 0000000..a3c89ea
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_attributes.cpp
@@ -0,0 +1,2 @@
+
+void unusedFunc [[noreturn]] () { throw 1; }
diff --git a/Tests/CompileFeatures/cxx_auto_type.cpp b/Tests/CompileFeatures/cxx_auto_type.cpp
new file mode 100644
index 0000000..7dbf04f
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_auto_type.cpp
@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+  auto x = 3.14;
+}
diff --git a/Tests/CompileFeatures/cxx_binary_literals.cpp b/Tests/CompileFeatures/cxx_binary_literals.cpp
new file mode 100644
index 0000000..14a9e75
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_binary_literals.cpp
@@ -0,0 +1,6 @@
+
+int someFunc()
+{
+  int i = 0b101;
+  return i - 5;
+}
diff --git a/Tests/CompileFeatures/cxx_constexpr.cpp b/Tests/CompileFeatures/cxx_constexpr.cpp
new file mode 100644
index 0000000..570c10f
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_constexpr.cpp
@@ -0,0 +1,5 @@
+
+constexpr int getNum()
+{
+  return 42;
+}
diff --git a/Tests/CompileFeatures/cxx_contextual_conversions.cpp b/Tests/CompileFeatures/cxx_contextual_conversions.cpp
new file mode 100644
index 0000000..3438624
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_contextual_conversions.cpp
@@ -0,0 +1,33 @@
+
+#define assert(E) if(!(E)) return 1;
+
+template<class T>
+class zero_init
+{
+public:
+  zero_init( )
+    : val( static_cast<T>(0) ) { }
+  zero_init( T val ) : val( val )
+  { }
+  operator T & ( ) { return val; }
+  operator T ( ) const { return val; }
+private:
+  T val;
+};
+
+int someFunc()
+{
+  zero_init<int*> p; assert( p == 0 );
+  p = new int(7);
+  assert( *p == 7 );
+  delete p;
+
+  zero_init<int> i; assert( i == 0 );
+  i = 7;
+  assert( i == 7 );
+  switch( i ) {  }
+
+  int *vp = new int[i];
+
+  return 0;
+}
diff --git a/Tests/CompileFeatures/cxx_decltype.cpp b/Tests/CompileFeatures/cxx_decltype.cpp
new file mode 100644
index 0000000..24ec51e
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_decltype.cpp
@@ -0,0 +1,7 @@
+
+int someFunc()
+{
+  int i = 0;
+  decltype(i) other = 0;
+  return other;
+}
diff --git a/Tests/CompileFeatures/cxx_decltype_auto.cpp b/Tests/CompileFeatures/cxx_decltype_auto.cpp
new file mode 100644
index 0000000..900bb6d
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_decltype_auto.cpp
@@ -0,0 +1,6 @@
+
+int someFunc(int argc, char**)
+{
+  decltype(auto) i = argc;
+  return 0;
+}
diff --git a/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp b/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp
new file mode 100644
index 0000000..109d038
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp
@@ -0,0 +1,14 @@
+
+template<class T>
+struct A
+{
+  ~A() = delete;
+};
+
+template<class T> auto h() -> A<T>;
+template<class T> auto i(T) -> T;
+template<class T> auto f(T) -> decltype(i(h<T>()));
+template<class T> auto f(T) -> void;
+auto g() -> void {
+  f(42);
+}
diff --git a/Tests/CompileFeatures/cxx_default_function_template_args.cpp b/Tests/CompileFeatures/cxx_default_function_template_args.cpp
new file mode 100644
index 0000000..3d14c52
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_default_function_template_args.cpp
@@ -0,0 +1,12 @@
+
+template<typename T = int>
+int someFunc()
+{
+  T t = 0;
+  return t;
+}
+
+void otherFunc()
+{
+  someFunc();
+}
diff --git a/Tests/CompileFeatures/cxx_defaulted_functions.cpp b/Tests/CompileFeatures/cxx_defaulted_functions.cpp
new file mode 100644
index 0000000..b679a92
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_defaulted_functions.cpp
@@ -0,0 +1,9 @@
+
+struct A {
+  A() = default;
+};
+
+void someFunc()
+{
+  A a;
+}
diff --git a/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp b/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp
new file mode 100644
index 0000000..14f9871
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp
@@ -0,0 +1,7 @@
+
+struct A
+{
+  A() = default;
+  A& operator=(A&&) = default;
+  A(A&&) = default;
+};
diff --git a/Tests/CompileFeatures/cxx_delegating_constructors.cpp b/Tests/CompileFeatures/cxx_delegating_constructors.cpp
new file mode 100644
index 0000000..4b41615
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_delegating_constructors.cpp
@@ -0,0 +1,15 @@
+
+class Foo
+{
+public:
+  Foo(int i);
+
+  Foo(double d)
+    : Foo(static_cast<int>(d))
+  {
+
+  }
+
+private:
+  int m_i;
+};
diff --git a/Tests/CompileFeatures/cxx_deleted_functions.cpp b/Tests/CompileFeatures/cxx_deleted_functions.cpp
new file mode 100644
index 0000000..4ecb1e9
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_deleted_functions.cpp
@@ -0,0 +1,6 @@
+
+struct A
+{
+  A(const A&) = delete;
+  A& operator=(const A&) = delete;
+};
diff --git a/Tests/CompileFeatures/cxx_digit_separators.cpp b/Tests/CompileFeatures/cxx_digit_separators.cpp
new file mode 100644
index 0000000..abcd1c8
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_digit_separators.cpp
@@ -0,0 +1,6 @@
+
+int someFunc()
+{
+  int one_thousand = 1'000;
+  return one_thousand - 1000;
+}
diff --git a/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp b/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp
new file mode 100644
index 0000000..a7e1445
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp
@@ -0,0 +1,8 @@
+
+enum SomeEnum : short;
+
+void someFunc()
+{
+  SomeEnum value;
+  int i = value;
+}
diff --git a/Tests/CompileFeatures/cxx_explicit_conversions.cpp b/Tests/CompileFeatures/cxx_explicit_conversions.cpp
new file mode 100644
index 0000000..0decdcd
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_explicit_conversions.cpp
@@ -0,0 +1,10 @@
+
+class A
+{
+  int m_i;
+public:
+  explicit operator bool()
+  {
+    return m_i != 0;
+  }
+};
diff --git a/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp b/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp
new file mode 100644
index 0000000..631c699
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp
@@ -0,0 +1,25 @@
+
+template <typename T>
+struct B
+{
+  B() : m_i(42) {}
+private:
+  int m_i;
+  friend T;
+};
+
+struct A
+{
+  template<typename T>
+  int getBValue(B<T> b)
+  {
+    return b.m_i;
+  }
+};
+
+void someFunc()
+{
+  A a;
+  B<A> b;
+  a.getBValue(b);
+}
diff --git a/Tests/CompileFeatures/cxx_extern_templates.cpp b/Tests/CompileFeatures/cxx_extern_templates.cpp
new file mode 100644
index 0000000..9fa4aa4
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_extern_templates.cpp
@@ -0,0 +1,12 @@
+
+template<typename T>
+void someFunc()
+{
+}
+
+extern template void someFunc<int>();
+
+void otherFunc()
+{
+  someFunc<int>();
+}
diff --git a/Tests/CompileFeatures/cxx_final.cpp b/Tests/CompileFeatures/cxx_final.cpp
new file mode 100644
index 0000000..598cb94
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_final.cpp
@@ -0,0 +1,2 @@
+
+struct A final {};
diff --git a/Tests/CompileFeatures/cxx_func_identifier.cpp b/Tests/CompileFeatures/cxx_func_identifier.cpp
new file mode 100644
index 0000000..0c3595c
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_func_identifier.cpp
@@ -0,0 +1,6 @@
+
+void someFunc()
+{
+  bool b = sizeof(__func__);
+  (void)b;
+}
diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp
new file mode 100644
index 0000000..8013ef5
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp
@@ -0,0 +1,23 @@
+
+// Dummy implementation. Test only the compiler feature.
+namespace std {
+  typedef decltype(sizeof(int)) size_t;
+  template <class _E>
+  class initializer_list
+  {
+    const _E* __begin_;
+    size_t    __size_;
+
+  };
+}
+
+template <typename T>
+struct A
+{
+  A(std::initializer_list<T>) {}
+};
+
+void someFunc()
+{
+  A<int> as = { 1, 2, 3, 4 };
+}
diff --git a/Tests/CompileFeatures/cxx_generic_lambdas.cpp b/Tests/CompileFeatures/cxx_generic_lambdas.cpp
new file mode 100644
index 0000000..ae1b78e
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_generic_lambdas.cpp
@@ -0,0 +1,6 @@
+
+int someFunc()
+{
+  auto identity = [](auto a) { return a; };
+  return identity(0);
+}
diff --git a/Tests/CompileFeatures/cxx_inheriting_constructors.cpp b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp
new file mode 100644
index 0000000..a83b624
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp
@@ -0,0 +1,18 @@
+
+struct A
+{
+  int m_i;
+
+  A(int i) : m_i(i) {}
+};
+
+struct B : public A
+{
+  using A::A;
+};
+
+void someFunc()
+{
+  int i;
+  B b(i);
+}
diff --git a/Tests/CompileFeatures/cxx_inline_namespaces.cpp b/Tests/CompileFeatures/cxx_inline_namespaces.cpp
new file mode 100644
index 0000000..59fa9c8
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_inline_namespaces.cpp
@@ -0,0 +1,26 @@
+namespace Lib
+{
+inline namespace Lib_1
+{
+  template <typename T> class A;
+}
+
+template <typename T> void g(T);
+}
+
+struct MyClass {
+
+};
+namespace Lib
+{
+template<>
+class A<MyClass> {
+
+};
+}
+
+void someFunc()
+{
+  Lib::A<MyClass> a;
+  g(a);  // ok, Lib is an associated namespace of A
+}
diff --git a/Tests/CompileFeatures/cxx_lambda_init_captures.cpp b/Tests/CompileFeatures/cxx_lambda_init_captures.cpp
new file mode 100644
index 0000000..7e337fa
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_lambda_init_captures.cpp
@@ -0,0 +1,6 @@
+
+int someFunc()
+{
+  int a = 0;
+  return [b = static_cast<int&&>(a)]() { return b; }();
+}
diff --git a/Tests/CompileFeatures/cxx_lambdas.cpp b/Tests/CompileFeatures/cxx_lambdas.cpp
new file mode 100644
index 0000000..eecaa23
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_lambdas.cpp
@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+  [](){}();
+}
diff --git a/Tests/CompileFeatures/cxx_local_type_template_args.cpp b/Tests/CompileFeatures/cxx_local_type_template_args.cpp
new file mode 100644
index 0000000..802ea7a
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_local_type_template_args.cpp
@@ -0,0 +1,21 @@
+
+template <typename T>
+class X { };
+template <typename T>
+void f(T t) { }
+struct {} unnamed_obj;
+void f() {
+  struct A { };
+  enum { e1 };
+  typedef struct {} B;
+  B b;
+  X<A> x1;
+  X<A*> x2;
+  X<B> x3;
+  f(e1);
+  f(unnamed_obj);
+  f(b);
+  (void)x1;
+  (void)x2;
+  (void)x3;
+}
diff --git a/Tests/CompileFeatures/cxx_long_long_type.cpp b/Tests/CompileFeatures/cxx_long_long_type.cpp
new file mode 100644
index 0000000..670324c
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_long_long_type.cpp
@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+  long long ll = 9223372036854775807LL;
+}
diff --git a/Tests/CompileFeatures/cxx_noexcept.cpp b/Tests/CompileFeatures/cxx_noexcept.cpp
new file mode 100644
index 0000000..a3c05b8
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_noexcept.cpp
@@ -0,0 +1,5 @@
+
+void someFunc() noexcept
+{
+
+}
diff --git a/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp b/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp
new file mode 100644
index 0000000..6b7fa70
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp
@@ -0,0 +1,4 @@
+class A
+{
+  int m_i = 42;
+};
diff --git a/Tests/CompileFeatures/cxx_nullptr.cpp b/Tests/CompileFeatures/cxx_nullptr.cpp
new file mode 100644
index 0000000..96307df
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_nullptr.cpp
@@ -0,0 +1,10 @@
+
+void someFunc(int*)
+{
+
+}
+
+void otherFunc()
+{
+  someFunc(nullptr);
+}
diff --git a/Tests/CompileFeatures/cxx_override.cpp b/Tests/CompileFeatures/cxx_override.cpp
new file mode 100644
index 0000000..55bec13
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_override.cpp
@@ -0,0 +1,7 @@
+
+struct A {
+  virtual void doNothing() {}
+};
+struct B : A {
+  void doNothing() override {}
+};
diff --git a/Tests/CompileFeatures/cxx_range_for.cpp b/Tests/CompileFeatures/cxx_range_for.cpp
new file mode 100644
index 0000000..892109e
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_range_for.cpp
@@ -0,0 +1,10 @@
+
+void someFunc()
+{
+  int accumulated = 0;
+  int numbers[] = { 1, 2, 5 };
+  for (int i : numbers)
+    {
+    accumulated += i;
+    }
+}
diff --git a/Tests/CompileFeatures/cxx_raw_string_literals.cpp b/Tests/CompileFeatures/cxx_raw_string_literals.cpp
new file mode 100644
index 0000000..ea4d231
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_raw_string_literals.cpp
@@ -0,0 +1,7 @@
+
+void someFunc()
+{
+const char p[] = R"(a\
+b
+c)";
+}
diff --git a/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp b/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp
new file mode 100644
index 0000000..83a2361
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp
@@ -0,0 +1,11 @@
+
+struct test{
+  void f() & { }
+  void f() && { }
+};
+
+void someFunc(){
+  test t;
+  t.f(); // lvalue
+  test().f(); // rvalue
+}
diff --git a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp
new file mode 100644
index 0000000..bce82e3
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp
@@ -0,0 +1,23 @@
+
+struct X {
+  constexpr X() : n(5) {
+    n *= 2;
+  }
+  int n;
+};
+
+constexpr int g(const int (&is)[4]) {
+  X x;
+  int r = x.n;
+  for (int i = 0; i < 5; ++i)
+    r += i;
+  for (auto& i : is)
+    r += i;
+  return r;
+}
+
+int someFunc()
+{
+  constexpr int k3 = g({ 4, 5, 6, 7 });
+  return k3 - 42;
+}
diff --git a/Tests/CompileFeatures/cxx_return_type_deduction.cpp b/Tests/CompileFeatures/cxx_return_type_deduction.cpp
new file mode 100644
index 0000000..009e919
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_return_type_deduction.cpp
@@ -0,0 +1,10 @@
+
+auto sum(int a, int b)
+{
+  return a+b;
+}
+
+int someFunc()
+{
+  return sum(3, -3);
+}
diff --git a/Tests/CompileFeatures/cxx_right_angle_brackets.cpp b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp
new file mode 100644
index 0000000..2713fd8
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp
@@ -0,0 +1,12 @@
+
+template<typename T>
+struct A
+{
+  typedef T Result;
+};
+
+void someFunc()
+{
+  A<A<int>> object;
+  (void)object;
+}
diff --git a/Tests/CompileFeatures/cxx_rvalue_references.cpp b/Tests/CompileFeatures/cxx_rvalue_references.cpp
new file mode 100644
index 0000000..787026a
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_rvalue_references.cpp
@@ -0,0 +1,5 @@
+
+void someFunc(int&&)
+{
+
+}
diff --git a/Tests/CompileFeatures/cxx_sizeof_member.cpp b/Tests/CompileFeatures/cxx_sizeof_member.cpp
new file mode 100644
index 0000000..ae143d2
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_sizeof_member.cpp
@@ -0,0 +1,10 @@
+
+struct A
+{
+  int m_i;
+};
+
+int someFunc()
+{
+  return sizeof(A::m_i) > 0 ? 1 : 2;
+}
diff --git a/Tests/CompileFeatures/cxx_static_assert.cpp b/Tests/CompileFeatures/cxx_static_assert.cpp
new file mode 100644
index 0000000..6aa8678
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_static_assert.cpp
@@ -0,0 +1,2 @@
+
+static_assert(true, "static_assert test");
diff --git a/Tests/CompileFeatures/cxx_strong_enums.cpp b/Tests/CompileFeatures/cxx_strong_enums.cpp
new file mode 100644
index 0000000..6262456
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_strong_enums.cpp
@@ -0,0 +1,7 @@
+
+enum class Colors
+{
+  RedColor,
+  GreenColor,
+  BlueColor
+};
diff --git a/Tests/CompileFeatures/cxx_template_template_parameters.cpp b/Tests/CompileFeatures/cxx_template_template_parameters.cpp
new file mode 100644
index 0000000..0fdd18d
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_template_template_parameters.cpp
@@ -0,0 +1,18 @@
+
+template<template <typename> class T, typename U>
+void someFunc(T<U>)
+{
+
+}
+
+template<typename T>
+struct A
+{
+
+};
+
+void otherFunc()
+{
+  A<int> a;
+  someFunc(a);
+}
diff --git a/Tests/CompileFeatures/cxx_thread_local.cpp b/Tests/CompileFeatures/cxx_thread_local.cpp
new file mode 100644
index 0000000..1fb27e2
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_thread_local.cpp
@@ -0,0 +1,2 @@
+
+thread_local unsigned int rage = 1;
diff --git a/Tests/CompileFeatures/cxx_trailing_return_types.cpp b/Tests/CompileFeatures/cxx_trailing_return_types.cpp
new file mode 100644
index 0000000..01a76cb
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_trailing_return_types.cpp
@@ -0,0 +1,5 @@
+
+auto someFunc() -> int
+{
+  return 42;
+}
diff --git a/Tests/CompileFeatures/cxx_unicode_literals.cpp b/Tests/CompileFeatures/cxx_unicode_literals.cpp
new file mode 100644
index 0000000..a7b7df0
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_unicode_literals.cpp
@@ -0,0 +1,3 @@
+
+const char16_t lit_16[] = u"\u00DA";
+const char32_t lit_32[] = U"\u00DA";
diff --git a/Tests/CompileFeatures/cxx_uniform_initialization.cpp b/Tests/CompileFeatures/cxx_uniform_initialization.cpp
new file mode 100644
index 0000000..82c76e2
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_uniform_initialization.cpp
@@ -0,0 +1,9 @@
+struct A {};
+struct B {
+  B(A) {}
+};
+
+void Func()
+{
+  B b{A{}};
+}
diff --git a/Tests/CompileFeatures/cxx_unrestricted_unions.cpp b/Tests/CompileFeatures/cxx_unrestricted_unions.cpp
new file mode 100644
index 0000000..698fd61
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_unrestricted_unions.cpp
@@ -0,0 +1,11 @@
+
+struct point {
+  point() {}
+  point(int x, int y) : x_(x), y_(y) {}
+  int x_, y_;
+};
+union u {
+  point p_;
+  int i_;
+  const char* s_;
+};
diff --git a/Tests/CompileFeatures/cxx_user_literals.cpp b/Tests/CompileFeatures/cxx_user_literals.cpp
new file mode 100644
index 0000000..9e5a588
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_user_literals.cpp
@@ -0,0 +1,7 @@
+
+long double operator "" _meters(long double);
+
+void someFunc()
+{
+  long double i = 1.2_meters;
+}
diff --git a/Tests/CompileFeatures/cxx_variable_templates.cpp b/Tests/CompileFeatures/cxx_variable_templates.cpp
new file mode 100644
index 0000000..5d4bdbc
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_variable_templates.cpp
@@ -0,0 +1,10 @@
+
+template<typename T>
+constexpr T pi = T(3.1415926535897932385);
+
+int someFunc()
+{
+  auto pi_int = pi<int>;
+  auto pi_float = pi<float>;
+  return pi_int - 3;
+}
diff --git a/Tests/CompileFeatures/cxx_variadic_macros.cpp b/Tests/CompileFeatures/cxx_variadic_macros.cpp
new file mode 100644
index 0000000..4d007a5
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_variadic_macros.cpp
@@ -0,0 +1,12 @@
+
+int someFunc(int, char, int)
+{
+  return 0;
+}
+
+#define FUNC_WRAPPER(...) someFunc(__VA_ARGS__)
+
+void otherFunc()
+{
+  FUNC_WRAPPER(42, 'a', 7);
+}
diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp
new file mode 100644
index 0000000..1d5a706
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp
@@ -0,0 +1,65 @@
+template<int I, int... Is>
+struct Interface;
+
+template<int I>
+struct Interface<I>
+{
+  static int accumulate()
+  {
+    return I;
+  }
+};
+
+template<int I, int... Is>
+struct Interface
+{
+  static int accumulate()
+  {
+    return I + Interface<Is...>::accumulate();
+  }
+};
+
+// Note: split this into a separate test if a
+// cxx_variadic_template_template_parameters feature is added.
+
+template<typename T>
+struct eval {
+  enum {
+    Matched = 0
+  };
+};
+
+template<template<typename...> class T, typename... U>
+struct eval<T<U...> > {
+  enum {
+    Matched = 1
+  };
+};
+
+template<typename...>
+struct A {
+
+};
+template<typename T>
+struct B {
+
+};
+template<typename T, typename U>
+struct C {
+
+};
+template<typename T, typename U, typename...>
+struct D {
+
+};
+
+// Note: This test assumes that a compiler supporting this feature
+// supports static_assert. Add a workaround if that does not hold.
+static_assert(eval<A<> >::Matched, "A Matches");
+static_assert(eval<A<int> >::Matched, "A Matches");
+static_assert(eval<A<int, char> >::Matched, "A Matches");
+static_assert(eval<B<int> >::Matched, "B Matches");
+static_assert(eval<C<int, char> >::Matched, "C Matches");
+static_assert(eval<D<int, char> >::Matched, "D Matches");
+static_assert(eval<D<int, char, bool> >::Matched, "D Matches");
+static_assert(eval<D<int, char, bool, double> >::Matched, "D Matches");
diff --git a/Tests/CompileFeatures/feature_test.cpp b/Tests/CompileFeatures/feature_test.cpp
new file mode 100644
index 0000000..4406c16
--- /dev/null
+++ b/Tests/CompileFeatures/feature_test.cpp
@@ -0,0 +1,10 @@
+
+#define STRINGIFY_IMPL(X) #X
+#define STRINGIFY(X) STRINGIFY_IMPL(X)
+
+#include STRINGIFY(TEST)
+
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp
new file mode 100644
index 0000000..ca38883
--- /dev/null
+++ b/Tests/CompileFeatures/genex_test.cpp
@@ -0,0 +1,21 @@
+
+#if !HAVE_OVERRIDE_CONTROL
+#error "Expect override control feature"
+#else
+
+struct A
+{
+  virtual int getA() { return 7; }
+};
+
+struct B final : A
+{
+  int getA() override { return 42; }
+};
+
+#endif
+
+int main()
+{
+
+}
diff --git a/Tests/CompileFeatures/main.c b/Tests/CompileFeatures/main.c
new file mode 100644
index 0000000..831c5eb2
--- /dev/null
+++ b/Tests/CompileFeatures/main.c
@@ -0,0 +1,12 @@
+
+int foo(int * restrict a, int * restrict b)
+{
+  (void)a;
+  (void)b;
+  return 0;
+}
+
+int main()
+{
+  return 0;
+}
diff --git a/Tests/CompileFeatures/main.cpp b/Tests/CompileFeatures/main.cpp
new file mode 100644
index 0000000..3a8e0fc
--- /dev/null
+++ b/Tests/CompileFeatures/main.cpp
@@ -0,0 +1,6 @@
+
+int main(int,char**)
+{
+  auto value = 0;
+  return value;
+}
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index fcde44d..222250c 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -36,7 +36,7 @@
 #
 macro(TEST_ARGC value1 value2)
   add_definitions(${value1} ${value2})
-  if (${ARGC} MATCHES 4)
+  if (${ARGC} EQUAL 4)
     add_definitions(${ARGV2} ${ARGV3})
   endif ()
 endmacro()
@@ -70,7 +70,7 @@
   message(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4")
 endif()
 
-if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-V")
   if(NOT CMAKE_COMPILER_IS_GNUCXX)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
   endif()
@@ -83,6 +83,14 @@
   PROPERTY COMPILE_DEFINITIONS_RELEASE
   CMAKE_IS_FUN_IN_RELEASE_MODE
   )
+set_property(DIRECTORY
+  PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO
+  CMAKE_IS_FUN_IN_RELEASE_MODE
+  )
+set_property(DIRECTORY
+  PROPERTY COMPILE_DEFINITIONS_MINSIZEREL
+  CMAKE_IS_FUN_IN_RELEASE_MODE
+  )
 
 set(TEST_SEP "a b c")
 separate_arguments(TEST_SEP)
@@ -392,6 +400,21 @@
     "string(REGEX REPLACE ... ) test failed (\"${RESULT}\" v. \"a[b]c[d]e\")")
 endif()
 
+#
+# This tests needs Ansi C++98
+#
+set(CMAKE_CXX_STANDARD 98)
+#
+# GNU extensions are needed for stricmp() on Windows.
+#
+set(CMAKE_CXX_EXTENSIONS TRUE)
+
+# Those versions of the HP compiler that need a flag to get proper C++98
+# template support also need a flag to use the newer C++ library.
+if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
+    CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
+endif ()
 
 #
 # Create the libs and the main exe
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index a4a0e0e..3f17dcc 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -36,7 +36,7 @@
 #
 macro(TEST_ARGC value1 value2)
   add_definitions(${value1} ${value2})
-  if (${ARGC} MATCHES 4)
+  if (${ARGC} EQUAL 4)
     add_definitions(${ARGV2} ${ARGV3})
   endif ()
 endmacro()
@@ -70,7 +70,7 @@
   message(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4")
 endif()
 
-if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-V")
   if(NOT CMAKE_COMPILER_IS_GNUCXX)
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
   endif()
@@ -83,6 +83,14 @@
   PROPERTY COMPILE_DEFINITIONS_RELEASE
   CMAKE_IS_FUN_IN_RELEASE_MODE
   )
+set_property(DIRECTORY
+  PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO
+  CMAKE_IS_FUN_IN_RELEASE_MODE
+  )
+set_property(DIRECTORY
+  PROPERTY COMPILE_DEFINITIONS_MINSIZEREL
+  CMAKE_IS_FUN_IN_RELEASE_MODE
+  )
 
 set(TEST_SEP "a b c")
 separate_arguments(TEST_SEP)
@@ -362,6 +370,21 @@
     "string(REGEX REPLACE ... ) test failed (\"${RESULT}\" v. \"a[b]c[d]e\")")
 endif()
 
+#
+# This tests needs Ansi C++98
+#
+set(CMAKE_CXX_STANDARD 98)
+#
+# GNU extensions are needed for stricmp() on Windows.
+#
+set(CMAKE_CXX_EXTENSIONS TRUE)
+
+# Those versions of the HP compiler that need a flag to get proper C++98
+# template support also need a flag to use the newer C++ library.
+if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
+    CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
+endif ()
 
 #
 # Create the libs and the main exe
diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt
new file mode 100644
index 0000000..c272257
--- /dev/null
+++ b/Tests/ConfigSources/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(ConfigSources)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_SOURCES
+  iface_src.cpp
+  $<$<CONFIG:Debug>:iface_debug_src.cpp>
+  $<$<CONFIG:Release>:does_not_exist.cpp>
+)
+
+add_executable(ConfigSources
+  $<$<CONFIG:Debug>:main.cpp>
+  $<$<CONFIG:Release>:does_not_exist.cpp>
+)
+target_link_libraries(ConfigSources iface)
diff --git a/Tests/ConfigSources/iface_debug.h b/Tests/ConfigSources/iface_debug.h
new file mode 100644
index 0000000..a23d737
--- /dev/null
+++ b/Tests/ConfigSources/iface_debug.h
@@ -0,0 +1,4 @@
+
+int iface_src();
+
+int iface_debug();
diff --git a/Tests/ConfigSources/iface_debug_src.cpp b/Tests/ConfigSources/iface_debug_src.cpp
new file mode 100644
index 0000000..63b22fc
--- /dev/null
+++ b/Tests/ConfigSources/iface_debug_src.cpp
@@ -0,0 +1,7 @@
+
+#include "iface_debug.h"
+
+int iface_debug()
+{
+  return 0;
+}
diff --git a/Tests/ConfigSources/iface_src.cpp b/Tests/ConfigSources/iface_src.cpp
new file mode 100644
index 0000000..c3a0c8f
--- /dev/null
+++ b/Tests/ConfigSources/iface_src.cpp
@@ -0,0 +1,5 @@
+
+int iface_src()
+{
+  return 0;
+}
diff --git a/Tests/ConfigSources/main.cpp b/Tests/ConfigSources/main.cpp
new file mode 100644
index 0000000..71af72f
--- /dev/null
+++ b/Tests/ConfigSources/main.cpp
@@ -0,0 +1,7 @@
+
+#include "iface_debug.h"
+
+int main(int argc, char** argv)
+{
+  return iface_src() + iface_debug();
+}
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index bbae387..b97cd16 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -185,7 +185,7 @@
 # here to test adding the generation rule after referencing the
 # generated source in a target.
 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/generated.c
-  DEPENDS generator
+  DEPENDS $<1:generator> $<0:does_not_exist>
   COMMAND generator
   ARGS ${PROJECT_BINARY_DIR}/generated.c
   )
@@ -221,8 +221,11 @@
 
 add_executable(tcat tcat.cxx)
 
+# Test that list expansion from a generator expression works.
+set_property(TARGET tcat PROPERTY DEPSLIST tcat gen_redirect_in.c)
+
 add_custom_command(OUTPUT gen_redirect.c
-  DEPENDS tcat gen_redirect_in.c
+  DEPENDS $<TARGET_PROPERTY:tcat,DEPSLIST>
   COMMAND tcat < ${CMAKE_CURRENT_SOURCE_DIR}/gen_redirect_in.c > gen_redirect.c
   COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> gen_redirect.c
   VERBATIM
@@ -364,8 +367,8 @@
 
 foreach(arg ${CHECK_ARGS} "")
   set(ARG "${arg}")
-  string(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}")
-  string(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}")
+  string(REPLACE "\\" "\\\\" ARG "${ARG}")
+  string(REPLACE "\"" "\\\"" ARG "${ARG}")
   set(EXPECTED_ARGUMENTS
     "${EXPECTED_ARGUMENTS}  \"${ARG}\",
 ")
@@ -453,3 +456,30 @@
 set_property(SOURCE source_in_custom_target
   PROPERTY COMPILE_DEFINITIONS "TEST"
 )
+
+set(gen_path "${CMAKE_CURRENT_BINARY_DIR}//./foo")
+set(gen_file "${gen_path}/foo.cxx")
+
+add_custom_command(
+  OUTPUT "${gen_file}"
+  # Make sure the output directory exists before trying to write to it.
+  COMMAND ${CMAKE_COMMAND} -E make_directory "${gen_path}"
+  COMMAND ${CMAKE_COMMAND} -E touch "${gen_file}"
+)
+
+add_library(NormOutput "${gen_file}")
+
+set(gen_path "${gen_path}/bar")
+set(gen_file "${gen_path}/bar.cxx")
+
+add_custom_command(
+  OUTPUT "${gen_path}"
+  COMMAND ${CMAKE_COMMAND} -E make_directory "${gen_path}"
+)
+
+add_custom_command(
+  OUTPUT "${gen_file}"
+  DEPENDS "${gen_path}"
+  COMMAND ${CMAKE_COMMAND} -E touch "${gen_file}")
+
+add_library(NormDepends "${gen_file}")
diff --git a/Tests/CxxDialect/CMakeLists.txt b/Tests/CxxDialect/CMakeLists.txt
new file mode 100644
index 0000000..8c90339
--- /dev/null
+++ b/Tests/CxxDialect/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 2.8.12)
+cmake_policy(SET CMP0025 NEW)
+project(CxxDialect)
+
+add_executable(use_typeof use_typeof.cxx)
+set_property(TARGET use_typeof PROPERTY CXX_STANDARD 98)
+
+add_executable(use_constexpr use_constexpr.cxx)
+set_property(TARGET use_constexpr PROPERTY CXX_STANDARD 11)
+
+add_executable(CxxDialect use_constexpr_and_typeof.cxx)
+set_property(TARGET CxxDialect PROPERTY CXX_STANDARD 11)
+
+try_compile(typeof_no_extensions_works
+  "${CMAKE_CURRENT_BINARY_DIR}/use_typeof_test"
+  "${CMAKE_CURRENT_SOURCE_DIR}/use_typeof.cxx"
+  COMPILE_DEFINITIONS
+  CMAKE_FLAGS
+    "-DCMAKE_CXX_STANDARD=98"
+    "-DCMAKE_CXX_EXTENSIONS=FALSE"
+  OUTPUT_VARIABLE OUTPUT
+)
+
+if (typeof_no_extensions_works)
+  message("Use of typeof extension with extensions disabled works, but is expected to fail: ${OUTPUT}")
+else()
+  message("Use of typeof extension with extensions disabled fails, as expected")
+endif()
diff --git a/Tests/CxxDialect/use_constexpr.cxx b/Tests/CxxDialect/use_constexpr.cxx
new file mode 100644
index 0000000..30ccc4c
--- /dev/null
+++ b/Tests/CxxDialect/use_constexpr.cxx
@@ -0,0 +1,10 @@
+
+constexpr int foo()
+{
+  return 0;
+}
+
+int main(int argc, char**)
+{
+  return foo();
+}
diff --git a/Tests/CxxDialect/use_constexpr_and_typeof.cxx b/Tests/CxxDialect/use_constexpr_and_typeof.cxx
new file mode 100644
index 0000000..af217b6
--- /dev/null
+++ b/Tests/CxxDialect/use_constexpr_and_typeof.cxx
@@ -0,0 +1,11 @@
+
+constexpr int foo()
+{
+  return 0;
+}
+
+int main(int argc, char**)
+{
+  typeof(argc) ret = foo();
+  return ret;
+}
diff --git a/Tests/CxxDialect/use_typeof.cxx b/Tests/CxxDialect/use_typeof.cxx
new file mode 100644
index 0000000..dabb61f
--- /dev/null
+++ b/Tests/CxxDialect/use_typeof.cxx
@@ -0,0 +1,6 @@
+
+int main(int argc, char**)
+{
+  typeof(argc) ret = 0;
+  return ret;
+}
diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt
index 02a0371..a6f8921 100644
--- a/Tests/ExportImport/CMakeLists.txt
+++ b/Tests/ExportImport/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 2.7.20090711)
 project(ExportImport C CXX)
-if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
-  set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
+if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+  set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
 endif()
 
 # Wipe out the install tree to make sure the exporter works.
diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt
index 9d4793d..523fc29 100644
--- a/Tests/ExportImport/Export/Interface/CMakeLists.txt
+++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt
@@ -23,7 +23,13 @@
 add_library(sharediface INTERFACE)
 target_link_libraries(sharediface INTERFACE sharedlib)
 
-install(TARGETS headeronly sharediface
+add_library(use_auto_type INTERFACE)
+target_compile_features(use_auto_type INTERFACE cxx_auto_type)
+
+add_library(use_c_restrict INTERFACE)
+target_compile_features(use_c_restrict INTERFACE c_restrict)
+
+install(TARGETS headeronly sharediface use_auto_type use_c_restrict
   EXPORT expInterface
 )
 install(TARGETS sharedlib
diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt
index 5e809a2..189f7a2 100644
--- a/Tests/ExportImport/Import/CMakeLists.txt
+++ b/Tests/ExportImport/Import/CMakeLists.txt
@@ -1,4 +1,5 @@
 cmake_minimum_required (VERSION 2.7.20090711)
+cmake_policy(SET CMP0025 NEW)
 project(Import C CXX)
 
 # Import everything in a subdirectory.
diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt
index cf7e2bc..4028405 100644
--- a/Tests/ExportImport/Import/Interface/CMakeLists.txt
+++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt
@@ -17,6 +17,7 @@
 add_executable(interfacetest_bld interfacetest.cpp)
 target_link_libraries(interfacetest_bld bld::sharediface)
 
+include(CheckCSourceCompiles)
 include(CheckCXXSourceCompiles)
 
 macro(do_try_compile prefix)
@@ -40,6 +41,43 @@
   if(NOT ${prefix}IFACE_TRY_COMPILE)
     message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
   endif()
+
+  if (";${CMAKE_C_COMPILE_FEATURES};" MATCHES ";c_restrict;")
+    set(CMAKE_REQUIRED_LIBRARIES ${prefix}::use_c_restrict)
+    check_c_source_compiles(
+      "
+    int foo(int * restrict a, int * restrict b)
+    {
+      (void)a;
+      (void)b;
+      return 0;
+    }
+    int main()
+    {
+      return 0;
+    }
+    " ${prefix}IMPORTED_IFACE_C_RESTRICT)
+
+    if(NOT ${prefix}IMPORTED_IFACE_C_RESTRICT)
+      message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
+    endif()
+  endif()
+  if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_auto_type;")
+    set(CMAKE_REQUIRED_LIBRARIES ${prefix}::use_auto_type)
+    check_cxx_source_compiles(
+      "
+    int main(int,char**)
+    {
+      auto value = 0;
+      return value;
+    }
+    " ${prefix}IMPORTED_IFACE_AUTO_TYPE)
+
+    if(NOT ${prefix}IMPORTED_IFACE_AUTO_TYPE)
+      message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
+    endif()
+  endif()
+
 endmacro()
 
 do_try_compile(bld)
diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in
index fba6ee2..f600d90 100644
--- a/Tests/ExportImport/InitialCache.cmake.in
+++ b/Tests/ExportImport/InitialCache.cmake.in
@@ -1,4 +1,4 @@
-set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program")
+set(CMAKE_MAKE_PROGRAM "@CMake_TEST_NESTED_MAKE_PROGRAM@" CACHE FILEPATH "Make Program")
 set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler")
 set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags")
 set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags")
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index d9344ec..0ed5561 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -98,6 +98,7 @@
   CVS_TAG ""
   DEPENDS "MinimalNoOpProject" NonExternalProjectTarget
   DOWNLOAD_COMMAND ""
+  DOWNLOAD_NO_PROGRESS 1
   INSTALL_COMMAND ""
   PATCH_COMMAND ""
   STEP_TARGETS install update
diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
index b6f848a..ea59a8e 100644
--- a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
+++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
@@ -12,7 +12,7 @@
 
   # Configure
   execute_process(COMMAND ${CMAKE_COMMAND}
-    -G ${CMAKE_TEST_GENERATOR} -T "${CMAKE_TEST_GENERATOR_TOOLSET}"
+    -G ${CMAKE_GENERATOR} -T "${CMAKE_GENERATOR_TOOLSET}"
     -DTEST_GIT_TAG:STRING=${desired_tag}
     ${ExternalProjectUpdate_SOURCE_DIR}
     WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}
diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt
index 5d1b376..8e21c32 100644
--- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt
+++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt
@@ -10,7 +10,7 @@
                   ERROR_QUIET
                   TIMEOUT 10)
   string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT)
-  if("${MAKE_VERSION_OUTPUT}" MATCHES ".*GNU MAKE.*")
+  if("${MAKE_VERSION_OUTPUT}" MATCHES "GNU MAKE")
 
     # build a library which we can search during the test
     add_library(foo STATIC foo.cpp)
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index a77713f..092bf20 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -320,18 +320,55 @@
 
 #-----------------------------------------------------------------------------
 # Test export(PACKAGE) with find_package.
+
+# Choose a unique version.
+string(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION})
+string(RANDOM LENGTH 4 ALPHABET "0123456789" v)
+set(version "${version}.${v}")
+
 message(STATUS "Preparing export(PACKAGE) test project")
 try_compile(EXPORTER_COMPILED
-  ${FindPackageTest_BINARY_DIR}/Exporter
+  ${FindPackageTest_BINARY_DIR}/Exporter-build
   ${FindPackageTest_SOURCE_DIR}/Exporter
   CMakeTestExportPackage dummy
+  CMAKE_FLAGS "-UCMAKE_EXPORT_NO_PACKAGE_REGISTRY"
+    -Dversion=${version}
   OUTPUT_VARIABLE output)
 message(STATUS "Searching for export(PACKAGE) test project")
 set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
   "Wipe out find results for testing." FORCE)
-string(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION})
 find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
 
+message(STATUS "Searching for export(PACKAGE) test project with CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=TRUE")
+set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY TRUE)
+set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
+  "Wipe out find results for testing." FORCE)
+find_package(CMakeTestExportPackage  1.${version} EXACT QUIET)
+if(CMakeTestExportPackage_FOUND)
+  message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!")
+endif()
+unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY)
+
+message(STATUS "Remove export(PACKAGE) test project")
+file(REMOVE_RECURSE ${FindPackageTest_BINARY_DIR}/Exporter-build)
+set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
+  "Wipe out find results for testing." FORCE)
+find_package(CMakeTestExportPackage QUIET) # Should clean the user package cache
+#
+message(STATUS "Preparing export(PACKAGE) test project with CMAKE_EXPORT_NO_PACKAGE_REGISTRY=TRUE")
+try_compile(EXPORTER_COMPILED
+  ${FindPackageTest_BINARY_DIR}/Exporter-build
+  ${FindPackageTest_SOURCE_DIR}/Exporter
+  CMakeTestExportPackage dummy
+  CMAKE_FLAGS "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY:BOOL=TRUE"
+    -Dversion=${version}
+  OUTPUT_VARIABLE output)
+message(STATUS "Searching for export(PACKAGE) test project")
+find_package(CMakeTestExportPackage 1.${version} EXACT QUIET)
+if(CMakeTestExportPackage_FOUND)
+  message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!")
+endif()
+
 #-----------------------------------------------------------------------------
 # Test configure_package_config_file().
 
diff --git a/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in b/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in
index 42bd84e..6eac6e6 100644
--- a/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in
+++ b/Tests/FindPackageTest/Exporter/CMakeTestExportPackageConfigVersion.cmake.in
@@ -1,5 +1,5 @@
 # Test config file.
-set(PACKAGE_VERSION "1.@CMAKE_VERSION@")
+set(PACKAGE_VERSION "1.@version@")
 if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "${PACKAGE_VERSION}")
   set(PACKAGE_VERSION_COMPATIBLE 1)
   set(PACKAGE_VERSION_EXACT 1)
diff --git a/Tests/FindPackageTest/FindLotsOfComponents.cmake b/Tests/FindPackageTest/FindLotsOfComponents.cmake
index 9076d86..5d959c5 100644
--- a/Tests/FindPackageTest/FindLotsOfComponents.cmake
+++ b/Tests/FindPackageTest/FindLotsOfComponents.cmake
@@ -4,7 +4,7 @@
 set(LotsOfComponents_BComp_FOUND FALSE)
 set(LotsOfComponents_CComp_FOUND TRUE)
 
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
 
 find_package_handle_standard_args(LotsOfComponents REQUIRED_VARS LOC_FOO
                                                    HANDLE_COMPONENTS)
diff --git a/Tests/FindPackageTest/FindSomePackage.cmake b/Tests/FindPackageTest/FindSomePackage.cmake
index 83d1d0e..7283d24 100644
--- a/Tests/FindPackageTest/FindSomePackage.cmake
+++ b/Tests/FindPackageTest/FindSomePackage.cmake
@@ -1,6 +1,6 @@
 set(SOP_FOO TRUE)
 
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
 
 find_package_handle_standard_args(SomePackage REQUIRED_VARS SOP_FOO
                                               FOUND_VAR SomePackage_FOUND )
diff --git a/Tests/FindPackageTest/FindUpperCasePackage.cmake b/Tests/FindPackageTest/FindUpperCasePackage.cmake
index 66c2fea..425d417 100644
--- a/Tests/FindPackageTest/FindUpperCasePackage.cmake
+++ b/Tests/FindPackageTest/FindUpperCasePackage.cmake
@@ -1,6 +1,6 @@
 set(UCP_FOO TRUE)
 
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
 
 find_package_handle_standard_args(UpperCasePackage REQUIRED_VARS UCP_FOO
                                                    FOUND_VAR UPPERCASEPACKAGE_FOUND )
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index 7918129..ef3b317 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/Tests/Fortran/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 3.0)
 project(testf C CXX Fortran)
-if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
-  set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
+if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+  set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
 endif()
 
 message("CTEST_FULL_OUTPUT ")
@@ -208,7 +208,7 @@
                          -DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}
                          -DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL}
                          -DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO}
-                         -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}
+                         -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_NESTED_MAKE_PROGRAM}
                          ${External_BUILD_TYPE}
     VERBATIM
     )
diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in
index 3436309..28c38e4 100644
--- a/Tests/FortranC/Flags.cmake.in
+++ b/Tests/FortranC/Flags.cmake.in
@@ -14,8 +14,8 @@
 
 execute_process(
   WORKING_DIRECTORY "${bld}"
-  COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@"
-                           -T "@CMAKE_TEST_GENERATOR_TOOLSET@"
+  COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_GENERATOR@"
+                           -T "@CMAKE_GENERATOR_TOOLSET@"
                            "-DFortranC_TEST_FLAGS=1"
                            "-DCMAKE_C_COMPILER=${bld}/cc.sh"
                            "-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@"
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index a0e34ef..758165c 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -166,7 +166,7 @@
 set_property(TARGET imported4 APPEND PROPERTY
   INCLUDE_DIRECTORIES $<TARGET_PROPERTY:imported3,INTERFACE_INCLUDE_DIRECTORIES>)
 
-add_executable(someexe empty.cpp)
+add_executable(someexe $<1:empty.cpp> $<0:does_not_exist>)
 add_executable(Alias::SomeExe ALIAS someexe)
 
 add_library(Alias::SomeLib ALIAS empty1)
diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt
index 5c7b921..eeb3653 100644
--- a/Tests/MacRuntimePath/CMakeLists.txt
+++ b/Tests/MacRuntimePath/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required (VERSION 2.8)
 project(MacRuntimePath)
-if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
-  set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
+if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+  set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
 endif()
 
 # Wipe out the install tree to make sure the exporter works.
diff --git a/Tests/MacRuntimePath/InitialCache.cmake.in b/Tests/MacRuntimePath/InitialCache.cmake.in
index 3dc9041..a9f6a3c 100644
--- a/Tests/MacRuntimePath/InitialCache.cmake.in
+++ b/Tests/MacRuntimePath/InitialCache.cmake.in
@@ -1,4 +1,4 @@
-set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program")
+set(CMAKE_MAKE_PROGRAM "@CMake_TEST_NESTED_MAKE_PROGRAM@" CACHE FILEPATH "Make Program")
 set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler")
 set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags")
 set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags")
diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt
index 5a6f3d5..ebca48e 100644
--- a/Tests/Module/ExternalData/CMakeLists.txt
+++ b/Tests/Module/ExternalData/CMakeLists.txt
@@ -23,6 +23,8 @@
   COMMAND ${CMAKE_COMMAND}
     -D Data=DATA{Data.dat}
     ${Data1CheckSpaces}
+    -D DataMissing=DATA{DataMissing.dat}
+    -D DataMissingWithAssociated=DATA{DataMissing.dat,Data.dat}
     -D SeriesA=DATA{SeriesA.dat,:}
     -D SeriesB=DATA{SeriesB.dat,:}
     -D SeriesC=DATA{SeriesC.dat,:}
diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake
index 5770245..485b5c6 100644
--- a/Tests/Module/ExternalData/Data1Check.cmake
+++ b/Tests/Module/ExternalData/Data1Check.cmake
@@ -8,6 +8,28 @@
     message(SEND_ERROR "Input file:\n  ${DataSpace}\ndoes not have expected content, but [[${lines}]]")
   endif()
 endif()
+if(DataMissing)
+  if(EXISTS "${DataMissing}")
+    message(SEND_ERROR
+      "Input file:\n"
+      "  ${DataMissing}\n"
+      "exists but should not."
+      )
+  endif()
+else()
+  message(SEND_ERROR "DataMissing is not set!")
+endif()
+if(DataMissingWithAssociated)
+  if(EXISTS "${DataMissingWithAssociated}")
+    message(SEND_ERROR
+      "Input file:\n"
+      "  ${DataMissingWithAssociated}\n"
+      "exists but should not."
+      )
+  endif()
+else()
+  message(SEND_ERROR "DataMissingWithAssociated is not set!")
+endif()
 set(SeriesAn1 "1\\.dat")
 set(SeriesBn1 "_1\\.dat")
 set(SeriesCn1 "\\.1\\.dat")
diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt
new file mode 100644
index 0000000..dcb998a
--- /dev/null
+++ b/Tests/Module/FindDependency/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+cmake_minimum_required(VERSION 3.0)
+project(FindDependency)
+
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages")
+
+find_package(Pack1 REQUIRED)
+find_package(Pack4 4.3 EXACT REQUIRED)
+
+add_executable(FindDependency main.cpp)
+target_link_libraries(FindDependency Pack1::Lib Pack4::Lib)
diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp
new file mode 100644
index 0000000..50c5958
--- /dev/null
+++ b/Tests/Module/FindDependency/main.cpp
@@ -0,0 +1,29 @@
+
+#ifndef HAVE_PACK1
+#error Expected HAVE_PACK1
+#endif
+
+#ifndef HAVE_PACK2
+#error Expected HAVE_PACK2
+#endif
+
+#ifndef HAVE_PACK3
+#error Expected HAVE_PACK3
+#endif
+
+#ifndef HAVE_PACK4
+#error Expected HAVE_PACK4
+#endif
+
+#ifndef HAVE_PACK5
+#error Expected HAVE_PACK5
+#endif
+
+#ifndef HAVE_PACK6
+#error Expected HAVE_PACK6
+#endif
+
+int main(int argc, char** argv)
+{
+  return 0;
+}
diff --git a/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake b/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake
new file mode 100644
index 0000000..ff533c2
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake
@@ -0,0 +1,9 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack2 2.3)
+find_dependency(Pack3)
+
+add_library(Pack1::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack1::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK1)
+set_property(TARGET Pack1::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack2::Lib Pack3::Lib)
diff --git a/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake
new file mode 100644
index 0000000..dfb7b6c
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "1.3")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake b/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake
new file mode 100644
index 0000000..672288e
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake
@@ -0,0 +1,5 @@
+
+set(PACK2_VAR ON)
+
+add_library(Pack2::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack2::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK2)
diff --git a/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake
new file mode 100644
index 0000000..42f58c0
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "2.4")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake b/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake
new file mode 100644
index 0000000..25c32f3
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake
@@ -0,0 +1,5 @@
+
+set(PACK3_VAR ON)
+
+add_library(Pack3::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack3::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK3)
diff --git a/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake
new file mode 100644
index 0000000..870f747
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "1.4")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake
new file mode 100644
index 0000000..62fddb1
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake
@@ -0,0 +1,9 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack5 3.1) # Actual version is 3.3. EXACT not propagated.
+find_dependency(Pack6 5.5 EXACT)
+
+add_library(Pack4::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack4::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK4)
+set_property(TARGET Pack4::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack5::Lib Pack6::Lib)
diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake
new file mode 100644
index 0000000..ae982b0
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "4.3")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake
new file mode 100644
index 0000000..1edda9a
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake
@@ -0,0 +1,3 @@
+
+add_library(Pack5::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack5::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK5)
diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake
new file mode 100644
index 0000000..e944f96
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "3.3")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake
new file mode 100644
index 0000000..d6c85fb
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake
@@ -0,0 +1,3 @@
+
+add_library(Pack6::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack6::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK6)
diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake
new file mode 100644
index 0000000..0dd00d2
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "5.5")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt
index bf867a9..b52c44d 100644
--- a/Tests/Module/GenerateExportHeader/CMakeLists.txt
+++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt
@@ -57,6 +57,15 @@
 
 include(GenerateExportHeader)
 
+set(CMAKE_CXX_STANDARD 98)
+
+# Those versions of the HP compiler that need a flag to get proper C++98
+# template support also need a flag to use the newer C++ library.
+if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
+    CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
+endif ()
+
 add_subdirectory(lib_shared_and_static)
 
 add_compiler_export_flags()
diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
new file mode 100644
index 0000000..ab0ebc3
--- /dev/null
+++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
@@ -0,0 +1,81 @@
+cmake_minimum_required(VERSION 3.0.0)
+project(WriteCompilerDetectionHeader)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+include(WriteCompilerDetectionHeader)
+
+get_property(cxx_known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
+get_property(c_known_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
+
+write_compiler_detection_header(
+  FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h"
+  PREFIX TEST
+  COMPILERS GNU Clang
+  VERSION 3.1
+  PROLOG "// something"
+  EPILOG "// more"
+  FEATURES
+    ${cxx_known_features} ${c_known_features}
+)
+
+if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES)
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp"
+    "int main(int,char**) { return 0; }\n"
+  )
+  add_executable(WriteCompilerDetectionHeader "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp")
+
+  include(CheckCXXSourceCompiles)
+  check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h\"\nint main() { return 0; }\n"
+    file_include_works
+  )
+  if (file_include_works)
+    message(SEND_ERROR "Inclusion of ${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h was expected to cause an error, but did not.")
+  endif()
+  return()
+endif()
+
+macro(set_defines target true_defs false_defs)
+  set(defines)
+  foreach(def ${true_defs})
+    list(APPEND defines ${def}=1)
+  endforeach()
+  foreach(def ${false_defs})
+    list(APPEND defines ${def}=0)
+  endforeach()
+  target_compile_definitions(${target}
+    PRIVATE
+      ${defines}
+  )
+endmacro()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL GNU
+    OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
+  # False for C++98 mode.
+  list(APPEND false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
+  list(APPEND false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
+endif()
+
+add_executable(WriteCompilerDetectionHeader main.cpp)
+set_property(TARGET WriteCompilerDetectionHeader PROPERTY CXX_STANDARD 98)
+set_defines(WriteCompilerDetectionHeader "${true_defs}" "${false_defs}")
+
+if(MSVC)
+  return() # MSVC has only one mode.
+endif()
+
+# Since GNU 4.7
+if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;")
+  list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
+  list(REMOVE_ITEM false_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
+endif()
+
+# Since GNU 4.4
+if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_variadic_templates;")
+  list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
+  list(REMOVE_ITEM false_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
+endif()
+
+add_executable(WriteCompilerDetectionHeader_11 main.cpp)
+set_property(TARGET WriteCompilerDetectionHeader_11 PROPERTY CXX_STANDARD 11)
+set_defines(WriteCompilerDetectionHeader_11 "${true_defs}" "${false_defs}")
diff --git a/Tests/Module/WriteCompilerDetectionHeader/main.cpp b/Tests/Module/WriteCompilerDetectionHeader/main.cpp
new file mode 100644
index 0000000..8b4ea52
--- /dev/null
+++ b/Tests/Module/WriteCompilerDetectionHeader/main.cpp
@@ -0,0 +1,19 @@
+
+#include "test_compiler_detection.h"
+
+#define JOIN_IMPL(A, B) A ## B
+#define JOIN(A, B) JOIN_IMPL(A, B)
+#define CHECK(FEATURE) (JOIN(TEST_COMPILER_, FEATURE) == JOIN(EXPECTED_COMPILER_, FEATURE))
+
+#if !CHECK(CXX_DELEGATING_CONSTRUCTORS)
+#error cxx_delegating_constructors expected availability did not match.
+#endif
+
+#if !CHECK(CXX_VARIADIC_TEMPLATES)
+#error cxx_variadic_templates expected availability did not match.
+#endif
+
+int main()
+{
+  return 0;
+}
diff --git a/Tests/MumpsCoverage/Accounts_ReceivableTest.cmcov b/Tests/MumpsCoverage/Accounts_ReceivableTest.cmcov
deleted file mode 100644
index c3b3342..0000000
--- a/Tests/MumpsCoverage/Accounts_ReceivableTest.cmcov
+++ /dev/null
@@ -1,304 +0,0 @@
-Routine,Line,RtnLine,Code

-DDIOL,1,0,"DDIOL ;SFISC/MKO-THE LOADER ;1:53 PM  12 Sep 1995"

-,2,0," ;;22.0;VA FileMan;;Mar 30, 1999"

-,3,0," ;Per VHA Directive 10-93-142, this routine should not be modified."

-,4,0," ;"

-,5,0,"EN(A,G,FMT) ;Write the text contained in local array A or global array G"

-,6,0," ;If one string passed, use format FMT"

-,7,0," N %,Y,DINAKED"

-,8,0," S DINAKED=$$LGR^%ZOSV"

-,9,0," ;"

-,10,0," S:'$D(A) A="""""

-,11,0," I $G(A)="""",$D(A)<9,$G(FMT)="""",$G(G)'?1""^""1A.7AN,$G(G)'?1""^""1A.7AN1""("".E1"")"" Q"

-,12,0," ;"

-,13,0," G:$D(DDS) SM"

-,14,0," G:$D(DIQUIET) LD"

-,15,0," ;"

-,16,0," N F,I,S"

-,17,0," I $D(A)=1,$G(G)="""" D"

-,18,0," . S F=$S($G(FMT)]"""":FMT,1:""!"")"

-,19,0," . W @F,A"

-,20,0," ;"

-,21,0," E  I $D(A)>9 S I=0 F  S I=$O(A(I)) Q:I'=+$P(I,""E"")  D"

-,22,0," . S F=$G(A(I,""F""),""!"") S:F="""" F=""?0"""

-,23,0," . W @F,$G(A(I))"

-,24,0," ;"

-,25,0," E  S I=0 F  S I=$O(@G@(I)) Q:I'=+$P(I,""E"")  D"

-,26,0," . S S=$G(@G@(I,0),$G(@G@(I)))"

-,27,0," . S F=$G(@G@(I,""F""),""!"") S:F="""" F=""?0"""

-,28,0," . W @F,S"

-,29,0," ;"

-,30,0," I DINAKED]"""" S DINAKED=$S(DINAKED["""""""""""":$O(@DINAKED),1:$D(@DINAKED))"

-,31,0," Q"

-,32,0," ;"

-,33,0,"LD ;Load text into ^TMP"

-,34,0," N I,N,T"

-,35,0," S T=$S($G(DDIOLFLG)[""H"":""DIHELP"",1:""DIMSG"")"

-,36,0," S N=$O(^TMP(T,$J,"" ""),-1)"

-,37,0," ;"

-,38,0," I $D(A)=1,$G(G)="""" D"

-,39,0," . D LD1(A,$S($G(FMT)]"""":FMT,1:""!""))"

-,40,0," ;"

-,41,0," E  I $D(A)>9 S I=0 F  S I=$O(A(I)) Q:I'=+$P(I,""E"")  D"

-,42,0," . D LD1($G(A(I)),$G(A(I,""F""),""!""))"

-,43,0," ;"

-,44,0," E  S I=0 F  S I=$O(@G@(I)) Q:I'=+$P(I,""E"")  D"

-,45,0," . D LD1($G(@G@(I),$G(@G@(I,0))),$G(@G@(I,""F""),""!""))"

-,46,0," ;"

-,47,0," K:'N @T S:N @T=N"

-,48,0," I DINAKED]"""" S DINAKED=$S(DINAKED["""""""""""":$O(@DINAKED),1:$D(@DINAKED))"

-,49,0," Q"

-,50,0," ;"

-,51,0,"LD1(S,F) ;Load string S, with format F"

-,52,0," ;In: N and T"

-,53,0," N C,J,L"

-,54,0," S:S[$C(7) S=$TR(S,$C(7),"""")"

-,55,0," F J=1:1:$L(F,""!"")-1 S N=N+1,^TMP(T,$J,N)="""""

-,56,0," S:'N N=1"

-,57,0," S:F[""?"" @(""C=""_$P(F,""?"",2))"

-,58,0," S L=$G(^TMP(T,$J,N))"

-,59,0," S ^TMP(T,$J,N)=L_$J("""",$G(C)-$L(L))_S"

-,60,0," Q"

-,61,0," ;"

-,62,0,"SM ;Print text in ScreenMan's Command Area"

-,63,0," I $D(DDSID),$D(DTOUT)!$D(DUOUT) G SMQ"

-,64,0," N DDIOL"

-,65,0," S DDIOL=1"

-,66,0," ;"

-,67,0," I $D(A)=1&($G(G)="""")!($D(A)>9) D"

-,68,0," . D MSG^DDSMSG(.A,"""",$G(FMT))"

-,69,0," E  I $D(@G@(+$O(@G@(0)),0))#2 D"

-,70,0," . D WP^DDSMSG(G)"

-,71,0," E  D HLP^DDSMSG(G)"

-,72,0," ;"

-,73,0,"SMQ I DINAKED]"""" S DINAKED=$S(DINAKED["""""""""""":$O(@DINAKED),1:$D(@DINAKED))"

-,74,0," Q"

-Totals for DDIOL,,0,

-XINDEX,1,0,"XINDEX ;ISC/REL,GFT,GRK,RWF - INDEX & CROSS-REFERENCE ;08/04/08  13:19"

-,2,1," ;;7.3;TOOLKIT;**20,27,48,61,66,68,110,121,128**;Apr 25, 1995;Build 1"

-,3,0," ; Per VHA Directive 2004-038, this routine should not be modified."

-,4,1," G ^XINDX6"

-,5,107216,"SEP F I=1:1 S CH=$E(LIN,I) D QUOTE:CH=Q Q:"" ""[CH"

-,6,107216," S ARG=$E(LIN,1,I-1) S:CH="" "" I=I+1 S LIN=$E(LIN,I,999) Q"

-,7,36371,"QUOTE F I=I+1:1 S CH=$E(LIN,I) Q:CH=""""!(CH=Q)"

-,8,36371," Q:CH]""""  S ERR=6 G ^XINDX1"

-,9,0,"ALIVE ;enter here from taskman"

-,10,1," D SETUP^XINDX7 ;Get ready to process"

-,11,468,"A2 S RTN=$O(^UTILITY($J,RTN)) G ^XINDX5:RTN="""""

-,12,467," S INDLC=(RTN?1""|""1.4L.NP) D LOAD:'INDLC"

-,13,467," I $D(ZTQUEUED),$$S^%ZTLOAD S RTN=""~"",IND(""QUIT"")=1,ZTSTOP=1 G A2"

-,14,467," I 'INDDS,INDLC W !!?10,""Data Dictionaries"",! S INDDS=1"

-,15,467," D BEG"

-,16,467," G A2"

-,17,0," ;"

-,18,467,"LOAD S X=RTN,XCNP=0,DIF=""^UTILITY(""_$J_"",1,RTN,0,"" X ^%ZOSF(""TEST"") Q:'$T  X ^%ZOSF(""LOAD"") S ^UTILITY($J,1,RTN,0,0)=XCNP-1"

-,19,467," I $D(^UTILITY($J,1,RTN,0,0)) S ^UTILITY($J,1,RTN,""RSUM"")=""B""_$$SUMB^XPDRSUM($NA(^UTILITY($J,1,RTN,0)))"

-,20,467," Q"

-,21,0,"BEG ;"

-,22,467," S %=INDLC*5 W:$X+10+%>IOM ! W RTN,$J("""",10+%-$L(RTN))"

-,23,467," S (IND(""DO""),IND(""SZT""),IND(""SZC""),LABO)=0,LC=$G(^UTILITY($J,1,RTN,0,0))"

-,24,467," I LC="""" W !,"">>>Routine '"",RTN,""' not found <<<"",! Q"

-,25,467," S TXT="""",LAB=$P(^UTILITY($J,1,RTN,0,1,0),"" "") I RTN'=$P(LAB,""("") D E^XINDX1(17)"

-,26,467," I 'INDLC,LAB[""("" D E^XINDX1(55) S LAB=$P(LAB,""("")"

-,27,0," ;if M routine(not compiled template or DD) and has more than 2 lines, check lines 1 & 2"

-,28,467," I 'INDLC,LC>2 D"

-,29,467," . N LABO S LABO=1"

-,30,467," . S LIN=$G(^UTILITY($J,1,RTN,0,1,0)),TXT=1"

-,31,0," . ;check 1st line (site/dev - ) patch 128"

-,32,467," . I $P(LIN,"";"",2,4)'?.E1""/"".E.1""-"".E D E^XINDX1(62)"

-,33,467," . S LIN=$G(^UTILITY($J,1,RTN,0,2,0)),TXT=2"

-,34,0," . ;check 2nd line (;;nn.nn[TV]nn;package;.anything)"

-,35,467," . I $P(LIN,"";"",3,99)'?1.2N1"".""1.2N.1(1""T"",1""V"").2N1"";""1A.AP1"";"".E D E^XINDX1(44) ;patch 121"

-,36,467," . I $L(INP(11)) X INP(11) ;Version number check"

-,37,467," . I $L(INP(12)) X INP(12) ;Patch number check"

-,38,467,"B5 F TXT=1:1:LC S LIN=^UTILITY($J,1,RTN,0,TXT,0),LN=$L(LIN),IND(""SZT"")=IND(""SZT"")+LN+2 D LN,ST ;Process Line"

-,39,467," S LAB="""",LABO=0,TXT=0,^UTILITY($J,1,RTN,0)=IND(""SZT"")_""^""_LC_""^""_IND(""SZC"")"

-,40,467," I IND(""SZT"")>INP(""MAX""),'INDLC S ERR=35,ERR(1)=IND(""SZT"") D ^XINDX1"

-,41,467," I IND(""SZT"")-IND(""SZC"")>INP(""CMAX""),'INDLC S ERR=58,ERR(1)=IND(""SZT"")-IND(""SZC"") D ^XINDX1"

-,42,467," D POSTRTN"

-,43,467," Q"

-,44,0," ;Proccess one line, LN = Length, LIN = Line."

-,45,44620,"LN K V S (ARG,GRB,IND(""COM""),IND(""DOL""),IND(""F""))="""",X=$P(LIN,"" "")"

-,46,44620," I '$L(X) S LABO=LABO+1 G CD"

-,47,5073," S (IND(""COM""),LAB)=$P(X,""(""),ARG=$P($P(X,""("",2),"")""),LABO=0,IND(""PP"")=X?1.8E1""("".E1"")"""

-,48,5073," D:$L(ARG) NE^XINDX3 ;Process formal parameters as New list."

-,49,5073," I 'INDLC,'$$VT^XINDX2(LAB) D E^XINDX1($S(LAB=$$CASE^XINDX52(LAB):37,1:55)) ;Check for bad labels"

-,50,5073," I $D(^UTILITY($J,1,RTN,""T"",LAB)) D E^XINDX1(15) G CD ;DUP label"

-,51,5073," S ^UTILITY($J,1,RTN,""T"",LAB)="""""

-,52,44620,"CD I LN>245 D:'(LN=246&($E(RTN,1,3)=""|dd"")) E^XINDX1(19) ;patch 119"

-,53,44620," D:LIN'?1.ANP E^XINDX1(18)"

-,54,44620," S LIN=$P(LIN,"" "",2,999),IND(""LCC"")=1"

-,55,44620," I LIN="""" D E^XINDX1(42) Q  ;Blank line ;p110"

-,56,44620," S I=0 ;Watch the scope of I, counts dots"

-,57,44620," I "" .""[$E(LIN) D  S X=$L($E(LIN,1,I),""."")-1,LIN=$E(LIN,I,999)"

-,58,10770," . F I=1:1:245 Q:"". ""'[$E(LIN,I)"

-,59,10770," . Q"

-,60,0," ;check dots against Do level IND(""DO""), IND(""DOL"")=dot level"

-,61,44620," D:'I&$G(IND(""DO1"")) E^XINDX1(51) S IND(""DO1"")=0 S:'I IND(""DO"")=0"

-,62,44620," I I D:X>IND(""DO"") E^XINDX1(51) S (IND(""DO""),IND(""DOL""))=X"

-,63,0," ;Count Comment lines, skip ;; lines"

-,64,44620," I $E(LIN)="";"",$E(LIN,2)'="";"" S IND(""SZC"")=IND(""SZC"")+$L(LIN) ;p110"

-,65,0," ;Process commands on line."

-,66,116081,"EE I LIN="""" D ^XINDX2 Q"

-,67,71461," S COM=$E(LIN),GK="""",ARG="""""

-,68,71461," I COM="";"" S LIN="""" G EE ;p110"

-,69,54870," I COM="" "" S ERR=$S(LIN?1."" "":13,1:0),LIN=$S(ERR:"""",1:$E(LIN,2,999)) D:ERR ^XINDX1 G EE"

-,70,53608," D SEP"

-,71,53608," S CM=$P(ARG,"":"",1),POST=$P(ARG,"":"",2,999),IND(""COM"")=IND(""COM"")_$C(9)_COM,ERR=48"

-,72,53608," D:ARG["":""&(POST']"""") ^XINDX1 S:POST]"""" GRB=GRB_$C(9)_POST,IND(""COM"")=IND(""COM"")_"":"""

-,73,0," ;SAC now allows lowercase commands"

-,74,53608," I CM?.E1L.E S CM=$$CASE^XINDX52(CM),COM=$E(CM) ;I IND(""LCC"") S IND(""LCC"")=0 D E^XINDX1(47)"

-,75,53608," I CM="""" D E^XINDX1(21) G EE ;Missing command"

-,76,53608," S CX=$G(IND(""CMD"",CM)) I CX="""" D  G:CX="""" EE"

-,77,0," . I $E(CM)=""Z"" S CX=""^Z"" Q  ;Proccess Z commands"

-,78,0," . D E^XINDX1(1) S LIN="""" Q"

-,79,53608," S CX=$P(CX,""^"",2,9)"

-,80,53608," D SEP I '$L(LIN),CH="" "" D E^XINDX1(13) ;trailing space"

-,81,53608," I ARG="""",""CGJMORSUWX""[COM S ERR=49 G ^XINDX1"

-,82,53608," I CX>0 D E^XINDX1(CX) S CX="""""

-,83,53608," D:$L(CX) @CX S:ARG'="""" GRB=GRB_$C(9)_ARG G EE"

-,84,0,"B S ERR=25 G ^XINDX1"

-,85,0,"C S ERR=29 G ^XINDX1"

-,86,0,"D G DG1^XINDX4"

-,87,0,"E Q:ARG=""""  S ERR=7 G ^XINDX1"

-,88,1559,"F G:ARG]"""" FR^XINDX4 S IND(""F"")=1 Q"

-,89,1932,"G G DG^XINDX4"

-,90,11,"H Q:ARG'=""""  S ERR=32 G ^XINDX1"

-,91,0,"J S ERR=36,ARG="""" G ^XINDX1"

-,92,2218,"K S ERR=$S(ARG?1""("".E:22,ARG?."" "":23,1:0) D:ERR ^XINDX1"

-,93,2218," G KL^XINDX3"

-,94,259,"L G LO^XINDX4"

-,95,30,"M G S^XINDX3"

-,96,1721,"N G NE^XINDX3"

-,97,0,"O S ERR=34 D ^XINDX1,O^XINDX3 Q"

-,98,7762,"Q Q:ARG=""""  G Q^XINDX4"

-,99,85,"R S RDTIME=0 G RD^XINDX3"

-,100,17549,"S G S^XINDX3"

-,101,0,"TR Q  ;What to process. p110"

-,102,72,"U S ARG=$P(ARG,"":"") Q"

-,103,0,"V S ARG="""",ERR=20 G ^XINDX1"

-,104,4584,"W G WR^XINDX4"

-,105,220,"X G XE^XINDX4"

-,106,0,"Z S ERR=2 D ^XINDX1 G ZC^XINDX4"

-,107,0," ;"

-,108,0," ;Save off items from line."

-,109,44620,"ST S R=LAB_$S(LABO:""+""_LABO,1:"""")"

-,110,0," ;Local variable, Global, Marked Items, Naked global, Internal ref, eXternal ref., Tag ref."

-,111,44620," S LOC="""" F  S LOC=$O(V(LOC)),S="""" Q:LOC=""""  F  S S=$O(V(LOC,S)) Q:S=""""  D SET"

-,112,44620," S ^UTILITY($J,1,RTN,""COM"",TXT)=IND(""COM"")"

-,113,44620," Q"

-,114,0," ;"

-,115,85079,"SET I V(LOC,S)]"""" F %=""!"",""~"" I V(LOC,S)[%,$G(^UTILITY($J,1,RTN,LOC,S))'[% S ^(S)=$G(^(S))_%"

-,116,85079," S %=0"

-,117,86891,"SE2 S ARG=$G(^UTILITY($J,1,RTN,LOC,S,%)) I $L(ARG)>230 S %=%+1 G SE2"

-,118,85079," S ^UTILITY($J,1,RTN,LOC,S,%)=ARG_R_V(LOC,S)_"","""

-,119,85079," Q"

-,120,0," ;"

-,121,0,"POSTRTN ;Do more overall checking"

-,122,467," N V,E,T,T1,T2"

-,123,467," S T="""" ;Check for missing Labels"

-,124,467," F  S T=$O(^UTILITY($J,1,RTN,""I"",T)),T2=T Q:T=""""  S T1=$G(^(T,0)) D"

-,125,2091," . Q:$E(T2,1,2)=""@("""

-,126,2044," . S:$E(T2,1,2)=""$$"" T2=$E(T2,3,99)"

-,127,2044," . I T2]"""",'$D(^UTILITY($J,1,RTN,""T"",$P(T2,""+"",1))) D"

-,128,0," . . F I=1:1:$L(T1,"","")-1 S LAB=$P(T1,"","",I),LABO=+$P(LAB,""+"",2),LAB=$P(LAB,""+""),E=14,E(1)=T D E^XINDX1(.E)"

-,129,0," . . Q"

-,130,2044," . Q"

-,131,467," S LAB="""",LABO=0 ;Check for valid label names"

-,132,467," I 'INDLC F  S LAB=$O(^UTILITY($J,1,RTN,""T"",LAB)) Q:LAB=""""  D"

-,133,5073," . I '$$VA^XINDX2(LAB) D E^XINDX1(55) Q"

-,134,5073," . D:'$$VT^XINDX2(LAB) E^XINDX1(37)"

-,135,5073," . Q"

-,136,467," S LAB="""",LABO=0 ;Check for valid variable names."

-,137,467," F  S LAB=$O(^UTILITY($J,1,RTN,""L"",LAB)) Q:LAB=""""  D"

-,138,15909," . D VLNF^XINDX3($P(LAB,""(""))"

-,139,15909," . Q"

-,140,467," Q"

-,141,0," ;"

-,142,0,"QUICK ;Quick, Just get a routine an print the results"

-,143,0," D QUICK^XINDX6()"

-,144,0," Q"

-Totals for XINDEX,,2446443,

-XINDX1,1,0,"XINDX1 ;ISC/REL,GRK,RWF - ERROR ROUTINE ;08/05/08  13:59"

-,2,2," ;;7.3;TOOLKIT;**20,61,66,68,110,121,128**;Apr 25, 1995;Build 1"

-,3,0," ; Per VHA Directive 2004-038, this routine should not be modified."

-,4,2," G A"

-,5,0,"E(ERR) ;"

-,6,75,"A N %,%1 ;TXT is the line of the error."

-,7,75," S ERTX=LAB_$S(LABO:""+""_LABO,1:"""")_$C(9),%1=$T(ERROR+ERR),ERTX=ERTX_$S(ERR:$P(%1,"";"",4,9),1:ERR) ;p110"

-,8,75," I ERTX[""|"" F %=1:1 S ERTX=$P(ERTX,""|"")_$S($D(ERR(%)):ERR(%),1:""??"")_$P(ERTX,""|"",%+1,99) Q:ERTX'[""|"""

-,9,75,"B I $P(%1,"";"",3)]"""" D  Q:%1]""""  ;Don't flag kernel doing kernel."

-,10,0," . S %1=$P(%1,"";"",3)"

-,11,0," . F  Q:RTN[$P(%1,"","")  S %1=$P(%1,"","",2,99) ;quit if RTN[%1 or null."

-,12,0," . Q"

-,13,75," I ERR=17,$E(RTN)'=""%"",$E(LAB)=""%"" Q  ;Don't flag %RTN w/o %."

-,14,0," ;Global is Error Line,tab,error tag,tab,error text"

-,15,75," S %=$G(^UTILITY($J,1,RTN,""E"",0))+1,^(0)=%,^(%)=TXT_$C(9)_ERTX"

-,16,75," Q"

-,17,0," ;"

-,18,0," ;F = Fatal, S = Standard, W = Warning, I = Info"

-,19,0,"ERROR ;"

-,20,0,"1 ;;;F - UNDEFINED COMMAND (rest of line not checked)."

-,21,0,"2 ;;;F - Non-standard (Undefined) 'Z' command."

-,22,0,"3 ;;XTRMON;F - Undefined Function."

-,23,0,"4 ;;;F - Undefined Special Variable."

-,24,0,"5 ;;;F - Unmatched Parenthesis."

-,25,0,"6 ;;;F - Unmatched Quotation Marks."

-,26,0,"7 ;;;F - ELSE Command followed by only one space."

-,27,0,"8 ;;;F - FOR Command did not contain '='."

-,28,0,"9 ;;;I - QUIT Command followed by only one space."

-,29,0,"10 ;;;F - Unrecognized argument in SET command."

-,30,0,"11 ;;;W - Invalid local variable name."

-,31,0,"12 ;;;W - Invalid global variable name."

-,32,0,"13 ;;;W - Blank(s) at end of line."

-,33,0,"14 ;;;F - Call to missing label '|' in this routine."

-,34,0,"15 ;;;W - Duplicate label. (M57)"

-,35,0,"16 ;;;F - Error in pattern code."

-,36,0,"17 ;;;W - First line label NOT routine name."

-,37,0,"18 ;;;W - Line contains a CONTROL (non-graphic) character."

-,38,0,"19 ;;;S - Line is longer than 245 bytes."

-,39,0,"20 ;;;S - View command used."

-,40,0,"21 ;;;F - General Syntax Error."

-,41,0,"22 ;;;S - Exclusive Kill."

-,42,0,"23 ;;;S - Unargumented Kill."

-,43,0,"24 ;;;S - Kill of an unsubscripted global."

-,44,0,"25 ;;;S - Break command used."

-,45,0,"26 ;;;S - Exclusive or Unargumented NEW command."

-,46,0,"27 ;;;S - $View function used."

-,47,0,"28 ;;ZOSV,ZIS,ZT;S - Non-standard $Z special variable used."

-,48,0,"29 ;;ZIS,ZTM;S - 'Close' command should be invoked through 'D ^%ZISC'."

-,49,0,"30 ;;;S - LABEL+OFFSET syntax."

-,50,0,"31 ;;ZOSV,ZIS,ZT;S - Non-standard $Z function used."

-,51,0,"32 ;;;S - 'HALT' command should be invoked through 'G ^XUSCLEAN'."

-,52,0,"33 ;;;S - Read command doesn't have a timeout."

-,53,0,"34 ;;ZIS;S - 'OPEN' command should be invoked through ^%ZIS."

-,54,0,"35 ;;;S - Routine exceeds SACC maximum size of 20000 (|)."

-,55,0,"36 ;;ZTM;S - Should use 'TASKMAN' instead of 'JOB' command."

-,56,0,"37 ;;;F - Label is not valid."

-,57,0,"38 ;;;F - Call to this |"

-,58,0,"39 ;;ZIS,XUS,XUP;S - Kill of a protected variable (|)."

-,59,0,"40 ;;;S - Space where a command should be."

-,60,0,"41 ;;;I - Star or pound READ used."

-,61,0,"42 ;;;W - Null line (no commands or comment)."

-,62,0,"43 ;;;F - Invalid or wrong number of arguments to a function."

-,63,0,"44 ;;;S - 2nd line of routine violates the SAC."

-,64,0,"45 ;;ZT,ZIS,XUTM,XTER;S - Set to a '%' global."

-,65,0,"46 ;;;F - Quoted string not followed by a separator."

-,66,0,"47 ;;;S - Lowercase command(s) used in line."

-,67,0,"48 ;;;F - Missing argument to a command post-conditional."

-,68,0,"49 ;;;F - Command missing an argument."

-,69,0,"50 ;;ZTM;S - Extended reference."

-,70,0,"51 ;;;F - Block structure mismatch."

-,71,0,"52 ;;;F - Reference to routine '^|'. That isn't in this UCI."

-,72,0,"53 ;;;F - Bad Number."

-,73,0,"54 ;;XG;S - Access to SSVN's restricted to Kernel."

-,74,0,"55 ;;;S - Violates VA programming standards."

-,75,0,"56 ;;;S - Patch number '|' missing from second line."

-,76,0,"57 ;;;S - Lower/Mixed case Variable name used."

-,77,0,"58 ;;;S - Routine code exceeds SACC maximum size of 15000 (|)."

-,78,0,"59 ;;;F - Bad WRITE syntax."

-,79,0,"60 ;;;S - Lock missing Timeout."

-,80,0,"61 ;;;S - Non-Incremental Lock."

-,81,0,"62 ;;;S - First line of routine violates the SAC."

-,82,0,"63 ;;;F - GO or DO mismatch from block structure (M45)."

-Totals for XINDX1,,529,

diff --git a/Tests/MumpsCoverage/Accounts_ReceivableTest.mcov b/Tests/MumpsCoverage/Accounts_ReceivableTest.mcov
deleted file mode 100644
index 3c585f5..0000000
--- a/Tests/MumpsCoverage/Accounts_ReceivableTest.mcov
+++ /dev/null
@@ -1,1445 +0,0 @@
-%GO Global Output Utility
-GT.M 17-APR-2012 17:18:27 ZWR
-^ZZCOVERAGE("%RSEL","SRC")="1:0:0:0"
-^ZZCOVERAGE("%RSEL","SRC",1)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","SRC",2)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","SRC",3)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","SRC",4)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","SRC",5)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","SRC",6)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","SRC",7)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init")="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",1)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",3)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",4)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",5)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",6)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",7)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",8)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",8,"FOR_LOOP",1)=1
-^ZZCOVERAGE("%RSEL","init",9)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",10)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",11)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",12)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",13)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",14)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",15)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",16)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",17)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","init",17,"FOR_LOOP",1)=2
-^ZZCOVERAGE("%RSEL","init",18)="2:0:0:0"
-^ZZCOVERAGE("%RSEL","init",19)="2:0:0:0"
-^ZZCOVERAGE("%RSEL","init",20)="2:0:0:0"
-^ZZCOVERAGE("%RSEL","init",40)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","main")="1:32001:84004:116005"
-^ZZCOVERAGE("%RSEL","main",1)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","main",2)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","main",3)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","main",3,"FOR_LOOP",1)=468
-^ZZCOVERAGE("%RSEL","main",4)="468:0:24003:24003"
-^ZZCOVERAGE("%RSEL","main",5)="468:0:0:0"
-^ZZCOVERAGE("%RSEL","main",6)="468:32001:48001:80002"
-^ZZCOVERAGE("%RSEL","main",7)="467:0:12000:12000"
-^ZZCOVERAGE("%RSEL","main",8)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","main",9)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","main",10)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","main",11)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","main",12)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","main",13)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","main",14)="1:0:0:0"
-^ZZCOVERAGE("%RSEL","next")="1403:12001:20002:32003"
-^ZZCOVERAGE("%RSEL","next",0)="1403:0:0:0"
-^ZZCOVERAGE("%RSEL","next",1)="1403:12001:20002:32003"
-^ZZCOVERAGE("%RSEL","next",1,"FOR_LOOP",1)=1403
-^ZZCOVERAGE("%RSEL","next",2)="1403:0:0:0"
-^ZZCOVERAGE("%RSEL","save")="467:0:4001:4001"
-^ZZCOVERAGE("%RSEL","save",1)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","save",5)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","save",6)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","save",7)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","save",8)="467:0:4001:4001"
-^ZZCOVERAGE("%RSEL","save",9)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","search")="934:0:16001:16001"
-^ZZCOVERAGE("%RSEL","search",0)="934:0:4000:4000"
-^ZZCOVERAGE("%RSEL","search",1)="934:0:0:0"
-^ZZCOVERAGE("%RSEL","search",2)="934:0:4001:4001"
-^ZZCOVERAGE("%RSEL","search",2,"FOR_LOOP",1)=1868
-^ZZCOVERAGE("%RSEL","search",3)="934:0:8000:8000"
-^ZZCOVERAGE("%RSEL","search",4)="934:0:0:0"
-^ZZCOVERAGE("%RSEL","search",5)="934:0:0:0"
-^ZZCOVERAGE("%RSEL","start")="468:0:4001:4001"
-^ZZCOVERAGE("%RSEL","start",0)="468:0:0:0"
-^ZZCOVERAGE("%RSEL","start",1)="468:0:0:0"
-^ZZCOVERAGE("%RSEL","start",2)="468:0:0:0"
-^ZZCOVERAGE("%RSEL","start",2,"FOR_LOOP",1)=936
-^ZZCOVERAGE("%RSEL","start",3)="468:0:0:0"
-^ZZCOVERAGE("%RSEL","work")="467:20002:24001:44003"
-^ZZCOVERAGE("%RSEL","work",1)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","work",2)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","work",3)="467:0:4000:4000"
-^ZZCOVERAGE("%RSEL","work",4)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","work",6)="467:4000:12000:16000"
-^ZZCOVERAGE("%RSEL","work",6,"FOR_LOOP",1)=3421
-^ZZCOVERAGE("%RSEL","work",7)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","work",8)="467:4001:0:4001"
-^ZZCOVERAGE("%RSEL","work",9)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","work",10)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","work",11)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","work",12)="467:4000:0:4000"
-^ZZCOVERAGE("%RSEL","work",13)="467:0:4000:4000"
-^ZZCOVERAGE("%RSEL","work",14)="467:0:0:0"
-^ZZCOVERAGE("%RSEL","work",15)="467:4001:4001:8002"
-^ZZCOVERAGE("%RSEL","work",15,"FOR_LOOP",1)=934
-^ZZCOVERAGE("%RSEL","work",16)="467:0:0:0"
-^ZZCOVERAGE("%ZIS","%ZIS")="2:0:0:0"
-^ZZCOVERAGE("%ZIS","%ZIS",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","%ZIS",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","A",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","A",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","CLEAN")="3:0:0:0"
-^ZZCOVERAGE("%ZIS","CLEAN",1)="3:0:0:0"
-^ZZCOVERAGE("%ZIS","CLEAN",2)="3:0:0:0"
-^ZZCOVERAGE("%ZIS","CLEAN",3)="3:0:0:0"
-^ZZCOVERAGE("%ZIS","CLEAN",4)="3:0:0:0"
-^ZZCOVERAGE("%ZIS","GETHOME")="2:0:0:0"
-^ZZCOVERAGE("%ZIS","GETHOME",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","GETHOME",1)="1:0:0:0"
-^ZZCOVERAGE("%ZIS","GETHOME",3)="1:0:0:0"
-^ZZCOVERAGE("%ZIS","GETHOME",4)="1:0:0:0"
-^ZZCOVERAGE("%ZIS","GETHOME",5)="1:0:0:0"
-^ZZCOVERAGE("%ZIS","GETHOME",6)="1:0:0:0"
-^ZZCOVERAGE("%ZIS","GETHOME",7)="1:0:0:0"
-^ZZCOVERAGE("%ZIS","HOME")="1:0:0:0"
-^ZZCOVERAGE("%ZIS","HOME",1)="1:0:0:0"
-^ZZCOVERAGE("%ZIS","HOME",2)="1:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",6)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",8)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",10)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",11)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",12)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",13)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","INIT",15)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","K2",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","K2",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","K2",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","K2",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","VIRTUAL")="2:0:0:0"
-^ZZCOVERAGE("%ZIS","VIRTUAL",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","VIRTUAL",4,"FOR_LOOP",1)=6
-^ZZCOVERAGE("%ZIS","VIRTUAL",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","VIRTUAL",7)="2:0:0:0"
-^ZZCOVERAGE("%ZIS","VTLKUP")="4:0:0:0"
-^ZZCOVERAGE("%ZIS","VTLKUP",0)="4:0:0:0"
-^ZZCOVERAGE("%ZIS","VTLKUP",0,"FOR_LOOP",1)=8
-^ZZCOVERAGE("%ZIS","VTLKUP",1)="4:0:0:0"
-^ZZCOVERAGE("%ZIS1","EX2",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","EX2",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","EXIT",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","EXIT",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","EXIT",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","EXIT",6)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","EXIT",7)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","EXIT",8)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","EXIT",9)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","G",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","IOP")="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","IOP",1)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","K2")="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","K2",1)="4:0:0:0"
-^ZZCOVERAGE("%ZIS1","K2",2)="4:0:0:0"
-^ZZCOVERAGE("%ZIS1","K2",3)="4:0:0:0"
-^ZZCOVERAGE("%ZIS1","K2",4)="4:0:0:0"
-^ZZCOVERAGE("%ZIS1","KIL",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","KIL",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","KIL",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",6)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",7)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",8)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",9)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",10)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",11)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","L1",12)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","LKUP")="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","LKUP",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","LKUP",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","LKUP",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","MAIN",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","R")="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","R",0)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","R",1)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","R",2)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","RD",0)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","RD",1)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","RD",2)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","RD",3)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","RD",4)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","RD",5)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","SBR")="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","SBR",1)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","SBR",2)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","SBR",3)="1:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETQ")="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETQ",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETQ",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETQ",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETQ",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETQ",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",7)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",8)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",9)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",10)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",11)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",12)="2:0:0:0"
-^ZZCOVERAGE("%ZIS1","SETVAR",13)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","CHECK",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","CHECK",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","CHECK",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","CHECK",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","CHECK",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","CHECK",6)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","IOPAR")="4:0:0:0"
-^ZZCOVERAGE("%ZIS2","IOPAR",0)="4:0:0:0"
-^ZZCOVERAGE("%ZIS2","IOPAR",1)="4:0:0:0"
-^ZZCOVERAGE("%ZIS2","L2")="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","L2",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","OCPU",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","OOS",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","OOS",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","OTHCPU")="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","OTHCPU",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","OTHCPU",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","OTHCPU",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","OTHCPU",2,"FOR_LOOP",1)=4
-^ZZCOVERAGE("%ZIS2","OTHCPU",3)="4:0:0:0"
-^ZZCOVERAGE("%ZIS2","OTHCPU",4)="4:0:0:0"
-^ZZCOVERAGE("%ZIS2","OTHCPU",5)="4:0:0:0"
-^ZZCOVERAGE("%ZIS2","OTHCPU",15)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","PTIME",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","QUECHK")="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","QUECHK",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","QUECHK",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","QUECHK",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","QUECHK",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","QUECHK",9)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","QUECHK",13)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","SLAVE",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","T2",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","T2",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",10)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",11)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",12)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",15)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",16)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","TMPVAR",18)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","VTRM",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS2","VTRM",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","%ZIS3",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","%ZIS3",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","%ZIS3",6)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","%ZIS3",8)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","%ZIS3",9)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","%ZIS3",11)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","ALTP",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","ASKMAR",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","ASKMAR",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","MARGN")="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","MARGN",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","MARGN",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","MARGN",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","MARGN",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","Q",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","Q",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","Q",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","SETPAR")="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","SETPAR",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","SETPAR",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","ST")="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","ST",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","ST",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","ST",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","ST",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","STP",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","STP",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","STP",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","STP",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","TRM",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","TRM",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","TRM",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","TRM",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","TRM",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","W")="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","W",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","W",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS3","W",2)="1:0:0:0"
-^ZZCOVERAGE("%ZIS3","W",3)="1:0:0:0"
-^ZZCOVERAGE("%ZIS4","O")="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","O",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","O",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","O1")="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","O1",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","O1",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","O1",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","O1",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",4)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",5)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",9)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",10)="2:0:0:0"
-^ZZCOVERAGE("%ZIS4","OPAR",12)="2:0:0:0"
-^ZZCOVERAGE("%ZIS6","ANSBAK",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS6","ANSBAK",2)="2:0:0:0"
-^ZZCOVERAGE("%ZIS6","ANSBAK",3)="2:0:0:0"
-^ZZCOVERAGE("%ZIS6","OXECUTE",1)="2:0:0:0"
-^ZZCOVERAGE("%ZIS6","QUIT",0)="2:0:0:0"
-^ZZCOVERAGE("%ZIS6","QUIT",1)="2:0:0:0"
-^ZZCOVERAGE("%ZISC","C0")="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",1)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",3)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",5)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",6)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",8)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",9)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",10)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",13)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",16)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",17)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",21)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",26)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",27)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",29)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",32)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",33)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",34)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",37)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",41)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","C0",43)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS")="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",0)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",1)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",2)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",3)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",4)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",5)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",6)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",7)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CIOS",8)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CLOSPP")="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CLOSPP",0)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CLOSPP",1)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","CLOSPP",2)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","END",0)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","END",2)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","END",4)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","FF")="1:0:0:0"
-^ZZCOVERAGE("%ZISC","FF",0)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","FF",1)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","FF",2)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","RM")="1:0:0:0"
-^ZZCOVERAGE("%ZISC","RM",0)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","RM",1)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","S1",0)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","S1",1)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",2)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",4)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",5)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",6)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",7)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",8)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",9)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",10)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SETIO",12)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SUBTYPE")="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SUBTYPE",1)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SUBTYPE",2)="1:0:0:0"
-^ZZCOVERAGE("%ZISC","SUBTYPE",3)="1:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LINEPORT")="1:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LINEPORT",0)="1:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LINEPORT",2)="1:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LINEPORT",3)="1:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LINEPORT",4)="1:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LINEPORT",5)="1:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LINEPORT",6)="1:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTIEN")="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTIEN",0)="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTIEN",1)="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTNAM")="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTNAM",0)="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTNAM",1)="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTNAM",2)="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTNAM",3)="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTNAM",5)="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTNAM",6)="3:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTSUB")="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTSUB",0)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTSUB",1)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTSUB",2)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","LNPRTSUB",3)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","SYMBOL")="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","SYMBOL",0)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","SYMBOL",1)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","SYMBOL",3)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","SYMBOL",4)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","SYMBOL",5)="2:0:0:0"
-^ZZCOVERAGE("%ZISUTL","SYMBOL",5,"FOR_LOOP",1)=40
-^ZZCOVERAGE("%ZISUTL","SYMBOL",6)="40:0:0:0"
-^ZZCOVERAGE("%ZISUTL","SYMBOL",10)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","GETENV")="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","GETENV",1)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","GETENV",2)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","GETENV",3)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","LGR")="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","LGR",0)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","LGR",1)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","PRI")="1:0:0:0"
-^ZZCOVERAGE("%ZOSV","PRI",0)="1:0:0:0"
-^ZZCOVERAGE("%ZOSV","PRI",3)="1:0:0:0"
-^ZZCOVERAGE("%ZOSV","RETURN")="2:0:4000:4000"
-^ZZCOVERAGE("%ZOSV","RETURN",0)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","RETURN",2)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","RETURN",3)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","RETURN",4)="2:0:4000:4000"
-^ZZCOVERAGE("%ZOSV","RETURN",5)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","RETURN",7)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","TEMP")="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","TEMP",0)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV","TEMP",2)="2:0:0:0"
-^ZZCOVERAGE("%ZOSV2","LOAD")="467:1000060:340019:1340079"
-^ZZCOVERAGE("%ZOSV2","LOAD",0)="467:0:0:0"
-^ZZCOVERAGE("%ZOSV2","LOAD",1)="467:0:8001:8001"
-^ZZCOVERAGE("%ZOSV2","LOAD",2)="467:1000060:320018:1320078"
-^ZZCOVERAGE("%ZOSV2","LOAD",2,"FOR_LOOP",1)=45087
-^ZZCOVERAGE("%ZOSV2","LOAD",3)="467:0:12000:12000"
-^ZZCOVERAGE("DIALOG","EZBLD")="2:0:4000:4000"
-^ZZCOVERAGE("DIALOG","EZBLD",0)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","EZBLD",2)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","EZBLD",3)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","EZBLD",4)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","EZBLD",5)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","EZBLD",6)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","EZBLD",7)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","EZBLD",8)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","EZBLD",9)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","PARAM")="2:0:0:0"
-^ZZCOVERAGE("DIALOG","PARAM",0)="4:0:0:0"
-^ZZCOVERAGE("DIALOG","PARAM",1)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","PARAM",2)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","PARAM",3)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","Q1",0)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","Q2")="2:0:0:0"
-^ZZCOVERAGE("DIALOG","Q2",0)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","QEZ",0)="2:0:4000:4000"
-^ZZCOVERAGE("DIALOG","QEZ",1)="2:0:0:0"
-^ZZCOVERAGE("DIALOG","QP",0)="2:0:0:0"
-^ZZCOVERAGE("DIC","A1",0)="2:0:0:0"
-^ZZCOVERAGE("DIC","ASK",0)="2:0:0:0"
-^ZZCOVERAGE("DIC","ASK",1)="2:0:0:0"
-^ZZCOVERAGE("DIC","ASK",2)="2:0:0:0"
-^ZZCOVERAGE("DIC","ASK",3)="2:0:0:0"
-^ZZCOVERAGE("DIC","ASK",4)="2:0:0:0"
-^ZZCOVERAGE("DIC","DIC")="2:0:0:0"
-^ZZCOVERAGE("DIC","DIC",3)="2:0:0:0"
-^ZZCOVERAGE("DIC","DIC",4)="2:0:0:0"
-^ZZCOVERAGE("DIC","DIC",5)="2:0:0:0"
-^ZZCOVERAGE("DIC","DIC",6)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",0)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",1)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",2)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",3)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",4)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",5)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",6)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",7)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",8)="2:0:0:0"
-^ZZCOVERAGE("DIC","EN",9)="2:0:0:0"
-^ZZCOVERAGE("DIC","RTN",0)="2:0:0:0"
-^ZZCOVERAGE("DIC","RTN",3)="2:0:0:0"
-^ZZCOVERAGE("DIC","RTN",6)="2:0:0:0"
-^ZZCOVERAGE("DIC","X",1)="2:0:0:0"
-^ZZCOVERAGE("DIC","X",4)="2:0:0:0"
-^ZZCOVERAGE("DIC","X",5)="2:0:0:0"
-^ZZCOVERAGE("DIC","X",6)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE")="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",0)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",1)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",2)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",3)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",4)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",7)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",8)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",11)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",12)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",13)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",14)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",15)="2:0:0:0"
-^ZZCOVERAGE("DIC0","GETFILE",16)="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT")="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT",1)="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT",2)="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT",3)="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT",4)="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT",5)="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT",6)="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT",7)="2:0:0:0"
-^ZZCOVERAGE("DIC0","INIT",8)="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN")="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN",0)="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN",1)="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN",2)="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN",3)="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN",4)="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN",5)="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN",5,"FOR_LOOP",1)=2
-^ZZCOVERAGE("DIC0","SETIEN",6)="2:0:0:0"
-^ZZCOVERAGE("DIC0","SETIEN",7)="2:0:0:0"
-^ZZCOVERAGE("DIC1","B",0)="2:0:0:0"
-^ZZCOVERAGE("DIC1","DIC1")="2:0:0:0"
-^ZZCOVERAGE("DIC1","DIC1",3)="2:0:0:0"
-^ZZCOVERAGE("DIC1","DIC1",4)="2:0:0:0"
-^ZZCOVERAGE("DIC1","DIC1",5)="2:0:0:0"
-^ZZCOVERAGE("DIC1","DO")="4:0:0:0"
-^ZZCOVERAGE("DIC1","DO",1)="4:0:0:0"
-^ZZCOVERAGE("DIC1","DO",2)="2:0:0:0"
-^ZZCOVERAGE("DIC1","DO2",0)="2:0:0:0"
-^ZZCOVERAGE("DIC1","DO2",1)="2:0:0:0"
-^ZZCOVERAGE("DIC1","DO2",2)="2:0:0:0"
-^ZZCOVERAGE("DIC1","DO2",3)="2:0:0:0"
-^ZZCOVERAGE("DIC1","GETFA")="4:0:0:0"
-^ZZCOVERAGE("DIC1","GETFA",0)="4:0:0:0"
-^ZZCOVERAGE("DIC1","GETFA",2)="4:0:0:0"
-^ZZCOVERAGE("DIC1","P",1)="2:0:0:0"
-^ZZCOVERAGE("DIC1","P",2)="2:0:0:0"
-^ZZCOVERAGE("DIC1","PROMPT",1)="2:0:0:0"
-^ZZCOVERAGE("DIC1","PROMPT",2)="2:0:0:0"
-^ZZCOVERAGE("DIC1","W",0)="2:0:0:0"
-^ZZCOVERAGE("DIC1","W",0,"FOR_LOOP",1)=4
-^ZZCOVERAGE("DIC1","W",1)="3:0:0:0"
-^ZZCOVERAGE("DIC1","W",2)="3:0:0:0"
-^ZZCOVERAGE("DIC1","W",3)="2:0:0:0"
-^ZZCOVERAGE("DIC1","W",4)="2:0:0:0"
-^ZZCOVERAGE("DIC1","W",5)="2:0:0:0"
-^ZZCOVERAGE("DIC1","W",6)="2:0:0:0"
-^ZZCOVERAGE("DIC1","WOV")="1:0:0:0"
-^ZZCOVERAGE("DIC1","WOV",0)="1:0:0:0"
-^ZZCOVERAGE("DIC1","WOV",1)="1:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT")="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",0)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",1)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",2)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",3)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",3,"FOR_LOOP",1)=2
-^ZZCOVERAGE("DIC11","GETPRMT",4)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",8)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",9)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",10)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",11)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",12)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",13)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",14)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",15)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",16)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",17)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",18)="2:0:0:0"
-^ZZCOVERAGE("DIC11","GETPRMT",19)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",0)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",1)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",2)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",3)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",4)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",6)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",8)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",9)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",11)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",12)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",13)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",14)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",15)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PR1",16)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PROMPT")="2:0:0:0"
-^ZZCOVERAGE("DIC11","PROMPT",0)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PROMPT",1)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PROMPT",1,"FOR_LOOP",1)=2
-^ZZCOVERAGE("DIC11","PROMPT",2)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PROMPT",3)="2:0:0:0"
-^ZZCOVERAGE("DIC11","PROMPT",5)="2:0:0:0"
-^ZZCOVERAGE("DIC2","PGM")="4:0:0:0"
-^ZZCOVERAGE("DIC2","PGM",0)="4:0:0:0"
-^ZZCOVERAGE("DIC2","PGM",1)="4:0:0:0"
-^ZZCOVERAGE("DIC2","PGM",2)="4:0:0:0"
-^ZZCOVERAGE("DIC2","Q")="2:0:0:0"
-^ZZCOVERAGE("DIC2","Q",0)="2:0:0:0"
-^ZZCOVERAGE("DIC2","Q",1)="2:0:0:0"
-^ZZCOVERAGE("DIC2","Q",2)="2:0:0:0"
-^ZZCOVERAGE("DICL","DINDEX")="2:0:0:0"
-^ZZCOVERAGE("DICL","DINDEX",0)="2:0:0:0"
-^ZZCOVERAGE("DICL","DINDEX",1)="2:0:0:0"
-^ZZCOVERAGE("DICL","DINDEX",2)="2:0:0:0"
-^ZZCOVERAGE("DICL","DINDEX",5)="2:0:0:0"
-^ZZCOVERAGE("DICL","DINDEX",6)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","I1",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","I1",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","I1",4)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","I1",5)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","INDEX")="2:0:0:0"
-^ZZCOVERAGE("DICUIX","INDEX",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X1",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X1",8)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X1",9)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",4)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",5)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",8)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",11)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",12)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",13)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",14)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",15)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",15,"FOR_LOOP",1)=2
-^ZZCOVERAGE("DICUIX","X2",16)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",17)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",18)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",19)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",20)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",21)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",22)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",23)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",24)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",25)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",26)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",27)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",28)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",29)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",30)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",31)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",32)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","X2",33)="2:0:0:0"
-^ZZCOVERAGE("DICUIX","XREF")="2:0:0:0"
-^ZZCOVERAGE("DICUIX","XREF",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G1",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G1",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G1",4)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G2",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G2",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G3",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G30",1)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G4",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G4",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G4",4)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G4",5)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G4",6)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G4",7)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G5",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G5",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","G5",7)="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","GET")="2:0:0:0"
-^ZZCOVERAGE("DICUIX1","GET",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C1",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C1",1)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C2",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C2",1)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C3",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C3",1)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C3",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C3",5)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",1)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",4)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",5)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",6)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",7)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",8)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",9)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",10)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",11)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",12)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",17)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",18)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",23)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C4",24)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C5",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C5",1)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C6",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C6",18)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C6",19)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C6",20)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C7",0)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","C7",7)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON1")="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON1",1)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON1",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON1",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON1",4)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON1",5)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON1",6)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON1",7)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2")="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",1)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",2)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",3)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",4)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",5)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",6)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",7)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",8)="2:0:0:0"
-^ZZCOVERAGE("DICUIX2","COMMON2",9)="2:0:0:0"
-^ZZCOVERAGE("DIEFU","IENX",1)="2:0:0:0"
-^ZZCOVERAGE("DIEFU","IENX",2)="2:0:0:0"
-^ZZCOVERAGE("DIEFU","IENX",3)="2:0:0:0"
-^ZZCOVERAGE("DIEFU","IENX",3,"FOR_LOOP",1)=4
-^ZZCOVERAGE("DIEFU","IENX",4)="2:0:0:0"
-^ZZCOVERAGE("DIEFU","IENX",5)="2:0:0:0"
-^ZZCOVERAGE("DILF","CREF")="4:0:0:0"
-^ZZCOVERAGE("DILF","CREF",0)="4:0:0:0"
-^ZZCOVERAGE("DILF","IENS")="2:0:0:0"
-^ZZCOVERAGE("DILF","IENS",0)="2:0:0:0"
-^ZZCOVERAGE("DILF","IENS",1)="2:0:0:0"
-^ZZCOVERAGE("DILF","OREF")="2:0:0:0"
-^ZZCOVERAGE("DILF","OREF",0)="2:0:0:0"
-^ZZCOVERAGE("DILIBF","FNO")="2:0:0:0"
-^ZZCOVERAGE("DILIBF","FNO",0)="2:0:0:0"
-^ZZCOVERAGE("DILIBF","FNO",1)="2:0:0:0"
-^ZZCOVERAGE("DILIBF","FNO",2)="2:0:0:0"
-^ZZCOVERAGE("DIQGU","ENCREF",0)="4:0:0:0"
-^ZZCOVERAGE("DIQGU","ENOREF",0)="2:0:0:0"
-^ZZCOVERAGE("DIQGU","OR2")="2:0:0:0"
-^ZZCOVERAGE("DIQGU","OR2",0)="2:0:0:0"
-^ZZCOVERAGE("XINDEX","A2",0)="468:0:4000:4000"
-^ZZCOVERAGE("XINDEX","A2",1)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","A2",2)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","A2",3)="467:4000:0:4000"
-^ZZCOVERAGE("XINDEX","A2",4)="467:0:4000:4000"
-^ZZCOVERAGE("XINDEX","A2",5)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","ALIVE",1)="1:0:0:0"
-^ZZCOVERAGE("XINDEX","B5",0)="467:188012:220012:408024"
-^ZZCOVERAGE("XINDEX","B5",0,"FOR_LOOP",1)=44620
-^ZZCOVERAGE("XINDEX","B5",1)="467:20000:8000:28000"
-^ZZCOVERAGE("XINDEX","B5",2)="467:4000:0:4000"
-^ZZCOVERAGE("XINDEX","B5",3)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","B5",4)="467:4000:0:4000"
-^ZZCOVERAGE("XINDEX","B5",5)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","BEG")="467:2460149:2872194:5332343"
-^ZZCOVERAGE("XINDEX","BEG",1)="467:8000:0:8000"
-^ZZCOVERAGE("XINDEX","BEG",2)="467:4000:0:4000"
-^ZZCOVERAGE("XINDEX","BEG",3)="467:0:4000:4000"
-^ZZCOVERAGE("XINDEX","BEG",4)="467:0:4000:4000"
-^ZZCOVERAGE("XINDEX","BEG",5)="467:4001:0:4001"
-^ZZCOVERAGE("XINDEX","BEG",7)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","BEG",8)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","BEG",9)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","BEG",11)="467:4000:0:4000"
-^ZZCOVERAGE("XINDEX","BEG",12)="467:0:4000:4000"
-^ZZCOVERAGE("XINDEX","BEG",14)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","BEG",15)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","BEG",16)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","CD",0)="44620:32001:36002:68003"
-^ZZCOVERAGE("XINDEX","CD",1)="44620:40002:60004:100006"
-^ZZCOVERAGE("XINDEX","CD",2)="44620:40001:60002:100003"
-^ZZCOVERAGE("XINDEX","CD",3)="44620:36002:44004:80006"
-^ZZCOVERAGE("XINDEX","CD",4)="44620:28000:40002:68002"
-^ZZCOVERAGE("XINDEX","CD",5)="44620:28002:52001:80003"
-^ZZCOVERAGE("XINDEX","CD",6)="10770:28003:20000:48003"
-^ZZCOVERAGE("XINDEX","CD",6,"FOR_LOOP",1)=57531
-^ZZCOVERAGE("XINDEX","CD",7)="10770:24004:16000:40004"
-^ZZCOVERAGE("XINDEX","CD",9)="44620:60005:40004:100009"
-^ZZCOVERAGE("XINDEX","CD",10)="44620:44003:48005:92008"
-^ZZCOVERAGE("XINDEX","CD",12)="44620:52004:44002:96006"
-^ZZCOVERAGE("XINDEX","EE",0)="116081:148007:200014:348021"
-^ZZCOVERAGE("XINDEX","EE",1)="71461:44004:44002:88006"
-^ZZCOVERAGE("XINDEX","EE",2)="71461:100007:80003:180010"
-^ZZCOVERAGE("XINDEX","EE",3)="54870:44001:48001:92002"
-^ZZCOVERAGE("XINDEX","EE",4)="53608:88008:100009:188017"
-^ZZCOVERAGE("XINDEX","EE",5)="53608:72006:68004:140010"
-^ZZCOVERAGE("XINDEX","EE",6)="53608:76005:72004:148009"
-^ZZCOVERAGE("XINDEX","EE",8)="53608:60003:64005:124008"
-^ZZCOVERAGE("XINDEX","EE",9)="53608:48003:72003:120006"
-^ZZCOVERAGE("XINDEX","EE",10)="53608:52002:96008:148010"
-^ZZCOVERAGE("XINDEX","EE",13)="53608:52003:44001:96004"
-^ZZCOVERAGE("XINDEX","EE",14)="53608:96007:112006:208013"
-^ZZCOVERAGE("XINDEX","EE",15)="53608:24001:52004:76005"
-^ZZCOVERAGE("XINDEX","EE",16)="53608:52005:88007:140012"
-^ZZCOVERAGE("XINDEX","EE",17)="53608:128008:208017:336025"
-^ZZCOVERAGE("XINDEX","F")="1559:4000:4001:8001"
-^ZZCOVERAGE("XINDEX","F",0)="1559:4000:0:4000"
-^ZZCOVERAGE("XINDEX","G")="1932:56003:96009:152012"
-^ZZCOVERAGE("XINDEX","G",0)="1932:4000:8002:12002"
-^ZZCOVERAGE("XINDEX","H")="11:0:0:0"
-^ZZCOVERAGE("XINDEX","H",0)="11:0:0:0"
-^ZZCOVERAGE("XINDEX","K")="2218:40001:24002:64003"
-^ZZCOVERAGE("XINDEX","K",0)="2218:4000:4000:8000"
-^ZZCOVERAGE("XINDEX","K",1)="2218:0:4001:4001"
-^ZZCOVERAGE("XINDEX","L")="259:4001:4000:8001"
-^ZZCOVERAGE("XINDEX","L",0)="259:0:0:0"
-^ZZCOVERAGE("XINDEX","LN",0)="44620:68005:104005:172010"
-^ZZCOVERAGE("XINDEX","LN",1)="44620:40001:64004:104005"
-^ZZCOVERAGE("XINDEX","LN",2)="5073:12000:4001:16001"
-^ZZCOVERAGE("XINDEX","LN",3)="5073:4000:8000:12000"
-^ZZCOVERAGE("XINDEX","LN",4)="5073:20001:0:20001"
-^ZZCOVERAGE("XINDEX","LN",5)="5073:20003:12002:32005"
-^ZZCOVERAGE("XINDEX","LN",6)="5073:12002:16000:28002"
-^ZZCOVERAGE("XINDEX","LOAD")="467:88003:196019:284022"
-^ZZCOVERAGE("XINDEX","LOAD",0)="467:88003:196019:284022"
-^ZZCOVERAGE("XINDEX","LOAD",1)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","LOAD",2)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","M")="30:4000:0:4000"
-^ZZCOVERAGE("XINDEX","M",0)="30:0:0:0"
-^ZZCOVERAGE("XINDEX","N")="1721:88005:80004:168009"
-^ZZCOVERAGE("XINDEX","N",0)="1721:4000:0:4000"
-^ZZCOVERAGE("XINDEX","POSTRTN")="467:108009:96003:204012"
-^ZZCOVERAGE("XINDEX","POSTRTN",1)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","POSTRTN",2)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","POSTRTN",3)="467:12000:8000:20000"
-^ZZCOVERAGE("XINDEX","POSTRTN",3,"FOR_LOOP",1)=2558
-^ZZCOVERAGE("XINDEX","POSTRTN",4)="2091:0:0:0"
-^ZZCOVERAGE("XINDEX","POSTRTN",5)="2044:4000:0:4000"
-^ZZCOVERAGE("XINDEX","POSTRTN",6)="2044:4000:0:4000"
-^ZZCOVERAGE("XINDEX","POSTRTN",9)="2044:0:0:0"
-^ZZCOVERAGE("XINDEX","POSTRTN",10)="467:0:4000:4000"
-^ZZCOVERAGE("XINDEX","POSTRTN",11)="467:12002:16001:28003"
-^ZZCOVERAGE("XINDEX","POSTRTN",11,"FOR_LOOP",1)=5540
-^ZZCOVERAGE("XINDEX","POSTRTN",12)="5073:0:4000:4000"
-^ZZCOVERAGE("XINDEX","POSTRTN",13)="5073:8000:4000:12000"
-^ZZCOVERAGE("XINDEX","POSTRTN",14)="5073:0:0:0"
-^ZZCOVERAGE("XINDEX","POSTRTN",15)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","POSTRTN",16)="467:28001:20001:48002"
-^ZZCOVERAGE("XINDEX","POSTRTN",16,"FOR_LOOP",1)=16376
-^ZZCOVERAGE("XINDEX","POSTRTN",17)="15909:40006:40001:80007"
-^ZZCOVERAGE("XINDEX","POSTRTN",18)="15909:0:0:0"
-^ZZCOVERAGE("XINDEX","POSTRTN",19)="467:0:0:0"
-^ZZCOVERAGE("XINDEX","Q")="7762:12000:20001:32001"
-^ZZCOVERAGE("XINDEX","Q",0)="7762:4000:16001:20001"
-^ZZCOVERAGE("XINDEX","QUOTE")="36371:188012:232009:420021"
-^ZZCOVERAGE("XINDEX","QUOTE",0)="36371:156010:192008:348018"
-^ZZCOVERAGE("XINDEX","QUOTE",0,"FOR_LOOP",1)=323268
-^ZZCOVERAGE("XINDEX","QUOTE",1)="36371:20002:20001:40003"
-^ZZCOVERAGE("XINDEX","R")="85:0:8001:8001"
-^ZZCOVERAGE("XINDEX","R",0)="85:0:0:0"
-^ZZCOVERAGE("XINDEX","S")="17549:716055:988057:1704112"
-^ZZCOVERAGE("XINDEX","S",0)="17549:28003:28003:56006"
-^ZZCOVERAGE("XINDEX","SE2",0)="86891:176010:272017:448027"
-^ZZCOVERAGE("XINDEX","SE2",1)="85079:264015:376016:640031"
-^ZZCOVERAGE("XINDEX","SE2",2)="85079:72005:112010:184015"
-^ZZCOVERAGE("XINDEX","SEP")="107216:736054:648038:1384092"
-^ZZCOVERAGE("XINDEX","SEP",0)="107216:580045:440030:1020075"
-^ZZCOVERAGE("XINDEX","SEP",0,"FOR_LOOP",1)=1019212
-^ZZCOVERAGE("XINDEX","SEP",1)="107216:120007:144005:264012"
-^ZZCOVERAGE("XINDEX","SET")="85079:772044:1124063:1896107"
-^ZZCOVERAGE("XINDEX","SET",0)="85079:176007:168008:344015"
-^ZZCOVERAGE("XINDEX","SET",0,"FOR_LOOP",1)=74812
-^ZZCOVERAGE("XINDEX","SET",1)="85079:64005:144010:208015"
-^ZZCOVERAGE("XINDEX","ST",0)="44620:68001:56004:124005"
-^ZZCOVERAGE("XINDEX","ST",2)="44620:260012:376038:636050"
-^ZZCOVERAGE("XINDEX","ST",2,"FOR_LOOP",1)=85813
-^ZZCOVERAGE("XINDEX","ST",2,"FOR_LOOP",2)=126272
-^ZZCOVERAGE("XINDEX","ST",3)="44620:224014:184014:408028"
-^ZZCOVERAGE("XINDEX","ST",4)="44620:0:0:0"
-^ZZCOVERAGE("XINDEX","U")="72:0:0:0"
-^ZZCOVERAGE("XINDEX","U",0)="72:0:0:0"
-^ZZCOVERAGE("XINDEX","W")="4584:156009:200014:356023"
-^ZZCOVERAGE("XINDEX","W",0)="4584:0:16001:16001"
-^ZZCOVERAGE("XINDEX","X")="220:0:0:0"
-^ZZCOVERAGE("XINDEX","X",0)="220:0:0:0"
-^ZZCOVERAGE("XINDEX","XINDEX")="1:32002:36000:68002"
-^ZZCOVERAGE("XINDEX","XINDEX",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX1","A",0)="75:0:4000:4000"
-^ZZCOVERAGE("XINDX1","A",1)="75:0:0:0"
-^ZZCOVERAGE("XINDX1","A",2)="75:0:0:0"
-^ZZCOVERAGE("XINDX1","B",0)="75:0:0:0"
-^ZZCOVERAGE("XINDX1","B",4)="75:0:0:0"
-^ZZCOVERAGE("XINDX1","B",6)="75:0:0:0"
-^ZZCOVERAGE("XINDX1","B",7)="75:0:0:0"
-^ZZCOVERAGE("XINDX1","E")="73:0:4000:4000"
-^ZZCOVERAGE("XINDX1","E",0)="73:0:0:0"
-^ZZCOVERAGE("XINDX1","XINDX1")="2:0:0:0"
-^ZZCOVERAGE("XINDX1","XINDX1",3)="2:0:0:0"
-^ZZCOVERAGE("XINDX10","ASK")="1:0:0:0"
-^ZZCOVERAGE("XINDX10","ASK",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX10","ASK",2)="1:0:0:0"
-^ZZCOVERAGE("XINDX10","ASK",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX10","ASK",8)="1:0:0:0"
-^ZZCOVERAGE("XINDX2","%")="44620:132010:232014:364024"
-^ZZCOVERAGE("XINDX2","%",0)="44620:96008:92005:188013"
-^ZZCOVERAGE("XINDX2","%",0,"FOR_LOOP",1)=62810
-^ZZCOVERAGE("XINDX2","%",1)="44620:16001:68003:84004"
-^ZZCOVERAGE("XINDX2","ARG")="329774:1516089:2124136:3640225"
-^ZZCOVERAGE("XINDX2","ARG",1)="330498:328020:360021:688041"
-^ZZCOVERAGE("XINDX2","ARG",2)="262221:228015:296022:524037"
-^ZZCOVERAGE("XINDX2","ARG",3)="226556:260020:468034:728054"
-^ZZCOVERAGE("XINDX2","ARG",4)="126854:104004:160011:264015"
-^ZZCOVERAGE("XINDX2","ARG",5)="117750:136007:148011:284018"
-^ZZCOVERAGE("XINDX2","ARG",6)="88629:60001:96003:156004"
-^ZZCOVERAGE("XINDX2","ARG",7)="88424:80005:100006:180011"
-^ZZCOVERAGE("XINDX2","ARG",8)="86550:72002:108007:180009"
-^ZZCOVERAGE("XINDX2","ARGG")="18715:288018:352019:640037"
-^ZZCOVERAGE("XINDX2","ARGG",0)="18715:76007:84005:160012"
-^ZZCOVERAGE("XINDX2","ARGG",0,"FOR_LOOP",1)=49672
-^ZZCOVERAGE("XINDX2","ARGS")="44410:464031:676031:1140062"
-^ZZCOVERAGE("XINDX2","ARGS",1)="63125:620038:844037:1464075"
-^ZZCOVERAGE("XINDX2","ARGS",1,"FOR_LOOP",1)=291597
-^ZZCOVERAGE("XINDX2","ARGS",2)="63125:24001:60004:84005"
-^ZZCOVERAGE("XINDX2","DN")="44410:208011:284017:492028"
-^ZZCOVERAGE("XINDX2","DN",0)="44410:44003:108008:152011"
-^ZZCOVERAGE("XINDX2","DN",1)="44410:152008:144006:296014"
-^ZZCOVERAGE("XINDX2","EXT",1)="1970:4000:8001:12001"
-^ZZCOVERAGE("XINDX2","EXT",2)="1970:0:0:0"
-^ZZCOVERAGE("XINDX2","EXT",3)="1970:8001:12001:20002"
-^ZZCOVERAGE("XINDX2","EXT",4)="1970:0:4000:4000"
-^ZZCOVERAGE("XINDX2","FLUSH")="94:0:0:0"
-^ZZCOVERAGE("XINDX2","FLUSH",0)="94:0:0:0"
-^ZZCOVERAGE("XINDX2","FLUSH",1)="94:0:0:0"
-^ZZCOVERAGE("XINDX2","FLUSH",1,"FOR_LOOP",1)=415
-^ZZCOVERAGE("XINDX2","FLUSH",2)="94:0:0:0"
-^ZZCOVERAGE("XINDX2","FNC")="12:0:0:0"
-^ZZCOVERAGE("XINDX2","FNC",0)="12:0:0:0"
-^ZZCOVERAGE("XINDX2","FNC",1)="12:0:0:0"
-^ZZCOVERAGE("XINDX2","FNC",2)="12:0:0:0"
-^ZZCOVERAGE("XINDX2","FNC",3)="12:0:0:0"
-^ZZCOVERAGE("XINDX2","FNC",4)="12:0:0:0"
-^ZZCOVERAGE("XINDX2","FUN")="29121:340019:424027:764046"
-^ZZCOVERAGE("XINDX2","FUN",0)="29121:36004:40002:76006"
-^ZZCOVERAGE("XINDX2","FUN",1)="23452:48002:72003:120005"
-^ZZCOVERAGE("XINDX2","FUN",2)="23452:20000:44003:64003"
-^ZZCOVERAGE("XINDX2","FUN",3)="23393:96004:56005:152009"
-^ZZCOVERAGE("XINDX2","FUN",3,"FOR_LOOP",1)=147754
-^ZZCOVERAGE("XINDX2","FUN",4)="23393:48003:56005:104008"
-^ZZCOVERAGE("XINDX2","FUN",5)="23393:60004:92005:152009"
-^ZZCOVERAGE("XINDX2","GLO",0)="9104:28002:28001:56003"
-^ZZCOVERAGE("XINDX2","GLO",1)="9104:12001:20001:32002"
-^ZZCOVERAGE("XINDX2","GLO",2)="9104:16000:28001:44001"
-^ZZCOVERAGE("XINDX2","GLO",3)="9104:36002:80004:116006"
-^ZZCOVERAGE("XINDX2","GLO",4)="9104:8000:4000:12000"
-^ZZCOVERAGE("XINDX2","INC")="322910:416022:652029:1068051"
-^ZZCOVERAGE("XINDX2","INC",0)="365505:320019:472020:792039"
-^ZZCOVERAGE("XINDX2","INC2")="42595:104006:148008:252014"
-^ZZCOVERAGE("XINDX2","INC2",0)="42595:48001:40003:88004"
-^ZZCOVERAGE("XINDX2","LOC")="99702:576031:736052:1312083"
-^ZZCOVERAGE("XINDX2","LOC",0)="99702:144010:156013:300023"
-^ZZCOVERAGE("XINDX2","LOC",1)="99702:124004:148011:272015"
-^ZZCOVERAGE("XINDX2","LOC",2)="99702:212011:272014:484025"
-^ZZCOVERAGE("XINDX2","LOC",3)="99702:52005:96006:148011"
-^ZZCOVERAGE("XINDX2","NAK",0)="996:0:0:0"
-^ZZCOVERAGE("XINDX2","NAK",1)="996:0:0:0"
-^ZZCOVERAGE("XINDX2","PAT")="205:4000:0:4000"
-^ZZCOVERAGE("XINDX2","PAT",0)="205:0:0:0"
-^ZZCOVERAGE("XINDX2","PAT",1)="205:4000:0:4000"
-^ZZCOVERAGE("XINDX2","PAT",1,"FOR_LOOP",1)=457
-^ZZCOVERAGE("XINDX2","PAT",2)="205:0:0:0"
-^ZZCOVERAGE("XINDX2","PATCODE")="457:4000:4000:8000"
-^ZZCOVERAGE("XINDX2","PATCODE",0)="457:0:4000:4000"
-^ZZCOVERAGE("XINDX2","PATCODE",1)="358:4000:0:4000"
-^ZZCOVERAGE("XINDX2","PATCODE",1,"FOR_LOOP",1)=791
-^ZZCOVERAGE("XINDX2","PATCODE",2)="358:0:0:0"
-^ZZCOVERAGE("XINDX2","PATCODE",3)="358:0:0:0"
-^ZZCOVERAGE("XINDX2","PATCODE",4)="358:0:0:0"
-^ZZCOVERAGE("XINDX2","PATQ")="99:4000:4000:8000"
-^ZZCOVERAGE("XINDX2","PATQ",0)="99:0:4000:4000"
-^ZZCOVERAGE("XINDX2","PATQ",0,"FOR_LOOP",1)=247
-^ZZCOVERAGE("XINDX2","PATQ",1)="99:4000:0:4000"
-^ZZCOVERAGE("XINDX2","PATQ",2)="99:0:0:0"
-^ZZCOVERAGE("XINDX2","PEEK")="112687:168013:248022:416035"
-^ZZCOVERAGE("XINDX2","PEEK",0)="112687:120009:164010:284019"
-^ZZCOVERAGE("XINDX2","PEEKDN")="17373:56002:40000:96002"
-^ZZCOVERAGE("XINDX2","PEEKDN",0)="17373:48002:32000:80002"
-^ZZCOVERAGE("XINDX2","REPCNT")="457:0:0:0"
-^ZZCOVERAGE("XINDX2","REPCNT",0)="457:0:0:0"
-^ZZCOVERAGE("XINDX2","REPCNT",0,"FOR_LOOP",1)=1004
-^ZZCOVERAGE("XINDX2","REPCNT",1)="457:0:0:0"
-^ZZCOVERAGE("XINDX2","REPCNT",2)="457:0:0:0"
-^ZZCOVERAGE("XINDX2","SPV",1)="3699:0:8001:8001"
-^ZZCOVERAGE("XINDX2","SPV",2)="3699:0:0:0"
-^ZZCOVERAGE("XINDX2","ST")="110835:464030:648049:1112079"
-^ZZCOVERAGE("XINDX2","ST",0)="110835:192009:248021:440030"
-^ZZCOVERAGE("XINDX2","ST",1)="110835:100008:156011:256019"
-^ZZCOVERAGE("XINDX2","ST",2)="110835:76005:116005:192010"
-^ZZCOVERAGE("XINDX2","TEXT",0)="59:0:0:0"
-^ZZCOVERAGE("XINDX2","TEXT",1)="59:0:0:0"
-^ZZCOVERAGE("XINDX2","TEXT",2)="59:0:0:0"
-^ZZCOVERAGE("XINDX2","TEXT",3)="59:0:0:0"
-^ZZCOVERAGE("XINDX2","UP")="44410:116012:180012:296024"
-^ZZCOVERAGE("XINDX2","UP",1)="44410:112012:116006:228018"
-^ZZCOVERAGE("XINDX2","VA")="5073:16001:20000:36001"
-^ZZCOVERAGE("XINDX2","VA",0)="5073:4000:12000:16000"
-^ZZCOVERAGE("XINDX2","VA",1)="5073:8000:4000:12000"
-^ZZCOVERAGE("XINDX2","VT")="10205:4001:24002:28003"
-^ZZCOVERAGE("XINDX2","VT",0)="10205:0:8000:8000"
-^ZZCOVERAGE("XINDX2","VT",1)="10205:0:4000:4000"
-^ZZCOVERAGE("XINDX3","A",0)="8136:36001:12001:48002"
-^ZZCOVERAGE("XINDX3","ASM")="312:12001:0:12001"
-^ZZCOVERAGE("XINDX3","ASM",0)="312:0:0:0"
-^ZZCOVERAGE("XINDX3","ASM",1)="312:8001:0:8001"
-^ZZCOVERAGE("XINDX3","ASM",1,"FOR_LOOP",1)=2110
-^ZZCOVERAGE("XINDX3","ASM",2)="312:0:0:0"
-^ZZCOVERAGE("XINDX3","DN")="498:4000:4000:8000"
-^ZZCOVERAGE("XINDX3","DN",0)="498:0:4000:4000"
-^ZZCOVERAGE("XINDX3","DN",1)="498:4000:0:4000"
-^ZZCOVERAGE("XINDX3","FL")="63250:152007:260014:412021"
-^ZZCOVERAGE("XINDX3","FL",1)="63250:72000:144009:216009"
-^ZZCOVERAGE("XINDX3","FL",2)="63250:64006:80004:144010"
-^ZZCOVERAGE("XINDX3","INC")="145482:224018:308026:532044"
-^ZZCOVERAGE("XINDX3","INC",0)="145482:188015:196015:384030"
-^ZZCOVERAGE("XINDX3","KL",1)="2218:0:4000:4000"
-^ZZCOVERAGE("XINDX3","KL1")="28:0:0:0"
-^ZZCOVERAGE("XINDX3","KL1",0)="28:0:0:0"
-^ZZCOVERAGE("XINDX3","KL2")="724:4000:28000:32000"
-^ZZCOVERAGE("XINDX3","KL2",0)="724:0:0:0"
-^ZZCOVERAGE("XINDX3","KL2",1)="724:0:4000:4000"
-^ZZCOVERAGE("XINDX3","KL2",2)="724:0:0:0"
-^ZZCOVERAGE("XINDX3","KL3")="3320:12002:36002:48004"
-^ZZCOVERAGE("XINDX3","KL3",0)="3320:4000:8000:12000"
-^ZZCOVERAGE("XINDX3","KL3",1)="3320:4001:4000:8001"
-^ZZCOVERAGE("XINDX3","KL5",0)="3320:0:20002:20002"
-^ZZCOVERAGE("XINDX3","MULT")="498:8001:4000:12001"
-^ZZCOVERAGE("XINDX3","MULT",0)="498:4001:0:4001"
-^ZZCOVERAGE("XINDX3","MULT",1)="498:4000:4000:8000"
-^ZZCOVERAGE("XINDX3","MULT",1,"FOR_LOOP",1)=2401
-^ZZCOVERAGE("XINDX3","MULT",2)="498:0:0:0"
-^ZZCOVERAGE("XINDX3","N2",0)="23604:68004:36003:104007"
-^ZZCOVERAGE("XINDX3","N2",3)="11802:16002:4000:20002"
-^ZZCOVERAGE("XINDX3","N2",4)="187:0:0:0"
-^ZZCOVERAGE("XINDX3","N2",5)="187:0:0:0"
-^ZZCOVERAGE("XINDX3","N2",6)="11628:12001:20002:32003"
-^ZZCOVERAGE("XINDX3","N2",7)="11628:12000:8000:20000"
-^ZZCOVERAGE("XINDX3","NE")="779:32002:16001:48003"
-^ZZCOVERAGE("XINDX3","NE",1)="2500:4000:4000:8000"
-^ZZCOVERAGE("XINDX3","NE",2)="2500:4000:20000:24000"
-^ZZCOVERAGE("XINDX3","PEEK")="498:0:0:0"
-^ZZCOVERAGE("XINDX3","PEEK",0)="498:0:0:0"
-^ZZCOVERAGE("XINDX3","PEEKDN")="39:0:0:0"
-^ZZCOVERAGE("XINDX3","PEEKDN",0)="39:0:0:0"
-^ZZCOVERAGE("XINDX3","RD",0)="85:0:0:0"
-^ZZCOVERAGE("XINDX3","RD1",0)="278:0:4001:4001"
-^ZZCOVERAGE("XINDX3","RD1",3)="193:0:4000:4000"
-^ZZCOVERAGE("XINDX3","RD1",4)="85:0:0:0"
-^ZZCOVERAGE("XINDX3","RD1",5)="85:0:0:0"
-^ZZCOVERAGE("XINDX3","RD2")="85:0:4000:4000"
-^ZZCOVERAGE("XINDX3","RD2",0)="255:0:0:0"
-^ZZCOVERAGE("XINDX3","RD2",1)="170:0:0:0"
-^ZZCOVERAGE("XINDX3","RD2",2)="170:0:4000:4000"
-^ZZCOVERAGE("XINDX3","RD2",3)="85:0:0:0"
-^ZZCOVERAGE("XINDX3","RD3")="108:0:0:0"
-^ZZCOVERAGE("XINDX3","RD3",0)="161:0:0:0"
-^ZZCOVERAGE("XINDX3","RD3",1)="37:0:0:0"
-^ZZCOVERAGE("XINDX3","RD3",2)="37:0:0:0"
-^ZZCOVERAGE("XINDX3","S",1)="17579:48005:56003:104008"
-^ZZCOVERAGE("XINDX3","S2",0)="110559:164008:220011:384019"
-^ZZCOVERAGE("XINDX3","S2",1)="92980:64007:96005:160012"
-^ZZCOVERAGE("XINDX3","S2",2)="92980:52004:100005:152009"
-^ZZCOVERAGE("XINDX3","S2",3)="87238:60005:68003:128008"
-^ZZCOVERAGE("XINDX3","S2",4)="63916:68007:68004:136011"
-^ZZCOVERAGE("XINDX3","S2",5)="846:0:0:0"
-^ZZCOVERAGE("XINDX3","S2",6)="846:0:4000:4000"
-^ZZCOVERAGE("XINDX3","S2",10)="63916:56004:60003:116007"
-^ZZCOVERAGE("XINDX3","S2",11)="62481:40002:60003:100005"
-^ZZCOVERAGE("XINDX3","S2",12)="62313:56003:56005:112008"
-^ZZCOVERAGE("XINDX3","S2",13)="61815:76007:152010:228017"
-^ZZCOVERAGE("XINDX3","UP")="498:8000:4000:12000"
-^ZZCOVERAGE("XINDX3","UP",1)="498:8000:4000:12000"
-^ZZCOVERAGE("XINDX3","VLN",1)="15909:32002:16001:48003"
-^ZZCOVERAGE("XINDX3","VLN",2)="15909:44002:28003:72005"
-^ZZCOVERAGE("XINDX3","VLNF")="15909:120006:60005:180011"
-^ZZCOVERAGE("XINDX3","VLNF",0)="15909:32002:12001:44003"
-^ZZCOVERAGE("XINDX4","CNG")="2186:0:24001:24001"
-^ZZCOVERAGE("XINDX4","CNG",0)="2186:0:0:0"
-^ZZCOVERAGE("XINDX4","CNG",2)="2186:0:8001:8001"
-^ZZCOVERAGE("XINDX4","CNG",2,"FOR_LOOP",1)=2202
-^ZZCOVERAGE("XINDX4","CNG",3)="2186:0:12000:12000"
-^ZZCOVERAGE("XINDX4","DG",0)="8937:20003:16000:36003"
-^ZZCOVERAGE("XINDX4","DG",1)="8937:12000:16001:28001"
-^ZZCOVERAGE("XINDX4","DG",2)="8937:8001:20002:28003"
-^ZZCOVERAGE("XINDX4","DG",3)="8937:16000:12000:28000"
-^ZZCOVERAGE("XINDX4","DG",4)="8937:4000:12001:16001"
-^ZZCOVERAGE("XINDX4","DG",5)="8937:0:12002:12002"
-^ZZCOVERAGE("XINDX4","DG",6)="8937:12001:12000:24001"
-^ZZCOVERAGE("XINDX4","DG",7)="8937:12000:20003:32003"
-^ZZCOVERAGE("XINDX4","DG",8)="8937:24001:4001:28002"
-^ZZCOVERAGE("XINDX4","DG",9)="8937:4000:12001:16001"
-^ZZCOVERAGE("XINDX4","DG",10)="8937:16001:28001:44002"
-^ZZCOVERAGE("XINDX4","DG",11)="8937:8000:12000:20000"
-^ZZCOVERAGE("XINDX4","DG",12)="8937:4000:16002:20002"
-^ZZCOVERAGE("XINDX4","DG",13)="8937:8000:12002:20002"
-^ZZCOVERAGE("XINDX4","DG",14)="8937:0:4000:4000"
-^ZZCOVERAGE("XINDX4","DG",15)="8937:36002:32002:68004"
-^ZZCOVERAGE("XINDX4","DG",16)="8937:8001:4001:12002"
-^ZZCOVERAGE("XINDX4","DG",17)="8387:12002:4000:16002"
-^ZZCOVERAGE("XINDX4","DG1")="8449:168011:180013:348024"
-^ZZCOVERAGE("XINDX4","DG1",0)="8449:12001:16001:28002"
-^ZZCOVERAGE("XINDX4","FR",0)="525:0:4001:4001"
-^ZZCOVERAGE("XINDX4","FR",1)="525:0:0:0"
-^ZZCOVERAGE("XINDX4","FR",2)="525:0:0:0"
-^ZZCOVERAGE("XINDX4","INSIDE")="2202:4001:32001:36002"
-^ZZCOVERAGE("XINDX4","INSIDE",0)="2202:0:16000:16000"
-^ZZCOVERAGE("XINDX4","INSIDE",1)="2202:0:4000:4000"
-^ZZCOVERAGE("XINDX4","INSIDE",2)="2202:4001:4000:8001"
-^ZZCOVERAGE("XINDX4","LO",1)="259:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",2)="259:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",3)="259:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",4)="259:0:4000:4000"
-^ZZCOVERAGE("XINDX4","LO",4,"FOR_LOOP",1)=260
-^ZZCOVERAGE("XINDX4","LO",5)="260:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",6)="260:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",7)="260:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",8)="89:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",9)="89:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",10)="89:4001:0:4001"
-^ZZCOVERAGE("XINDX4","LO",12)="259:0:0:0"
-^ZZCOVERAGE("XINDX4","LO",13)="259:0:0:0"
-^ZZCOVERAGE("XINDX4","LOOP")="14735:44003:108008:152011"
-^ZZCOVERAGE("XINDX4","LOOP",0)="14735:28002:72005:100007"
-^ZZCOVERAGE("XINDX4","LOOP",0,"FOR_LOOP",1)=68121
-^ZZCOVERAGE("XINDX4","LOOP",1)="14735:4000:32003:36003"
-^ZZCOVERAGE("XINDX4","PAREN")="2638:24000:36004:60004"
-^ZZCOVERAGE("XINDX4","PAREN",0)="2638:4000:8000:12000"
-^ZZCOVERAGE("XINDX4","PAREN",1)="2638:20000:16001:36001"
-^ZZCOVERAGE("XINDX4","PAREN",1,"FOR_LOOP",1)=50171
-^ZZCOVERAGE("XINDX4","PAREN",2)="2638:0:8002:8002"
-^ZZCOVERAGE("XINDX4","PAREN",3)="2638:0:0:0"
-^ZZCOVERAGE("XINDX4","PRUNE")="2186:8001:16001:24002"
-^ZZCOVERAGE("XINDX4","PRUNE",0)="2186:8001:4000:12001"
-^ZZCOVERAGE("XINDX4","PRUNE",1)="2186:0:8001:8001"
-^ZZCOVERAGE("XINDX4","PRUNE",1,"FOR_LOOP",1)=2186
-^ZZCOVERAGE("XINDX4","PRUNE",2)="2186:0:4000:4000"
-^ZZCOVERAGE("XINDX4","PRUNE",2,"FOR_LOOP",1)=2187
-^ZZCOVERAGE("XINDX4","PRUNE",3)="2186:0:0:0"
-^ZZCOVERAGE("XINDX4","Q",1)="747:8000:0:8000"
-^ZZCOVERAGE("XINDX4","Q",2)="747:0:0:0"
-^ZZCOVERAGE("XINDX4","QUOTE")="2402:28002:28000:56002"
-^ZZCOVERAGE("XINDX4","QUOTE",0)="2402:20002:20000:40002"
-^ZZCOVERAGE("XINDX4","QUOTE",0,"FOR_LOOP",1)=23674
-^ZZCOVERAGE("XINDX4","QUOTE",1)="2402:0:0:0"
-^ZZCOVERAGE("XINDX4","QUOTE",2)="2402:8000:4000:12000"
-^ZZCOVERAGE("XINDX4","ST")="8937:24000:16002:40002"
-^ZZCOVERAGE("XINDX4","ST",0)="8937:12000:8000:20000"
-^ZZCOVERAGE("XINDX4","ST",1)="8937:8000:8002:16002"
-^ZZCOVERAGE("XINDX4","WR",0)="4584:12001:12000:24001"
-^ZZCOVERAGE("XINDX4","WR",1)="4584:0:8000:8000"
-^ZZCOVERAGE("XINDX4","WR",2)="4584:72004:56006:128010"
-^ZZCOVERAGE("XINDX4","WR",2,"FOR_LOOP",1)=27607
-^ZZCOVERAGE("XINDX4","WR",3)="23023:8002:32003:40005"
-^ZZCOVERAGE("XINDX4","WR",4)="20835:12000:32001:44001"
-^ZZCOVERAGE("XINDX4","WR",5)="20835:24002:8001:32003"
-^ZZCOVERAGE("XINDX4","WR",6)="20835:24000:36002:60002"
-^ZZCOVERAGE("XINDX4","WR",7)="20835:0:0:0"
-^ZZCOVERAGE("XINDX4","WR",8)="4584:4000:0:4000"
-^ZZCOVERAGE("XINDX4","XE",0)="220:0:0:0"
-^ZZCOVERAGE("XINDX4","XE",1)="220:0:0:0"
-^ZZCOVERAGE("XINDX5","A",0)="468:0:4000:4000"
-^ZZCOVERAGE("XINDX5","A",1)="467:28002:24000:52002"
-^ZZCOVERAGE("XINDX5","A",1,"FOR_LOOP",1)=4011
-^ZZCOVERAGE("XINDX5","A",2)="467:0:0:0"
-^ZZCOVERAGE("XINDX5","AA")="3544:48004:68006:116010"
-^ZZCOVERAGE("XINDX5","AA",0)="3544:8002:16003:24005"
-^ZZCOVERAGE("XINDX5","AA",1)="1902:0:4000:4000"
-^ZZCOVERAGE("XINDX5","AA",2)="1902:4001:0:4001"
-^ZZCOVERAGE("XINDX5","AA",3)="1902:12001:4001:16002"
-^ZZCOVERAGE("XINDX5","AA",4)="1902:12000:32002:44002"
-^ZZCOVERAGE("XINDX5","AA",5)="1902:0:0:0"
-^ZZCOVERAGE("XINDX5","AA",6)="1209:0:0:0"
-^ZZCOVERAGE("XINDX5","AA",7)="1209:8000:4000:12000"
-^ZZCOVERAGE("XINDX5","AA",8)="1209:0:0:0"
-^ZZCOVERAGE("XINDX5","AA",9)="1642:0:4000:4000"
-^ZZCOVERAGE("XINDX5","AA",10)="1594:0:0:0"
-^ZZCOVERAGE("XINDX5","AA",11)="1594:4000:4000:8000"
-^ZZCOVERAGE("XINDX5","AA",12)="1642:0:0:0"
-^ZZCOVERAGE("XINDX5","B",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","CLEAN",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","CLEAN",2)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","CLEAN",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","END",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","END",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","END",2)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","END",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","VTAG")="4320:12000:16001:28001"
-^ZZCOVERAGE("XINDX5","VTAG",0)="4320:12000:8001:20001"
-^ZZCOVERAGE("XINDX5","VTAG",1)="4320:0:4000:4000"
-^ZZCOVERAGE("XINDX5","XINDX5",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","XINDX5",4)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","XINDX5",5)="1:0:0:0"
-^ZZCOVERAGE("XINDX5","XINDX5",7)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","B")="1:0:4001:4001"
-^ZZCOVERAGE("XINDX51","B",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","B",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","B",3)="1:0:4001:4001"
-^ZZCOVERAGE("XINDX51","B",3,"FOR_LOOP",1)=468
-^ZZCOVERAGE("XINDX51","B",4)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","B",6)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","BHDR")="60:0:4000:4000"
-^ZZCOVERAGE("XINDX51","BHDR",0)="60:0:4000:4000"
-^ZZCOVERAGE("XINDX51","BHDR",1)="60:0:0:0"
-^ZZCOVERAGE("XINDX51","END",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","HD")="60:0:0:0"
-^ZZCOVERAGE("XINDX51","HD",0)="60:0:0:0"
-^ZZCOVERAGE("XINDX51","HD",1)="60:0:0:0"
-^ZZCOVERAGE("XINDX51","HD1")="1:0:0:0"
-^ZZCOVERAGE("XINDX51","HD1",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","HD1",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","HD2")="60:4000:0:4000"
-^ZZCOVERAGE("XINDX51","HD2",0)="60:4000:0:4000"
-^ZZCOVERAGE("XINDX51","HD2",1)="60:0:0:0"
-^ZZCOVERAGE("XINDX51","WAIT")="1:0:0:0"
-^ZZCOVERAGE("XINDX51","WAIT",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","WAIT",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","WAIT",2)="1:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR")="60:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR",0)="60:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR",1)="60:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR",2)="60:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR",2,"FOR_LOOP",1)=135
-^ZZCOVERAGE("XINDX51","WERR",3)="75:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR",4)="75:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR",5)="75:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR",6)="75:0:0:0"
-^ZZCOVERAGE("XINDX51","WERR",7)="60:0:0:0"
-^ZZCOVERAGE("XINDX51","WORL")="70:0:0:0"
-^ZZCOVERAGE("XINDX51","WORL",0)="70:0:0:0"
-^ZZCOVERAGE("XINDX51","WORL",1)="70:0:0:0"
-^ZZCOVERAGE("XINDX51","WORL",2)="70:0:0:0"
-^ZZCOVERAGE("XINDX51","WORL",3)="70:0:0:0"
-^ZZCOVERAGE("XINDX51","WORL",3,"FOR_LOOP",1)=76
-^ZZCOVERAGE("XINDX51","WORL",4)="70:0:0:0"
-^ZZCOVERAGE("XINDX52","CASE")="2:0:0:0"
-^ZZCOVERAGE("XINDX52","CASE",0)="2:0:0:0"
-^ZZCOVERAGE("XINDX52","CASE",1)="2:0:0:0"
-^ZZCOVERAGE("XINDX6","ANS")="2:0:0:0"
-^ZZCOVERAGE("XINDX6","ANS",0)="2:0:0:0"
-^ZZCOVERAGE("XINDX6","ANS",1)="2:0:0:0"
-^ZZCOVERAGE("XINDX6","ANS",1,"FOR_LOOP",1)=2
-^ZZCOVERAGE("XINDX6","ANS",2)="2:0:0:0"
-^ZZCOVERAGE("XINDX6","ASKRTN")="1:4000:0:4000"
-^ZZCOVERAGE("XINDX6","ASKRTN",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","ASKRTN",1,"FOR_LOOP",1)=468
-^ZZCOVERAGE("XINDX6","ASKRTN",2)="1:4000:0:4000"
-^ZZCOVERAGE("XINDX6","ASKRTN",2,"FOR_LOOP",1)=468
-^ZZCOVERAGE("XINDX6","ASKRTN",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","DEVICE",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","DEVICE",2)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","DEVICE",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","L7",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","L7",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","NY")="1:0:0:0"
-^ZZCOVERAGE("XINDX6","NY",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","PARAM")="1:0:0:0"
-^ZZCOVERAGE("XINDX6","PARAM",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","PARAM",2)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","PARAM",2,"FOR_LOOP",1)=10
-^ZZCOVERAGE("XINDX6","PARAM",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","PARAM",4)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","PARAM",5)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","PARAM",6)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","PARAM",7)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","RD")="2:0:0:0"
-^ZZCOVERAGE("XINDX6","RD",0)="2:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",5)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",6)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",7)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",8)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",9)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",10)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",11)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",12)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","XINDX6",13)="1:0:0:0"
-^ZZCOVERAGE("XINDX6","YN")="1:0:0:0"
-^ZZCOVERAGE("XINDX6","YN",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD")="1:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD",0)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD",1,"FOR_LOOP",1)=10
-^ZZCOVERAGE("XINDX7","BUILD",2)="9:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD",3)="6:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD",3,"FOR_LOOP",1)=85
-^ZZCOVERAGE("XINDX7","BUILD",4)="79:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD",5)="79:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD",6)="6:0:0:0"
-^ZZCOVERAGE("XINDX7","BUILD",7)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR")="2:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR",0)="2:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR",1)="2:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR",2)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR",4)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR",5)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR",6)="2:0:0:0"
-^ZZCOVERAGE("XINDX7","HDR",7)="2:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP")="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",1)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",2)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",3)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",4)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",6)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",7)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",7,"FOR_LOOP",1)=468
-^ZZCOVERAGE("XINDX7","SETUP",8)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",9)="1:0:0:0"
-^ZZCOVERAGE("XINDX7","SETUP",10)="1:0:0:0"
-^ZZCOVERAGE("XINDX9","ADD")="406841:436032:684041:1120073"
-^ZZCOVERAGE("XINDX9","ADD",0)="598820:552042:692040:1244082"
-^ZZCOVERAGE("XINDX9","AR")="197699:748039:1052073:1800112"
-^ZZCOVERAGE("XINDX9","AR",0)="197699:708036:936061:1644097"
-^ZZCOVERAGE("XINDX9","CASE")="23461:28003:92005:120008"
-^ZZCOVERAGE("XINDX9","CASE",0)="23461:12002:48003:60005"
-^ZZCOVERAGE("XINDX9","CASE",1)="23461:12001:28000:40001"
-^ZZCOVERAGE("XINDX9","DN")="45002:204010:248016:452026"
-^ZZCOVERAGE("XINDX9","DN",0)="45002:176008:196011:372019"
-^ZZCOVERAGE("XINDX9","DN",1)="45002:16001:24003:40004"
-^ZZCOVERAGE("XINDX9","EXT",1)="1970:4000:12001:16001"
-^ZZCOVERAGE("XINDX9","FNC")="29146:96005:104009:200014"
-^ZZCOVERAGE("XINDX9","FNC",0)="29146:28001:20003:48004"
-^ZZCOVERAGE("XINDX9","FNC",1)="29146:44002:72005:116007"
-^ZZCOVERAGE("XINDX9","FNC",2)="12:0:0:0"
-^ZZCOVERAGE("XINDX9","FNC",3)="12:0:0:0"
-^ZZCOVERAGE("XINDX9","FUNC")="29134:284015:400024:684039"
-^ZZCOVERAGE("XINDX9","FUNC",1)="29134:112005:120007:232012"
-^ZZCOVERAGE("XINDX9","FUNC",2)="23461:48003:72004:120007"
-^ZZCOVERAGE("XINDX9","FUNC",3)="23461:20000:32001:52001"
-^ZZCOVERAGE("XINDX9","FX",0)="23461:68004:116009:184013"
-^ZZCOVERAGE("XINDX9","GVAR")="29134:96004:180015:276019"
-^ZZCOVERAGE("XINDX9","GVAR",0)="29134:28000:44003:72003"
-^ZZCOVERAGE("XINDX9","GVAR",1)="29134:32001:72005:104006"
-^ZZCOVERAGE("XINDX9","GVAR",2)="29134:16000:24002:40002"
-^ZZCOVERAGE("XINDX9","INC")="29134:64003:64007:128010"
-^ZZCOVERAGE("XINDX9","INC",0)="29134:20001:12001:32002"
-^ZZCOVERAGE("XINDX9","INC",1)="29134:32002:40004:72006"
-^ZZCOVERAGE("XINDX9","NEW")="287703:532032:660032:1192064"
-^ZZCOVERAGE("XINDX9","NEW",0)="287703:200012:244014:444026"
-^ZZCOVERAGE("XINDX9","NEW",1)="287703:220014:248008:468022"
-^ZZCOVERAGE("XINDX9","NUM")="45379:292023:340026:632049"
-^ZZCOVERAGE("XINDX9","NUM",0)="45379:92006:84006:176012"
-^ZZCOVERAGE("XINDX9","NUM",0,"FOR_LOOP",1)=71145
-^ZZCOVERAGE("XINDX9","NUM",1)="45379:40005:48002:88007"
-^ZZCOVERAGE("XINDX9","NUM",2)="45379:40004:56005:96009"
-^ZZCOVERAGE("XINDX9","NUM",3)="45379:76003:88008:164011"
-^ZZCOVERAGE("XINDX9","NUM",4)="45379:24003:40003:64006"
-^ZZCOVERAGE("XINDX9","PA2",0)="518346:544028:668032:1212060"
-^ZZCOVERAGE("XINDX9","PA2",1)="472665:532043:620035:1152078"
-^ZZCOVERAGE("XINDX9","PA2",2)="317803:264019:292021:556040"
-^ZZCOVERAGE("XINDX9","PA2",3)="317803:200013:324018:524031"
-^ZZCOVERAGE("XINDX9","PA2",4)="307072:348020:492025:840045"
-^ZZCOVERAGE("XINDX9","PA2",5)="197397:160015:296011:456026"
-^ZZCOVERAGE("XINDX9","PA2",6)="152018:120016:132005:252021"
-^ZZCOVERAGE("XINDX9","PA2",7)="152018:116009:112008:228017"
-^ZZCOVERAGE("XINDX9","PA2",8)="151813:96008:168010:264018"
-^ZZCOVERAGE("XINDX9","PA2",9)="151813:100008:172009:272017"
-^ZZCOVERAGE("XINDX9","PA2",10)="151813:220008:324022:544030"
-^ZZCOVERAGE("XINDX9","PA2",11)="151813:168011:152010:320021"
-^ZZCOVERAGE("XINDX9","PA2",12)="151813:128009:148012:276021"
-^ZZCOVERAGE("XINDX9","PA2",13)="151813:136005:104009:240014"
-^ZZCOVERAGE("XINDX9","PARSE")="45681:3356226:4340257:7696483"
-^ZZCOVERAGE("XINDX9","PARSE",0)="45681:104007:108007:212014"
-^ZZCOVERAGE("XINDX9","PAT")="205:0:0:0"
-^ZZCOVERAGE("XINDX9","PAT",0)="205:0:0:0"
-^ZZCOVERAGE("XINDX9","PAT",1)="205:0:0:0"
-^ZZCOVERAGE("XINDX9","PAT",1,"FOR_LOOP",1)=1185
-^ZZCOVERAGE("XINDX9","PAT",2)="205:0:0:0"
-^ZZCOVERAGE("XINDX9","PAT",3)="205:0:0:0"
-^ZZCOVERAGE("XINDX9","PAT",4)="205:0:0:0"
-^ZZCOVERAGE("XINDX9","PATC")="28:0:0:0"
-^ZZCOVERAGE("XINDX9","PATC",0)="28:0:0:0"
-^ZZCOVERAGE("XINDX9","PATQ")="99:0:8000:8000"
-^ZZCOVERAGE("XINDX9","PATQ",0)="99:0:0:0"
-^ZZCOVERAGE("XINDX9","PATQ",0,"FOR_LOOP",1)=247
-^ZZCOVERAGE("XINDX9","PATQ",1)="99:0:0:0"
-^ZZCOVERAGE("XINDX9","PATQ",2)="99:0:8000:8000"
-^ZZCOVERAGE("XINDX9","PATU")="15:0:0:0"
-^ZZCOVERAGE("XINDX9","PATU",0)="15:0:0:0"
-^ZZCOVERAGE("XINDX9","PEND",0)="45681:68001:140014:208015"
-^ZZCOVERAGE("XINDX9","PEND",1)="45681:36004:52005:88009"
-^ZZCOVERAGE("XINDX9","QUOTE")="35724:244013:304019:548032"
-^ZZCOVERAGE("XINDX9","QUOTE",0)="36272:172010:140009:312019"
-^ZZCOVERAGE("XINDX9","QUOTE",0,"FOR_LOOP",1)=323021
-^ZZCOVERAGE("XINDX9","QUOTE",1)="36272:28001:72004:100005"
-^ZZCOVERAGE("XINDX9","QUOTE",2)="35724:28001:24003:52004"
-^ZZCOVERAGE("XINDX9","QUOTE",3)="35724:16001:52002:68003"
-^ZZCOVERAGE("XINDX9","SPV",0)="3703:4000:12000:16000"
-^ZZCOVERAGE("XINDX9","SPV",1)="3703:8001:4000:12001"
-^ZZCOVERAGE("XINDX9","SPV",2)="3703:8001:4000:12001"
-^ZZCOVERAGE("XINDX9","SPV",3)="3703:4000:8001:12001"
-^ZZCOVERAGE("XINDX9","STR")="287703:560037:724043:1284080"
-^ZZCOVERAGE("XINDX9","STR",0)="287703:300018:312020:612038"
-^ZZCOVERAGE("XINDX9","SUM")="213322:612034:916052:1528086"
-^ZZCOVERAGE("XINDX9","SUM",0)="213322:160009:208011:368020"
-^ZZCOVERAGE("XINDX9","SUM",1)="213322:212007:280018:492025"
-^ZZCOVERAGE("XINDX9","SUM",2)="213322:136012:268012:404024"
-^ZZCOVERAGE("XINDX9","UP")="45002:396026:440029:836055"
-^ZZCOVERAGE("XINDX9","UP",0)="45002:24003:44001:68004"
-^ZZCOVERAGE("XINDX9","UP",1)="45002:180008:192016:372024"
-^ZZCOVERAGE("XINDX9","UP",2)="45002:136010:128005:264015"
-^ZZCOVERAGE("XINDX9","UP",3)="45002:40003:52003:92006"
-^ZZCOVERAGE("XINDX9","VAR")="138809:828044:1004072:1832116"
-^ZZCOVERAGE("XINDX9","VAR",0)="138809:376018:336017:712035"
-^ZZCOVERAGE("XINDX9","VAR",0,"FOR_LOOP",1)=462128
-^ZZCOVERAGE("XINDX9","VAR",1)="138809:292018:376034:668052"
-^ZZCOVERAGE("XINDX9","VAR",2)="138809:116003:144008:260011"
-^ZZCOVERAGE("XINDX9","XINDX9")="45681:296016:320021:616037"
-^ZZCOVERAGE("XINDX9","XINDX9",3)="45681:52003:128006:180009"
-^ZZCOVERAGE("XINDX9","XINDX9",4)="45681:164006:112008:276014"
-^ZZCOVERAGE("XINDX9","XINDX9",4,"FOR_LOOP",1)=128269
-^ZZCOVERAGE("XINDX9","XINDX9",5)="45681:48004:52005:100009"
-^ZZCOVERAGE("XLFDT","DT")="1:0:0:0"
-^ZZCOVERAGE("XLFDT","DT",0)="1:0:0:0"
-^ZZCOVERAGE("XLFDT","DT",1)="1:0:0:0"
-^ZZCOVERAGE("XLFDT","HR")="3:0:0:0"
-^ZZCOVERAGE("XLFDT","HR",0)="3:0:0:0"
-^ZZCOVERAGE("XLFDT","HR",1)="3:0:0:0"
-^ZZCOVERAGE("XLFDT","HTE")="1:0:0:0"
-^ZZCOVERAGE("XLFDT","HTE",0)="1:0:0:0"
-^ZZCOVERAGE("XLFDT","HTE",1)="1:0:0:0"
-^ZZCOVERAGE("XLFDT","HTE",2)="1:0:0:0"
-^ZZCOVERAGE("XLFDT","HTE",3)="1:0:0:0"
-^ZZCOVERAGE("XLFDT","HTFM")="2:0:0:0"
-^ZZCOVERAGE("XLFDT","HTFM",0)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","HTFM",1)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","HTFM",2)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","HTFM",3)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","HTFM",4)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","HTFM",5)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","T2",0)="1:0:0:0"
-^ZZCOVERAGE("XLFDT","T2",1)="1:0:0:0"
-^ZZCOVERAGE("XLFDT","YMD")="2:0:0:0"
-^ZZCOVERAGE("XLFDT","YMD",1)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","YMD",2)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","YMD",3)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","YMD",4)="2:0:0:0"
-^ZZCOVERAGE("XLFDT","YMD",5)="2:0:0:0"
-^ZZCOVERAGE("XLFDT1","F1",1)="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","FMT")="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","FMT",1)="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","FMT",2)="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","M")="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","M",0)="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","TM",1)="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","TM",2)="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","TM",3)="1:0:0:0"
-^ZZCOVERAGE("XLFDT1","TM",7)="1:0:0:0"
-^ZZCOVERAGE("XPDRSUM","SUMB")="467:1808124:180014:1988138"
-^ZZCOVERAGE("XPDRSUM","SUMB",0)="467:8000:0:8000"
-^ZZCOVERAGE("XPDRSUM","SUMB",2)="467:0:0:0"
-^ZZCOVERAGE("XPDRSUM","SUMB",3)="467:1796124:180014:1976138"
-^ZZCOVERAGE("XPDRSUM","SUMB",3,"FOR_LOOP",1)=44620
-^ZZCOVERAGE("XPDRSUM","SUMB",3,"FOR_LOOP",2)=1566704
-^ZZCOVERAGE("XPDRSUM","SUMB",4)="467:0:0:0"
-^ZZCOVERAGE("XTRUTL1","BUILD")="1:0:0:0"
-^ZZCOVERAGE("XTRUTL1","BUILD",0)="1:0:0:0"
-^ZZCOVERAGE("XTRUTL1","BUILD",1)="1:0:0:0"
-^ZZCOVERAGE("XTRUTL1","BUILD",2)="1:0:0:0"
-^ZZCOVERAGE("XTRUTL1","BUILD",3)="1:0:0:0"
-
-
diff --git a/Tests/MumpsCoverage/VistA-FOIA/Packages/Toolkit/Routines/XINDEX.m b/Tests/MumpsCoverage/VistA-FOIA/Packages/Toolkit/Routines/XINDEX.m
deleted file mode 100644
index b045221..0000000
--- a/Tests/MumpsCoverage/VistA-FOIA/Packages/Toolkit/Routines/XINDEX.m
+++ /dev/null
@@ -1,144 +0,0 @@
-XINDEX ;ISC/REL,GFT,GRK,RWF - INDEX & CROSS-REFERENCE ;08/04/08  13:19
- ;;7.3;TOOLKIT;**20,27,48,61,66,68,110,121,128**;Apr 25, 1995;Build 1
- ; Per VHA Directive 2004-038, this routine should not be modified.
- G ^XINDX6
-SEP F I=1:1 S CH=$E(LIN,I) D QUOTE:CH=Q Q:" "[CH
- S ARG=$E(LIN,1,I-1) S:CH=" " I=I+1 S LIN=$E(LIN,I,999) Q
-QUOTE F I=I+1:1 S CH=$E(LIN,I) Q:CH=""!(CH=Q)
- Q:CH]""  S ERR=6 G ^XINDX1
-ALIVE ;enter here from taskman
- D SETUP^XINDX7 ;Get ready to process
-A2 S RTN=$O(^UTILITY($J,RTN)) G ^XINDX5:RTN=""
- S INDLC=(RTN?1"|"1.4L.NP) D LOAD:'INDLC
- I $D(ZTQUEUED),$$S^%ZTLOAD S RTN="~",IND("QUIT")=1,ZTSTOP=1 G A2
- I 'INDDS,INDLC W !!?10,"Data Dictionaries",! S INDDS=1
- D BEG
- G A2
- ;
-LOAD S X=RTN,XCNP=0,DIF="^UTILITY("_$J_",1,RTN,0," X ^%ZOSF("TEST") Q:'$T  X ^%ZOSF("LOAD") S ^UTILITY($J,1,RTN,0,0)=XCNP-1
- I $D(^UTILITY($J,1,RTN,0,0)) S ^UTILITY($J,1,RTN,"RSUM")="B"_$$SUMB^XPDRSUM($NA(^UTILITY($J,1,RTN,0)))
- Q
-BEG ;
- S %=INDLC*5 W:$X+10+%>IOM ! W RTN,$J("",10+%-$L(RTN))
- S (IND("DO"),IND("SZT"),IND("SZC"),LABO)=0,LC=$G(^UTILITY($J,1,RTN,0,0))
- I LC="" W !,">>>Routine '",RTN,"' not found <<<",! Q
- S TXT="",LAB=$P(^UTILITY($J,1,RTN,0,1,0)," ") I RTN'=$P(LAB,"(") D E^XINDX1(17)
- I 'INDLC,LAB["(" D E^XINDX1(55) S LAB=$P(LAB,"(")
- ;if M routine(not compiled template or DD) and has more than 2 lines, check lines 1 & 2
- I 'INDLC,LC>2 D
- . N LABO S LABO=1
- . S LIN=$G(^UTILITY($J,1,RTN,0,1,0)),TXT=1
- . ;check 1st line (site/dev - ) patch 128
- . I $P(LIN,";",2,4)'?.E1"/".E.1"-".E D E^XINDX1(62)
- . S LIN=$G(^UTILITY($J,1,RTN,0,2,0)),TXT=2
- . ;check 2nd line (;;nn.nn[TV]nn;package;.anything)
- . I $P(LIN,";",3,99)'?1.2N1"."1.2N.1(1"T",1"V").2N1";"1A.AP1";".E D E^XINDX1(44) ;patch 121
- . I $L(INP(11)) X INP(11) ;Version number check
- . I $L(INP(12)) X INP(12) ;Patch number check
-B5 F TXT=1:1:LC S LIN=^UTILITY($J,1,RTN,0,TXT,0),LN=$L(LIN),IND("SZT")=IND("SZT")+LN+2 D LN,ST ;Process Line
- S LAB="",LABO=0,TXT=0,^UTILITY($J,1,RTN,0)=IND("SZT")_"^"_LC_"^"_IND("SZC")
- I IND("SZT")>INP("MAX"),'INDLC S ERR=35,ERR(1)=IND("SZT") D ^XINDX1
- I IND("SZT")-IND("SZC")>INP("CMAX"),'INDLC S ERR=58,ERR(1)=IND("SZT")-IND("SZC") D ^XINDX1
- D POSTRTN
- Q
- ;Proccess one line, LN = Length, LIN = Line.
-LN K V S (ARG,GRB,IND("COM"),IND("DOL"),IND("F"))="",X=$P(LIN," ")
- I '$L(X) S LABO=LABO+1 G CD
- S (IND("COM"),LAB)=$P(X,"("),ARG=$P($P(X,"(",2),")"),LABO=0,IND("PP")=X?1.8E1"(".E1")"
- D:$L(ARG) NE^XINDX3 ;Process formal parameters as New list.
- I 'INDLC,'$$VT^XINDX2(LAB) D E^XINDX1($S(LAB=$$CASE^XINDX52(LAB):37,1:55)) ;Check for bad labels
- I $D(^UTILITY($J,1,RTN,"T",LAB)) D E^XINDX1(15) G CD ;DUP label
- S ^UTILITY($J,1,RTN,"T",LAB)=""
-CD I LN>245 D:'(LN=246&($E(RTN,1,3)="|dd")) E^XINDX1(19) ;patch 119
- D:LIN'?1.ANP E^XINDX1(18)
- S LIN=$P(LIN," ",2,999),IND("LCC")=1
- I LIN="" D E^XINDX1(42) Q  ;Blank line ;p110
- S I=0 ;Watch the scope of I, counts dots
- I " ."[$E(LIN) D  S X=$L($E(LIN,1,I),".")-1,LIN=$E(LIN,I,999)
- . F I=1:1:245 Q:". "'[$E(LIN,I)
- . Q
- ;check dots against Do level IND("DO"), IND("DOL")=dot level
- D:'I&$G(IND("DO1")) E^XINDX1(51) S IND("DO1")=0 S:'I IND("DO")=0
- I I D:X>IND("DO") E^XINDX1(51) S (IND("DO"),IND("DOL"))=X
- ;Count Comment lines, skip ;; lines
- I $E(LIN)=";",$E(LIN,2)'=";" S IND("SZC")=IND("SZC")+$L(LIN) ;p110
- ;Process commands on line.
-EE I LIN="" D ^XINDX2 Q
- S COM=$E(LIN),GK="",ARG=""
- I COM=";" S LIN="" G EE ;p110
- I COM=" " S ERR=$S(LIN?1." ":13,1:0),LIN=$S(ERR:"",1:$E(LIN,2,999)) D:ERR ^XINDX1 G EE
- D SEP
- S CM=$P(ARG,":",1),POST=$P(ARG,":",2,999),IND("COM")=IND("COM")_$C(9)_COM,ERR=48
- D:ARG[":"&(POST']"") ^XINDX1 S:POST]"" GRB=GRB_$C(9)_POST,IND("COM")=IND("COM")_":"
- ;SAC now allows lowercase commands
- I CM?.E1L.E S CM=$$CASE^XINDX52(CM),COM=$E(CM) ;I IND("LCC") S IND("LCC")=0 D E^XINDX1(47)
- I CM="" D E^XINDX1(21) G EE ;Missing command
- S CX=$G(IND("CMD",CM)) I CX="" D  G:CX="" EE
- . I $E(CM)="Z" S CX="^Z" Q  ;Proccess Z commands
- . D E^XINDX1(1) S LIN="" Q
- S CX=$P(CX,"^",2,9)
- D SEP I '$L(LIN),CH=" " D E^XINDX1(13) ;trailing space
- I ARG="","CGJMORSUWX"[COM S ERR=49 G ^XINDX1
- I CX>0 D E^XINDX1(CX) S CX=""
- D:$L(CX) @CX S:ARG'="" GRB=GRB_$C(9)_ARG G EE
-B S ERR=25 G ^XINDX1
-C S ERR=29 G ^XINDX1
-D G DG1^XINDX4
-E Q:ARG=""  S ERR=7 G ^XINDX1
-F G:ARG]"" FR^XINDX4 S IND("F")=1 Q
-G G DG^XINDX4
-H Q:ARG'=""  S ERR=32 G ^XINDX1
-J S ERR=36,ARG="" G ^XINDX1
-K S ERR=$S(ARG?1"(".E:22,ARG?." ":23,1:0) D:ERR ^XINDX1
- G KL^XINDX3
-L G LO^XINDX4
-M G S^XINDX3
-N G NE^XINDX3
-O S ERR=34 D ^XINDX1,O^XINDX3 Q
-Q Q:ARG=""  G Q^XINDX4
-R S RDTIME=0 G RD^XINDX3
-S G S^XINDX3
-TR Q  ;What to process. p110
-U S ARG=$P(ARG,":") Q
-V S ARG="",ERR=20 G ^XINDX1
-W G WR^XINDX4
-X G XE^XINDX4
-Z S ERR=2 D ^XINDX1 G ZC^XINDX4
- ;
- ;Save off items from line.
-ST S R=LAB_$S(LABO:"+"_LABO,1:"")
- ;Local variable, Global, Marked Items, Naked global, Internal ref, eXternal ref., Tag ref.
- S LOC="" F  S LOC=$O(V(LOC)),S="" Q:LOC=""  F  S S=$O(V(LOC,S)) Q:S=""  D SET
- S ^UTILITY($J,1,RTN,"COM",TXT)=IND("COM")
- Q
- ;
-SET I V(LOC,S)]"" F %="!","~" I V(LOC,S)[%,$G(^UTILITY($J,1,RTN,LOC,S))'[% S ^(S)=$G(^(S))_%
- S %=0
-SE2 S ARG=$G(^UTILITY($J,1,RTN,LOC,S,%)) I $L(ARG)>230 S %=%+1 G SE2
- S ^UTILITY($J,1,RTN,LOC,S,%)=ARG_R_V(LOC,S)_","
- Q
- ;
-POSTRTN ;Do more overall checking
- N V,E,T,T1,T2
- S T="" ;Check for missing Labels
- F  S T=$O(^UTILITY($J,1,RTN,"I",T)),T2=T Q:T=""  S T1=$G(^(T,0)) D
- . Q:$E(T2,1,2)="@("
- . S:$E(T2,1,2)="$$" T2=$E(T2,3,99)
- . I T2]"",'$D(^UTILITY($J,1,RTN,"T",$P(T2,"+",1))) D
- . . F I=1:1:$L(T1,",")-1 S LAB=$P(T1,",",I),LABO=+$P(LAB,"+",2),LAB=$P(LAB,"+"),E=14,E(1)=T D E^XINDX1(.E)
- . . Q
- . Q
- S LAB="",LABO=0 ;Check for valid label names
- I 'INDLC F  S LAB=$O(^UTILITY($J,1,RTN,"T",LAB)) Q:LAB=""  D
- . I '$$VA^XINDX2(LAB) D E^XINDX1(55) Q
- . D:'$$VT^XINDX2(LAB) E^XINDX1(37)
- . Q
- S LAB="",LABO=0 ;Check for valid variable names.
- F  S LAB=$O(^UTILITY($J,1,RTN,"L",LAB)) Q:LAB=""  D
- . D VLNF^XINDX3($P(LAB,"("))
- . Q
- Q
- ;
-QUICK ;Quick, Just get a routine an print the results
- D QUICK^XINDX6()
- Q
diff --git a/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m b/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m
new file mode 100644
index 0000000..9a08edf
--- /dev/null
+++ b/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m
@@ -0,0 +1,36 @@
+ZZCOVTST;OSEHRA/JPS -- Test routine for Coverage Parsing;4/28/2014
+	; (tab) This is series of comments
+	; (tab) it should all be not executable
+        ; (spaces) one of these sets might be a problem
+        ; (spaces) we will have to see.
+EN	; This entry point shouldn't be found without fixing
+ N D
+ S D=1 ;An executable line
+ D T1^ZZCOVTST
+ I '$$T5 W "RETURNED FROM t5",!
+ Q
+ ; This line not executable
+ ;
+T1 ; This line should always be found
+ N D
+ S D=2
+ W !,D,!,"This is the second entry point",!
+ D T2^ZZCOVTST(D)
+ Q
+ ;
+T2(EQ) ; This is debatable and only called with ENT^ROU notation
+ N D
+ S D=3
+ W !,D,!,EQ,"This is the third entry point",!
+ D T3^ZZCOVTST
+ Q
+ ;
+T3  N D S D=4 W D,!,"Fourth Entry point",! Q
+ ;
+T4  N D S D=5 W "Shouldn't be executed"
+ W "Lots to not do"
+ Q
+T5(EQ) ;this entry point is called with a $$ notation
+ W "THIS IS THE $$ NOTATION!",!
+ Q 0
+ ;
diff --git a/Tests/MumpsCoverage/ZZCOVTST.cmcov b/Tests/MumpsCoverage/ZZCOVTST.cmcov
new file mode 100644
index 0000000..798e5b2
--- /dev/null
+++ b/Tests/MumpsCoverage/ZZCOVTST.cmcov
@@ -0,0 +1,38 @@
+Routine,Line,RtnLine,Code

+ZZCOVTST,1,0,"ZZCOVTST;OSEHRA/JPS -- Test routine for Coverage Parsing;4/28/2014"

+,2,0," ; (tab) This is series of comments"

+,3,0," ; (tab) it should all be not executable"

+,4,0,"        ; (spaces) one of these sets might be a problem"

+,5,0,"        ; (spaces) we will have to see."

+,6,0,"EN ; This entry point shouldn't be found without fixing"

+,7,1," N D"

+,8,1," S D=1 ;An executable line"

+,9,1," D T1^ZZCOVTST"

+,10,1,"I '$$T5 W ""RETURNED FROM t5"",!"

+,11,1," Q"

+,12,0," ; This line not executable"

+,13,0," ;"

+,14,0,"T1 ; This line should always be found"

+,15,1," N D"

+,16,1," S D=2"

+,17,1," W !,D,!,""This is the second entry point"",!"

+,18,1," D T2^ZZCOVTST(D)"

+,19,1," Q"

+,20,0," ;"

+,21,0,"T2(EQ) ; This is debatable"

+,22,1," N D"

+,23,1," S D=3"

+,24,1," W !,D,!,EQ,""This is the third entry point"",!"

+,25,1," D T3^ZZCOVTST"

+,26,1," Q"

+,27,0," ;"

+,28,1,"T3  N D S D=4 W D,!,""Fourth Entry point"",! Q"

+,29,0," ;"

+,30,0,"T4  N D S D=5 W ""Shouldn't be executed"""

+,31,0," W ""Lots to not do"""

+,32,0," Q"

+,33,1,"T5()"

+,34,1," W ""THIS IS ONE WITH $$ NOTATION"",1"

+,35,1," Q 0"

+,36,0," ;"

+Totals for ZZCOVTST,,19,

diff --git a/Tests/MumpsCoverage/ZZCOVTST.mcov b/Tests/MumpsCoverage/ZZCOVTST.mcov
new file mode 100644
index 0000000..f73d354
--- /dev/null
+++ b/Tests/MumpsCoverage/ZZCOVTST.mcov
@@ -0,0 +1,30 @@
+%GO Global Output Utility
+GT.M 30-APR-2014 14:24:46 ZWR
+^ZZCOVERAGE("*CHILDREN")="0:0:0"
+^ZZCOVERAGE("*RUN")="24000:88000:112000"
+^ZZCOVERAGE("ZZCOVTST","EN")="1:4000:8000:12000:6464583"
+^ZZCOVERAGE("ZZCOVTST","EN",1)="1:0:0:0:20"
+^ZZCOVERAGE("ZZCOVTST","EN",2)="1:0:0:0:14"
+^ZZCOVERAGE("ZZCOVTST","EN",3)="1:0:0:0:26"
+^ZZCOVERAGE("ZZCOVTST","EN",4)="1:0:0:0:228"
+^ZZCOVERAGE("ZZCOVTST","T1")="1:0:0:0:92"
+^ZZCOVERAGE("ZZCOVTST","T1",1)="1:0:0:0:13"
+^ZZCOVERAGE("ZZCOVTST","T1",2)="1:0:0:0:12"
+^ZZCOVERAGE("ZZCOVTST","T1",3)="1:0:0:0:14"
+^ZZCOVERAGE("ZZCOVTST","T1",4)="1:0:0:0:29"
+^ZZCOVERAGE("ZZCOVTST","T1",5)="1:0:0:0:12"
+^ZZCOVERAGE("ZZCOVTST","T2")="1:0:0:0:102"
+^ZZCOVERAGE("ZZCOVTST","T2",0)="1:0:0:0:14"
+^ZZCOVERAGE("ZZCOVTST","T2",1)="1:0:0:0:12"
+^ZZCOVERAGE("ZZCOVTST","T2",2)="1:0:0:0:12"
+^ZZCOVERAGE("ZZCOVTST","T2",3)="1:0:0:0:14"
+^ZZCOVERAGE("ZZCOVTST","T2",4)="1:0:0:0:25"
+^ZZCOVERAGE("ZZCOVTST","T2",5)="1:0:0:0:12"
+^ZZCOVERAGE("ZZCOVTST","T3")="1:0:0:0:28"
+^ZZCOVERAGE("ZZCOVTST","T3",0)="1:0:0:0:17"
+^ZZCOVERAGE("ZZCOVTST","T5")="1:0:0:0:388"
+^ZZCOVERAGE("ZZCOVTST","T5",0)="1:0:0:0:114"
+^ZZCOVERAGE("ZZCOVTST","T5",1)="1:0:0:0:28"
+^ZZCOVERAGE("ZZCOVTST","T5",2)="1:0:0:0:14"
+
+
diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt
index 28e46b1..90af600 100644
--- a/Tests/PDBDirectoryAndName/CMakeLists.txt
+++ b/Tests/PDBDirectoryAndName/CMakeLists.txt
@@ -6,6 +6,13 @@
   message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel")
 endif()
 
+# Intel 11.1 does not support /Fd but Intel 14.0 does.
+# TODO: Did a version in between these add it?
+if(CMAKE_C_COMPILER_ID STREQUAL Intel AND
+   CMAKE_C_COMPILER_VERSION VERSION_LESS 14.0)
+  set(NO_COMPILE_PDB 1)
+endif()
+
 set(my_targets "")
 
 add_library(mylibA SHARED mylibA.c)
@@ -17,12 +24,12 @@
 
 add_library(mylibB STATIC mylibB.c)
 set_target_properties(mylibB PROPERTIES
-    PDB_NAME "mylibB_Special"
-    PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB"
+    COMPILE_PDB_NAME "mylibB_Special"
+    COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB"
 )
-# TODO: The only .pdb available for a static library is that generated
-# by the compiler /Fd option which is not the same as the linker /pdb.
-# list(APPEND my_targets mylibB)
+if(NOT NO_COMPILE_PDB)
+  list(APPEND my_targets mylibB)
+endif()
 
 add_library(mylibC SHARED mylibC.c)
 set_target_properties(mylibC PROPERTIES
@@ -32,10 +39,11 @@
 
 add_library(mylibD STATIC mylibD.c)
 set_target_properties(mylibD PROPERTIES
-    PDB_NAME "mylibD_Special"
+    COMPILE_PDB_NAME "mylibD_Special"
 )
-# TODO: See comment for mylibB.
-# list(APPEND my_targets mylibD)
+if(NOT NO_COMPILE_PDB)
+  list(APPEND my_targets mylibD)
+endif()
 
 add_executable(myexe myexe.c)
 set_target_properties(myexe PROPERTIES
@@ -66,6 +74,12 @@
 foreach(t ${my_targets})
   get_property(pdb_name TARGET ${t} PROPERTY PDB_NAME)
   get_property(pdb_dir TARGET ${t} PROPERTY PDB_OUTPUT_DIRECTORY)
+  if(NOT pdb_name)
+    get_property(pdb_name TARGET ${t} PROPERTY COMPILE_PDB_NAME)
+  endif()
+  if(NOT pdb_dir)
+    get_property(pdb_dir TARGET ${t} PROPERTY COMPILE_PDB_OUTPUT_DIRECTORY)
+  endif()
   if(NOT pdb_dir)
     set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR})
   endif()
diff --git a/Tests/PerConfig/perconfig.cmake b/Tests/PerConfig/perconfig.cmake
index 6a710ca..0731041 100644
--- a/Tests/PerConfig/perconfig.cmake
+++ b/Tests/PerConfig/perconfig.cmake
@@ -30,7 +30,7 @@
 # Verify that the implementation files are named correctly.
 foreach(lib pcStatic pcShared)
   file(STRINGS "${${lib}_file}" info LIMIT_COUNT 1 REGEX "INFO:[^[]*\\[")
-  if(NOT "${info}" MATCHES ".*INFO:symbol\\[${lib}\\].*")
+  if(NOT "${info}" MATCHES "INFO:symbol\\[${lib}\\]")
     message(SEND_ERROR "No INFO:symbol[${lib}] found in:\n  ${${lib}_file}")
   endif()
 endforeach()
diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt
index c6ed15d..ecdece8 100644
--- a/Tests/Plugin/CMakeLists.txt
+++ b/Tests/Plugin/CMakeLists.txt
@@ -24,6 +24,16 @@
   ${Plugin_SOURCE_DIR}/include
   )
 
+# We need proper C++98 support from the compiler
+set(CMAKE_CXX_STANDARD 98)
+
+# Those versions of the HP compiler that need a flag to get proper C++98
+# template support also need a flag to use the newer C++ library.
+if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
+    CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
+endif ()
+
 # Create an executable that exports an API for use by plugins.
 add_executable(example_exe src/example_exe.cxx)
 set_target_properties(example_exe PROPERTIES
diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt
index 285d596..11fca45 100644
--- a/Tests/Properties/CMakeLists.txt
+++ b/Tests/Properties/CMakeLists.txt
@@ -143,3 +143,5 @@
 set_property(CACHE SOME_ENTRY PROPERTY ADVANCED "${expect_ADVANCED}")
 set_property(CACHE SOME_ENTRY PROPERTY STRINGS "${expect_STRINGS}")
 check_cache_props()
+
+add_subdirectory(SubDir2)
diff --git a/Tests/Properties/SubDir2/CMakeLists.txt b/Tests/Properties/SubDir2/CMakeLists.txt
new file mode 100644
index 0000000..377dc83
--- /dev/null
+++ b/Tests/Properties/SubDir2/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/../subdirtest.cxx"
+  PROPERTIES COMPILE_DEFINITIONS SUBDIR_TEST)
+
+add_executable(subdirtest "${CMAKE_CURRENT_SOURCE_DIR}/../subdirtest.cxx")
diff --git a/Tests/Properties/subdirtest.cxx b/Tests/Properties/subdirtest.cxx
new file mode 100644
index 0000000..02d8f3d
--- /dev/null
+++ b/Tests/Properties/subdirtest.cxx
@@ -0,0 +1,9 @@
+
+#ifndef SUBDIR_TEST
+#error Expected SUBDIR_TEST
+#endif
+
+int main(int, char**)
+{
+  return 0;
+}
diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt
index af9fc3f..ae0a02b 100644
--- a/Tests/Qt4Targets/CMakeLists.txt
+++ b/Tests/Qt4Targets/CMakeLists.txt
@@ -36,3 +36,45 @@
 set_property(TARGET Qt4WrapMacroTest PROPERTY AUTOMOC OFF)
 target_include_directories(Qt4WrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
 target_link_libraries(Qt4WrapMacroTest Qt4::QtGui)
+
+macro(test_incremental def)
+  set(timeformat "%Y%j%H%M%S")
+  try_compile(RESULT
+    "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild_${def}"
+    "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc"
+    IncrementalMoc
+    CMAKE_FLAGS -D${def}=0 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+    OUTPUT_VARIABLE output
+    )
+  file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild_${def}/moc_foo.cpp" tsvar_before "${timeformat}")
+  if (NOT tsvar_before)
+    message(SEND_ERROR
+      "Unable to read timestamp from moc file from first build with -D${def}!\n"
+      "try_compile output:\n${output}"
+      )
+  endif()
+
+  execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2) # Ensure that the timestamp will change.
+
+  try_compile(RESULT
+    "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild_${def}"
+    "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc"
+    IncrementalMoc
+    CMAKE_FLAGS -D${def}=1 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+    OUTPUT_VARIABLE output
+    )
+  file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild_${def}/moc_foo.cpp" tsvar_after "${timeformat}")
+  if (NOT tsvar_after)
+    message(SEND_ERROR
+      "Unable to read timestamp from moc file from second build!\n"
+      "try_compile output:\n${output}"
+      )
+  endif()
+
+  if (NOT tsvar_after GREATER tsvar_before)
+    message(SEND_ERROR "Rebuild did not re-create moc file with -D${def}. Before: ${tsvar_before}. After: ${tsvar_after}")
+  endif()
+endmacro()
+
+test_incremental(ADD_TARGET_DEF)
+test_incremental(ADD_DIR_DEF)
diff --git a/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
new file mode 100644
index 0000000..65e2b64
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
@@ -0,0 +1,21 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+project(IncrementalMoc)
+
+find_package(Qt4 REQUIRED)
+
+if (ADD_TARGET_DEF)
+  set(target_args TARGET testlib)
+endif()
+
+if (ADD_DIR_DEF)
+  add_definitions(-DNEW_DEF)
+endif()
+
+qt4_generate_moc(foo.h moc_foo.cpp ${target_args})
+
+add_library(testlib foo.cpp moc_foo.cpp)
+target_link_libraries(testlib Qt4::QtCore)
+if (ADD_TARGET_DEF)
+  target_compile_definitions(testlib PRIVATE NEW_DEF)
+endif()
diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.cpp b/Tests/Qt4Targets/IncrementalMoc/foo.cpp
new file mode 100644
index 0000000..e924f7e
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/foo.cpp
@@ -0,0 +1,8 @@
+
+#include "foo.h"
+
+Foo::Foo()
+  : QObject(0)
+{
+
+}
diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.h b/Tests/Qt4Targets/IncrementalMoc/foo.h
new file mode 100644
index 0000000..38d899f
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/foo.h
@@ -0,0 +1,9 @@
+
+#include <QObject>
+
+class Foo : QObject
+{
+  Q_OBJECT
+public:
+  Foo();
+};
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 0821b45..3973653 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -64,9 +64,15 @@
   DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in"
 )
 
-add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
+message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
+if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" AND NOT CMAKE_CONFIGURATION_TYPES)
+  set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>)
+  add_definitions(-DTEST_DEBUG_CLASS)
+endif()
+
+add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
                xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
-               test.qrc resourcetester.cpp generated.cpp
+               test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs}
 )
 set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h")
 
diff --git a/Tests/QtAutogen/debug_class.cpp b/Tests/QtAutogen/debug_class.cpp
new file mode 100644
index 0000000..58e72e4
--- /dev/null
+++ b/Tests/QtAutogen/debug_class.cpp
@@ -0,0 +1,9 @@
+
+#include "debug_class.h"
+#include "ui_debug_class.h"
+
+DebugClass::DebugClass(QWidget *parent)
+  : QWidget(parent), ui(new Ui::DebugClass)
+{
+  ui->setupUi(this);
+}
diff --git a/Tests/QtAutogen/debug_class.h b/Tests/QtAutogen/debug_class.h
new file mode 100644
index 0000000..71bc104
--- /dev/null
+++ b/Tests/QtAutogen/debug_class.h
@@ -0,0 +1,20 @@
+
+#include <QWidget>
+
+namespace Ui
+{
+class DebugClass;
+}
+
+class DebugClass : public QWidget
+{
+  Q_OBJECT
+public:
+  explicit DebugClass(QWidget *parent = 0);
+
+signals:
+  void someSignal();
+
+private:
+  Ui::DebugClass *ui;
+};
diff --git a/Tests/QtAutogen/debug_class.ui b/Tests/QtAutogen/debug_class.ui
new file mode 100644
index 0000000..dc2e1ac
--- /dev/null
+++ b/Tests/QtAutogen/debug_class.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DebugClass</class>
+ <widget class="QWidget" name="DebugClass">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>DebugClass</string>
+  </property>
+  <widget class="QCheckBox" name="checkBox">
+   <property name="geometry">
+    <rect>
+     <x>50</x>
+     <y>20</y>
+     <width>82</width>
+     <height>21</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>CheckBox</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>40</x>
+     <y>70</y>
+     <width>94</width>
+     <height>24</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>PushButton</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/debug_resource.qrc b/Tests/QtAutogen/debug_resource.qrc
new file mode 100644
index 0000000..db98b9b
--- /dev/null
+++ b/Tests/QtAutogen/debug_resource.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+    <file>debug_class.ui</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/main.cpp b/Tests/QtAutogen/main.cpp
index c8a036e..eb59665 100644
--- a/Tests/QtAutogen/main.cpp
+++ b/Tests/QtAutogen/main.cpp
@@ -51,6 +51,11 @@
 #include "yaf.h"
 #include "libC.h"
 #include "resourcetester.h"
+#ifdef TEST_DEBUG_CLASS
+#include "debug_class.h"
+#include <iostream>
+#endif
+
 
 int main(int argv, char **args)
 {
@@ -81,5 +86,9 @@
 
   QTimer::singleShot(0, &rt, SLOT(doTest()));
 
+#ifdef TEST_DEBUG_CLASS
+  std::cout << DebugClass::staticMetaObject.className() << std::endl;
+#endif
+
   return app.exec();
 }
diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp
index 43314e1..043ec75 100644
--- a/Tests/QtAutogen/resourcetester.cpp
+++ b/Tests/QtAutogen/resourcetester.cpp
@@ -16,6 +16,12 @@
 {
   if (!QFile::exists(":/CMakeLists.txt"))
       qApp->exit(EXIT_FAILURE);
+  if (!QFile::exists(":/main.cpp"))
+      qApp->exit(EXIT_FAILURE);
+#ifdef TEST_DEBUG_CLASS
+  if (!QFile::exists(":/debug_class.ui"))
+      qApp->exit(EXIT_FAILURE);
+#endif
 
   QTimer::singleShot(0, qApp, SLOT(quit()));
 }
diff --git a/Tests/QtAutogen/second_resource.qrc b/Tests/QtAutogen/second_resource.qrc
new file mode 100644
index 0000000..27bfb14
--- /dev/null
+++ b/Tests/QtAutogen/second_resource.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+    <file>main.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/second_widget.cpp b/Tests/QtAutogen/second_widget.cpp
new file mode 100644
index 0000000..65ba962
--- /dev/null
+++ b/Tests/QtAutogen/second_widget.cpp
@@ -0,0 +1,14 @@
+
+#include "second_widget.h"
+#include "ui_second_widget.h"
+
+SecondWidget::SecondWidget(QWidget *parent)
+  : QWidget(parent), ui(new Ui::SecondWidget)
+{
+  ui->setupUi(this);
+}
+
+SecondWidget::~SecondWidget()
+{
+  delete ui;
+}
diff --git a/Tests/QtAutogen/second_widget.h b/Tests/QtAutogen/second_widget.h
new file mode 100644
index 0000000..fe4d175
--- /dev/null
+++ b/Tests/QtAutogen/second_widget.h
@@ -0,0 +1,19 @@
+
+#include <QWidget>
+
+namespace Ui
+{
+class SecondWidget;
+}
+
+class SecondWidget : public QWidget
+{
+  Q_OBJECT
+public:
+  explicit SecondWidget(QWidget *parent = 0);
+
+  ~SecondWidget();
+
+private:
+  Ui::SecondWidget* ui;
+};
diff --git a/Tests/QtAutogen/second_widget.ui b/Tests/QtAutogen/second_widget.ui
new file mode 100644
index 0000000..4effa58
--- /dev/null
+++ b/Tests/QtAutogen/second_widget.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SecondWidget</class>
+ <widget class="QWidget" name="SecondWidget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>80</x>
+     <y>20</y>
+     <width>94</width>
+     <height>24</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>PushButton</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/CMP0026/ObjlibNotDefined-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/CMP0026/ObjlibNotDefined-result.txt
diff --git a/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt b/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt
new file mode 100644
index 0000000..87d198d
--- /dev/null
+++ b/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt
@@ -0,0 +1,12 @@
+CMake Warning \(dev\) at ObjlibNotDefined.cmake:[0-9]+ \(get_target_property\):
+  Policy CMP0026 is not set: Disallow use of the LOCATION target property.
+  Run "cmake --help-policy CMP0026" for policy details.  Use the cmake_policy
+  command to set the policy and suppress this warning.
+
+  The LOCATION property should not be read from target "objlibuser".  Use the
+  target name directly with add_custom_command, or use the generator
+  expression \$<TARGET_FILE>, as appropriate.
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0026/ObjlibNotDefined.cmake b/Tests/RunCMake/CMP0026/ObjlibNotDefined.cmake
new file mode 100644
index 0000000..194760c
--- /dev/null
+++ b/Tests/RunCMake/CMP0026/ObjlibNotDefined.cmake
@@ -0,0 +1,13 @@
+
+enable_language(CXX)
+
+add_executable(objlibuser
+    empty.cpp
+    $<TARGET_OBJECTS:bar>
+)
+
+get_target_property(_location objlibuser LOCATION)
+
+add_library(bar OBJECT
+    empty.cpp
+)
diff --git a/Tests/RunCMake/CMP0026/RunCMakeTest.cmake b/Tests/RunCMake/CMP0026/RunCMakeTest.cmake
index 1824cc6..7c2582f 100644
--- a/Tests/RunCMake/CMP0026/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMP0026/RunCMakeTest.cmake
@@ -9,3 +9,4 @@
 run_cmake(CMP0026-LOCATION-CONFIG-NEW)
 run_cmake(CMP0026-LOCATION-CONFIG-OLD)
 run_cmake(CMP0026-LOCATION-CONFIG-WARN)
+run_cmake(ObjlibNotDefined)
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt
diff --git a/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt
new file mode 100644
index 0000000..e5578ba
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt
@@ -0,0 +1 @@
+^Sources: "empty.cpp;\$<TARGET_OBJECTS:objects>"$
diff --git a/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake b/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake
new file mode 100644
index 0000000..f304bf1
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake
@@ -0,0 +1,10 @@
+
+cmake_policy(SET CMP0051 NEW)
+
+add_library(objects OBJECT empty.cpp)
+
+add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
+
+get_target_property(srcs empty SOURCES)
+
+message("Sources: \"${srcs}\"")
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt
diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt
new file mode 100644
index 0000000..cc17f33
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt
@@ -0,0 +1 @@
+^Sources: "empty.cpp"$
diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake b/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake
new file mode 100644
index 0000000..0243e94
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake
@@ -0,0 +1,10 @@
+
+cmake_policy(SET CMP0051 OLD)
+
+add_library(objects OBJECT empty.cpp)
+
+add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
+
+get_target_property(srcs empty SOURCES)
+
+message("Sources: \"${srcs}\"")
diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-Dir/CMakeLists.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-Dir/CMakeLists.txt
new file mode 100644
index 0000000..77cbad5
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-WARN-Dir/CMakeLists.txt
@@ -0,0 +1 @@
+add_library(empty2 ../empty.cpp $<TARGET_OBJECTS:objects>)
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt
diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt
new file mode 100644
index 0000000..ae2e468
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt
@@ -0,0 +1,31 @@
+CMake Warning \(dev\) at CMP0051-WARN.cmake:6 \(get_target_property\):
+  Policy CMP0051 is not set: List TARGET_OBJECTS in SOURCES target property.
+  Run "cmake --help-policy CMP0051" for policy details.  Use the cmake_policy
+  command to set the policy and suppress this warning.
+
+  Target "empty" contains \$<TARGET_OBJECTS> generator expression in its
+  sources list.  This content was not previously part of the SOURCES property
+  when that property was read at configure time.  Code reading that property
+  needs to be adapted to ignore the generator expression using the
+  string\(GENEX_STRIP\) command.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+Sources: "empty.cpp"
+*
+CMake Warning \(dev\) at CMP0051-WARN.cmake:12 \(get_target_property\):
+  Policy CMP0051 is not set: List TARGET_OBJECTS in SOURCES target property.
+  Run "cmake --help-policy CMP0051" for policy details.  Use the cmake_policy
+  command to set the policy and suppress this warning.
+
+  Target "empty2" contains \$<TARGET_OBJECTS> generator expression in its
+  sources list.  This content was not previously part of the SOURCES property
+  when that property was read at configure time.  Code reading that property
+  needs to be adapted to ignore the generator expression using the
+  string\(GENEX_STRIP\) command.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+Sources: "../empty.cpp"$
diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake b/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake
new file mode 100644
index 0000000..744598f
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake
@@ -0,0 +1,14 @@
+
+add_library(objects OBJECT empty.cpp)
+
+add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
+
+get_target_property(srcs empty SOURCES)
+
+message("Sources: \"${srcs}\"")
+
+add_subdirectory(CMP0051-WARN-Dir)
+
+get_target_property(srcs empty2 SOURCES)
+
+message("Sources: \"${srcs}\"")
diff --git a/Tests/RunCMake/CMP0051/CMakeLists.txt b/Tests/RunCMake/CMP0051/CMakeLists.txt
new file mode 100644
index 0000000..3482e6b
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0051/RunCMakeTest.cmake b/Tests/RunCMake/CMP0051/RunCMakeTest.cmake
new file mode 100644
index 0000000..621192d
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0051-OLD)
+run_cmake(CMP0051-NEW)
+run_cmake(CMP0051-WARN)
diff --git a/Tests/RunCMake/CMP0051/empty.cpp b/Tests/RunCMake/CMP0051/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/CMP0053/CMP0053-NEW-stderr.txt b/Tests/RunCMake/CMP0053/CMP0053-NEW-stderr.txt
new file mode 100644
index 0000000..836b0ff
--- /dev/null
+++ b/Tests/RunCMake/CMP0053/CMP0053-NEW-stderr.txt
@@ -0,0 +1,2 @@
+^called
+--><--$
diff --git a/Tests/RunCMake/CMP0053/CMP0053-NEW.cmake b/Tests/RunCMake/CMP0053/CMP0053-NEW.cmake
new file mode 100644
index 0000000..6ffedc6
--- /dev/null
+++ b/Tests/RunCMake/CMP0053/CMP0053-NEW.cmake
@@ -0,0 +1,8 @@
+cmake_policy(SET CMP0053 NEW)
+
+function (watch_callback)
+  message("called")
+endfunction ()
+
+variable_watch(test watch_callback)
+message("-->${test}<--")
diff --git a/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt b/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt
new file mode 100644
index 0000000..836b0ff
--- /dev/null
+++ b/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt
@@ -0,0 +1,2 @@
+^called
+--><--$
diff --git a/Tests/RunCMake/CMP0053/CMP0053-OLD.cmake b/Tests/RunCMake/CMP0053/CMP0053-OLD.cmake
new file mode 100644
index 0000000..41f5347
--- /dev/null
+++ b/Tests/RunCMake/CMP0053/CMP0053-OLD.cmake
@@ -0,0 +1,8 @@
+cmake_policy(SET CMP0053 OLD)
+
+function (watch_callback)
+  message("called")
+endfunction ()
+
+variable_watch(test watch_callback)
+message("-->${test}<--")
diff --git a/Tests/RunCMake/CMP0053/CMP0053-WARN-stderr.txt b/Tests/RunCMake/CMP0053/CMP0053-WARN-stderr.txt
new file mode 100644
index 0000000..836b0ff
--- /dev/null
+++ b/Tests/RunCMake/CMP0053/CMP0053-WARN-stderr.txt
@@ -0,0 +1,2 @@
+^called
+--><--$
diff --git a/Tests/RunCMake/CMP0053/CMP0053-WARN.cmake b/Tests/RunCMake/CMP0053/CMP0053-WARN.cmake
new file mode 100644
index 0000000..b010d13
--- /dev/null
+++ b/Tests/RunCMake/CMP0053/CMP0053-WARN.cmake
@@ -0,0 +1,6 @@
+function (watch_callback)
+  message("called")
+endfunction ()
+
+variable_watch(test watch_callback)
+message("-->${test}<--")
diff --git a/Tests/RunCMake/CMP0053/CMakeLists.txt b/Tests/RunCMake/CMP0053/CMakeLists.txt
new file mode 100644
index 0000000..3482e6b
--- /dev/null
+++ b/Tests/RunCMake/CMP0053/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0053/RunCMakeTest.cmake b/Tests/RunCMake/CMP0053/RunCMakeTest.cmake
new file mode 100644
index 0000000..6521ac0
--- /dev/null
+++ b/Tests/RunCMake/CMP0053/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0053-OLD)
+run_cmake(CMP0053-NEW)
+run_cmake(CMP0053-WARN)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 9bb097b..06272ce 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -3,8 +3,8 @@
 macro(add_RunCMake_test test)
   add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND}
     -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}
-    -DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR}
-    -DRunCMake_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET}
+    -DRunCMake_GENERATOR=${CMAKE_GENERATOR}
+    -DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
     -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test}
     -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test}
     ${${test}_ARGS}
@@ -16,6 +16,10 @@
   set(GeneratorToolset_ARGS -DXCODE_BELOW_3=1)
 endif()
 
+if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 2)
+  set(TargetSources_ARGS -DXCODE_BELOW_2=1)
+endif()
+
 add_RunCMake_test(CMP0019)
 add_RunCMake_test(CMP0022)
 add_RunCMake_test(CMP0026)
@@ -34,20 +38,28 @@
 add_RunCMake_test(CMP0046)
 add_RunCMake_test(CMP0049)
 add_RunCMake_test(CMP0050)
+add_RunCMake_test(CMP0051)
+add_RunCMake_test(CMP0053)
 add_RunCMake_test(CTest)
-if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
+if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
   add_RunCMake_test(CompilerChange)
 endif()
 add_RunCMake_test(CompilerNotFound)
 add_RunCMake_test(Configure)
 add_RunCMake_test(DisallowedCommands)
 add_RunCMake_test(ExternalData)
+add_RunCMake_test(FeatureSummary)
 add_RunCMake_test(FPHSA)
 add_RunCMake_test(GeneratorExpression)
 add_RunCMake_test(GeneratorToolset)
 add_RunCMake_test(TargetPropertyGeneratorExpressions)
 add_RunCMake_test(Languages)
 add_RunCMake_test(ObjectLibrary)
+add_RunCMake_test(TargetObjects)
+add_RunCMake_test(TargetSources)
+add_RunCMake_test(find_dependency)
+add_RunCMake_test(CompileFeatures)
+add_RunCMake_test(WriteCompilerDetectionHeader)
 if(NOT WIN32)
   add_RunCMake_test(PositionIndependentCode)
   set(SKIP_VISIBILITY 0)
@@ -77,6 +89,7 @@
 add_RunCMake_test(build_command)
 add_RunCMake_test(export)
 add_RunCMake_test(cmake_minimum_required)
+add_RunCMake_test(file)
 add_RunCMake_test(find_package)
 add_RunCMake_test(get_filename_component)
 add_RunCMake_test(if)
@@ -94,6 +107,7 @@
 add_RunCMake_test(alias_targets)
 add_RunCMake_test(interface_library)
 add_RunCMake_test(no_install_prefix)
+add_RunCMake_test(configure_file)
 
 find_package(Qt4 QUIET)
 find_package(Qt5Core QUIET)
@@ -105,15 +119,27 @@
   add_RunCMake_test(ObsoleteQtMacros)
 endif()
 
-if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+  add_RunCMake_test(FindPkgConfig)
+endif()
+
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]")
   add_RunCMake_test(include_external_msproject)
   add_RunCMake_test(SolutionGlobalSections)
 endif()
 
+if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3)
+  add_RunCMake_test(XcodeProject)
+endif()
+
 add_RunCMake_test(File_Generate)
 add_RunCMake_test(ExportWithoutLanguage)
 add_RunCMake_test(target_link_libraries)
+
+add_RunCMake_test(target_compile_features)
 add_RunCMake_test(CheckModules)
 add_RunCMake_test(CommandLine)
 
 add_RunCMake_test(install)
+add_RunCMake_test(CPackInstallProperties)
diff --git a/Tests/RunCMake/CPackInstallProperties/Append-check.cmake b/Tests/RunCMake/CPackInstallProperties/Append-check.cmake
new file mode 100644
index 0000000..017b30d
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/Append-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_property("append.txt" CPACK_TEST_PROP "value1;value2;value3")
diff --git a/Tests/RunCMake/CPackInstallProperties/Append.cmake b/Tests/RunCMake/CPackInstallProperties/Append.cmake
new file mode 100644
index 0000000..cecc45f
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/Append.cmake
@@ -0,0 +1,2 @@
+set_property(INSTALL append.txt PROPERTY CPACK_TEST_PROP value1)
+set_property(INSTALL append.txt PROPERTY CPACK_TEST_PROP value2 value3 APPEND)
diff --git a/Tests/RunCMake/CPackInstallProperties/CMakeLists.txt b/Tests/RunCMake/CPackInstallProperties/CMakeLists.txt
new file mode 100644
index 0000000..89ff7c4
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.0)
+
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
+
+include(CPack)
diff --git a/Tests/RunCMake/CPackInstallProperties/FilenameGenex-check.cmake b/Tests/RunCMake/CPackInstallProperties/FilenameGenex-check.cmake
new file mode 100644
index 0000000..8c9e967
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/FilenameGenex-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_property(${EXPECTED_MYTEST_NAME} CPACK_TEST_PROP2 PROP_VALUE2)
diff --git a/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake b/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake
new file mode 100644
index 0000000..1a373b9
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake
@@ -0,0 +1,7 @@
+add_executable(mytest test.cpp)
+
+file(GENERATE OUTPUT runtest_info.cmake CONTENT [[
+set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>")
+]])
+
+set_property(INSTALL $<TARGET_FILE_NAME:mytest> PROPERTY CPACK_TEST_PROP2 PROP_VALUE2)
diff --git a/Tests/RunCMake/CPackInstallProperties/MultipleValues-check.cmake b/Tests/RunCMake/CPackInstallProperties/MultipleValues-check.cmake
new file mode 100644
index 0000000..91278ba
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/MultipleValues-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_property("multiple_values.txt" CPACK_TEST_PROP "value1;value2;value3")
diff --git a/Tests/RunCMake/CPackInstallProperties/MultipleValues.cmake b/Tests/RunCMake/CPackInstallProperties/MultipleValues.cmake
new file mode 100644
index 0000000..26db52a
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/MultipleValues.cmake
@@ -0,0 +1 @@
+set_property(INSTALL multiple_values.txt PROPERTY CPACK_TEST_PROP value1 value2 value3)
diff --git a/Tests/RunCMake/CPackInstallProperties/PerConfigValue-check.cmake b/Tests/RunCMake/CPackInstallProperties/PerConfigValue-check.cmake
new file mode 100644
index 0000000..2966d88
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/PerConfigValue-check.cmake
@@ -0,0 +1,13 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+file(GLOB INFO_FILES ${RunCMake_TEST_BINARY_DIR}/runtest_info_*.cmake)
+
+if(NOT INFO_FILES)
+  message(FATAL_ERROR "missing expected info files")
+endif()
+
+foreach(INFO_FILE IN LISTS INFO_FILES)
+  include(${INFO_FILE})
+  include(${RunCMake_TEST_BINARY_DIR}/CPackProperties.cmake)
+  test_property("config.cpp" FOO ${EXPECTED_MYTEST_NAME})
+endforeach()
diff --git a/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake b/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake
new file mode 100644
index 0000000..77fe8ed
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake
@@ -0,0 +1,14 @@
+add_executable(mytest test.cpp)
+
+foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES)
+  string(TOUPPER ${CONFIG} UPPER_CONFIG)
+  set_property(TARGET mytest PROPERTY
+    OUTPUT_NAME_${UPPER_CONFIG} bar_${CONFIG})
+endforeach()
+
+file(GENERATE OUTPUT runtest_info_$<CONFIG>.cmake CONTENT [[
+set(CPACK_BUILD_CONFIG "$<CONFIG>")
+set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>")
+]])
+
+set_property(INSTALL config.cpp PROPERTY FOO $<TARGET_FILE_NAME:mytest>)
diff --git a/Tests/RunCMake/CPackInstallProperties/Replace-check.cmake b/Tests/RunCMake/CPackInstallProperties/Replace-check.cmake
new file mode 100644
index 0000000..6e492e7
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/Replace-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_property("replace.txt" CPACK_TEST_PROP "value2")
diff --git a/Tests/RunCMake/CPackInstallProperties/Replace.cmake b/Tests/RunCMake/CPackInstallProperties/Replace.cmake
new file mode 100644
index 0000000..104d5a4
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/Replace.cmake
@@ -0,0 +1,2 @@
+set_property(INSTALL replace.txt PROPERTY CPACK_TEST_PROP value1)
+set_property(INSTALL replace.txt PROPERTY CPACK_TEST_PROP value2)
diff --git a/Tests/RunCMake/CPackInstallProperties/RunCMakeTest.cmake b/Tests/RunCMake/CPackInstallProperties/RunCMakeTest.cmake
new file mode 100644
index 0000000..d244ac5
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/RunCMakeTest.cmake
@@ -0,0 +1,9 @@
+include(RunCMake)
+
+run_cmake(Simple)
+run_cmake(FilenameGenex)
+run_cmake(ValueGenex)
+run_cmake(MultipleValues)
+run_cmake(Append)
+run_cmake(Replace)
+run_cmake(PerConfigValue)
diff --git a/Tests/RunCMake/CPackInstallProperties/Simple-check.cmake b/Tests/RunCMake/CPackInstallProperties/Simple-check.cmake
new file mode 100644
index 0000000..6a7ee2a
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/Simple-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_property("foo/test.cpp" CPACK_TEST_PROP PROP_VALUE)
diff --git a/Tests/RunCMake/CPackInstallProperties/Simple.cmake b/Tests/RunCMake/CPackInstallProperties/Simple.cmake
new file mode 100644
index 0000000..2eb8755
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/Simple.cmake
@@ -0,0 +1 @@
+set_property(INSTALL foo/test.cpp PROPERTY CPACK_TEST_PROP PROP_VALUE)
diff --git a/Tests/RunCMake/CPackInstallProperties/ValueGenex-check.cmake b/Tests/RunCMake/CPackInstallProperties/ValueGenex-check.cmake
new file mode 100644
index 0000000..cdfbcda
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/ValueGenex-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_property("bar/test.cpp" CPACK_TEST_PROP ${EXPECTED_MYTEST_NAME})
diff --git a/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake b/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake
new file mode 100644
index 0000000..2e1d465
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake
@@ -0,0 +1,7 @@
+add_executable(mytest test.cpp)
+
+file(GENERATE OUTPUT runtest_info.cmake CONTENT [[
+set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>")
+]])
+
+set_property(INSTALL bar/test.cpp PROPERTY CPACK_TEST_PROP $<TARGET_FILE_NAME:mytest>)
diff --git a/Tests/RunCMake/CPackInstallProperties/check.cmake b/Tests/RunCMake/CPackInstallProperties/check.cmake
new file mode 100644
index 0000000..65aa467
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/check.cmake
@@ -0,0 +1,12 @@
+function(test_property FILE NAME EXPECTED_VALUE)
+  get_property(ACTUAL_VALUE INSTALL "${FILE}" PROPERTY "${NAME}")
+
+  if(NOT "${ACTUAL_VALUE}" STREQUAL "${EXPECTED_VALUE}")
+    message(FATAL_ERROR "${NAME}@${FILE}: property mismatch expected [${EXPECTED_VALUE}] actual [${ACTUAL_VALUE}] (Config:${CPACK_BUILD_CONFIG})")
+  endif()
+endfunction()
+
+set(CPACK_BUILD_CONFIG Debug)
+include(${RunCMake_TEST_BINARY_DIR}/CPackProperties.cmake)
+
+include(${RunCMake_TEST_BINARY_DIR}/runtest_info.cmake OPTIONAL)
diff --git a/Tests/RunCMake/CPackInstallProperties/test.cpp b/Tests/RunCMake/CPackInstallProperties/test.cpp
new file mode 100644
index 0000000..237c8ce
--- /dev/null
+++ b/Tests/RunCMake/CPackInstallProperties/test.cpp
@@ -0,0 +1 @@
+int main() {}
diff --git a/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake b/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake
new file mode 100644
index 0000000..b2dcd7f
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake
@@ -0,0 +1,4 @@
+enable_language(CXX)
+include(CheckTypeSize)
+check_type_size(int SIZEOF_INT LANGUAGE CXX)
+check_type_size(int SIZEOF_INT BUILTIN_TYPES_ONLY LANGUAGE CXX)
diff --git a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
index fda7ebf..5b4e57e 100644
--- a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
@@ -12,3 +12,5 @@
 run_cmake(CheckTypeSizeMissingLanguage)
 run_cmake(CheckTypeSizeUnknownArgument)
 run_cmake(CheckTypeSizeMixedArgs)
+
+run_cmake(CheckTypeSizeOkNoC)
diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
index 17b8a5c..82a34d5 100644
--- a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
+++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
@@ -1,4 +1,11 @@
 CMake Debug Log:
+  Boolean compatibility of property "BOOL_PROP7" for target
+  "CompatibleInterface" \(result: "FALSE"\):
+
+   \* Target "CompatibleInterface" property is implied by use.
+   \* Target "iface1" property value "FALSE" \(Agree\)
++
+CMake Debug Log:
   Boolean compatibility of property "BOOL_PROP1" for target
   "CompatibleInterface" \(result: "TRUE"\):
 
@@ -40,13 +47,6 @@
    \* Target "iface2" property value "FALSE" \(Agree\)
 +
 CMake Debug Log:
-  Boolean compatibility of property "BOOL_PROP7" for target
-  "CompatibleInterface" \(result: "FALSE"\):
-
-   \* Target "CompatibleInterface" property is implied by use.
-   \* Target "iface1" property value "FALSE" \(Agree\)
-+
-CMake Debug Log:
   String compatibility of property "STRING_PROP1" for target
   "CompatibleInterface" \(result: "prop1"\):
 
diff --git a/Tests/RunCMake/CompileFeatures/CMakeLists.txt b/Tests/RunCMake/CompileFeatures/CMakeLists.txt
new file mode 100644
index 0000000..3482e6b
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle-stderr.txt b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle-stderr.txt
new file mode 100644
index 0000000..a584d7d
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle-stderr.txt
@@ -0,0 +1,7 @@
+CMake Error in CMakeLists.txt:
+  The COMPILE_FEATURES property of target "empty1" was evaluated when
+  computing the link implementation, and the "CXX_STANDARD" was "98" for that
+  computation.  Computing the COMPILE_FEATURES based on the link
+  implementation resulted in a higher "CXX_STANDARD" "11".  This is not
+  permitted.  The COMPILE_FEATURES may not both depend on and be depended on
+  by the link implementation.
diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake
new file mode 100644
index 0000000..9d56bc0
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycle.cmake
@@ -0,0 +1,15 @@
+
+add_library(empty1 empty.cpp)
+
+add_library(empty2 INTERFACE)
+add_library(empty3 INTERFACE)
+target_compile_features(empty3 INTERFACE cxx_constexpr)
+
+target_link_libraries(empty1
+  # When starting, $<COMPILE_FEATURES:cxx_final> is '0', so 'freeze' the
+  # CXX_STANDARD at 98 during computation.
+  $<$<COMPILE_FEATURES:cxx_final>:empty2>
+  # This would add cxx_constexpr, but that would require CXX_STANDARD = 11,
+  # which is not allowed after freeze.  Report an error.
+  empty3
+)
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved-stderr.txt b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake
new file mode 100644
index 0000000..0df548b
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/LinkImplementationFeatureCycleSolved.cmake
@@ -0,0 +1,14 @@
+
+add_library(empty1 empty.cpp)
+
+add_library(empty2 INTERFACE)
+add_library(empty3 INTERFACE)
+target_compile_features(empty3 INTERFACE cxx_constexpr)
+
+target_link_libraries(empty1
+  $<$<COMPILE_FEATURES:cxx_final>:empty2>
+  empty3
+)
+# This, or populating the COMPILE_FEATURES property with a feature in the
+# same standard as cxx_final, solves the cycle above.
+set_property(TARGET empty1 PROPERTY CXX_STANDARD 11)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-stderr.txt
new file mode 100644
index 0000000..fd18c88
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at NoSupportedCFeatures.cmake:[0-9]+ \(target_compile_features\):
+  target_compile_features no known features for C compiler
+
+  "[^"]*"
+
+  version *[.0-9]+\.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures.cmake
new file mode 100644
index 0000000..3624d4b
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeatures.cmake
@@ -0,0 +1,5 @@
+
+enable_language(C)
+
+add_library(no_features empty.c)
+target_compile_features(no_features PRIVATE c_static_assert)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-stderr.txt
new file mode 100644
index 0000000..df647e8
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+  No known features for C compiler
+
+  "[^"]*"
+
+  version *[.0-9]+\.
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex.cmake
new file mode 100644
index 0000000..b6053aa
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCFeaturesGenex.cmake
@@ -0,0 +1,5 @@
+
+enable_language(C)
+
+add_library(no_features empty.c)
+target_compile_features(no_features PRIVATE $<1:c_static_assert>)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt
new file mode 100644
index 0000000..fc882cb
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at NoSupportedCxxFeatures.cmake:3 \(target_compile_features\):
+  target_compile_features no known features for CXX compiler
+
+  "[^"]*"
+
+  version *[.0-9]+\.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake
new file mode 100644
index 0000000..5121948
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake
@@ -0,0 +1,3 @@
+
+add_library(no_features empty.cpp)
+target_compile_features(no_features PRIVATE cxx_constexpr)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt
new file mode 100644
index 0000000..66d0d41
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+  No known features for CXX compiler
+
+  "[^"]*"
+
+  version *[.0-9]+\.
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake
new file mode 100644
index 0000000..490f187
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake
@@ -0,0 +1,3 @@
+
+add_library(no_features empty.cpp)
+target_compile_features(no_features PRIVATE $<1:cxx_constexpr>)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NonValidTarget1-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NonValidTarget1-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NonValidTarget1-stderr.txt b/Tests/RunCMake/CompileFeatures/NonValidTarget1-stderr.txt
new file mode 100644
index 0000000..7f3b43b
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NonValidTarget1-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget1.cmake:[0-9]+ \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<COMPILE_FEATURES:cxx_final>
+
+  \$<COMPILE_FEATURE> may only be used with binary targets.  It may not be
+  used with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake b/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake
new file mode 100644
index 0000000..c6707c1
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NonValidTarget1.cmake
@@ -0,0 +1,17 @@
+
+set(genexvar $<COMPILE_FEATURES:cxx_final>)
+
+if (HAVE_FINAL)
+  set(expected_result 1)
+else()
+  set(expected_result 0)
+endif()
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file${HAVE_FINAL}.cpp"
+  COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file${genexvar}.cpp"
+)
+
+add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file${genexvar}.cpp")
+if (HAVE_FINAL)
+  target_compile_features(empty PRIVATE cxx_final)
+endif()
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NonValidTarget2-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NonValidTarget2-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NonValidTarget2-stderr.txt b/Tests/RunCMake/CompileFeatures/NonValidTarget2-stderr.txt
new file mode 100644
index 0000000..635150c
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NonValidTarget2-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget2.cmake:4 \(add_custom_target\):
+  Error evaluating generator expression:
+
+    \$<COMPILE_FEATURES:cxx_final>
+
+  \$<COMPILE_FEATURE> may only be used with binary targets.  It may not be
+  used with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CompileFeatures/NonValidTarget2.cmake b/Tests/RunCMake/CompileFeatures/NonValidTarget2.cmake
new file mode 100644
index 0000000..eb84692
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NonValidTarget2.cmake
@@ -0,0 +1,8 @@
+
+set(genexvar $<COMPILE_FEATURES:cxx_final>)
+
+add_custom_target(copy_target
+  COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file${genexvar}.txt"
+)
+
+add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file${genexvar}.cpp")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NotAFeature-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt
new file mode 100644
index 0000000..ff60e50
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error in CMakeLists.txt:
+  Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature.cmake
new file mode 100644
index 0000000..35246c8
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature.cmake
@@ -0,0 +1,3 @@
+
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "not_a_feature")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt
new file mode 100644
index 0000000..ff60e50
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error in CMakeLists.txt:
+  Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake
new file mode 100644
index 0000000..ad2bd37
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake
@@ -0,0 +1,3 @@
+
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "$<1:not_a_feature>")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt
new file mode 100644
index 0000000..ff60e50
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error in CMakeLists.txt:
+  Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake
new file mode 100644
index 0000000..7311aec
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake
@@ -0,0 +1,6 @@
+
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_COMPILE_FEATURES "not_a_feature")
+
+add_library(somelib STATIC empty.cpp)
+target_link_libraries(somelib iface)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt
new file mode 100644
index 0000000..60a8e51
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt
@@ -0,0 +1,11 @@
+CMake Debug Log at NotAFeature_OriginDebug.cmake:4 \(set_property\):
+  Used compile features for target somelib:
+
+   \* not_a_feature
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error in CMakeLists.txt:
+  Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake
new file mode 100644
index 0000000..350c2ea
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake
@@ -0,0 +1,4 @@
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES)
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "not_a_feature")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt
new file mode 100644
index 0000000..08e20a8
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt
@@ -0,0 +1,11 @@
+CMake Debug Log at NotAFeature_OriginDebugGenex.cmake:4 \(set_property\):
+  Used compile features for target somelib:
+
+   \* not_a_feature
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error in CMakeLists.txt:
+  Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake
new file mode 100644
index 0000000..2122981
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake
@@ -0,0 +1,4 @@
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES)
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "$<1:not_a_feature>")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt
new file mode 100644
index 0000000..23c3305
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt
@@ -0,0 +1,11 @@
+CMake Debug Log at NotAFeature_OriginDebugTransitive.cmake:6 \(target_link_libraries\):
+  Used compile features for target somelib:
+
+   \* not_a_feature
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+
+
+CMake Error in CMakeLists.txt:
+  Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake
new file mode 100644
index 0000000..05d0073
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake
@@ -0,0 +1,6 @@
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES)
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_COMPILE_FEATURES "not_a_feature")
+add_library(somelib STATIC empty.cpp)
+target_link_libraries(somelib iface)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt
new file mode 100644
index 0000000..d819d15
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at NotAFeature_OriginDebug_target_compile_features.cmake:4 \(target_compile_features\):
+  target_compile_features specified unknown feature "not_a_feature" for
+  target "somelib".
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake
new file mode 100644
index 0000000..467d9a1
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake
@@ -0,0 +1,4 @@
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES)
+add_library(somelib STATIC empty.cpp)
+target_compile_features(somelib PRIVATE not_a_feature)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/RequireCXX11-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/RequireCXX11-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX11-stderr.txt b/Tests/RunCMake/CompileFeatures/RequireCXX11-stderr.txt
new file mode 100644
index 0000000..0fc9112
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX11-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Target "foo" requires the language dialect "CXX11" , but CMake does not
+  know the compile flags to use to enable it.
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX11.cmake b/Tests/RunCMake/CompileFeatures/RequireCXX11.cmake
new file mode 100644
index 0000000..f60504f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX11.cmake
@@ -0,0 +1,5 @@
+
+add_library(foo empty.cpp)
+set_property(TARGET foo PROPERTY CXX_STANDARD 11)
+set_property(TARGET foo PROPERTY CXX_EXTENSIONS FALSE)
+set_property(TARGET foo PROPERTY CXX_STANDARD_REQUIRED TRUE)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/RequireCXX11Ext-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/RequireCXX11Ext-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX11Ext-stderr.txt b/Tests/RunCMake/CompileFeatures/RequireCXX11Ext-stderr.txt
new file mode 100644
index 0000000..5c68a1c
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX11Ext-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Target "foo" requires the language dialect "CXX11" \(with compiler
+  extensions\), but CMake does not know the compile flags to use to enable it.
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX11Ext.cmake b/Tests/RunCMake/CompileFeatures/RequireCXX11Ext.cmake
new file mode 100644
index 0000000..10b251a
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX11Ext.cmake
@@ -0,0 +1,4 @@
+
+add_library(foo empty.cpp)
+set_property(TARGET foo PROPERTY CXX_STANDARD 11)
+set_property(TARGET foo PROPERTY CXX_STANDARD_REQUIRED TRUE)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/RequireCXX11ExtVariable-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/RequireCXX11ExtVariable-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX11ExtVariable-stderr.txt b/Tests/RunCMake/CompileFeatures/RequireCXX11ExtVariable-stderr.txt
new file mode 100644
index 0000000..5c68a1c
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX11ExtVariable-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Target "foo" requires the language dialect "CXX11" \(with compiler
+  extensions\), but CMake does not know the compile flags to use to enable it.
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX11ExtVariable.cmake b/Tests/RunCMake/CompileFeatures/RequireCXX11ExtVariable.cmake
new file mode 100644
index 0000000..29703db
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX11ExtVariable.cmake
@@ -0,0 +1,4 @@
+
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
+add_library(foo empty.cpp)
+set_property(TARGET foo PROPERTY CXX_STANDARD 11)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/RequireCXX11Variable-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/RequireCXX11Variable-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX11Variable-stderr.txt b/Tests/RunCMake/CompileFeatures/RequireCXX11Variable-stderr.txt
new file mode 100644
index 0000000..0fc9112
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX11Variable-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Target "foo" requires the language dialect "CXX11" , but CMake does not
+  know the compile flags to use to enable it.
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX11Variable.cmake b/Tests/RunCMake/CompileFeatures/RequireCXX11Variable.cmake
new file mode 100644
index 0000000..c480997
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX11Variable.cmake
@@ -0,0 +1,5 @@
+
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
+add_library(foo empty.cpp)
+set_property(TARGET foo PROPERTY CXX_STANDARD 11)
+set_property(TARGET foo PROPERTY CXX_EXTENSIONS FALSE)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/RequireCXX98-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/RequireCXX98-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX98-stderr.txt b/Tests/RunCMake/CompileFeatures/RequireCXX98-stderr.txt
new file mode 100644
index 0000000..47c8688
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX98-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Target "foo" requires the language dialect "CXX98" , but CMake does not
+  know the compile flags to use to enable it.
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX98.cmake b/Tests/RunCMake/CompileFeatures/RequireCXX98.cmake
new file mode 100644
index 0000000..fd9fb60
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX98.cmake
@@ -0,0 +1,5 @@
+
+add_library(foo empty.cpp)
+set_property(TARGET foo PROPERTY CXX_STANDARD 98)
+set_property(TARGET foo PROPERTY CXX_STANDARD_REQUIRED TRUE)
+set_property(TARGET foo PROPERTY CXX_EXTENSIONS FALSE)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/RequireCXX98Ext-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/RequireCXX98Ext-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX98Ext-stderr.txt b/Tests/RunCMake/CompileFeatures/RequireCXX98Ext-stderr.txt
new file mode 100644
index 0000000..b4fdf8a
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX98Ext-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Target "foo" requires the language dialect "CXX98" \(with compiler
+  extensions\), but CMake does not know the compile flags to use to enable it.
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX98Ext.cmake b/Tests/RunCMake/CompileFeatures/RequireCXX98Ext.cmake
new file mode 100644
index 0000000..4ea595e
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX98Ext.cmake
@@ -0,0 +1,4 @@
+
+add_library(foo empty.cpp)
+set_property(TARGET foo PROPERTY CXX_STANDARD 98)
+set_property(TARGET foo PROPERTY CXX_STANDARD_REQUIRED TRUE)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/RequireCXX98ExtVariable-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/RequireCXX98ExtVariable-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX98ExtVariable-stderr.txt b/Tests/RunCMake/CompileFeatures/RequireCXX98ExtVariable-stderr.txt
new file mode 100644
index 0000000..b4fdf8a
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX98ExtVariable-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Target "foo" requires the language dialect "CXX98" \(with compiler
+  extensions\), but CMake does not know the compile flags to use to enable it.
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX98ExtVariable.cmake b/Tests/RunCMake/CompileFeatures/RequireCXX98ExtVariable.cmake
new file mode 100644
index 0000000..0e3ef8d
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX98ExtVariable.cmake
@@ -0,0 +1,4 @@
+
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
+add_library(foo empty.cpp)
+set_property(TARGET foo PROPERTY CXX_STANDARD 98)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/RequireCXX98Variable-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/CompileFeatures/RequireCXX98Variable-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX98Variable-stderr.txt b/Tests/RunCMake/CompileFeatures/RequireCXX98Variable-stderr.txt
new file mode 100644
index 0000000..47c8688
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX98Variable-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+  Target "foo" requires the language dialect "CXX98" , but CMake does not
+  know the compile flags to use to enable it.
diff --git a/Tests/RunCMake/CompileFeatures/RequireCXX98Variable.cmake b/Tests/RunCMake/CompileFeatures/RequireCXX98Variable.cmake
new file mode 100644
index 0000000..7562264
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RequireCXX98Variable.cmake
@@ -0,0 +1,5 @@
+
+set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
+add_library(foo empty.cpp)
+set_property(TARGET foo PROPERTY CXX_STANDARD 98)
+set_property(TARGET foo PROPERTY CXX_EXTENSIONS FALSE)
diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
new file mode 100644
index 0000000..1892a5c
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
@@ -0,0 +1,54 @@
+include(RunCMake)
+
+run_cmake(NotAFeature)
+run_cmake(NotAFeatureGenex)
+run_cmake(NotAFeatureTransitive)
+run_cmake(NotAFeature_OriginDebug)
+run_cmake(NotAFeature_OriginDebugGenex)
+run_cmake(NotAFeature_OriginDebugTransitive)
+run_cmake(NotAFeature_OriginDebug_target_compile_features)
+
+run_cmake(generate_feature_list)
+file(READ
+  "${RunCMake_BINARY_DIR}/generate_feature_list-build/c_features.txt"
+  C_FEATURES
+)
+file(READ
+  "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt"
+  CXX_FEATURES
+)
+
+if (NOT C_FEATURES)
+  run_cmake(NoSupportedCFeatures)
+  run_cmake(NoSupportedCFeaturesGenex)
+endif()
+
+if (NOT CXX_FEATURES)
+  run_cmake(NoSupportedCxxFeatures)
+  run_cmake(NoSupportedCxxFeaturesGenex)
+else()
+  run_cmake(LinkImplementationFeatureCycle)
+  run_cmake(LinkImplementationFeatureCycleSolved)
+
+  if (";${CXX_FEATURES};" MATCHES ";cxx_final;")
+    set(RunCMake_TEST_OPTIONS "-DHAVE_FINAL=1")
+  endif()
+  run_cmake(NonValidTarget1)
+  run_cmake(NonValidTarget2)
+  unset(RunCMake_TEST_OPTIONS)
+endif()
+
+foreach(standard 98 11)
+  file(READ
+    "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx${standard}_flag.txt"
+    CXX${standard}_FLAG
+  )
+  if (CXX${standard}_FLAG STREQUAL NOTFOUND)
+    run_cmake(RequireCXX${standard})
+    run_cmake(RequireCXX${standard}Variable)
+  endif()
+  if (CXX${standard}EXT_FLAG STREQUAL NOTFOUND)
+    run_cmake(RequireCXX${standard}Ext)
+    run_cmake(RequireCXX${standard}ExtVariable)
+  endif()
+endforeach()
diff --git a/Tests/RunCMake/CompileFeatures/empty.c b/Tests/RunCMake/CompileFeatures/empty.c
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/empty.c
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/CompileFeatures/empty.cpp b/Tests/RunCMake/CompileFeatures/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
new file mode 100644
index 0000000..09e17b1
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
@@ -0,0 +1,29 @@
+
+enable_language(C)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/c_features.txt"
+  "${CMAKE_C_COMPILE_FEATURES}"
+)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_features.txt"
+  "${CMAKE_CXX_COMPILE_FEATURES}"
+)
+
+foreach(standard 98 11)
+  set(CXX${standard}_FLAG NOTFOUND)
+  if (DEFINED CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION)
+    set(CXX${standard}_FLAG ${CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION})
+  endif()
+
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx${standard}_flag.txt"
+    "${CXX${standard}_FLAG}"
+  )
+  set(CXX${standard}EXT_FLAG NOTFOUND)
+  if (DEFINED CMAKE_CXX${standard}_EXTENSION_COMPILE_OPTION)
+    set(CXX${standard}EXT_FLAG ${CMAKE_CXX${standard}_EXTENSION_COMPILE_OPTION})
+  endif()
+
+  file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx${standard}ext_flag.txt"
+    "${CXX${standard}EXT_FLAG}"
+  )
+endforeach()
diff --git a/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt b/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt
index bb87f4c..92fe233 100644
--- a/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt
+++ b/Tests/RunCMake/Configure/FailCopyFileABI-stdout.txt
@@ -1,4 +1,4 @@
 -- Detecting C compiler ABI info
--- Detecting C compiler ABI info - failed
+-- Detecting C compiler ABI info - failed.*
 -- Configuring done
 -- Generating done
diff --git a/Tests/RunCMake/ExternalData/Directory1-stderr.txt b/Tests/RunCMake/ExternalData/Directory1-stderr.txt
index 85c250f..2bc3c60 100644
--- a/Tests/RunCMake/ExternalData/Directory1-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory1-stderr.txt
@@ -7,7 +7,7 @@
 
     Directory1
 
-  that does not exist as a file \(with or without an extension\)!
+  that is directory instead of a file!
 Call Stack \(most recent call first\):
   .*
   Directory1.cmake:3 \(ExternalData_Add_Test\)
diff --git a/Tests/RunCMake/ExternalData/Directory3-stderr.txt b/Tests/RunCMake/ExternalData/Directory3-stderr.txt
index 56a341e..ceed2a0 100644
--- a/Tests/RunCMake/ExternalData/Directory3-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory3-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
   Data file referenced by argument
 
     DATA{Directory3/\*}
@@ -12,3 +12,4 @@
   .*
   Directory3.cmake:3 \(ExternalData_Add_Test\)
   CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/MissingData-result.txt b/Tests/RunCMake/ExternalData/MissingData-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/ExternalData/MissingData-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/Tests/RunCMake/ExternalData/MissingData-stderr.txt b/Tests/RunCMake/ExternalData/MissingData-stderr.txt
index e794f95..39ed2f1 100644
--- a/Tests/RunCMake/ExternalData/MissingData-stderr.txt
+++ b/Tests/RunCMake/ExternalData/MissingData-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
   Data file referenced by argument
 
     DATA{MissingData.txt}
@@ -10,5 +10,6 @@
   that does not exist as a file \(with or without an extension\)!
 Call Stack \(most recent call first\):
   .*
-  MissingData.cmake:2 \(ExternalData_Add_Test\)
+  MissingData.cmake:4 \(ExternalData_Expand_Arguments\)
   CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/MissingData-stdout.txt b/Tests/RunCMake/ExternalData/MissingData-stdout.txt
new file mode 100644
index 0000000..addd40e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingData-stdout.txt
@@ -0,0 +1 @@
+-- Missing data reference correctly transformed!
diff --git a/Tests/RunCMake/ExternalData/MissingData.cmake b/Tests/RunCMake/ExternalData/MissingData.cmake
index b3c8a5c..f5fefd5 100644
--- a/Tests/RunCMake/ExternalData/MissingData.cmake
+++ b/Tests/RunCMake/ExternalData/MissingData.cmake
@@ -1,5 +1,10 @@
 include(ExternalData)
-ExternalData_Add_Test(Data
-  NAME Test
-  COMMAND ${CMAKE_COMMAND} -E echo DATA{MissingData.txt}
-  )
+
+set(output "${CMAKE_SOURCE_DIR}/MissingData.txt")
+ExternalData_Expand_Arguments(Data args DATA{MissingData.txt})
+if("x${args}" STREQUAL "x${output}")
+  message(STATUS "Missing data reference correctly transformed!")
+else()
+  message(FATAL_ERROR "Missing data reference transformed to:\n  ${args}\n"
+    "but we expected:\n  ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt
new file mode 100644
index 0000000..315af5e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt
@@ -0,0 +1,15 @@
+CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+  Data file referenced by argument
+
+    DATA{MissingData.txt,Data.txt}
+
+  corresponds to source tree path
+
+    MissingData.txt
+
+  that does not exist as a file \(with or without an extension\)!
+Call Stack \(most recent call first\):
+  .*
+  MissingDataWithAssociated.cmake:4 \(ExternalData_Expand_Arguments\)
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt
new file mode 100644
index 0000000..addd40e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt
@@ -0,0 +1 @@
+-- Missing data reference correctly transformed!
diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake b/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake
new file mode 100644
index 0000000..a4c4638
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake
@@ -0,0 +1,10 @@
+include(ExternalData)
+
+set(output "${CMAKE_BINARY_DIR}/MissingData.txt")
+ExternalData_Expand_Arguments(Data args DATA{MissingData.txt,Data.txt})
+if("x${args}" STREQUAL "x${output}")
+  message(STATUS "Missing data reference correctly transformed!")
+else()
+  message(FATAL_ERROR "Missing data reference transformed to:\n  ${args}\n"
+    "but we expected:\n  ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
index 93ff08f..04e3d59 100644
--- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
@@ -15,6 +15,7 @@
 run_cmake(LinkContentSHA1)
 run_cmake(LinkDirectory1)
 run_cmake(MissingData)
+run_cmake(MissingDataWithAssociated)
 run_cmake(NoLinkInSource)
 run_cmake(NoURLTemplates)
 run_cmake(NormalData1)
diff --git a/Tests/RunCMake/FeatureSummary/CMakeLists.txt b/Tests/RunCMake/FeatureSummary/CMakeLists.txt
new file mode 100644
index 0000000..72abfc8
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt
new file mode 100644
index 0000000..9a3f023
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt
@@ -0,0 +1,7 @@
+-- The following features have been enabled:
+
+ \* Foo , Foo\.
+
+-- The following features have been disabled:
+
+ \* Bar , Bar\.
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake
new file mode 100644
index 0000000..ec5ebcb
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT ALL)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt
new file mode 100644
index 0000000..4d8f25f
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt
@@ -0,0 +1,7 @@
+-- The following features have been disabled:
+
+ \* Bar , Bar\.
+
+-- The following features have been enabled:
+
+ \* Foo , Foo\.
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake
new file mode 100644
index 0000000..d04ba88
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT DISABLED_FEATURES ENABLED_FEATURES)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt
new file mode 100644
index 0000000..18d9ebd
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
+  The WHAT argument of FEATURE_SUMMARY\(\) contains ALL, which cannot be
+  combined with other values\.
+Call Stack \(most recent call first\):
+  FeatureSummaryWhatListAll\.cmake:[0-9]+ \(feature_summary\)
+  CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake
new file mode 100644
index 0000000..1877ea5
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT ENABLED_FEATURES ALL)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt
new file mode 100644
index 0000000..3ad3750
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
+  The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid
+  value\.
+Call Stack \(most recent call first\):
+  FeatureSummaryWhatListUnknown\.cmake:[0-9]+ \(feature_summary\)
+  CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake
new file mode 100644
index 0000000..46088d4
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT ENABLED_FEATURES FOO)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt
new file mode 100644
index 0000000..240632d
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt
@@ -0,0 +1 @@
+ \* Foo , Foo\.
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake
new file mode 100644
index 0000000..593dfb6
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT ENABLED_FEATURES)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt
new file mode 100644
index 0000000..c78853c
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
+  The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid
+  value\.
+Call Stack \(most recent call first\):
+  FeatureSummaryWhatSingleUnknown\.cmake:[0-9]+ \(feature_summary\)
+  CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake
new file mode 100644
index 0000000..c2d6d2e
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT FOO)
diff --git a/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake
new file mode 100644
index 0000000..1417338
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(FeatureSummaryWhatAll)
+run_cmake(FeatureSummaryWhatSingle)
+run_cmake(FeatureSummaryWhatSingleUnknown)
+run_cmake(FeatureSummaryWhatList)
+run_cmake(FeatureSummaryWhatListUnknown)
+run_cmake(FeatureSummaryWhatListAll)
diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
index f07431c..f23fa19 100644
--- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
+++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
@@ -8,3 +8,30 @@
 run_cmake(EmptyCondition2)
 run_cmake(BadCondition)
 run_cmake(DebugEvaluate)
+
+set(timeformat "%Y%j%H%M%S")
+
+file(REMOVE "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt")
+set(RunCMake_TEST_FILE "WriteIfDifferent")
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/WriteIfDifferent-build")
+run_cmake(WriteIfDifferent-prepare)
+unset(RunCMake_TEST_FILE)
+unset(RunCMake_TEST_BINARY_DIR)
+file(TIMESTAMP "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt" timestamp ${timeformat})
+if(NOT timestamp)
+  message(SEND_ERROR "Could not get timestamp for \"${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt\"")
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
+
+set(RunCMake_TEST_NO_CLEAN ON)
+run_cmake(WriteIfDifferent)
+file(TIMESTAMP "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt" timestamp_after ${timeformat})
+if(NOT timestamp_after)
+  message(SEND_ERROR "Could not get timestamp for \"${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt\"")
+endif()
+unset(RunCMake_TEST_NO_CLEAN)
+
+if (NOT timestamp_after STREQUAL timestamp)
+  message(SEND_ERROR "WriteIfDifferent changed output file.")
+endif()
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt b/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
new file mode 100644
index 0000000..d1d832a
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
@@ -0,0 +1,5 @@
+
+file(GENERATE
+  OUTPUT output_file.txt
+  CONTENT "123"
+)
diff --git a/Tests/RunCMake/FindPkgConfig/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt
new file mode 100644
index 0000000..72abfc8
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake
new file mode 100644
index 0000000..924976e
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake
@@ -0,0 +1,41 @@
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+    set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+    set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+    set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+    set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+if(WIN32)
+  set(expected_path "C:\\baz")
+else()
+  set(expected_path "/baz")
+endif()
+
+
+pkg_check_modules(FOO "${expected_path}")
+
+if(NOT "FOO_FOUND")
+  message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
+
+
+
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+
+pkg_check_modules(BAR "${expected_path}" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
+
+if(NOT "BAR_FOUND")
+  message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake
new file mode 100644
index 0000000..4a66e85
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake
@@ -0,0 +1,51 @@
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+    set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+    set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+    set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+    set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+
+if(NOT DEFINED CMAKE_SYSTEM_NAME
+    OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+    AND NOT CMAKE_CROSSCOMPILING))
+  if(EXISTS "/etc/debian_version") # is this a debian system ?
+    if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
+      # Cannot create directories for all the existing architectures...
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+    else()
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+    endif()
+  else()
+    # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
+    get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+    if(uselib64)
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+    endif()
+  endif()
+else()
+  if(WIN32)
+    set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig")
+  else()
+    set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+  endif()
+endif()
+
+
+pkg_check_modules(FOO "${expected_path}")
+
+if(NOT "FOO_FOUND")
+  message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake
new file mode 100644
index 0000000..0b057b8
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake
@@ -0,0 +1,51 @@
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+    set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+    set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+    set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+    set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+
+if(NOT DEFINED CMAKE_SYSTEM_NAME
+    OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+    AND NOT CMAKE_CROSSCOMPILING))
+  if(EXISTS "/etc/debian_version") # is this a debian system ?
+    if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
+      # Cannot create directories for all the existing architectures...
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
+    else()
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
+    endif()
+  else()
+    # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
+    get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+    if(uselib64)
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
+    endif()
+  endif()
+else()
+  if(WIN32)
+    set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig")
+  else()
+    set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
+  endif()
+endif()
+
+
+pkg_check_modules(FOO "${expected_path}" NO_CMAKE_ENVIRONMENT_PATH)
+
+if(NOT "FOO_FOUND")
+  message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake
new file mode 100644
index 0000000..a3154f1
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake
@@ -0,0 +1,51 @@
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+    set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+    set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+    set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+    set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+    set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+
+if(NOT DEFINED CMAKE_SYSTEM_NAME
+    OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+    AND NOT CMAKE_CROSSCOMPILING))
+  if(EXISTS "/etc/debian_version") # is this a debian system ?
+    if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
+      # Cannot create directories for all the existing architectures...
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+    else()
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+    endif()
+  else()
+    # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
+    get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+    if(uselib64)
+      set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+    endif()
+  endif()
+else()
+  if(WIN32)
+    set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig")
+  else()
+    set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+  endif()
+endif()
+
+
+pkg_check_modules(FOO "${expected_path}" NO_CMAKE_PATH)
+
+if(NOT "FOO_FOUND")
+  message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
new file mode 100644
index 0000000..bca93bb
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -0,0 +1,6 @@
+include(RunCMake)
+
+run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH)
+run_cmake(FindPkgConfig_PKGCONFIG_PATH)
+run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH)
+run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH)
diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat
new file mode 100755
index 0000000..f2f86b0
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat
@@ -0,0 +1,18 @@
+@ECHO OFF
+IF "%1"=="" (
+  EXIT /B 255
+)
+IF "%1"=="--version" (
+  ECHO 0.0-cmake-dummy
+  EXIT /B 0
+)
+
+IF "%1"=="--exists" (
+  SHIFT
+  ECHO Expected: %*
+  ECHO Found:    %PKG_CONFIG_PATH%
+  IF NOT "%*"=="%PKG_CONFIG_PATH%" (
+    EXIT /B 1
+  )
+)
+EXIT /B 0
diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh
new file mode 100755
index 0000000..852e841
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# This is a replacement for pkg-config that compares the string passed
+# to the --exists argument with the PKG_CONFIG_PATH environment variable
+# and returns 1 if they are different.
+
+case $1 in
+  --version)
+    echo "0.0-cmake-dummy"
+    ;;
+  --exists)
+    shift
+    echo "Expected: $@"
+    echo "Found:    ${PKG_CONFIG_PATH}"
+    [ "$@" = "${PKG_CONFIG_PATH}" ] || exit 1
+    ;;
+  *)
+    exit 255
+    ;;
+esac
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-result.txt
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt
new file mode 100644
index 0000000..dd7a183
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget-CXX_COMPILER_ID.cmake:4 \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<CXX_COMPILER_ID>
+
+  \$<CXX_COMPILER_ID> may only be used with binary targets.  It may not be
+  used with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake
new file mode 100644
index 0000000..7dd38da
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
+  COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<CXX_COMPILER_ID>.cpp"
+)
+
+add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-result.txt
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt
new file mode 100644
index 0000000..d4a064a
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget-CXX_COMPILER_VERSION.cmake:4 \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<CXX_COMPILER_VERSION>
+
+  \$<CXX_COMPILER_VERSION> may only be used with binary targets.  It may not
+  be used with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake
new file mode 100644
index 0000000..1afb2b5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
+  COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<CXX_COMPILER_VERSION>.cpp"
+)
+
+add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-result.txt
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt
new file mode 100644
index 0000000..b8e53ed
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget-C_COMPILER_ID.cmake:4 \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<C_COMPILER_ID>
+
+  \$<C_COMPILER_ID> may only be used with binary targets.  It may not be used
+  with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake
new file mode 100644
index 0000000..2d92ee3
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
+  COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_ID>.cpp"
+)
+
+add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-result.txt
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt
new file mode 100644
index 0000000..551efe9
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget-C_COMPILER_VERSION.cmake:4 \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<C_COMPILER_VERSION>
+
+  \$<C_COMPILER_VERSION> may only be used with binary targets.  It may not be
+  used with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake
new file mode 100644
index 0000000..9b8a531
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
+  COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_VERSION>.cpp"
+)
+
+add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-result.txt
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt
new file mode 100644
index 0000000..0e87538
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget-TARGET_POLICY.cmake:4 \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<TARGET_POLICY:CMP0004>
+
+  \$<TARGET_POLICY:prop> may only be used with binary targets.  It may not be
+  used with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake
new file mode 100644
index 0000000..10b37b5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
+  COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_POLICY:CMP0004>.cpp"
+)
+
+add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-result.txt
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt
new file mode 100644
index 0000000..08ad3c2
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at NonValidTarget-TARGET_PROPERTY.cmake:4 \(add_custom_command\):
+  Error evaluating generator expression:
+
+    \$<TARGET_PROPERTY:NotAProperty>
+
+  \$<TARGET_PROPERTY:prop> may only be used with binary targets.  It may not
+  be used with add_custom_command or add_custom_target.  Specify the target
+  to read a property from using the \$<TARGET_PROPERTY:tgt,prop> signature
+  instead.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake
new file mode 100644
index 0000000..64abc5f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake
@@ -0,0 +1,8 @@
+
+enable_language(CXX)
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
+  COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_PROPERTY:NotAProperty>.cpp"
+)
+
+add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
index f3f99ed..c8f3fdf 100644
--- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
@@ -10,3 +10,9 @@
 run_cmake(BadTargetTypeObject)
 run_cmake(BadInstallPrefix)
 run_cmake(CMP0044-WARN)
+run_cmake(NonValidTarget-C_COMPILER_ID)
+run_cmake(NonValidTarget-CXX_COMPILER_ID)
+run_cmake(NonValidTarget-C_COMPILER_VERSION)
+run_cmake(NonValidTarget-CXX_COMPILER_VERSION)
+run_cmake(NonValidTarget-TARGET_PROPERTY)
+run_cmake(NonValidTarget-TARGET_POLICY)
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt
index bf1f190..d0d526c 100644
--- a/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt
+++ b/Tests/RunCMake/GeneratorToolset/BadToolset-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error:
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
   Generator
 
     .*
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolset-toolchain.cmake b/Tests/RunCMake/GeneratorToolset/BadToolset-toolchain.cmake
new file mode 100644
index 0000000..7bbf327
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolset-toolchain.cmake
@@ -0,0 +1 @@
+set(CMAKE_GENERATOR_TOOLSET "Bad Toolset")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-result.txt
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-stderr.txt
new file mode 100644
index 0000000..d0d526c
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain-stderr.txt
@@ -0,0 +1,10 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+  Generator
+
+    .*
+
+  does not support toolset specification, but toolset
+
+    Bad Toolset
+
+  was specified.$
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain.cmake
new file mode 100644
index 0000000..2fc38e5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetToolchain.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
index 1ccc1ad..d39f33f 100644
--- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
@@ -12,6 +12,17 @@
 endif()
 
 set(RunCMake_GENERATOR_TOOLSET "")
+
 set(RunCMake_TEST_OPTIONS -T "Extra Toolset")
 run_cmake(TwoToolsets)
 unset(RunCMake_TEST_OPTIONS)
+
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012]|Xcode" AND NOT XCODE_BELOW_3)
+  set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestToolset-toolchain.cmake)
+  run_cmake(TestToolsetToolchain)
+  unset(RunCMake_TEST_OPTIONS)
+else()
+  set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/BadToolset-toolchain.cmake)
+  run_cmake(BadToolsetToolchain)
+  unset(RunCMake_TEST_OPTIONS)
+endif()
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolset-toolchain.cmake b/Tests/RunCMake/GeneratorToolset/TestToolset-toolchain.cmake
new file mode 100644
index 0000000..bee2ae4
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolset-toolchain.cmake
@@ -0,0 +1 @@
+set(CMAKE_GENERATOR_TOOLSET "Test Toolset")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-result.txt
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-stderr.txt
new file mode 100644
index 0000000..0623e90
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at TestToolsetToolchain.cmake:[0-9]+ \(message\):
+  CMAKE_GENERATOR_TOOLSET is "Test Toolset" as expected.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error at TestToolsetToolchain.cmake:[0-9]+ \(message\):
+  CMAKE_(VS|XCODE)_PLATFORM_TOOLSET is "Test Toolset" as expected.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain.cmake
new file mode 100644
index 0000000..7c1c415
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetToolchain.cmake
@@ -0,0 +1,25 @@
+if("x${CMAKE_GENERATOR_TOOLSET}" STREQUAL "xTest Toolset")
+  message(SEND_ERROR "CMAKE_GENERATOR_TOOLSET is \"Test Toolset\" as expected.")
+else()
+  message(FATAL_ERROR
+    "CMAKE_GENERATOR_TOOLSET is \"${CMAKE_GENERATOR_TOOLSET}\" "
+    "but should be \"Test Toolset\"!")
+endif()
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+  if("x${CMAKE_VS_PLATFORM_TOOLSET}" STREQUAL "xTest Toolset")
+    message(SEND_ERROR "CMAKE_VS_PLATFORM_TOOLSET is \"Test Toolset\" as expected.")
+  else()
+    message(FATAL_ERROR
+      "CMAKE_VS_PLATFORM_TOOLSET is \"${CMAKE_VS_PLATFORM_TOOLSET}\" "
+      "but should be \"Test Toolset\"!")
+  endif()
+endif()
+if(CMAKE_GENERATOR MATCHES "Xcode")
+  if("x${CMAKE_XCODE_PLATFORM_TOOLSET}" STREQUAL "xTest Toolset")
+    message(SEND_ERROR "CMAKE_XCODE_PLATFORM_TOOLSET is \"Test Toolset\" as expected.")
+  else()
+    message(FATAL_ERROR
+      "CMAKE_XCODE_PLATFORM_TOOLSET is \"${CMAKE_XCODE_PLATFORM_TOOLSET}\" "
+      "but should be \"Test Toolset\"!")
+  endif()
+endif()
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
index a1cac36..859dc3f 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
@@ -1,6 +1,8 @@
 CMake Error at BadSourceExpression1.cmake:1 \(add_library\):
-  Unrecognized generator expression:
+  Error evaluating generator expression:
 
     \$<BAD_EXPRESSION>
+
+  Expression did not evaluate to a known generator expression
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
index f1fcbe8..7060c61 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
@@ -1,4 +1,8 @@
 CMake Error at BadSourceExpression2.cmake:1 \(add_library\):
+  Error evaluating generator expression:
+
+    \$<TARGET_OBJECTS:DoesNotExist>
+
   Objects of target "DoesNotExist" referenced but no such target exists.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
index ad14a35..838b3d8 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
@@ -1,4 +1,8 @@
 CMake Error at BadSourceExpression3.cmake:2 \(add_library\):
+  Error evaluating generator expression:
+
+    \$<TARGET_OBJECTS:NotObjLib>
+
   Objects of target "NotObjLib" referenced but is not an OBJECT library.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 1d1c523..4ed2f43 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -25,7 +25,9 @@
       unset(expect_std${o})
     endif()
   endforeach()
-  set(RunCMake_TEST_SOURCE_DIR "${top_src}")
+  if (NOT RunCMake_TEST_SOURCE_DIR)
+    set(RunCMake_TEST_SOURCE_DIR "${top_src}")
+  endif()
   if(NOT RunCMake_TEST_BINARY_DIR)
     set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build")
   endif()
@@ -36,6 +38,9 @@
   if(NOT DEFINED RunCMake_TEST_OPTIONS)
     set(RunCMake_TEST_OPTIONS "")
   endif()
+  if (NOT RunCMake_TEST_FILE)
+    set(RunCMake_TEST_FILE "${test}")
+  endif()
   if(APPLE)
     list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW)
   endif()
@@ -52,7 +57,8 @@
       COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}"
                 -G "${RunCMake_GENERATOR}"
                 -T "${RunCMake_GENERATOR_TOOLSET}"
-                -DRunCMake_TEST=${test}
+                -DRunCMake_TEST=${RunCMake_TEST_FILE}
+                --no-warn-unused-cli
                 ${RunCMake_TEST_OPTIONS}
       WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
       OUTPUT_VARIABLE actual_stdout
diff --git a/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt
new file mode 100644
index 0000000..5dcd4d7
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt
@@ -0,0 +1 @@
+-->wrong<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariable.cmake b/Tests/RunCMake/Syntax/AtWithVariable.cmake
new file mode 100644
index 0000000..2bbf61d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariable.cmake
@@ -0,0 +1,9 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here.
+set(ref "@var@")
+
+# 'right' is dereferenced because 'var' was dereferenced when
+# assigning to 'ref' above.
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake
new file mode 100644
index 0000000..e06484c
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake
@@ -0,0 +1,8 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here.
+set(ref "@var@")
+
+# No dereference done at all.
+string(CONFIGURE "${ref}" output @ONLY)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt
new file mode 100644
index 0000000..90bffb6
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt
@@ -0,0 +1,5 @@
+-->==>\${right}<==
+==><==
+==>\${var}<==
+==>\${empty}<==
+<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake
new file mode 100644
index 0000000..bdd7bcd
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake
@@ -0,0 +1,9 @@
+set(right "wrong")
+set(var "\${right}")
+
+configure_file(
+  "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt"
+  @ONLY)
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake
new file mode 100644
index 0000000..840c7f0
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake
@@ -0,0 +1,8 @@
+# Literal since 'var' is not defined.
+set(ref "@var@")
+set(right "wrong")
+set(var "\${right}")
+
+# 'var' is dereferenced here.
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake
new file mode 100644
index 0000000..b657506
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake
@@ -0,0 +1,8 @@
+# Literal since 'var' is not defined.
+set(ref "@var@")
+set(right "wrong")
+set(var "\${right}")
+
+# 'var' is dereferenced, but now 'right'
+string(CONFIGURE "${ref}" output @ONLY)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt
new file mode 100644
index 0000000..43f029f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt
@@ -0,0 +1,5 @@
+-->==>\${right}<==
+==><==
+==>\${right}<==
+==><==
+<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake
new file mode 100644
index 0000000..c709099
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake
@@ -0,0 +1,8 @@
+set(right "wrong")
+set(var "\${right}")
+
+configure_file(
+  "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt")
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-NEW-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-At-NEW-stderr.txt
new file mode 100644
index 0000000..e3e5332
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-At-NEW-stderr.txt
@@ -0,0 +1 @@
+^-->\${right}<--$
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-NEW.cmake b/Tests/RunCMake/Syntax/CMP0053-At-NEW.cmake
new file mode 100644
index 0000000..40dbe46
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-At-NEW.cmake
@@ -0,0 +1,9 @@
+cmake_policy(SET CMP0053 NEW)
+
+set(right "wrong")
+set(var "\${right}")
+# Not expanded here with the new policy.
+set(ref "@var@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt
new file mode 100644
index 0000000..acfa30a
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt
@@ -0,0 +1 @@
+^-->wrong<--$
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-OLD.cmake b/Tests/RunCMake/Syntax/CMP0053-At-OLD.cmake
new file mode 100644
index 0000000..666f107
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-At-OLD.cmake
@@ -0,0 +1,9 @@
+cmake_policy(SET CMP0053 OLD)
+
+set(right "wrong")
+set(var "\${right}")
+# Expanded here with the old policy.
+set(ref "@var@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-WARN-newlines-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-At-WARN-newlines-stderr.txt
new file mode 100644
index 0000000..ec37021
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-At-WARN-newlines-stderr.txt
@@ -0,0 +1,27 @@
+^CMake Warning \(dev\) at CMP0053-At-WARN-newlines.cmake:4 \(set\):
+  Policy CMP0053 is not set: Simplify variable reference and escape sequence
+  evaluation.  Run "cmake --help-policy CMP0053" for policy details.  Use the
+  cmake_policy command to set the policy and suppress this warning.
+
+  For input:
+
+    '
+    @var@
+    '
+
+  the old evaluation rules produce:
+
+    '
+    \${right}
+    '
+
+  but the new evaluation rules produce:
+
+    '
+    @var@
+    '
+
+  Using the old result for compatibility since the policy is not set.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-WARN-newlines.cmake b/Tests/RunCMake/Syntax/CMP0053-At-WARN-newlines.cmake
new file mode 100644
index 0000000..c493505
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-At-WARN-newlines.cmake
@@ -0,0 +1,6 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here with the old policy.
+set(ref "
+@var@
+")
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-WARN-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-At-WARN-stderr.txt
new file mode 100644
index 0000000..697b7b3
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-At-WARN-stderr.txt
@@ -0,0 +1,21 @@
+^CMake Warning \(dev\) at CMP0053-At-WARN.cmake:4 \(set\):
+  Policy CMP0053 is not set: Simplify variable reference and escape sequence
+  evaluation.  Run "cmake --help-policy CMP0053" for policy details.  Use the
+  cmake_policy command to set the policy and suppress this warning.
+
+  For input:
+
+    '@var@'
+
+  the old evaluation rules produce:
+
+    '\${right}'
+
+  but the new evaluation rules produce:
+
+    '@var@'
+
+  Using the old result for compatibility since the policy is not set.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-WARN.cmake b/Tests/RunCMake/Syntax/CMP0053-At-WARN.cmake
new file mode 100644
index 0000000..19c7f53
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-At-WARN.cmake
@@ -0,0 +1,4 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here with the old policy.
+set(ref "@var@")
diff --git a/Tests/RunCMake/Syntax/CMP0053-NUL-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NUL-stderr.txt
new file mode 100644
index 0000000..09c7e7c
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NUL-stderr.txt
@@ -0,0 +1,56 @@
+^CMake Warning \(dev\) at CMP0053-NUL.cmake:1 \(set\):
+  Policy CMP0053 is not set: Simplify variable reference and escape sequence
+  evaluation.  Run "cmake --help-policy CMP0053" for policy details.  Use the
+  cmake_policy command to set the policy and suppress this warning.
+
+  For input:
+
+    '\\0'
+
+  the old evaluation rules produce:
+
+    ''
+
+  but the new evaluation rules produce an error:
+
+    Syntax error in cmake code at
+      .*/Tests/RunCMake/Syntax/CMP0053-NUL.cmake:1
+    when parsing string
+      \\0
+    Invalid character escape '\\0'.
+
+  Using the old result for compatibility since the policy is not set.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at CMP0053-NUL.cmake:2 \(set\):
+  Policy CMP0053 is not set: Simplify variable reference and escape sequence
+  evaluation.  Run "cmake --help-policy CMP0053" for policy details.  Use the
+  cmake_policy command to set the policy and suppress this warning.
+
+  For input:
+
+    '\\0'
+
+  the old evaluation rules produce:
+
+    ''
+
+  but the new evaluation rules produce an error:
+
+    Syntax error in cmake code at
+      .*/Tests/RunCMake/Syntax/CMP0053-NUL.cmake:2
+    when parsing string
+      \\0
+    Invalid character escape '\\0'.
+
+  Using the old result for compatibility since the policy is not set.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+--><--
+--><--
+--><--
+--><--$
diff --git a/Tests/RunCMake/Syntax/CMP0053-NUL.cmake b/Tests/RunCMake/Syntax/CMP0053-NUL.cmake
new file mode 100644
index 0000000..9ae0906
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NUL.cmake
@@ -0,0 +1,6 @@
+set(qnul "\0")
+set(nul \0)
+message(-->${nul}<--)
+message(-->${qnul}<--)
+message("-->${nul}<--")
+message("-->${qnul}<--")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturn-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturn-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturn-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturn-stderr.txt
new file mode 100644
index 0000000..9575778
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturn-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at CMP0053-NameWithCarriageReturn.cmake:2 \(message\):
+  message called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturn.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturn.cmake
new file mode 100644
index 0000000..b8a403d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturn.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message(${var\rwith\rcarriagereturn})
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturnQuoted.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturnQuoted.cmake
new file mode 100644
index 0000000..bb0d93f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithCarriageReturnQuoted.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message("${var\rwith\rcarriagereturn}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpaces-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpaces-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpaces-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpaces-stderr.txt
new file mode 100644
index 0000000..df67d37
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpaces-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at CMP0053-NameWithEscapedSpaces.cmake:2 \(message\):
+  message called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpaces.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpaces.cmake
new file mode 100644
index 0000000..805b2ca
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpaces.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message(${var\ with\ escaped\ space})
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpacesQuoted.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpacesQuoted.cmake
new file mode 100644
index 0000000..58d8e8f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedSpacesQuoted.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message("${var\ with\ escaped\ space}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabs-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabs-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabs-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabs-stderr.txt
new file mode 100644
index 0000000..059044f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabs-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at CMP0053-NameWithEscapedTabs.cmake:2 \(message\):
+  message called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabs.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabs.cmake
new file mode 100644
index 0000000..214ab5d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabs.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message(${var\	with\	escaped\	tab})
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabsQuoted.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabsQuoted.cmake
new file mode 100644
index 0000000..aa5123f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithEscapedTabsQuoted.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message("${var\	with\	escaped\	tab}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithNewline-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/CMP0053-NameWithNewline-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithNewline-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithNewline-stderr.txt
new file mode 100644
index 0000000..41f86e6
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithNewline-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at CMP0053-NameWithNewline.cmake:2 \(message\):
+  message called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithNewline.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithNewline.cmake
new file mode 100644
index 0000000..45b532e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithNewline.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message(${var\nwith\nnewline})
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithNewlineQuoted.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithNewlineQuoted.cmake
new file mode 100644
index 0000000..6fe568d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithNewlineQuoted.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message("${var\nwith\nnewline}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithSpaces-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/CMP0053-NameWithSpaces-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithSpaces-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithSpaces-stderr.txt
new file mode 100644
index 0000000..95e8684
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithSpaces-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at CMP0053-NameWithSpaces.cmake:2 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/CMP0053-NameWithSpaces.cmake:2
+
+  when parsing string
+
+    \${var
+
+  There is an unterminated variable reference.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithSpaces.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithSpaces.cmake
new file mode 100644
index 0000000..dae7d25
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithSpaces.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message(${var with space})
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted-stderr.txt
new file mode 100644
index 0000000..c4f3cfe
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at CMP0053-NameWithSpacesQuoted.cmake:2 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted.cmake:2
+
+  when parsing string
+
+    \${var with space}
+
+  Invalid character \(' '\) in a variable name: 'var'
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted.cmake
new file mode 100644
index 0000000..e252cff
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithSpacesQuoted.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message("${var with space}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithTabs-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/CMP0053-NameWithTabs-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithTabs-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithTabs-stderr.txt
new file mode 100644
index 0000000..b1678b3
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithTabs-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at CMP0053-NameWithTabs.cmake:2 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/CMP0053-NameWithTabs.cmake:2
+
+  when parsing string
+
+    \${var
+
+  There is an unterminated variable reference.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithTabs.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithTabs.cmake
new file mode 100644
index 0000000..45e3045
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithTabs.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message(${var	with	tab})
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted-result.txt
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted-stderr.txt
new file mode 100644
index 0000000..78adb5e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at CMP0053-NameWithTabsQuoted.cmake:2 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted.cmake:2
+
+  when parsing string
+
+    \${var	with	tab}
+
+  Invalid character \('	'\) in a variable name: 'var'
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted.cmake b/Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted.cmake
new file mode 100644
index 0000000..498675f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-NameWithTabsQuoted.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0053 NEW)
+message("${var	with	tab}")
diff --git a/Tests/RunCMake/Syntax/CMP0053-ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-ParenInENV-stderr.txt
new file mode 100644
index 0000000..7020c7e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-ParenInENV-stderr.txt
@@ -0,0 +1 @@
+-->value<--
diff --git a/Tests/RunCMake/Syntax/CMP0053-ParenInENV.cmake b/Tests/RunCMake/Syntax/CMP0053-ParenInENV.cmake
new file mode 100644
index 0000000..b5cdf0f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-ParenInENV.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0053 NEW)
+set("ENV{e(x)}" value)
+message(-->$ENV{e\(x\)}<--)
diff --git a/Tests/RunCMake/Syntax/CMP0053-ParenInQuotedENV-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-ParenInQuotedENV-stderr.txt
new file mode 100644
index 0000000..7020c7e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-ParenInQuotedENV-stderr.txt
@@ -0,0 +1 @@
+-->value<--
diff --git a/Tests/RunCMake/Syntax/CMP0053-ParenInQuotedENV.cmake b/Tests/RunCMake/Syntax/CMP0053-ParenInQuotedENV.cmake
new file mode 100644
index 0000000..5559d4b
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-ParenInQuotedENV.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0053 NEW)
+set("ENV{e(x)}" value)
+message("-->$ENV{e\(x\)}<--")
diff --git a/Tests/RunCMake/Syntax/CMP0053-WARN-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-WARN-stderr.txt
new file mode 100644
index 0000000..c706939
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-WARN-stderr.txt
@@ -0,0 +1,28 @@
+^CMake Warning \(dev\) at CMP0053-WARN.cmake:2 \(message\):
+  Policy CMP0053 is not set: Simplify variable reference and escape sequence
+  evaluation.  Run "cmake --help-policy CMP0053" for policy details.  Use the
+  cmake_policy command to set the policy and suppress this warning.
+
+  For input:
+
+    '\\'
+
+  the old evaluation rules produce:
+
+    '\\'
+
+  but the new evaluation rules produce an error:
+
+    Syntax error in cmake code at
+      .*/Tests/RunCMake/Syntax/CMP0053-WARN.cmake:2
+    when parsing string
+      \\
+    Invalid character escape '\\' \(at end of input\).
+
+  Using the old result for compatibility since the policy is not set.
+Call Stack \(most recent call first\):
+  CMP0053-WARN.cmake:5 \(escape\)
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+\\$
diff --git a/Tests/RunCMake/Syntax/CMP0053-WARN.cmake b/Tests/RunCMake/Syntax/CMP0053-WARN.cmake
new file mode 100644
index 0000000..6e8b07b
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-WARN.cmake
@@ -0,0 +1,5 @@
+macro (escape str)
+  message("${str}")
+endmacro ()
+
+escape("\\")
diff --git a/Tests/RunCMake/Syntax/CMakeLists.txt b/Tests/RunCMake/Syntax/CMakeLists.txt
index 618473a..4b3de84 100644
--- a/Tests/RunCMake/Syntax/CMakeLists.txt
+++ b/Tests/RunCMake/Syntax/CMakeLists.txt
@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 2.8.9)
+cmake_minimum_required(VERSION 2.8.12)
 project(${RunCMake_TEST} NONE)
 include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/Escape2-result.txt
similarity index 100%
rename from Tests/RunCMake/ExternalData/Directory3-result.txt
rename to Tests/RunCMake/Syntax/Escape2-result.txt
diff --git a/Tests/RunCMake/Syntax/Escape2-stderr.txt b/Tests/RunCMake/Syntax/Escape2-stderr.txt
new file mode 100644
index 0000000..cc3bdf0
--- /dev/null
+++ b/Tests/RunCMake/Syntax/Escape2-stderr.txt
@@ -0,0 +1,13 @@
+CMake Error at Escape2.cmake:4 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/Escape2.cmake:4
+
+  when parsing string
+
+    \\
+
+  Invalid character escape '\\' \(at end of input\).
+Call Stack \(most recent call first\):
+  Escape2.cmake:7 \(escape\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/Escape2.cmake b/Tests/RunCMake/Syntax/Escape2.cmake
new file mode 100644
index 0000000..078a822
--- /dev/null
+++ b/Tests/RunCMake/Syntax/Escape2.cmake
@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0053 NEW)
+
+macro (escape str)
+  message("${str}")
+endmacro ()
+
+escape("\\")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/EscapeChar-char-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/EscapeChar-char-result.txt
diff --git a/Tests/RunCMake/Syntax/EscapeChar-char-stderr.txt.in b/Tests/RunCMake/Syntax/EscapeChar-char-stderr.txt.in
new file mode 100644
index 0000000..d1d908c
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeChar-char-stderr.txt.in
@@ -0,0 +1,12 @@
+CMake Error at EscapeChar-@char@-@testnum@.cmake:3 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/EscapeChar-@char@-@testnum@.cmake:3
+
+  when parsing string
+
+    -->\\@char@<--
+
+  Invalid character escape '\\@char@'.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/EscapeChar-char.cmake.in b/Tests/RunCMake/Syntax/EscapeChar-char.cmake.in
new file mode 100644
index 0000000..6f265e5
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeChar-char.cmake.in
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0053 NEW)
+
+message("-->\@char@<--")
diff --git a/Tests/RunCMake/Syntax/EscapeCharsAllowed-stderr.txt b/Tests/RunCMake/Syntax/EscapeCharsAllowed-stderr.txt
new file mode 100644
index 0000000..e658de7
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeCharsAllowed-stderr.txt
@@ -0,0 +1,12 @@
+^-->semicolon<--
+-->dollar<--
+-->brace<--
+-->bracket<--
+-->newline<--
+-->octothorpe<--
+-->splat<--
+-->caret<--
+-->paren<--
+-->dquote<--
+-->top-levelsemicolon<--
+-->top-level;escaped;semicolon<--$
diff --git a/Tests/RunCMake/Syntax/EscapeCharsAllowed.cmake b/Tests/RunCMake/Syntax/EscapeCharsAllowed.cmake
new file mode 100644
index 0000000..e9c568d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeCharsAllowed.cmake
@@ -0,0 +1,26 @@
+cmake_policy(SET CMP0053 NEW)
+
+set("semicolon;in;name" semicolon)
+set("dollar$in$name" dollar)
+set("brace{in}name" brace)
+set("bracket[in]name" bracket)
+set("newline\nin\nname" newline)
+set("octothorpe\#in\#name" octothorpe)
+set("splat\@in\@name" splat)
+set("caret\^in\^name" caret)
+set("paren\(in\)name" paren)
+set("dquote\"in\"name" dquote)
+
+message("-->${semicolon\;in\;name}<--")
+message("-->${dollar\$in\$name}<--")
+message("-->${brace\{in\}name}<--")
+message("-->${bracket\[in\]name}<--")
+message("-->${newline\nin\nname}<--")
+message("-->${octothorpe\#in\#name}<--")
+message("-->${splat\@in\@name}<--")
+message("-->${caret\^in\^name}<--")
+message("-->${paren\(in\)name}<--")
+message("-->${dquote\"in\"name}<--")
+
+message(-->top-level;semicolon<--)
+message(-->top-level\;escaped\;semicolon<--)
diff --git a/Tests/RunCMake/Syntax/EscapeCharsDisallowed.cmake b/Tests/RunCMake/Syntax/EscapeCharsDisallowed.cmake
new file mode 100644
index 0000000..eef01a0
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeCharsDisallowed.cmake
@@ -0,0 +1,42 @@
+set(disallowed_chars
+  a b c d e f g h i j l m   o p q   s   u v w x y z
+  A B C D E F G H I J L M N O P Q R S T U V W X Y Z
+  0 1 2 3 4 5 6 6 7 8 9)
+set(testnum 0)
+
+configure_file(
+  "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+  "${RunCMake_BINARY_DIR}/CMakeLists.txt"
+  COPYONLY)
+
+foreach (char IN LISTS disallowed_chars)
+  configure_file(
+    "${RunCMake_SOURCE_DIR}/EscapeChar-char.cmake.in"
+    "${RunCMake_BINARY_DIR}/EscapeChar-${char}-${testnum}.cmake"
+    @ONLY)
+  configure_file(
+    "${RunCMake_SOURCE_DIR}/EscapeChar-char-stderr.txt.in"
+    "${RunCMake_BINARY_DIR}/EscapeChar-${char}-${testnum}-stderr.txt"
+    @ONLY)
+  configure_file(
+    "${RunCMake_SOURCE_DIR}/EscapeChar-char-result.txt"
+    "${RunCMake_BINARY_DIR}/EscapeChar-${char}-${testnum}-result.txt"
+    COPYONLY)
+
+  math(EXPR testnum "${testnum} + 1")
+endforeach ()
+
+function (run_tests)
+  set(GENERATED_RUNCMAKE_TESTS TRUE)
+  # Find the tests in the binary directory.
+  set(RunCMake_SOURCE_DIR "${RunCMake_BINARY_DIR}")
+
+  set(testnum 0)
+  foreach (char IN LISTS disallowed_chars)
+    run_cmake("EscapeChar-${char}-${testnum}")
+
+    math(EXPR testnum "${testnum} + 1")
+  endforeach ()
+endfunction ()
+
+run_tests()
diff --git a/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt
new file mode 100644
index 0000000..077272d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt
@@ -0,0 +1 @@
+-->"<--
diff --git a/Tests/RunCMake/Syntax/EscapeQuotes.cmake b/Tests/RunCMake/Syntax/EscapeQuotes.cmake
new file mode 100644
index 0000000..46d2b6f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeQuotes.cmake
@@ -0,0 +1,9 @@
+set(var "\"")
+set(ref "@var@")
+set(rref "\${var}")
+
+string(CONFIGURE "${ref}" output ESCAPE_QUOTES)
+message("-->${output}<--")
+
+string(CONFIGURE "${rref}" output ESCAPE_QUOTES)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/EscapedAt-stderr.txt b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt
new file mode 100644
index 0000000..a51c0d3
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt
@@ -0,0 +1 @@
+-->\\n<--
diff --git a/Tests/RunCMake/Syntax/EscapedAt.cmake b/Tests/RunCMake/Syntax/EscapedAt.cmake
new file mode 100644
index 0000000..1ced620
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapedAt.cmake
@@ -0,0 +1,5 @@
+set(var "n")
+set(ref "\\@var@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt
new file mode 100644
index 0000000..5da8b60
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt
@@ -0,0 +1 @@
+-->@foo@<--
diff --git a/Tests/RunCMake/Syntax/ExpandInAt.cmake b/Tests/RunCMake/Syntax/ExpandInAt.cmake
new file mode 100644
index 0000000..98f0277
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ExpandInAt.cmake
@@ -0,0 +1,6 @@
+set("\${varname}" bar)
+set(var foo)
+set(ref "@\${var}@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithCarriageReturn-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithCarriageReturn-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithCarriageReturn-stderr.txt b/Tests/RunCMake/Syntax/NameWithCarriageReturn-stderr.txt
new file mode 100644
index 0000000..7448b59
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithCarriageReturn-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithCarriageReturn.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithCarriageReturn.cmake:1
+
+  when parsing string
+
+    \${var\\rwith\\rcarriagereturn}
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(7\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithCarriageReturn.cmake b/Tests/RunCMake/Syntax/NameWithCarriageReturn.cmake
new file mode 100644
index 0000000..614f554
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithCarriageReturn.cmake
@@ -0,0 +1 @@
+message(${var\rwith\rcarriagereturn})
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-stderr.txt
new file mode 100644
index 0000000..f5e03ed
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithCarriageReturnQuoted.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted.cmake:1
+
+  when parsing string
+
+    \${var\\rwith\\rcarriagereturn}
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(7\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted.cmake b/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted.cmake
new file mode 100644
index 0000000..bac69e4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithCarriageReturnQuoted.cmake
@@ -0,0 +1 @@
+message("${var\rwith\rcarriagereturn}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithEscapedSpaces-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithEscapedSpaces-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithEscapedSpaces-stderr.txt b/Tests/RunCMake/Syntax/NameWithEscapedSpaces-stderr.txt
new file mode 100644
index 0000000..fa16a8a
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithEscapedSpaces-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithEscapedSpaces.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithEscapedSpaces.cmake:1
+
+  when parsing string
+
+    \${var\\ with\\ escaped\\ space}
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(7\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithEscapedSpaces.cmake b/Tests/RunCMake/Syntax/NameWithEscapedSpaces.cmake
new file mode 100644
index 0000000..6cb8401
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithEscapedSpaces.cmake
@@ -0,0 +1 @@
+message(${var\ with\ escaped\ space})
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-stderr.txt
new file mode 100644
index 0000000..07cbf24
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithEscapedSpacesQuoted.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted.cmake:1
+
+  when parsing string
+
+    \${var\\ with\\ escaped\\ space}
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(7\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted.cmake b/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted.cmake
new file mode 100644
index 0000000..2bd4bfd
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithEscapedSpacesQuoted.cmake
@@ -0,0 +1 @@
+message("${var\ with\ escaped\ space}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithEscapedTabs-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithEscapedTabs-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithEscapedTabs-stderr.txt b/Tests/RunCMake/Syntax/NameWithEscapedTabs-stderr.txt
new file mode 100644
index 0000000..d7fc38a
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithEscapedTabs-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithEscapedTabs.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithEscapedTabs.cmake:1
+
+  when parsing string
+
+    \${var\\	with\\	escaped\\	tab}
+
+  Invalid escape sequence \\.?
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithEscapedTabs.cmake b/Tests/RunCMake/Syntax/NameWithEscapedTabs.cmake
new file mode 100644
index 0000000..c6faa7a
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithEscapedTabs.cmake
@@ -0,0 +1 @@
+message(${var\	with\	escaped\	tab})
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted-stderr.txt
new file mode 100644
index 0000000..915dbaa
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithEscapedTabsQuoted.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted.cmake:1
+
+  when parsing string
+
+    \${var\\	with\\	escaped\\	tab}
+
+  Invalid escape sequence \\.?
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted.cmake b/Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted.cmake
new file mode 100644
index 0000000..d9be763
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithEscapedTabsQuoted.cmake
@@ -0,0 +1 @@
+message("${var\	with\	escaped\	tab}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithNewline-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithNewline-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithNewline-stderr.txt b/Tests/RunCMake/Syntax/NameWithNewline-stderr.txt
new file mode 100644
index 0000000..5cc111b
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithNewline-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithNewline.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithNewline.cmake:1
+
+  when parsing string
+
+    \${var\\nwith\\nnewline}
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(7\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithNewline.cmake b/Tests/RunCMake/Syntax/NameWithNewline.cmake
new file mode 100644
index 0000000..583bcb0
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithNewline.cmake
@@ -0,0 +1 @@
+message(${var\nwith\nnewline})
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithNewlineQuoted-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithNewlineQuoted-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithNewlineQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithNewlineQuoted-stderr.txt
new file mode 100644
index 0000000..0067c2f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithNewlineQuoted-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithNewlineQuoted.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithNewlineQuoted.cmake:1
+
+  when parsing string
+
+    \${var\\nwith\\nnewline}
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(7\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithNewlineQuoted.cmake b/Tests/RunCMake/Syntax/NameWithNewlineQuoted.cmake
new file mode 100644
index 0000000..da6d2cf
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithNewlineQuoted.cmake
@@ -0,0 +1 @@
+message("${var\nwith\nnewline}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithSpaces-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithSpaces-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithSpaces-stderr.txt b/Tests/RunCMake/Syntax/NameWithSpaces-stderr.txt
new file mode 100644
index 0000000..04bc226
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithSpaces-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithSpaces.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithSpaces.cmake:1
+
+  when parsing string
+
+    \${var
+
+  syntax error, unexpected \$end, expecting } \(5\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithSpaces.cmake b/Tests/RunCMake/Syntax/NameWithSpaces.cmake
new file mode 100644
index 0000000..01febe9
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithSpaces.cmake
@@ -0,0 +1 @@
+message(${var with space})
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithSpacesQuoted-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithSpacesQuoted-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithSpacesQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithSpacesQuoted-stderr.txt
new file mode 100644
index 0000000..66cf9a2
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithSpacesQuoted-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithSpacesQuoted.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithSpacesQuoted.cmake:1
+
+  when parsing string
+
+    \${var with space}
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(17\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithSpacesQuoted.cmake b/Tests/RunCMake/Syntax/NameWithSpacesQuoted.cmake
new file mode 100644
index 0000000..3fba53f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithSpacesQuoted.cmake
@@ -0,0 +1 @@
+message("${var with space}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithTabs-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithTabs-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithTabs-stderr.txt b/Tests/RunCMake/Syntax/NameWithTabs-stderr.txt
new file mode 100644
index 0000000..e888096
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithTabs-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithTabs.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithTabs.cmake:1
+
+  when parsing string
+
+    \${var
+
+  syntax error, unexpected \$end, expecting } \(5\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithTabs.cmake b/Tests/RunCMake/Syntax/NameWithTabs.cmake
new file mode 100644
index 0000000..c3b1bea
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithTabs.cmake
@@ -0,0 +1 @@
+message(${var	with	tab})
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/NameWithTabsQuoted-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/NameWithTabsQuoted-result.txt
diff --git a/Tests/RunCMake/Syntax/NameWithTabsQuoted-stderr.txt b/Tests/RunCMake/Syntax/NameWithTabsQuoted-stderr.txt
new file mode 100644
index 0000000..b020074
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithTabsQuoted-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at NameWithTabsQuoted.cmake:1 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/NameWithTabsQuoted.cmake:1
+
+  when parsing string
+
+    \${var	with	tab}
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(15\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/NameWithTabsQuoted.cmake b/Tests/RunCMake/Syntax/NameWithTabsQuoted.cmake
new file mode 100644
index 0000000..8ddb85d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NameWithTabsQuoted.cmake
@@ -0,0 +1 @@
+message("${var	with	tab}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/ParenInENV-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/ParenInENV-result.txt
diff --git a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt
new file mode 100644
index 0000000..7ecfe11
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt
@@ -0,0 +1,20 @@
+CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
+  Syntax Warning in cmake code at
+
+    .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21
+
+  Argument not separated from preceding token by whitespace.
+This warning is for project developers.  Use -Wno-dev to suppress it.
+
+CMake Error at ParenInENV.cmake:2 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2
+
+  when parsing string
+
+    -->\$ENV{e
+
+  syntax error, unexpected \$end, expecting } \(9\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/ParenInENV.cmake b/Tests/RunCMake/Syntax/ParenInENV.cmake
new file mode 100644
index 0000000..148f726
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInENV.cmake
@@ -0,0 +1,2 @@
+set("ENV{e(x)}" value)
+message(-->$ENV{e(x)}<--)
diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt
new file mode 100644
index 0000000..7020c7e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt
@@ -0,0 +1 @@
+-->value<--
diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake
new file mode 100644
index 0000000..6333717
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake
@@ -0,0 +1,2 @@
+set("ENV{e(x)}" value)
+message("-->$ENV{e(x)}<--")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/ParenInVarName0-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/ParenInVarName0-result.txt
diff --git a/Tests/RunCMake/Syntax/ParenInVarName0-stderr.txt b/Tests/RunCMake/Syntax/ParenInVarName0-stderr.txt
new file mode 100644
index 0000000..0a6b60f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInVarName0-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at ParenInVarName0.cmake:4 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/ParenInVarName0.cmake:4
+
+  when parsing string
+
+    -->\${e\(x\)}<--
+
+  Invalid character \('\('\) in a variable name: 'e'
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/ParenInVarName0.cmake b/Tests/RunCMake/Syntax/ParenInVarName0.cmake
new file mode 100644
index 0000000..f863d20
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInVarName0.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0053 NEW)
+
+set("e(x)" value)
+message("-->${e(x)}<--")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/ParenInVarName1-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/ParenInVarName1-result.txt
diff --git a/Tests/RunCMake/Syntax/ParenInVarName1-stderr.txt b/Tests/RunCMake/Syntax/ParenInVarName1-stderr.txt
new file mode 100644
index 0000000..81b1717
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInVarName1-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at ParenInVarName1.cmake:4 \(message\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/ParenInVarName1.cmake:4
+
+  when parsing string
+
+    -->\${e\(x\)}<--
+
+  syntax error, unexpected cal_SYMBOL, expecting } \(10\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/ParenInVarName1.cmake b/Tests/RunCMake/Syntax/ParenInVarName1.cmake
new file mode 100644
index 0000000..9fdc87b
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInVarName1.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0053 OLD)
+
+set("{e(x)}" value)
+message("-->${e(x)}<--")
diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
index 5f05cfc..cecd338 100644
--- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
@@ -5,6 +5,14 @@
 run_cmake(BOM-UTF-16-BE)
 run_cmake(BOM-UTF-32-LE)
 run_cmake(BOM-UTF-32-BE)
+run_cmake(CMP0053-At-OLD)
+run_cmake(CMP0053-At-NEW)
+run_cmake(CMP0053-At-WARN)
+run_cmake(CMP0053-At-WARN-newlines)
+run_cmake(CMP0053-WARN)
+run_cmake(CMP0053-NUL)
+run_cmake(CMP0053-ParenInENV)
+run_cmake(CMP0053-ParenInQuotedENV)
 run_cmake(CommandSpaces)
 run_cmake(CommandTabs)
 run_cmake(CommandNewlines)
@@ -25,6 +33,7 @@
 run_cmake(OneLetter)
 run_cmake(Unquoted0)
 run_cmake(Unquoted1)
+run_cmake(Unquoted2)
 run_cmake(Bracket0)
 run_cmake(Bracket1)
 run_cmake(Bracket2)
@@ -43,12 +52,59 @@
 run_cmake(BracketNoSpace4)
 run_cmake(BracketNoSpace5)
 run_cmake(Escape1)
+run_cmake(Escape2)
+run_cmake(EscapeCharsAllowed)
+include("${RunCMake_SOURCE_DIR}/EscapeCharsDisallowed.cmake")
 run_cmake(ParenNoSpace0)
 run_cmake(ParenNoSpace1)
 run_cmake(ParenNoSpace2)
+run_cmake(ParenInVarName0)
+run_cmake(ParenInVarName1)
 run_cmake(UnterminatedCall1)
 run_cmake(UnterminatedCall2)
 run_cmake(UnterminatedString)
+run_cmake(UnterminatedBrace0)
+run_cmake(UnterminatedBrace1)
+run_cmake(UnterminatedBrace2)
 run_cmake(UnterminatedBracket0)
 run_cmake(UnterminatedBracket1)
 run_cmake(UnterminatedBracketComment)
+
+# Variable expansion tests
+run_cmake(ExpandInAt)
+run_cmake(EscapedAt)
+run_cmake(EscapeQuotes)
+run_cmake(AtWithVariable)
+run_cmake(AtWithVariableEmptyExpansion)
+run_cmake(AtWithVariableAtOnly)
+run_cmake(AtWithVariableEmptyExpansionAtOnly)
+run_cmake(AtWithVariableFile)
+run_cmake(AtWithVariableAtOnlyFile)
+run_cmake(ParenInENV)
+run_cmake(ParenInQuotedENV)
+
+# Variable name tests
+run_cmake(NameWithSpaces)
+run_cmake(NameWithTabs)
+run_cmake(NameWithNewline)
+run_cmake(NameWithCarriageReturn)
+run_cmake(NameWithEscapedSpaces)
+run_cmake(NameWithEscapedTabs)
+run_cmake(NameWithSpacesQuoted)
+run_cmake(NameWithTabsQuoted)
+run_cmake(NameWithNewlineQuoted)
+run_cmake(NameWithCarriageReturnQuoted)
+run_cmake(NameWithEscapedSpacesQuoted)
+run_cmake(NameWithEscapedTabsQuoted)
+run_cmake(CMP0053-NameWithSpaces)
+run_cmake(CMP0053-NameWithTabs)
+run_cmake(CMP0053-NameWithNewline)
+run_cmake(CMP0053-NameWithCarriageReturn)
+run_cmake(CMP0053-NameWithEscapedSpaces)
+run_cmake(CMP0053-NameWithEscapedTabs)
+run_cmake(CMP0053-NameWithSpacesQuoted)
+run_cmake(CMP0053-NameWithTabsQuoted)
+run_cmake(CMP0053-NameWithNewlineQuoted)
+run_cmake(CMP0053-NameWithCarriageReturnQuoted)
+run_cmake(CMP0053-NameWithEscapedSpacesQuoted)
+run_cmake(CMP0053-NameWithEscapedTabsQuoted)
diff --git a/Tests/RunCMake/Syntax/Unquoted2-stderr.txt b/Tests/RunCMake/Syntax/Unquoted2-stderr.txt
new file mode 100644
index 0000000..eb8883e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/Unquoted2-stderr.txt
@@ -0,0 +1 @@
+^\[\[UnquotedBracketArgument1\]\]$
diff --git a/Tests/RunCMake/Syntax/Unquoted2.cmake b/Tests/RunCMake/Syntax/Unquoted2.cmake
new file mode 100644
index 0000000..d94057d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/Unquoted2.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0053 NEW)
+
+message(\[[Unquoted Bracket Argument 1]])
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/UnterminatedBrace0-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/UnterminatedBrace0-result.txt
diff --git a/Tests/RunCMake/Syntax/UnterminatedBrace0-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedBrace0-stderr.txt
new file mode 100644
index 0000000..1e0ce49
--- /dev/null
+++ b/Tests/RunCMake/Syntax/UnterminatedBrace0-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at UnterminatedBrace0.cmake:2 \(set\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/UnterminatedBrace0.cmake:2
+
+  when parsing string
+
+    \${
+
+  syntax error, unexpected \$end, expecting } \(2\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/UnterminatedBrace0.cmake b/Tests/RunCMake/Syntax/UnterminatedBrace0.cmake
new file mode 100644
index 0000000..0da1290
--- /dev/null
+++ b/Tests/RunCMake/Syntax/UnterminatedBrace0.cmake
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 3.0)
+set(var "${")
diff --git a/Tests/RunCMake/Syntax/UnterminatedBrace1-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedBrace1-stderr.txt
new file mode 100644
index 0000000..4e3c2b5
--- /dev/null
+++ b/Tests/RunCMake/Syntax/UnterminatedBrace1-stderr.txt
@@ -0,0 +1,13 @@
+CMake Warning \(dev\) at UnterminatedBrace1.cmake:3 \(set\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/UnterminatedBrace1.cmake:3
+
+  when parsing string
+
+    \${
+
+  syntax error, unexpected \$end, expecting } \(2\)
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/Syntax/UnterminatedBrace1.cmake b/Tests/RunCMake/Syntax/UnterminatedBrace1.cmake
new file mode 100644
index 0000000..93fba34
--- /dev/null
+++ b/Tests/RunCMake/Syntax/UnterminatedBrace1.cmake
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+cmake_policy(SET CMP0010 OLD)
+set(var "${")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/Syntax/UnterminatedBrace2-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/Syntax/UnterminatedBrace2-result.txt
diff --git a/Tests/RunCMake/Syntax/UnterminatedBrace2-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedBrace2-stderr.txt
new file mode 100644
index 0000000..b332d34
--- /dev/null
+++ b/Tests/RunCMake/Syntax/UnterminatedBrace2-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at UnterminatedBrace2.cmake:4 \(set\):
+  Syntax error in cmake code at
+
+    .*/Tests/RunCMake/Syntax/UnterminatedBrace2.cmake:4
+
+  when parsing string
+
+    \${
+
+  There is an unterminated variable reference.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/UnterminatedBrace2.cmake b/Tests/RunCMake/Syntax/UnterminatedBrace2.cmake
new file mode 100644
index 0000000..a650e5b
--- /dev/null
+++ b/Tests/RunCMake/Syntax/UnterminatedBrace2.cmake
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.0)
+cmake_policy(SET CMP0010 OLD)
+cmake_policy(SET CMP0053 NEW)
+set(var "${")
diff --git a/Tests/RunCMake/Syntax/atfile.txt.in b/Tests/RunCMake/Syntax/atfile.txt.in
new file mode 100644
index 0000000..3775919
--- /dev/null
+++ b/Tests/RunCMake/Syntax/atfile.txt.in
@@ -0,0 +1,4 @@
+==>@var@<==
+==>@empty@<==
+==>${var}<==
+==>${empty}<==
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/TargetObjects/BadContext-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/TargetObjects/BadContext-result.txt
diff --git a/Tests/RunCMake/TargetObjects/BadContext-stderr.txt b/Tests/RunCMake/TargetObjects/BadContext-stderr.txt
new file mode 100644
index 0000000..92f2c91
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/BadContext-stderr.txt
@@ -0,0 +1,17 @@
+CMake Error at BadContext.cmake:2 \(file\):
+  Error evaluating generator expression:
+
+    \$<TARGET_OBJECTS:NoTarget>
+
+  The evaluation of the TARGET_OBJECTS generator expression is only suitable
+  for consumption by CMake.  It is not suitable for writing out elsewhere.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error:
+  Error evaluating generator expression:
+
+    \$<TARGET_OBJECTS:NoTarget>
+
+  The evaluation of the TARGET_OBJECTS generator expression is only suitable
+  for consumption by CMake.  It is not suitable for writing out elsewhere.
diff --git a/Tests/RunCMake/TargetObjects/BadContext.cmake b/Tests/RunCMake/TargetObjects/BadContext.cmake
new file mode 100644
index 0000000..67962a4
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/BadContext.cmake
@@ -0,0 +1,4 @@
+
+file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:NoTarget>)
+
+install(FILES $<TARGET_OBJECTS:NoTarget> DESTINATION objects)
diff --git a/Tests/RunCMake/TargetObjects/CMakeLists.txt b/Tests/RunCMake/TargetObjects/CMakeLists.txt
new file mode 100644
index 0000000..be9d403
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST})
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake
new file mode 100644
index 0000000..85c76e2
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(BadContext)
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index f30c9a9..f4b744b 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -16,6 +16,7 @@
    \* CMP0041
    \* CMP0042
    \* CMP0046
+   \* CMP0052
 
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt
diff --git a/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake b/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake
new file mode 100644
index 0000000..464df36
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake
@@ -0,0 +1,13 @@
+
+cmake_policy(SET CMP0026 OLD)
+
+add_library(objlib OBJECT
+    empty_1.cpp
+)
+
+add_executable(my_exe
+    empty_2.cpp
+    $<TARGET_OBJECTS:objlib>
+)
+
+get_target_property( loc my_exe LOCATION)
diff --git a/Tests/RunCMake/TargetSources/CMakeLists.txt b/Tests/RunCMake/TargetSources/CMakeLists.txt
new file mode 100644
index 0000000..f452db1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt
diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt
new file mode 100644
index 0000000..1de5dd7
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt
@@ -0,0 +1,14 @@
+CMake Error in CMakeLists.txt:
+  Target "somelib" has source files which vary by configuration.  This is not
+  supported by the "[^"]+" generator.
+
+  Config "Debug":
+
+    .*/Tests/RunCMake/TargetSources/empty_1.cpp
+    .*/Tests/RunCMake/TargetSources/empty_2.cpp
+    .*/Tests/RunCMake/TargetSources/CMakeLists.txt
+
+  Config "Release":
+
+    .*/Tests/RunCMake/TargetSources/empty_1.cpp
+    .*/Tests/RunCMake/TargetSources/CMakeLists.txt
diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake b/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake
new file mode 100644
index 0000000..02af379
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake
@@ -0,0 +1,2 @@
+
+add_library(somelib empty_1.cpp $<$<CONFIG:Debug>:empty_2.cpp>)
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/TargetSources/OriginDebug-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/TargetSources/OriginDebug-result.txt
diff --git a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
new file mode 100644
index 0000000..11bc96c
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
@@ -0,0 +1,31 @@
+CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
+  Used sources for target OriginDebug:
+
+   \* .*Tests/RunCMake/TargetSources/empty_2.cpp
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+.*
+CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
+  Used sources for target OriginDebug:
+
+   \* .*Tests/RunCMake/TargetSources/empty_3.cpp
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+.*
+CMake Debug Log at OriginDebug.cmake:20 \(target_sources\):
+  Used sources for target OriginDebug:
+
+   \* .*Tests/RunCMake/TargetSources/empty_4.cpp
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
+.*
+CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
+  Used sources for target OriginDebug:
+
+   \* .*Tests/RunCMake/TargetSources/empty_1.cpp
+
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetSources/OriginDebug.cmake b/Tests/RunCMake/TargetSources/OriginDebug.cmake
new file mode 100644
index 0000000..5fe9ba7
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebug.cmake
@@ -0,0 +1,20 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(OriginDebug)
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES SOURCES)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_SOURCES
+  empty_1.cpp
+)
+
+add_library(OriginDebug empty_2.cpp)
+target_link_libraries(OriginDebug iface)
+
+set_property(TARGET OriginDebug APPEND PROPERTY SOURCES
+  empty_3.cpp
+)
+
+target_sources(OriginDebug PRIVATE empty_4.cpp)
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
new file mode 100644
index 0000000..fad7073
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
@@ -0,0 +1,40 @@
+CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
+  Used sources for target OriginDebug:
+
+   \* .*Tests/RunCMake/TargetSources/empty_2.cpp
+
+Call Stack \(most recent call first\):
+  OriginDebugIDE.cmake:4 \(include\)
+  CMakeLists.txt:3 \(include\)
++
+CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
+  Used sources for target OriginDebug:
+
+   \* .*Tests/RunCMake/TargetSources/empty_3.cpp
+
+Call Stack \(most recent call first\):
+  OriginDebugIDE.cmake:4 \(include\)
+  CMakeLists.txt:3 \(include\)
++
+CMake Debug Log at OriginDebug.cmake:20 \(target_sources\):
+  Used sources for target OriginDebug:
+
+   \* .*Tests/RunCMake/TargetSources/empty_4.cpp
+
+Call Stack \(most recent call first\):
+  OriginDebugIDE.cmake:4 \(include\)
+  CMakeLists.txt:3 \(include\)
++
+CMake Debug Log:
+  Used sources for target OriginDebug:
+
+   * .*CMakeLists.txt
++
+CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
+  Used sources for target OriginDebug:
+
+   \* .*Tests/RunCMake/TargetSources/empty_1.cpp
+
+Call Stack \(most recent call first\):
+  OriginDebugIDE.cmake:4 \(include\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake b/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake
new file mode 100644
index 0000000..a3cc3a8
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake
@@ -0,0 +1,4 @@
+
+# Separate test for the IDEs, because they show the CMakeLists.txt file
+# as a source file.
+include(${CMAKE_CURRENT_LIST_DIR}/OriginDebug.cmake)
diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake
new file mode 100644
index 0000000..1d2eaec
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake
@@ -0,0 +1,10 @@
+include(RunCMake)
+
+if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode" AND NOT XCODE_BELOW_2)
+  run_cmake(ConfigNotAllowed)
+  run_cmake(OriginDebugIDE)
+else()
+  run_cmake(OriginDebug)
+endif()
+
+run_cmake(CMP0026-LOCATION)
diff --git a/Tests/RunCMake/TargetSources/empty_1.cpp b/Tests/RunCMake/TargetSources/empty_1.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_1.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/empty_2.cpp b/Tests/RunCMake/TargetSources/empty_2.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_2.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/empty_3.cpp b/Tests/RunCMake/TargetSources/empty_3.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_3.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/empty_4.cpp b/Tests/RunCMake/TargetSources/empty_4.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_4.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/CMakeLists.txt
new file mode 100644
index 0000000..872338d
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/ExtraArgs-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/ExtraArgs-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/ExtraArgs-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/ExtraArgs-stderr.txt
new file mode 100644
index 0000000..62c4ff1
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/ExtraArgs-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  Unparsed arguments: GarbageArg
+Call Stack \(most recent call first\):
+  ExtraArgs.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/ExtraArgs.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/ExtraArgs.cmake
new file mode 100644
index 0000000..c2a21af
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/ExtraArgs.cmake
@@ -0,0 +1,10 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+  FILE "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+  PREFIX Pref
+  GarbageArg
+  COMPILERS GNU
+  FEATURES cxx_final
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/FileTypo-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/FileTypo-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/FileTypo-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/FileTypo-stderr.txt
new file mode 100644
index 0000000..3c0c076
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/FileTypo-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  write_compiler_detection_header: FILE parameter missing.
+Call Stack \(most recent call first\):
+  FileTypo.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/FileTypo.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/FileTypo.cmake
new file mode 100644
index 0000000..c90eda2
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/FileTypo.cmake
@@ -0,0 +1,7 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+  FILE_TYPO "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+  PREFIX Pref
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidArgs-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/InvalidArgs-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidArgs-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidArgs-stderr.txt
new file mode 100644
index 0000000..b4d7e08
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidArgs-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at InvalidArgs.cmake:4 \(write_compiler_detection_header\):
+  write_compiler_detection_header Function invoked with incorrect arguments
+  for function named: write_compiler_detection_header
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
++
+CMake Error at InvalidArgs.cmake:6 \(write_compiler_detection_header\):
+  write_compiler_detection_header Function invoked with incorrect arguments
+  for function named: write_compiler_detection_header
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidArgs.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidArgs.cmake
new file mode 100644
index 0000000..cfebae1
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidArgs.cmake
@@ -0,0 +1,6 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header()
+
+write_compiler_detection_header(FILE)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCXXFeature-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCXXFeature-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCXXFeature-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCXXFeature-stderr.txt
new file mode 100644
index 0000000..f34c9e1
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCXXFeature-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  Unsupported feature cxx_not_a_feature.
+Call Stack \(most recent call first\):
+  InvalidCXXFeature.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCXXFeature.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCXXFeature.cmake
new file mode 100644
index 0000000..da870fa
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCXXFeature.cmake
@@ -0,0 +1,10 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+    FILE "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+    PREFIX PREF_
+    COMPILERS GNU
+    FEATURES cxx_not_a_feature
+    VERSION 3.1
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCompiler-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCompiler-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCompiler-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCompiler-stderr.txt
new file mode 100644
index 0000000..f35f9f9
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCompiler-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  Unsupported compiler NOT_A_COMPILER.
+Call Stack \(most recent call first\):
+  InvalidCompiler.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCompiler.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCompiler.cmake
new file mode 100644
index 0000000..ecd0957
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidCompiler.cmake
@@ -0,0 +1,10 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+    FILE "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+    PREFIX PREF_
+    COMPILERS NOT_A_COMPILER
+    FEATURES cxx_final
+    VERSION 3.1
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt
new file mode 100644
index 0000000..0445744
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  Unsupported feature not_a_feature.
+Call Stack \(most recent call first\):
+  InvalidFeature.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature.cmake
new file mode 100644
index 0000000..cd83968
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature.cmake
@@ -0,0 +1,10 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+    FILE "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+    PREFIX PREF_
+    COMPILERS GNU
+    FEATURES not_a_feature
+    VERSION 3.1
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/NoCompiler-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/NoCompiler-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/NoCompiler-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/NoCompiler-stderr.txt
new file mode 100644
index 0000000..9451348
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/NoCompiler-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  Invalid arguments.  write_compiler_detection_header requires at least one
+  compiler.
+Call Stack \(most recent call first\):
+  NoCompiler.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/NoCompiler.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/NoCompiler.cmake
new file mode 100644
index 0000000..2dc14e9
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/NoCompiler.cmake
@@ -0,0 +1,10 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+    FILE "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+    PREFIX PREF_
+    # COMPILERS
+    FEATURES cxx_final
+    VERSION 3.1
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/NoFeature-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/NoFeature-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/NoFeature-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/NoFeature-stderr.txt
new file mode 100644
index 0000000..193f297
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/NoFeature-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  Invalid arguments.  write_compiler_detection_header requires at least one
+  feature.
+Call Stack \(most recent call first\):
+  NoFeature.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/NoFeature.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/NoFeature.cmake
new file mode 100644
index 0000000..1fbc129
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/NoFeature.cmake
@@ -0,0 +1,10 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+    FILE "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+    PREFIX PREF_
+    COMPILERS GNU
+    # FEATURES
+    VERSION 3.1
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/OldVersion-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/OldVersion-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/OldVersion-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/OldVersion-stderr.txt
new file mode 100644
index 0000000..842eb3f
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/OldVersion-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  VERSION parameter too low.
+Call Stack \(most recent call first\):
+  OldVersion.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/OldVersion.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/OldVersion.cmake
new file mode 100644
index 0000000..a6e3022
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/OldVersion.cmake
@@ -0,0 +1,10 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+  FILE "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+  PREFIX Pref
+  VERSION 3.0
+  COMPILERS GNU
+  FEATURES cxx_final
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/PrefixTypo-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/WriteCompilerDetectionHeader/PrefixTypo-result.txt
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/PrefixTypo-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/PrefixTypo-stderr.txt
new file mode 100644
index 0000000..5fdcdb8
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/PrefixTypo-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
+  write_compiler_detection_header: PREFIX parameter missing.
+Call Stack \(most recent call first\):
+  PrefixTypo.cmake:4 \(write_compiler_detection_header\)
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/PrefixTypo.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/PrefixTypo.cmake
new file mode 100644
index 0000000..8b6774c
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/PrefixTypo.cmake
@@ -0,0 +1,7 @@
+
+include(WriteCompilerDetectionHeader)
+
+write_compiler_detection_header(
+  FILE "${CMAKE_CURRENT_BINARY_DIR}/somefile"
+  PREFIX_TYPO Pref
+)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/RunCMakeTest.cmake b/Tests/RunCMake/WriteCompilerDetectionHeader/RunCMakeTest.cmake
new file mode 100644
index 0000000..be79d41
--- /dev/null
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/RunCMakeTest.cmake
@@ -0,0 +1,12 @@
+include(RunCMake)
+
+run_cmake(InvalidArgs)
+run_cmake(NoCompiler)
+run_cmake(NoFeature)
+run_cmake(FileTypo)
+run_cmake(PrefixTypo)
+run_cmake(ExtraArgs)
+run_cmake(OldVersion)
+run_cmake(InvalidCompiler)
+run_cmake(InvalidFeature)
+run_cmake(InvalidCXXFeature)
diff --git a/Tests/RunCMake/XcodeProject/CMakeLists.txt b/Tests/RunCMake/XcodeProject/CMakeLists.txt
new file mode 100644
index 0000000..12cd3c7
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
new file mode 100644
index 0000000..8e4026b
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(XcodeFileType)
diff --git a/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
new file mode 100644
index 0000000..7882d7f
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
@@ -0,0 +1,10 @@
+set(expect-default "explicitFileType = sourcecode")
+set(expect-explicit "explicitFileType = \"sourcecode.c.h\"")
+set(expect-lastKnown "lastKnownFileType = \"sourcecode.c.h\"")
+foreach(src default explicit lastKnown)
+  file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeFileType.xcodeproj/project.pbxproj actual-${src}
+       REGEX "PBXFileReference.*src-${src}")
+  if(NOT actual-${src} MATCHES "${expect-${src}}")
+    message(SEND_ERROR "src-${src} does not match '${expect-${src}}':\n ${actual-${src}}")
+  endif()
+endforeach()
diff --git a/Tests/RunCMake/XcodeProject/XcodeFileType.cmake b/Tests/RunCMake/XcodeProject/XcodeFileType.cmake
new file mode 100644
index 0000000..7faa781
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeFileType.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+add_executable(main main.c src-default src-explicit src-lastKnown)
+set_property(SOURCE src-explicit PROPERTY XCODE_EXPLICIT_FILE_TYPE sourcecode.c.h)
+set_property(SOURCE src-lastKnown PROPERTY XCODE_LAST_KNOWN_FILE_TYPE sourcecode.c.h)
diff --git a/Tests/RunCMake/XcodeProject/main.c b/Tests/RunCMake/XcodeProject/main.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/main.c
diff --git a/Tests/RunCMake/XcodeProject/src-default b/Tests/RunCMake/XcodeProject/src-default
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/src-default
diff --git a/Tests/RunCMake/XcodeProject/src-explicit b/Tests/RunCMake/XcodeProject/src-explicit
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/src-explicit
diff --git a/Tests/RunCMake/XcodeProject/src-lastKnown b/Tests/RunCMake/XcodeProject/src-lastKnown
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/src-lastKnown
diff --git a/Tests/RunCMake/configure_file/CMakeLists.txt b/Tests/RunCMake/configure_file/CMakeLists.txt
new file mode 100644
index 0000000..2897109
--- /dev/null
+++ b/Tests/RunCMake/configure_file/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/configure_file/NO-BOM.cmake b/Tests/RunCMake/configure_file/NO-BOM.cmake
new file mode 100644
index 0000000..003d526
--- /dev/null
+++ b/Tests/RunCMake/configure_file/NO-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(NO-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/NO-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/NO-BOM.txt.in b/Tests/RunCMake/configure_file/NO-BOM.txt.in
new file mode 100644
index 0000000..557db03
--- /dev/null
+++ b/Tests/RunCMake/configure_file/NO-BOM.txt.in
@@ -0,0 +1 @@
+Hello World
diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake
new file mode 100644
index 0000000..c8bfa57
--- /dev/null
+++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(NO-BOM)
+run_cmake(UTF8-BOM)
+run_cmake(UTF16LE-BOM)
+run_cmake(UTF16BE-BOM)
+run_cmake(UTF32LE-BOM)
+run_cmake(UTF32BE-BOM)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt
new file mode 100644
index 0000000..5132c4d
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF16BE-BOM.cmake:2 \(configure_file\):
+  File starts with a Byte-Order-Mark that is not UTF-8:
+
+    .*/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake
new file mode 100644
index 0000000..c570742
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF16BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16BE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
new file mode 100644
index 0000000..70fd9cb
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt
new file mode 100644
index 0000000..8f997bc
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF16LE-BOM.cmake:2 \(configure_file\):
+  File starts with a Byte-Order-Mark that is not UTF-8:
+
+    .*/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake
new file mode 100644
index 0000000..05c9cd7
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF16LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16LE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
new file mode 100644
index 0000000..036f8c5
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt
new file mode 100644
index 0000000..12811aa
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF32BE-BOM.cmake:2 \(configure_file\):
+  File starts with a Byte-Order-Mark that is not UTF-8:
+
+    .*/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake
new file mode 100644
index 0000000..0c6ea87
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF32BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32BE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
new file mode 100644
index 0000000..c87cfd5
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt
new file mode 100644
index 0000000..fa9e01a
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF32LE-BOM.cmake:2 \(configure_file\):
+  File starts with a Byte-Order-Mark that is not UTF-8:
+
+    .*/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake
new file mode 100644
index 0000000..b6351b0
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF32LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32LE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
new file mode 100644
index 0000000..27c8183
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.cmake b/Tests/RunCMake/configure_file/UTF8-BOM.cmake
new file mode 100644
index 0000000..af2adae
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF8-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF8-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF8-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.txt.in b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in
new file mode 100644
index 0000000..abc0aca
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in
@@ -0,0 +1 @@
+Hello World
diff --git a/Tests/RunCMake/file/CMakeLists.txt b/Tests/RunCMake/file/CMakeLists.txt
new file mode 100644
index 0000000..2897109
--- /dev/null
+++ b/Tests/RunCMake/file/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/file/FileOpenFailRead-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/file/FileOpenFailRead-result.txt
diff --git a/Tests/RunCMake/file/FileOpenFailRead-stderr.txt b/Tests/RunCMake/file/FileOpenFailRead-stderr.txt
new file mode 100644
index 0000000..23d4337
--- /dev/null
+++ b/Tests/RunCMake/file/FileOpenFailRead-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at FileOpenFailRead.cmake:[0-9]+ \(file\):
+  file failed to open for reading \(.*\):
+
+    .*/Tests/RunCMake/file/does_not_exist/file.txt
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/file/FileOpenFailRead.cmake b/Tests/RunCMake/file/FileOpenFailRead.cmake
new file mode 100644
index 0000000..4d4c6dc
--- /dev/null
+++ b/Tests/RunCMake/file/FileOpenFailRead.cmake
@@ -0,0 +1 @@
+file(READ "${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist/file.txt" content)
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake
new file mode 100644
index 0000000..7b05229
--- /dev/null
+++ b/Tests/RunCMake/file/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(FileOpenFailRead)
diff --git a/Tests/RunCMake/find_dependency/CMakeLists.txt b/Tests/RunCMake/find_dependency/CMakeLists.txt
new file mode 100644
index 0000000..04d09f2
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} NONE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/find_dependency/EXACT-no-version-result.txt
diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt
new file mode 100644
index 0000000..348f8bb
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+  Invalid arguments to find_dependency.  EXACT may only be specified if a
+  VERSION is specified
+Call Stack \(most recent call first\):
+  EXACT-no-version.cmake:4 \(find_dependency\)
+  CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version.cmake b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake
new file mode 100644
index 0000000..b05665b7
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 EXACT)
diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake
new file mode 100644
index 0000000..7d55ef6
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake
@@ -0,0 +1,2 @@
+
+add_library(Pack1::Lib INTERFACE IMPORTED)
diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake
new file mode 100644
index 0000000..dfb7b6c
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "1.3")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+  set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+  set(PACKAGE_VERSION_COMPATIBLE TRUE)
+  if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+    set(PACKAGE_VERSION_EXACT TRUE)
+  endif()
+endif()
diff --git a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake
new file mode 100644
index 0000000..9403136
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake
@@ -0,0 +1,7 @@
+include(RunCMake)
+
+run_cmake(EXACT-no-version)
+run_cmake(empty-version)
+run_cmake(empty-arg-3)
+run_cmake(invalid-arg-3)
+run_cmake(extra-args)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/find_dependency/empty-arg-3-result.txt
diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt
new file mode 100644
index 0000000..bf9b02b
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+  Invalid arguments to find_dependency
+Call Stack \(most recent call first\):
+  empty-arg-3.cmake:4 \(find_dependency\)
+  CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/empty-arg-3.cmake b/Tests/RunCMake/find_dependency/empty-arg-3.cmake
new file mode 100644
index 0000000..b08200a
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-arg-3.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 1.2 "")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/find_dependency/empty-version-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/find_dependency/empty-version-result.txt
diff --git a/Tests/RunCMake/find_dependency/empty-version-stderr.txt b/Tests/RunCMake/find_dependency/empty-version-stderr.txt
new file mode 100644
index 0000000..b5e9f46
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-version-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*/Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+  Invalid arguments to find_dependency.  VERSION is empty
+Call Stack \(most recent call first\):
+  empty-version.cmake:4 \(find_dependency\)
+  CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/empty-version.cmake b/Tests/RunCMake/find_dependency/empty-version.cmake
new file mode 100644
index 0000000..e6f17cd
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-version.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 "")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/find_dependency/extra-args-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/find_dependency/extra-args-result.txt
diff --git a/Tests/RunCMake/find_dependency/extra-args-stderr.txt b/Tests/RunCMake/find_dependency/extra-args-stderr.txt
new file mode 100644
index 0000000..83a7f02
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/extra-args-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+  Invalid arguments to find_dependency
+Call Stack \(most recent call first\):
+  extra-args.cmake:4 \(find_dependency\)
+  CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/extra-args.cmake b/Tests/RunCMake/find_dependency/extra-args.cmake
new file mode 100644
index 0000000..209645a
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/extra-args.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 1.2 EXACT PATHS "${CMAKE_BINARY_DIR}")
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/find_dependency/invalid-arg-3-result.txt
diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt
new file mode 100644
index 0000000..fee8d5d
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+  Invalid arguments to find_dependency
+Call Stack \(most recent call first\):
+  invalid-arg-3.cmake:4 \(find_dependency\)
+  CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3.cmake b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake
new file mode 100644
index 0000000..40ede07
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 1.2 EXACTYPO)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt
new file mode 100644
index 0000000..f0adc9f
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+  Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
+
+    ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-NEW-build/foo"
+
+  which is prefixed in the build directory.
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt
new file mode 100644
index 0000000..054bff5
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt
@@ -0,0 +1,20 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+  Policy CMP0052 is not set: Reject source and build dirs in installed
+  INTERFACE_INCLUDE_DIRECTORIES.  Run "cmake --help-policy CMP0052" for
+  policy details.  Use the cmake_policy command to set the policy and
+  suppress this warning.
+
+  Directory:
+
+      ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build/foo"
+
+  in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory
+  of the install directory:
+
+      ".*Tests/RunCMake/include_directories/prefix"
+
+  however it is also a subdirectory of the build tree:
+
+      ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build"
+
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/include_directories/CMakeLists.txt b/Tests/RunCMake/include_directories/CMakeLists.txt
index f452db1..3482e6b 100644
--- a/Tests/RunCMake/include_directories/CMakeLists.txt
+++ b/Tests/RunCMake/include_directories/CMakeLists.txt
@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 2.8.4)
+cmake_minimum_required(VERSION 3.0)
 project(${RunCMake_TEST} CXX)
 include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt
diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt b/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake b/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake
new file mode 100644
index 0000000..d6f08bd
--- /dev/null
+++ b/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake
@@ -0,0 +1,9 @@
+
+add_library(testTarget empty.cpp)
+target_include_directories(testTarget INTERFACE "${CMAKE_INSTALL_PREFIX}/dir")
+
+install(TARGETS testTarget EXPORT testTargets
+  DESTINATION lib
+)
+
+install(EXPORT testTargets DESTINATION lib/cmake)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/include_directories/InstallInBinDir-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/include_directories/InstallInBinDir-result.txt
diff --git a/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt b/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt
new file mode 100644
index 0000000..254fae1
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+  Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
+
+    ".*Tests/RunCMake/include_directories/InstallInBinDir-build/foo"
+
+  which is prefixed in the build directory.
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/include_directories/InstallInSrcDir-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/include_directories/InstallInSrcDir-result.txt
diff --git a/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt b/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt
new file mode 100644
index 0000000..7be3044
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+  Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
+
+    ".*Tests/RunCMake/include_directories/copy/foo"
+
+  which is prefixed in the source directory.
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt
diff --git a/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt b/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake b/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake
new file mode 100644
index 0000000..0f08e58
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake
@@ -0,0 +1,11 @@
+
+project(InstallPrefixInInterface)
+
+add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
+target_include_directories(testTarget INTERFACE "${CMAKE_INSTALL_PREFIX}/foo")
+
+install(TARGETS testTarget EXPORT testTargets
+  DESTINATION lib
+)
+
+install(EXPORT testTargets DESTINATION lib/cmake)
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt
diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt
diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake
index c00b924..c5b29d0 100644
--- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake
+++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake
@@ -12,3 +12,131 @@
 run_cmake(install_config)
 run_cmake(incomplete-genex)
 run_cmake(export-NOWARN)
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/DirInInstallPrefix/prefix")
+run_cmake(DirInInstallPrefix)
+
+configure_file(
+  "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+  "${RunCMake_BINARY_DIR}/copy/CMakeLists.txt"
+  COPYONLY
+)
+configure_file(
+  "${RunCMake_SOURCE_DIR}/empty.cpp"
+  "${RunCMake_BINARY_DIR}/copy/empty.cpp"
+  COPYONLY
+)
+configure_file(
+  "${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake"
+  "${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface.cmake"
+  COPYONLY
+)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface/prefix")
+set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface")
+set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/copy")
+run_cmake(InstallInSrcDir)
+unset(RunCMake_TEST_SOURCE_DIR)
+unset(RunCMake_TEST_FILE)
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallInBinDir-build/prefix")
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/InstallInBinDir-build")
+set(RunCMake_TEST_FILE "${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface")
+run_cmake(InstallInBinDir)
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_FILE)
+
+configure_file(
+  "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+  "${RunCMake_BINARY_DIR}/prefix/src/CMakeLists.txt"
+  COPYONLY
+)
+configure_file(
+  "${RunCMake_SOURCE_DIR}/empty.cpp"
+  "${RunCMake_BINARY_DIR}/prefix/src/empty.cpp"
+  COPYONLY
+)
+configure_file(
+  "${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake"
+  "${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake"
+  COPYONLY
+)
+
+foreach(policyStatus "" NEW OLD)
+  if (NOT "${policyStatus}" STREQUAL "")
+    set(policyOption -DCMAKE_POLICY_DEFAULT_CMP0052=${policyStatus})
+  else()
+    unset(policyOption)
+    set(policyStatus WARN)
+  endif()
+  set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption})
+  # Set the RunCMake_TEST_SOURCE_DIR here to the copy too. This is needed to run
+  # the test suite in-source properly.  Otherwise the install directory would be
+  # a subdirectory or the source directory, which is allowed and tested separately
+  # below.
+  set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/prefix/src")
+  set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/prefix/BinInInstallPrefix-CMP0052-${policyStatus}-build")
+  set(RunCMake_TEST_FILE "${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface")
+  run_cmake(BinInInstallPrefix-CMP0052-${policyStatus})
+  unset(RunCMake_TEST_BINARY_DIR)
+  unset(RunCMake_TEST_FILE)
+
+  set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface")
+  run_cmake(SrcInInstallPrefix-CMP0052-${policyStatus})
+  unset(RunCMake_TEST_SOURCE_DIR)
+  unset(RunCMake_TEST_FILE)
+endforeach()
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallPrefixInInterface-build/prefix")
+run_cmake(InstallPrefixInInterface)
+
+configure_file(
+  "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+  "${RunCMake_BINARY_DIR}/installToSrc/CMakeLists.txt"
+  COPYONLY
+)
+configure_file(
+  "${RunCMake_SOURCE_DIR}/empty.cpp"
+  "${RunCMake_BINARY_DIR}/installToSrc/empty.cpp"
+  COPYONLY
+)
+configure_file(
+  "${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake"
+  "${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface.cmake"
+  COPYONLY
+)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface/prefix")
+set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface")
+set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrc")
+run_cmake(InstallToPrefixInSrcDirOutOfSource)
+unset(RunCMake_TEST_SOURCE_DIR)
+unset(RunCMake_TEST_FILE)
+
+
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/installToSrcInSrc")
+set(RunCMake_TEST_NO_CLEAN ON)
+
+configure_file(
+  "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+  "${RunCMake_BINARY_DIR}/installToSrcInSrc/CMakeLists.txt"
+  COPYONLY
+)
+configure_file(
+  "${RunCMake_SOURCE_DIR}/empty.cpp"
+  "${RunCMake_BINARY_DIR}/installToSrcInSrc/empty.cpp"
+  COPYONLY
+)
+configure_file(
+  "${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake"
+  "${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface.cmake"
+  COPYONLY
+)
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface/prefix")
+set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface")
+set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc")
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc")
+run_cmake(InstallToPrefixInSrcDirInSource)
+unset(RunCMake_TEST_SOURCE_DIR)
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_FILE)
+unset(RunCMake_TEST_NO_CLEAN)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt
new file mode 100644
index 0000000..afa43e0
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+  Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
+
+    ".*Tests/RunCMake/include_directories/prefix/src/foo"
+
+  which is prefixed in the source directory.
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt
similarity index 100%
copy from Tests/RunCMake/set/PARENT_SCOPE-result.txt
copy to Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt
new file mode 100644
index 0000000..0b13fd8
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt
@@ -0,0 +1,20 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+  Policy CMP0052 is not set: Reject source and build dirs in installed
+  INTERFACE_INCLUDE_DIRECTORIES.  Run "cmake --help-policy CMP0052" for
+  policy details.  Use the cmake_policy command to set the policy and
+  suppress this warning.
+
+  Directory:
+
+      ".*Tests/RunCMake/include_directories/prefix/src/foo"
+
+  in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory
+  of the install directory:
+
+      ".*Tests/RunCMake/include_directories/prefix"
+
+  however it is also a subdirectory of the source tree:
+
+      ".*Tests/RunCMake/include_directories/prefix/src"
+
+This warning is for project developers.  Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/set/ParentScope-result.txt
similarity index 100%
rename from Tests/RunCMake/set/PARENT_SCOPE-result.txt
rename to Tests/RunCMake/set/ParentScope-result.txt
diff --git a/Tests/RunCMake/set/PARENT_SCOPE.cmake b/Tests/RunCMake/set/ParentScope.cmake
similarity index 100%
rename from Tests/RunCMake/set/PARENT_SCOPE.cmake
rename to Tests/RunCMake/set/ParentScope.cmake
diff --git a/Tests/RunCMake/set/RunCMakeTest.cmake b/Tests/RunCMake/set/RunCMakeTest.cmake
index 0b96b28..b8e8cf1 100644
--- a/Tests/RunCMake/set/RunCMakeTest.cmake
+++ b/Tests/RunCMake/set/RunCMakeTest.cmake
@@ -1,5 +1,5 @@
 include(RunCMake)
 
-run_cmake(PARENT_SCOPE)
+run_cmake(ParentScope)
 run_cmake(ParentPulling)
 run_cmake(ParentPullingRecursive)
diff --git a/Tests/RunCMake/target_compile_features/CMakeLists.txt b/Tests/RunCMake/target_compile_features/CMakeLists.txt
new file mode 100644
index 0000000..3482e6b
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake
new file mode 100644
index 0000000..33faf2b
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake
@@ -0,0 +1,13 @@
+include(RunCMake)
+
+run_cmake(not_enough_args)
+run_cmake(alias_target)
+run_cmake(utility_target)
+run_cmake(invalid_args)
+run_cmake(invalid_args_on_interface)
+run_cmake(imported_target)
+run_cmake(no_target)
+run_cmake(not_a_cxx_feature)
+run_cmake(no_matching_cxx_feature)
+run_cmake(not_a_c_feature)
+run_cmake(no_matching_c_feature)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/alias_target-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/alias_target-result.txt
diff --git a/Tests/RunCMake/target_compile_features/alias_target-stderr.txt b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt
new file mode 100644
index 0000000..417bf62
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at alias_target.cmake:4 \(target_compile_features\):
+  target_compile_features can not be used on an ALIAS target.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/alias_target.cmake b/Tests/RunCMake/target_compile_features/alias_target.cmake
new file mode 100644
index 0000000..d35ddba
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/alias_target.cmake
@@ -0,0 +1,4 @@
+
+add_executable(main empty.cpp)
+add_executable(Alias::Main ALIAS main)
+target_compile_features(Alias::Main PRIVATE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/target_compile_features/empty.c b/Tests/RunCMake/target_compile_features/empty.c
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/empty.c
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/target_compile_features/empty.cpp b/Tests/RunCMake/target_compile_features/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+  return 0;
+}
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/imported_target-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/imported_target-result.txt
diff --git a/Tests/RunCMake/target_compile_features/imported_target-stderr.txt b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt
new file mode 100644
index 0000000..c6ff5ec
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at imported_target.cmake:3 \(target_compile_features\):
+  Cannot specify compile features for imported target "main".
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/imported_target.cmake b/Tests/RunCMake/target_compile_features/imported_target.cmake
new file mode 100644
index 0000000..e248c2f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/imported_target.cmake
@@ -0,0 +1,3 @@
+
+add_library(main INTERFACE IMPORTED)
+target_compile_features(main INTERFACE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/invalid_args-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/invalid_args-result.txt
diff --git a/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt
new file mode 100644
index 0000000..bd5b7b9
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at invalid_args.cmake:3 \(target_compile_features\):
+  target_compile_features called with invalid arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/invalid_args.cmake b/Tests/RunCMake/target_compile_features/invalid_args.cmake
new file mode 100644
index 0000000..1a7fb37
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args.cmake
@@ -0,0 +1,3 @@
+
+add_executable(main empty.cpp)
+target_compile_features(main INVALID cxx_delegating_constructors)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt
diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt
new file mode 100644
index 0000000..c30209a
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at invalid_args_on_interface.cmake:3 \(target_compile_features\):
+  target_compile_features may only be set INTERFACE properties on INTERFACE
+  targets
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake b/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake
new file mode 100644
index 0000000..324d0f3
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake
@@ -0,0 +1,3 @@
+
+add_library(main INTERFACE)
+target_compile_features(main PRIVATE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/no_matching_c_feature-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/no_matching_c_feature-result.txt
diff --git a/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt
new file mode 100644
index 0000000..96b959c
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at no_matching_c_feature.cmake:[0-9][0-9]? \((target_compile_features|message)\):
+  The compiler feature "gnu_c_dummy" is not known to C compiler
+
+  "GNU"
+
+  version 4.8.1.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/no_matching_c_feature.cmake b/Tests/RunCMake/target_compile_features/no_matching_c_feature.cmake
new file mode 100644
index 0000000..a44caf2
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_matching_c_feature.cmake
@@ -0,0 +1,15 @@
+
+if (NOT ";${CMAKE_C_COMPILE_FEATURES};" MATCHES ";gnu_c_typeof;")
+  # Simulate passing the test.
+  message(SEND_ERROR
+    "The compiler feature \"gnu_c_dummy\" is not known to C compiler\n\"GNU\"\nversion 4.8.1."
+  )
+  return()
+endif()
+
+add_executable(main empty.c)
+
+target_compile_features(main
+  PRIVATE
+    gnu_c_typeof
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt
diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt
new file mode 100644
index 0000000..f976dfe
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at no_matching_cxx_feature.cmake:[0-9][0-9]? \((target_compile_features|message)\):
+  The compiler feature "[^"]+" is not known to CXX compiler
+
+  "[^"]*"
+
+  version *[.0-9]+\.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake
new file mode 100644
index 0000000..ab1fd76
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake
@@ -0,0 +1,26 @@
+
+if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;"
+    AND NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;" )
+  # Simulate passing the test.
+  message(SEND_ERROR
+    "The compiler feature \"gnu_cxx_dummy\" is not known to CXX compiler\n\"GNU\"\nversion 4.8.1."
+  )
+  return()
+endif()
+
+if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;")
+  set(feature msvc_cxx_sealed)
+  if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;")
+    # If a compiler supports both extensions, remove one of them.
+    list(REMOVE_ITEM CMAKE_CXX_COMPILE_FEATURES msvc_cxx_sealed)
+  endif()
+else()
+  set(feature gnu_cxx_typeof)
+endif()
+
+add_executable(main empty.cpp)
+
+target_compile_features(main
+  PRIVATE
+    ${feature}
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/no_target-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/no_target-result.txt
diff --git a/Tests/RunCMake/target_compile_features/no_target-stderr.txt b/Tests/RunCMake/target_compile_features/no_target-stderr.txt
new file mode 100644
index 0000000..323ba7a
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_target-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at no_target.cmake:2 \(target_compile_features\):
+  Cannot specify compile features for target "main" which is not built by
+  this project.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/no_target.cmake b/Tests/RunCMake/target_compile_features/no_target.cmake
new file mode 100644
index 0000000..3f0afe2
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_target.cmake
@@ -0,0 +1,2 @@
+
+target_compile_features(main INTERFACE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/not_a_c_feature-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/not_a_c_feature-result.txt
diff --git a/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt
new file mode 100644
index 0000000..6dd00f3
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at not_a_c_feature.cmake:3 \(target_compile_features\):
+  target_compile_features specified unknown feature "c_not_a_feature" for
+  target "main".
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/not_a_c_feature.cmake b/Tests/RunCMake/target_compile_features/not_a_c_feature.cmake
new file mode 100644
index 0000000..0420698
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_a_c_feature.cmake
@@ -0,0 +1,6 @@
+
+add_executable(main empty.c)
+target_compile_features(main
+  PRIVATE
+    c_not_a_feature
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt
diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt
new file mode 100644
index 0000000..efa2bad
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at not_a_cxx_feature.cmake:3 \(target_compile_features\):
+  target_compile_features specified unknown feature "cxx_not_a_feature" for
+  target "main".
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake b/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake
new file mode 100644
index 0000000..0207b72
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake
@@ -0,0 +1,6 @@
+
+add_executable(main empty.cpp)
+target_compile_features(main
+  PRIVATE
+    cxx_not_a_feature
+)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/not_enough_args-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/not_enough_args-result.txt
diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt
new file mode 100644
index 0000000..2f8d812
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at not_enough_args.cmake:3 \(target_compile_features\):
+  target_compile_features called with incorrect number of arguments
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/not_enough_args.cmake b/Tests/RunCMake/target_compile_features/not_enough_args.cmake
new file mode 100644
index 0000000..9561230
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_enough_args.cmake
@@ -0,0 +1,3 @@
+
+add_executable(main empty.cpp)
+target_compile_features(main)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/target_compile_features/utility_target-result.txt
similarity index 100%
copy from Tests/RunCMake/ExternalData/Directory3-result.txt
copy to Tests/RunCMake/target_compile_features/utility_target-result.txt
diff --git a/Tests/RunCMake/target_compile_features/utility_target-stderr.txt b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt
new file mode 100644
index 0000000..d239059
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at utility_target.cmake:4 \(target_compile_features\):
+  target_compile_features called with non-compilable target type
+Call Stack \(most recent call first\):
+  CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/utility_target.cmake b/Tests/RunCMake/target_compile_features/utility_target.cmake
new file mode 100644
index 0000000..8919056
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/utility_target.cmake
@@ -0,0 +1,4 @@
+
+add_custom_target(utility)
+
+target_compile_features(utility PRIVATE cxx_delegating_constructors)
diff --git a/Tests/SourcesProperty/CMakeLists.txt b/Tests/SourcesProperty/CMakeLists.txt
new file mode 100644
index 0000000..6c99e00
--- /dev/null
+++ b/Tests/SourcesProperty/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(SourcesProperty)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_SOURCES iface.cpp)
+
+add_executable(SourcesProperty main.cpp)
+target_link_libraries(SourcesProperty iface)
+
+set_property(TARGET SourcesProperty APPEND PROPERTY SOURCES prop.cpp)
diff --git a/Tests/SourcesProperty/iface.cpp b/Tests/SourcesProperty/iface.cpp
new file mode 100644
index 0000000..e38ac37
--- /dev/null
+++ b/Tests/SourcesProperty/iface.cpp
@@ -0,0 +1,5 @@
+
+int iface()
+{
+  return 0;
+}
diff --git a/Tests/SourcesProperty/iface.h b/Tests/SourcesProperty/iface.h
new file mode 100644
index 0000000..6da80a4
--- /dev/null
+++ b/Tests/SourcesProperty/iface.h
@@ -0,0 +1,4 @@
+
+int iface();
+
+int prop();
diff --git a/Tests/SourcesProperty/main.cpp b/Tests/SourcesProperty/main.cpp
new file mode 100644
index 0000000..33a97f4
--- /dev/null
+++ b/Tests/SourcesProperty/main.cpp
@@ -0,0 +1,7 @@
+
+#include "iface.h"
+
+int main(int argc, char** argv)
+{
+  return iface() + prop();
+}
diff --git a/Tests/SourcesProperty/prop.cpp b/Tests/SourcesProperty/prop.cpp
new file mode 100644
index 0000000..e343431
--- /dev/null
+++ b/Tests/SourcesProperty/prop.cpp
@@ -0,0 +1,5 @@
+
+int prop()
+{
+  return 0;
+}
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt
index 00383ab..4fa5a86 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -127,12 +127,6 @@
 
 file(RELATIVE_PATH relpath "/usr/local/bin" "/usr/X11R6/bin/xnest")
 
-# Escaping test
-set(var "\\ \" \  \t \n \r \# \( \) \0")
-message("Output: [${var}]")
-set(var \\ \" \  \t \n \r \# \( \) \0)
-message("Output: [${var}]")
-
 # Make-style unquoted argument test
 set(var $(VAR1)$(VAR2)/$(VAR3))
 message("Output: [${var}]")
@@ -141,13 +135,6 @@
   message(SEND_ERROR "Unquoted $(VAR) syntax is broken.")
 endif()
 
-# Obscure environment variable name
-set("ENV{x+(y)}" "Obscure environment variable value")
-message("Output: [$ENV{x+(y)}]")
-if(NOT "$ENV{x+(y)}" STREQUAL "Obscure environment variable value")
-  message(SEND_ERROR "Environment variable \"ENV{x+(y)}\" does not work.")
-endif()
-
 # Make directories test
 file(MAKE_DIRECTORY
   "${CMAKE_CURRENT_BINARY_DIR}/Includes"
@@ -286,3 +273,9 @@
 if(NOT MCI_1 STREQUAL _1one_two_)
   message(SEND_ERROR "MAKE_C_IDENTIFIER did not create expected result.")
 endif()
+
+string(GENEX_STRIP "one;$<1:two;three>;four;$<TARGET_OBJECTS:some_target>" strip_result)
+
+if (NOT strip_result STREQUAL "one;four")
+  message(SEND_ERROR "GENEX_STRIP did not create expected result: ${strip_result}")
+endif()
diff --git a/Tests/SubDirSpaces/CMakeLists.txt b/Tests/SubDirSpaces/CMakeLists.txt
index 69f1d68..40c265e 100644
--- a/Tests/SubDirSpaces/CMakeLists.txt
+++ b/Tests/SubDirSpaces/CMakeLists.txt
@@ -2,7 +2,7 @@
 project(SUBDIR)
 
 # Some systems do not seem to support rpath with spaces.
-if("${CMAKE_SYSTEM}" MATCHES "IRIX|QNX")
+if(CMAKE_SYSTEM_NAME MATCHES "IRIX|QNX")
   set(CMAKE_SKIP_BUILD_RPATH 1)
 endif()
 
diff --git a/Tests/SystemInformation/CMakeLists.txt b/Tests/SystemInformation/CMakeLists.txt
index c33380f..db54612 100644
--- a/Tests/SystemInformation/CMakeLists.txt
+++ b/Tests/SystemInformation/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.6)
+cmake_minimum_required (VERSION 3.0)
 project(SystemInformation)
 
 include_directories("This does not exists")
diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in
index df3bf49..f7e81e6 100644
--- a/Tests/SystemInformation/SystemInformation.in
+++ b/Tests/SystemInformation/SystemInformation.in
@@ -19,8 +19,26 @@
 CMAKE_COMPILER_IS_GNUCXX == "${CMAKE_COMPILER_IS_GNUCXX}"
 CMAKE_C_COMPILER_ID == "${CMAKE_C_COMPILER_ID}"
 CMAKE_C_COMPILER_VERSION == "${CMAKE_C_COMPILER_VERSION}"
+CMAKE_C90_STANDARD_COMPILE_OPTION == "${CMAKE_C90_STANDARD_COMPILE_OPTION}"
+CMAKE_C99_STANDARD_COMPILE_OPTION == "${CMAKE_C99_STANDARD_COMPILE_OPTION}"
+CMAKE_C11_STANDARD_COMPILE_OPTION == "${CMAKE_C11_STANDARD_COMPILE_OPTION}"
+CMAKE_C90_EXTENSION_COMPILE_OPTION == "${CMAKE_C90_EXTENSION_COMPILE_OPTION}"
+CMAKE_C99_EXTENSION_COMPILE_OPTION == "${CMAKE_C99_EXTENSION_COMPILE_OPTION}"
+CMAKE_C11_EXTENSION_COMPILE_OPTION == "${CMAKE_C11_EXTENSION_COMPILE_OPTION}"
+CMAKE_C_COMPILE_FEATURES == "${CMAKE_C_COMPILE_FEATURES}"
+CMAKE_C90_COMPILE_FEATURES == "${CMAKE_C90_COMPILE_FEATURES}"
+CMAKE_C99_COMPILE_FEATURES == "${CMAKE_C99_COMPILE_FEATURES}"
+CMAKE_C11_COMPILE_FEATURES == "${CMAKE_C11_COMPILE_FEATURES}"
 CMAKE_CXX_COMPILER_ID == "${CMAKE_CXX_COMPILER_ID}"
 CMAKE_CXX_COMPILER_VERSION == "${CMAKE_CXX_COMPILER_VERSION}"
+CMAKE_CXX98_STANDARD_COMPILE_OPTION == "${CMAKE_CXX98_STANDARD_COMPILE_OPTION}"
+CMAKE_CXX11_STANDARD_COMPILE_OPTION == "${CMAKE_CXX11_STANDARD_COMPILE_OPTION}"
+CMAKE_CXX98_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX98_EXTENSION_COMPILE_OPTION}"
+CMAKE_CXX11_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}"
+CMAKE_CXX_COMPILE_FEATURES == "${CMAKE_CXX_COMPILE_FEATURES}"
+CMAKE_CXX98_COMPILE_FEATURES == "${CMAKE_CXX98_COMPILE_FEATURES}"
+CMAKE_CXX11_COMPILE_FEATURES == "${CMAKE_CXX11_COMPILE_FEATURES}"
+CMAKE_CXX14_COMPILE_FEATURES == "${CMAKE_CXX14_COMPILE_FEATURES}"
 
 // C shared library flag
 CMAKE_SHARED_LIBRARY_C_FLAGS == "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
diff --git a/Utilities/Release/Cygwin/CMakeLists.txt b/Utilities/Release/Cygwin/CMakeLists.txt
index c59a6fa..73a8220 100644
--- a/Utilities/Release/Cygwin/CMakeLists.txt
+++ b/Utilities/Release/Cygwin/CMakeLists.txt
@@ -14,9 +14,9 @@
 configure_file("${CMake_SOURCE_DIR}/Utilities/Release/Cygwin/cygwin-setup.hint.in"
   "${CMake_BINARY_DIR}/setup.hint")
 configure_file("${CMake_SOURCE_DIR}/Utilities/Release/Cygwin/README.cygwin.in"
-  "${CMake_BINARY_DIR}/Docs/@CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@.README")
+  "${CMake_BINARY_DIR}/Docs/${CPACK_PACKAGE_FILE_NAME}-${CPACK_CYGWIN_PATCH_NUMBER}.README")
 install_files(/share/doc/Cygwin FILES
-  ${CMake_BINARY_DIR}/Docs/@CPACK_PACKAGE_FILE_NAME@-@CPACK_CYGWIN_PATCH_NUMBER@.README
+  ${CMake_BINARY_DIR}/Docs/${CPACK_PACKAGE_FILE_NAME}-${CPACK_CYGWIN_PATCH_NUMBER}.README
   )
 configure_file("${CMake_SOURCE_DIR}/Utilities/Release/Cygwin/cygwin-package.sh.in"
   ${CPACK_CYGWIN_BUILD_SCRIPT})
diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake
index 95428b6..a3f7032 100644
--- a/Utilities/Release/create-cmake-release.cmake
+++ b/Utilities/Release/create-cmake-release.cmake
@@ -10,9 +10,7 @@
   dashmacmini2_release.cmake  # Mac Darwin universal ppc;i386
   dashmacmini5_release.cmake  # Mac Darwin64 universal x86_64;i386
   magrathea_release.cmake     # Linux
-  v20n250_aix_release.cmake   # AIX 5.3
-  ferrari_sgi64_release.cmake # IRIX 64
-  ferrari_sgi_release.cmake   # IRIX
+  ibm_aix_release.cmake       # AIX
 )
 
 set(RELEASE_SCRIPTS_BATCH_2
diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake
index 9d418d9..6a27119 100644
--- a/Utilities/Release/dashmacmini2_release.cmake
+++ b/Utilities/Release/dashmacmini2_release.cmake
@@ -5,14 +5,14 @@
 set(HOST dashmacmini2)
 set(MAKE_PROGRAM "make")
 set(MAKE "${MAKE_PROGRAM} -j2")
-set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ")
+set(CPACK_BINARY_GENERATORS "DragNDrop TGZ TZ")
 set(INITIAL_CACHE "
 CMAKE_BUILD_TYPE:STRING=Release
 CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386
 CMAKE_USE_OPENSSL:BOOL=ON
-OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1c-install/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libssl.a
+OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libcrypto.a
+OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1g-install/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libssl.a
 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
 CPACK_SYSTEM_NAME:STRING=Darwin-universal
 BUILD_QtDialog:BOOL=TRUE
diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake
index aba68f8..16a30b3 100644
--- a/Utilities/Release/dashmacmini5_release.cmake
+++ b/Utilities/Release/dashmacmini5_release.cmake
@@ -5,13 +5,13 @@
 set(HOST dashmacmini5)
 set(MAKE_PROGRAM "make")
 set(MAKE "${MAKE_PROGRAM} -j5")
-set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ")
+set(CPACK_BINARY_GENERATORS "DragNDrop TGZ TZ")
 set(CPACK_SOURCE_GENERATORS "TGZ TZ")
 set(INITIAL_CACHE "
 CMAKE_USE_OPENSSL:BOOL=ON
-OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1c-install/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libssl.a
+OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libcrypto.a
+OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1g-install/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libssl.a
 CMAKE_BUILD_TYPE:STRING=Release
 CMAKE_OSX_ARCHITECTURES:STRING=x86_64;i386
 CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5
diff --git a/Utilities/Release/ferrari_sgi64_release.cmake b/Utilities/Release/ferrari_sgi64_release.cmake
deleted file mode 100644
index 4425f05..0000000
--- a/Utilities/Release/ferrari_sgi64_release.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-set(CMAKE_RELEASE_DIRECTORY "/home/whoffman/CMakeReleaseDirectory64")
-set(PROCESSORS 2)
-set(CFLAGS "-64")
-set(FFLAGS "-64")
-set(CXXFLAGS "-64")
-set(LDFLAGS="-64")
-set(HOST sgi)
-set(SCRIPT_NAME sgi64)
-set(MAKE_PROGRAM "make")
-set(MAKE "${MAKE_PROGRAM} -P")
-set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
-CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
-CPACK_SYSTEM_NAME:STRING=IRIX64-64
-")
-get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/ferrari_sgi_release.cmake b/Utilities/Release/ferrari_sgi_release.cmake
deleted file mode 100644
index ee5121a..0000000
--- a/Utilities/Release/ferrari_sgi_release.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-set(CMAKE_RELEASE_DIRECTORY "/home/whoffman/CMakeReleaseDirectory")
-set(PROCESSORS 2)
-set(HOST sgi)
-set(MAKE_PROGRAM "make")
-set(MAKE "${MAKE_PROGRAM} -P")
-set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
-CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
-CPACK_SYSTEM_NAME:STRING=IRIX64-n32
-")
-get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/ibm_aix_release.cmake b/Utilities/Release/ibm_aix_release.cmake
new file mode 100644
index 0000000..5a6efe6
--- /dev/null
+++ b/Utilities/Release/ibm_aix_release.cmake
@@ -0,0 +1,15 @@
+set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory")
+set(PROCESSORS 64)
+set(HOST "ibm-backend")
+set(SCRIPT_NAME aix)
+set(MAKE_PROGRAM "make")
+set(CC "xlc_r")
+set(CXX "xlC_r")
+set(FC "xlf")
+set(LDFLAGS "-Wl,-bmaxdata:0x80000000") # Push "Segmentation fault in extend_brk" over horizon
+set(INITIAL_CACHE "
+CMAKE_BUILD_TYPE:STRING=Release
+CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
+")
+get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
+include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/magrathea_release.cmake b/Utilities/Release/magrathea_release.cmake
index 93916e2..1bf75dd 100644
--- a/Utilities/Release/magrathea_release.cmake
+++ b/Utilities/Release/magrathea_release.cmake
@@ -11,9 +11,9 @@
 CURSES_INCLUDE_PATH:PATH=/usr/i686-gcc-332s/include/ncurses
 FORM_LIBRARY:FILEPATH=/usr/i686-gcc-332s/lib/libform.a
 CMAKE_USE_OPENSSL:BOOL=ON
-OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1c-install/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.1c-install/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1c-install/lib/libssl.a
+OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1g-install/lib/libcrypto.a
+OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.1g-install/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1g-install/lib/libssl.a
 CPACK_SYSTEM_NAME:STRING=Linux-i386
 BUILD_QtDialog:BOOL:=TRUE
 CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
diff --git a/Utilities/Release/release_cmake.cmake b/Utilities/Release/release_cmake.cmake
index 630f54f..4c4dd8a 100644
--- a/Utilities/Release/release_cmake.cmake
+++ b/Utilities/Release/release_cmake.cmake
@@ -4,9 +4,6 @@
 if(NOT DEFINED CPACK_BINARY_GENERATORS)
   set(CPACK_BINARY_GENERATORS "STGZ TGZ TZ")
 endif()
-if(DEFINED EXTRA_COPY)
-  set(HAS_EXTRA_COPY 1)
-endif()
 if(NOT DEFINED CMAKE_RELEASE_DIRECTORY)
   set(CMAKE_RELEASE_DIRECTORY "~/CMakeReleaseDirectory")
 endif()
@@ -55,11 +52,11 @@
 macro(remote_command comment command)
   message("${comment}")
   if(${ARGC} GREATER 2)
-    message("ssh ${HOST} ${EXTRA_HOP} ${command}")
-    execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2})
+    message("ssh ${HOST} ${command}")
+    execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2})
   else()
-    message("ssh ${HOST} ${EXTRA_HOP} ${command}")
-    execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result)
+    message("ssh ${HOST} ${command}")
+    execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result)
   endif()
   if(${result} GREATER 0)
     message(FATAL_ERROR "Error running command: ${command}, return value = ${result}")
@@ -67,14 +64,15 @@
 endmacro()
 
 if(CMAKE_DOC_TARBALL)
-  message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:'")
+  get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME)
+  string(REPLACE ".tar.gz" "-${SCRIPT_NAME}.tar.gz" CMAKE_DOC_TARBALL_STAGED "${CMAKE_DOC_TARBALL_NAME}")
+  message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:${CMAKE_DOC_TARBALL_STAGED}'")
   execute_process(COMMAND
-    scp ${CMAKE_DOC_TARBALL} ${HOST}:
+    scp ${CMAKE_DOC_TARBALL} ${HOST}:${CMAKE_DOC_TARBALL_STAGED}
     RESULT_VARIABLE result)
   if(${result} GREATER 0)
-    message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:'")
+    message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:${CMAKE_DOC_TARBALL_STAGED}'")
   endif()
-  get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME)
 endif()
 
 # set this so configure file will work from script mode
@@ -101,7 +99,7 @@
   if("${gen}" STREQUAL "STGZ")
     set(SUFFIXES ${SUFFIXES} "*.sh")
   endif()
-  if("${gen}" STREQUAL "PackageMaker")
+  if("${gen}" STREQUAL "DragNDrop")
     set(SUFFIXES ${SUFFIXES} "*.dmg")
   endif()
   if("${gen}" STREQUAL "TBZ2")
diff --git a/Utilities/Release/release_cmake.sh.in b/Utilities/Release/release_cmake.sh.in
index f41bda8..76fdb3a 100755
--- a/Utilities/Release/release_cmake.sh.in
+++ b/Utilities/Release/release_cmake.sh.in
@@ -18,7 +18,7 @@
 CMAKE_DOC_TARBALL=""
 if [ ! -z "@CMAKE_DOC_TARBALL_NAME@" ] ; then
     CMAKE_DOC_TARBALL=@CMAKE_RELEASE_DIRECTORY@/@CMAKE_DOC_TARBALL_NAME@
-    mv "$HOME/@CMAKE_DOC_TARBALL_NAME@" "$CMAKE_DOC_TARBALL"
+    mv "$HOME/@CMAKE_DOC_TARBALL_STAGED@" "$CMAKE_DOC_TARBALL"
     check_exit_value $? "mv doc tarball" || exit 1
 fi
 
@@ -155,11 +155,6 @@
 
 
 
-# need to add an extra copy thing here
-if [ ! -z "@EXTRA_COPY@" ]; then
-    @EXTRA_COPY@
-    check_exit_value $? "Extra copy step @EXTRA_COPY@" || exit 1
-fi
 echo "End release"
 date
 echo ""
diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake
index 9bf3523..5f4da8f 100644
--- a/Utilities/Release/upload_release.cmake
+++ b/Utilities/Release/upload_release.cmake
@@ -1,20 +1,19 @@
 set(CTEST_RUN_CURRENT_SCRIPT 0)
-if(NOT DEFINED PROJECT_PREFIX)
-  set(PROJECT_PREFIX cmake-)
-endif()
 if(NOT VERSION)
- set(VERSION 2.8)
+ set(VERSION 3.0)
 endif()
-set(dir "v${VERSION}")
-if("${VERSION}" MATCHES "master")
-  set(dir "dev")
+if(NOT DEFINED PROJECT_PREFIX)
+  set(PROJECT_PREFIX cmake-${VERSION})
+endif()
+if(NOT DEFINED DIR)
+  set(DIR "v${VERSION}")
 endif()
 file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*")
 list(SORT FILES)
 list(REVERSE FILES)
 message("${FILES}")
 set(UPLOAD_LOC
-  "kitware@www.cmake.org:/projects/FTP/pub/cmake/${dir}")
+  "kitware@www.cmake.org:/projects/FTP/pub/cmake/${DIR}")
 set(count 0)
 foreach(file ${FILES})
   if(NOT IS_DIRECTORY ${file})
diff --git a/Utilities/Release/v20n250_aix_release.cmake b/Utilities/Release/v20n250_aix_release.cmake
deleted file mode 100644
index cc8cd05..0000000
--- a/Utilities/Release/v20n250_aix_release.cmake
+++ /dev/null
@@ -1,22 +0,0 @@
-set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory")
-set(FINAL_PATH /u/noibm34/cmake-release)
-set(PROCESSORS 2)
-set(HOST "sshserv.centers.ihost.com")
-set(EXTRA_HOP "rsh p90n03")
-set(MAKE_PROGRAM "make")
-set(CC "xlc_r")
-set(CXX "xlC_r")
-set(FC "xlf")
-set(LDFLAGS "-Wl,-bmaxdata:0x80000000") # Push "Segmentation fault in extend_brk" over horizon
-set(INITIAL_CACHE "
-CMAKE_BUILD_TYPE:STRING=Release
-CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
-")
-set(EXTRA_COPY "
-rm -rf ~/cmake-release
-mkdir ~/cmake-release
-mv *.sh ~/cmake-release
-mv *.Z ~/cmake-release
-mv *.gz ~/cmake-release")
-get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include(${path}/release_cmake.cmake)
diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt
index 5e3e04b..951f7ab 100644
--- a/Utilities/Sphinx/CMakeLists.txt
+++ b/Utilities/Sphinx/CMakeLists.txt
@@ -25,6 +25,7 @@
 option(SPHINX_MAN "Build man pages with Sphinx" OFF)
 option(SPHINX_HTML "Build html help with Sphinx" OFF)
 option(SPHINX_SINGLEHTML "Build html single page help with Sphinx" OFF)
+option(SPHINX_QTHELP "Build Qt help with Sphinx" OFF)
 option(SPHINX_TEXT "Build text help with Sphinx (not installed)" OFF)
 find_program(SPHINX_EXECUTABLE
   NAMES sphinx-build
@@ -33,7 +34,7 @@
 
 mark_as_advanced(SPHINX_TEXT)
 
-if(NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_SINGLEHTML AND NOT SPHINX_TEXT)
+if(NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_SINGLEHTML AND NOT SPHINX_QTHELP AND NOT SPHINX_TEXT)
   return()
 elseif(NOT SPHINX_EXECUTABLE)
   message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!")
@@ -67,6 +68,30 @@
 if(SPHINX_TEXT)
   list(APPEND doc_formats text)
 endif()
+if(SPHINX_QTHELP)
+  find_program(QCOLLECTIONGENERATOR_EXECUTABLE
+    NAMES qcollectiongenerator
+    DOC "qcollectiongenerator tool"
+    )
+  if (NOT QCOLLECTIONGENERATOR_EXECUTABLE)
+    message(FATAL_ERROR "QCOLLECTIONGENERATOR_EXECUTABLE (qcollectiongenerator) not found!")
+  endif()
+  list(APPEND doc_formats qthelp)
+
+  set(qthelp_extra_commands
+    # Workaround for assistant prior to
+    # https://codereview.qt-project.org/#change,82250 in Qt 4.
+    COMMAND ${CMAKE_COMMAND} "-DCSS_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/_static"
+      -P "${CMAKE_CURRENT_SOURCE_DIR}/apply_qthelp_css_workaround.cmake"
+    # Workaround sphinx configurability:
+    # https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable
+    COMMAND ${CMAKE_COMMAND} "-DQTHELP_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/"
+      "-DCMake_VERSION=${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}"
+      -P "${CMAKE_CURRENT_SOURCE_DIR}/fixup_qthelp_names.cmake"
+    COMMAND qcollectiongenerator ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp
+  )
+endif()
+
 
 set(doc_format_outputs "")
 set(doc_format_last "")
@@ -82,6 +107,7 @@
             ${CMake_SOURCE_DIR}/Help
             ${CMAKE_CURRENT_BINARY_DIR}/${format}
             > ${doc_format_log} # log stdout, pass stderr
+    ${${format}_extra_commands}
     DEPENDS ${doc_format_last}
     COMMENT "sphinx-build ${format}: see Utilities/Sphinx/${doc_format_log}"
     VERBATIM
@@ -134,3 +160,9 @@
           PATTERN objects.inv EXCLUDE
           )
 endif()
+
+if(SPHINX_QTHELP)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake-${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}.qch
+          DESTINATION ${CMAKE_DOC_DIR}
+          )
+endif()
diff --git a/Utilities/Sphinx/apply_qthelp_css_workaround.cmake b/Utilities/Sphinx/apply_qthelp_css_workaround.cmake
new file mode 100644
index 0000000..8b74d12
--- /dev/null
+++ b/Utilities/Sphinx/apply_qthelp_css_workaround.cmake
@@ -0,0 +1,15 @@
+
+file(READ "${CSS_DIR}/basic.css" BasicCssContent)
+
+file(READ "${CSS_DIR}/default.css" DefaultCssContent)
+string(REPLACE
+  "@import url(\"basic.css\")" "${BasicCssContent}"
+  DefaultCssContent "${DefaultCssContent}"
+)
+
+file(READ "${CSS_DIR}/cmake.css" CMakeCssContent)
+string(REPLACE
+  "@import url(\"default.css\")" "${DefaultCssContent}"
+  CMakeCssContent "${CMakeCssContent}"
+)
+file(WRITE "${CSS_DIR}/cmake.css" "${CMakeCssContent}")
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index 0e8f280..2629bb3 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -21,6 +21,24 @@
 CMakeLexer.tokens["args"].append(('(\\$<)(.+?)(>)',
                                   bygroups(Operator, Name.Variable, Operator)))
 
+# Monkey patch for sphinx generating invalid content for qcollectiongenerator
+# https://bitbucket.org/birkenfeld/sphinx/issue/1435/qthelp-builder-should-htmlescape-keywords
+from sphinx.util.pycompat import htmlescape
+from sphinx.builders.qthelp import QtHelpBuilder
+old_build_keywords = QtHelpBuilder.build_keywords
+def new_build_keywords(self, title, refs, subitems):
+  old_items = old_build_keywords(self, title, refs, subitems)
+  new_items = []
+  for item in old_items:
+    before, rest = item.split("ref=\"", 1)
+    ref, after = rest.split("\"")
+    if ("<" in ref and ">" in ref):
+      new_items.append(before + "ref=\"" + htmlescape(ref) + "\"" + after)
+    else:
+      new_items.append(item)
+  return new_items
+QtHelpBuilder.build_keywords = new_build_keywords
+
 
 from docutils.parsers.rst import Directive, directives
 from docutils.transforms import Transform
@@ -124,6 +142,7 @@
     'prop_cache': _cmake_index_entry('cache property'),
     'prop_dir':   _cmake_index_entry('directory property'),
     'prop_gbl':   _cmake_index_entry('global property'),
+    'prop_inst':  _cmake_index_entry('installed file property'),
     'prop_sf':    _cmake_index_entry('source file property'),
     'prop_test':  _cmake_index_entry('test property'),
     'prop_tgt':   _cmake_index_entry('target property'),
@@ -251,6 +270,7 @@
         'prop_cache': ObjType('prop_cache', 'prop_cache'),
         'prop_dir':   ObjType('prop_dir',   'prop_dir'),
         'prop_gbl':   ObjType('prop_gbl',   'prop_gbl'),
+        'prop_inst':  ObjType('prop_inst',  'prop_inst'),
         'prop_sf':    ObjType('prop_sf',    'prop_sf'),
         'prop_test':  ObjType('prop_test',  'prop_test'),
         'prop_tgt':   ObjType('prop_tgt',   'prop_tgt'),
@@ -266,6 +286,7 @@
         # 'prop_cache': CMakeObject,
         # 'prop_dir':   CMakeObject,
         # 'prop_gbl':   CMakeObject,
+        # 'prop_inst':  CMakeObject,
         # 'prop_sf':    CMakeObject,
         # 'prop_test':  CMakeObject,
         # 'prop_tgt':   CMakeObject,
@@ -280,6 +301,7 @@
         'prop_cache': CMakeXRefRole(),
         'prop_dir':   CMakeXRefRole(),
         'prop_gbl':   CMakeXRefRole(),
+        'prop_inst':  CMakeXRefRole(),
         'prop_sf':    CMakeXRefRole(),
         'prop_test':  CMakeXRefRole(),
         'prop_tgt':   CMakeXRefRole(),
diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in
index e334389..d81bbcf 100644
--- a/Utilities/Sphinx/conf.py.in
+++ b/Utilities/Sphinx/conf.py.in
@@ -61,3 +61,7 @@
 html_title = 'CMake %s Documentation' % release
 html_short_title = '%s Documentation' % release
 html_favicon = 'cmake-favicon.ico'
+# Not supported yet by sphinx:
+# https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable
+# qthelp_namespace = "org.cmake"
+# qthelp_qch_name = "CMake-300.qch"
diff --git a/Utilities/Sphinx/fixup_qthelp_names.cmake b/Utilities/Sphinx/fixup_qthelp_names.cmake
new file mode 100644
index 0000000..e35ef25
--- /dev/null
+++ b/Utilities/Sphinx/fixup_qthelp_names.cmake
@@ -0,0 +1,32 @@
+
+file(READ "${QTHELP_DIR}/CMake.qhcp" QHCP_CONTENT)
+
+string(REPLACE
+  "<homePage>qthelp://org.sphinx.cmake" "<homePage>qthelp://org.cmake"
+  QHCP_CONTENT "${QHCP_CONTENT}"
+)
+string(REPLACE
+  "<startPage>qthelp://org.sphinx.cmake" "<startPage>qthelp://org.cmake"
+  QHCP_CONTENT "${QHCP_CONTENT}"
+)
+
+string(REPLACE
+  "<output>CMake.qch" "<output>CMake-${CMake_VERSION}.qch"
+  QHCP_CONTENT "${QHCP_CONTENT}"
+)
+string(REPLACE
+  "<file>CMake.qch" "<file>CMake-${CMake_VERSION}.qch"
+  QHCP_CONTENT "${QHCP_CONTENT}"
+)
+
+file(WRITE "${QTHELP_DIR}/CMake.qhcp" "${QHCP_CONTENT}")
+
+
+file(READ "${QTHELP_DIR}/CMake.qhp" QHP_CONTENT)
+
+string(REPLACE
+  "<namespace>org.sphinx.cmake" "<namespace>org.cmake"
+  QHP_CONTENT "${QHP_CONTENT}"
+)
+
+file(WRITE "${QTHELP_DIR}/CMake.qhp" "${QHP_CONTENT}")
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index abf04d8..1b918c9 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -172,6 +172,11 @@
   CHECK_LIBRARY_EXISTS_CONCAT("z"      inflateEnd   HAVE_LIBZ)
 ENDIF(NOT CURL_SPECIAL_LIBZ)
 
+# Include the local directories before any others so that we do not end up
+# including system curl's include directory first by mistake.
+INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR})
+
 OPTION(CMAKE_USE_OPENSSL "Use OpenSSL code with curl." OFF)
 MARK_AS_ADVANCED(CMAKE_USE_OPENSSL)
 IF(CMAKE_USE_OPENSSL)
@@ -679,8 +684,6 @@
 
 # The rest of the build
 
-INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR})
 OPTION(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" TRUE)
 IF(CMAKE_BUILD_CURL_SHARED)
   SET(LIBRARY_TYPE SHARED)
diff --git a/Utilities/cmlibarchive/.gitattributes b/Utilities/cmlibarchive/.gitattributes
index be7062b..562b12e 100644
--- a/Utilities/cmlibarchive/.gitattributes
+++ b/Utilities/cmlibarchive/.gitattributes
@@ -1,2 +1 @@
-*.h              whitespace=indent-with-non-tab,-blank-at-eol
-*.c              whitespace=indent-with-non-tab,-blank-at-eol
+* -whitespace
diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt
index 132bfeb..9b1533d 100644
--- a/Utilities/cmlibarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/CMakeLists.txt
@@ -28,11 +28,12 @@
 SET(VERSION                    "${_major}.${_trimmed_minor}.${_trimmed_revision}${_quality}")
 SET(BSDCPIO_VERSION_STRING     "${VERSION}")
 SET(BSDTAR_VERSION_STRING      "${VERSION}")
+SET(BSDCAT_VERSION_STRING      "${VERSION}")
 SET(LIBARCHIVE_VERSION_NUMBER  "${_version_number}")
 SET(LIBARCHIVE_VERSION_STRING  "${VERSION}")
 
 # INTERFACE_VERSION increments with every release
-# libarchive 2.7 == interface version 9 = 2 + 7 
+# libarchive 2.7 == interface version 9 = 2 + 7
 # libarchive 2.8 == interface version 10 = 2 + 8
 # libarchive 2.9 == interface version 11 = 2 + 9
 # libarchive 3.0 == interface version 12
@@ -69,6 +70,13 @@
 
 OPTION(ENABLE_NETTLE "Enable use of Nettle" ON)
 OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
+OPTION(ENABLE_LZMA "Enable the use of the system found LZMA library if found" ON)
+OPTION(ENABLE_ZLIB "Enable the use of the system found ZLIB library if found" ON)
+OPTION(ENABLE_BZip2 "Enable the use of the system found BZip2 library if found" ON)
+OPTION(ENABLE_EXPAT "Enable the use of the system found EXPAT library if found" ON)
+OPTION(ENABLE_PCREPOSIX "Enable the use of the system found PCREPOSIX library if found" ON)
+OPTION(ENABLE_LibGCC "Enable the use of the system found LibGCC library if found" ON)
+
 OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
 OPTION(ENABLE_ACL "Enable ACL support" ON)
 OPTION(ENABLE_ICONV "Enable iconv support" ON)
@@ -190,7 +198,7 @@
   #--- zconf.h.orig	2005-07-21 00:40:26.000000000
   #+++ zconf.h	2009-01-19 11:39:10.093750000
   #@@ -286,7 +286,7 @@
-  # 
+  #
   # #if 1           /* HAVE_UNISTD_H -- this line is updated by ./configure */
   # #  include <sys/types.h> /* for off_t */
   #-#  include <unistd.h>    /* for SEEK_* and off_t */
@@ -204,7 +212,11 @@
 #
 # Find ZLIB
 #
-FIND_PACKAGE(ZLIB)
+IF(ENABLE_ZLIB)
+  FIND_PACKAGE(ZLIB)
+ELSE()
+  SET(ZLIB_FOUND FALSE) # Override cached value
+ENDIF()
 IF(ZLIB_FOUND)
   SET(HAVE_LIBZ 1)
   SET(HAVE_ZLIB_H 1)
@@ -239,7 +251,11 @@
 #
 # Find BZip2
 #
-FIND_PACKAGE(BZip2)
+IF(ENABLE_BZip2)
+  FIND_PACKAGE(BZip2)
+ELSE()
+  SET(BZIP2_FOUND FALSE) # Override cached value
+ENDIF()
 IF(BZIP2_FOUND)
   SET(HAVE_LIBBZ2 1)
   SET(HAVE_BZLIB_H 1)
@@ -263,7 +279,13 @@
 #
 # Find LZMA
 #
-FIND_PACKAGE(LZMA)
+IF(ENABLE_LZMA)
+  FIND_PACKAGE(LZMA)
+ELSE()
+  SET(LZMA_FOUND FALSE) # Override cached value
+  SET(LZMADEC_FOUND FALSE) # Override cached value
+ENDIF()
+
 IF(LZMA_FOUND)
   SET(HAVE_LIBLZMA 1)
   SET(HAVE_LZMA_H 1)
@@ -283,6 +305,8 @@
   SET(HAVE_LZMADEC_H 1)
   INCLUDE_DIRECTORIES(${LZMADEC_INCLUDE_DIR})
   LIST(APPEND ADDITIONAL_LIBS ${LZMADEC_LIBRARIES})
+ELSE(LZMA_FOUND)
+# LZMA not found and will not be used.
 ENDIF(LZMA_FOUND)
 #
 # Find LZO2
@@ -327,7 +351,11 @@
 LA_CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
 
 # Alphabetize the rest unless there's a compelling reason
-LA_CHECK_INCLUDE_FILE("acl/libacl.h" HAVE_ACL_LIBACL_H)
+IF(ENABLE_ACL)
+  LA_CHECK_INCLUDE_FILE("acl/libacl.h" HAVE_ACL_LIBACL_H)
+ELSE(ENABLE_ACL)
+  SET(HAVE_ACL_LIBACL_H FALSE)
+ENDIF(ENABLE_ACL)
 LA_CHECK_INCLUDE_FILE("ctype.h" HAVE_CTYPE_H)
 LA_CHECK_INCLUDE_FILE("copyfile.h" HAVE_COPYFILE_H)
 LA_CHECK_INCLUDE_FILE("direct.h" HAVE_DIRECT_H)
@@ -510,16 +538,10 @@
 	FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c" "${SOURCE}")
 	MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}")
 
-    IF(CMAKE_REQUIRED_LINKER_FLAGS)
-      SET(CHECK_CRYPTO_ADD_LINKER_FLAGS
-        "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
-    ELSE(CMAKE_REQUIRED_LINKER_FLAGS)
-      SET(CHECK_CRYPTO_ADD_LINKER_FLAGS)
-    ENDIF(CMAKE_REQUIRED_LINKER_FLAGS)
 	TRY_COMPILE(ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}
 	  ${CMAKE_BINARY_DIR}
 	  ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c
-	  CMAKE_FLAGS ${CHECK_CRYPTO_ADD_LINKER_FLAGS}
+	  CMAKE_FLAGS
 	   "${TRY_CRYPTO_REQUIRED_LIBS}"
 	   "${TRY_CRYPTO_REQUIRED_INCLUDES}"
 	  OUTPUT_VARIABLE OUTPUT)
@@ -604,16 +626,10 @@
 	FILE(WRITE "${SOURCE_FILE}" "${SOURCE}")
 	MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN")
 
-    IF(CMAKE_REQUIRED_LINKER_FLAGS)
-      SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS
-        "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
-    ELSE(CMAKE_REQUIRED_LINKER_FLAGS)
-      SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS)
-    ENDIF(CMAKE_REQUIRED_LINKER_FLAGS)
 	TRY_COMPILE(ARCHIVE_CRYPTO_${CRYPTO}_WIN
 	  ${CMAKE_BINARY_DIR}
 	  ${SOURCE_FILE}
-	  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive" ${CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS}
+	  CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive"
 	  OUTPUT_VARIABLE OUTPUT)
 
 	IF (ARCHIVE_CRYPTO_${CRYPTO}_WIN)
@@ -1030,13 +1046,13 @@
 CHECK_TYPE_SIZE("__int64" __INT64)
 CHECK_TYPE_SIZE("unsigned __int64" UNSIGNED___INT64)
 
-CHECK_TYPE_SIZE(int16_t INT16_T) 
+CHECK_TYPE_SIZE(int16_t INT16_T)
 CHECK_TYPE_SIZE(int32_t INT32_T)
 CHECK_TYPE_SIZE(int64_t INT64_T)
 CHECK_TYPE_SIZE(intmax_t INTMAX_T)
-CHECK_TYPE_SIZE(uint8_t UINT8_T) 
-CHECK_TYPE_SIZE(uint16_t UINT16_T) 
-CHECK_TYPE_SIZE(uint32_t UINT32_T) 
+CHECK_TYPE_SIZE(uint8_t UINT8_T)
+CHECK_TYPE_SIZE(uint16_t UINT16_T)
+CHECK_TYPE_SIZE(uint32_t UINT32_T)
 CHECK_TYPE_SIZE(uint64_t UINT64_T)
 CHECK_TYPE_SIZE(uintmax_t UINTMAX_T)
 
diff --git a/Utilities/cmlibarchive/README-CMake.txt b/Utilities/cmlibarchive/README-CMake.txt
index ab105f0..8f3b29b 100644
--- a/Utilities/cmlibarchive/README-CMake.txt
+++ b/Utilities/cmlibarchive/README-CMake.txt
@@ -11,7 +11,7 @@
 Update libarchive from upstream as follows.  Create a local branch to
 explicitly reference the upstream snapshot branch head:
 
- git branch libarchive-upstream 35df7c8b
+ git branch libarchive-upstream 37f225b7
 
 Use a temporary directory to checkout the branch:
 
@@ -24,7 +24,7 @@
 Now place the (reduced) libarchive content in this directory.  See
 instructions shown by
 
- git log 35df7c8b
+ git log 37f225b7
 
 for help extracting the content from the upstream svn repo.  Then run
 the following commands to commit the new version.  Substitute the
@@ -34,8 +34,8 @@
 
  GIT_AUTHOR_NAME='LibArchive Upstream' \
  GIT_AUTHOR_EMAIL='libarchive-discuss@googlegroups.com' \
- GIT_AUTHOR_DATE='2013-02-09 12:17:57 -0500' \
- git commit -m 'libarchive 3.1.2 (reduced)' &&
+ GIT_AUTHOR_DATE='Mon Apr 14 19:19:05 2014 -0700' \
+ git commit -m 'libarchive 3.1.2-246-ga5a5d28b (reduced)' &&
  git commit --amend
 
 Edit the commit message to describe the procedure used to obtain the
diff --git a/Utilities/cmlibarchive/build/cmake/CreatePkgConfigFile.cmake b/Utilities/cmlibarchive/build/cmake/CreatePkgConfigFile.cmake
new file mode 100644
index 0000000..f96bbef
--- /dev/null
+++ b/Utilities/cmlibarchive/build/cmake/CreatePkgConfigFile.cmake
@@ -0,0 +1,31 @@
+# - Generate a libarchive.pc like autotools for pkg-config
+#
+
+# Set the required variables (we use the same input file as autotools)
+SET(prefix ${CMAKE_INSTALL_PREFIX})
+SET(exec_prefix \${prefix})
+SET(libdir \${exec_prefix}/lib)
+SET(includedir \${prefix}/include)
+# Now, this is not particularly pretty, nor is it terribly accurate...
+# Loop over all our additional libs
+FOREACH(mylib ${ADDITIONAL_LIBS})
+	# Extract the filename from the absolute path
+	GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE)
+	# Strip the lib prefix
+	STRING(REGEX REPLACE "^lib" "" mylib_name ${mylib_name})
+	# Append it to our LIBS string
+	SET(LIBS "${LIBS} -l${mylib_name}")
+ENDFOREACH()
+# libxml2 is easier, since it's already using pkg-config
+FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS})
+	SET(LIBS "${LIBS} ${mylib}")
+ENDFOREACH()
+# FIXME: The order of the libraries doesn't take dependencies into account,
+#	 thus there's a good chance it'll make some binutils versions unhappy...
+#	 This only affects Libs.private (looked up for static builds) though.
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in
+		${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
+		@ONLY)
+# And install it, of course ;).
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
+	DESTINATION "lib/pkgconfig")
diff --git a/Utilities/cmlibarchive/build/cmake/LibarchiveCodeCoverage.cmake b/Utilities/cmlibarchive/build/cmake/LibarchiveCodeCoverage.cmake
new file mode 100644
index 0000000..297b886
--- /dev/null
+++ b/Utilities/cmlibarchive/build/cmake/LibarchiveCodeCoverage.cmake
@@ -0,0 +1,68 @@
+#################################################################
+# Adds a build target called "coverage" for code coverage.
+#
+# This compiles the code using special GCC flags, run the tests,
+# and then generates a nice HTML output. This new "coverage" make
+# target will only be available if you build using GCC in Debug
+# mode. If any of the required programs (lcov and genhtml) were
+# not found, a FATAL_ERROR message is printed.
+#
+# If not already done, this code will set ENABLE_TEST to ON.
+#
+# To build the code coverage and open it in your browser do this:
+#
+#    mkdir debug
+#    cd debug
+#    cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
+#    make -j4
+#    make coverage
+#    xdg-open coverage/index.html
+#################################################################
+
+# Find programs we need 
+FIND_PROGRAM(LCOV_EXECUTABLE lcov DOC "Full path to lcov executable")
+FIND_PROGRAM(GENHTML_EXECUTABLE genhtml DOC "Full path to genhtml executable")
+MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
+
+# Check, compiler, build types and programs are available
+IF(NOT CMAKE_COMPILER_IS_GNUCC)
+MESSAGE(FATAL_ERROR "Coverage can only be built on GCC")
+ELSEIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+MESSAGE(FATAL_ERROR "Coverage can only be built in Debug mode")
+ELSEIF(NOT LCOV_EXECUTABLE)
+MESSAGE(FATAL_ERROR "lcov executable not found")
+ELSEIF(NOT GENHTML_EXECUTABLE)
+MESSAGE(FATAL_ERROR "genhtml executable not found")
+ENDIF(NOT CMAKE_COMPILER_IS_GNUCC)
+
+# Enable testing if not already done
+SET(ENABLE_TEST ON)
+
+#################################################################
+# Set special compiler and linker flags for test coverage
+#################################################################
+# 0. Enable debug: -g
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
+# 1. Disable optimizations: -O0
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
+# 2. Enable all kind of warnings:
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W")
+# 3. Enable special coverage flag (HINT: --coverage is a synonym for -fprofile-arcs -ftest-coverage)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
+#################################################################
+
+ADD_CUSTOM_TARGET(coverage
+COMMAND ${CMAKE_COMMAND} -E echo "Beginning test coverage. Output is written to coverage.log."
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-1/5: Reset all execution counts to zero"
+COMMAND ${LCOV_EXECUTABLE} --directory . --zerocounters > coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-2/5: Run testrunner"
+COMMAND ${CMAKE_CTEST_COMMAND} >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-3/5: Collect coverage data"
+COMMAND ${LCOV_EXECUTABLE} --capture --directory . --output-file "./coverage.info" >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-4/5: Generate HTML from coverage data"
+COMMAND ${GENHTML_EXECUTABLE} "coverage.info" --title="libarchive-${LIBARCHIVE_VERSION_STRING}" --show-details --legend --output-directory "./coverage"  >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-5/5: Open test coverage HTML output in browser: xdg-open ./coverage/index.html"
+COMMENT "Runs testrunner and generates coverage output (formats: .info and .html)")
+
diff --git a/Utilities/cmlibarchive/build/cmake/config.h.in b/Utilities/cmlibarchive/build/cmake/config.h.in
index 750ae66..32a29d0 100644
--- a/Utilities/cmlibarchive/build/cmake/config.h.in
+++ b/Utilities/cmlibarchive/build/cmake/config.h.in
@@ -292,6 +292,9 @@
 /* Version number of bsdtar */
 #cmakedefine BSDTAR_VERSION_STRING "${BSDTAR_VERSION_STRING}"
 
+/* Version number of bsdcat */
+#cmakedefine BSDCAT_VERSION_STRING "${BSDCAT_VERSION_STRING}"
+
 /* Define to 1 if you have the `acl_create_entry' function. */
 #cmakedefine HAVE_ACL_CREATE_ENTRY 1
 
@@ -1112,8 +1115,13 @@
 #cmakedefine _LARGE_FILES ${_LARGE_FILES}
 
 /* Define for Windows to use Windows 2000+ APIs. */
+#ifndef _WIN32_WINNT
 #cmakedefine _WIN32_WINNT ${_WIN32_WINNT}
+#endif // _WIN32_WINNT
+
+#ifndef WINVER
 #cmakedefine WINVER ${WINVER}
+#endif // WINVER
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #cmakedefine const ${const}
diff --git a/Utilities/cmlibarchive/libarchive/CMakeLists.txt b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
index 42781bc..8908a62 100644
--- a/Utilities/cmlibarchive/libarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
@@ -35,6 +35,8 @@
   archive_match.c
   archive_options.c
   archive_options_private.h
+  archive_pack_dev.h
+  archive_pack_dev.c
   archive_pathmatch.c
   archive_pathmatch.h
   archive_platform.h
@@ -52,6 +54,7 @@
   archive_read_disk_private.h
   archive_read_disk_set_standard_lookup.c
   archive_read_extract.c
+  archive_read_extract2.c
   archive_read_open_fd.c
   archive_read_open_file.c
   archive_read_open_filename.c
@@ -125,6 +128,7 @@
   archive_write_set_format_iso9660.c
   archive_write_set_format_mtree.c
   archive_write_set_format_pax.c
+  archive_write_set_format_raw.c
   archive_write_set_format_shar.c
   archive_write_set_format_ustar.c
   archive_write_set_format_v7tar.c
diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h
index 1a1d32a..9cf762d 100644
--- a/Utilities/cmlibarchive/libarchive/archive.h
+++ b/Utilities/cmlibarchive/libarchive/archive.h
@@ -54,7 +54,7 @@
 
 /* Get appropriate definitions of standard POSIX-style types. */
 /* These should match the types used in 'struct stat' */
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
 # define	__LA_INT64_T	__int64
 # if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
 #  define	__LA_SSIZE_T	ssize_t
@@ -137,6 +137,11 @@
 #define	ARCHIVE_VERSION_STRING "libarchive 3.1.2"
 __LA_DECL const char *	archive_version_string(void);
 
+/*
+ * Detailed textual name/version of the library and its dependencies.
+ */
+__LA_DECL const char *	archive_version_details(void);
+
 /* Declare our basic types. */
 struct archive;
 struct archive_entry;
@@ -289,6 +294,30 @@
 #define	ARCHIVE_FORMAT_RAR			0xD0000
 #define	ARCHIVE_FORMAT_7ZIP			0xE0000
 
+/*
+ * Codes returned by archive_read_format_capabilities().
+ *
+ * This list can be extended with values between 0 and 0xffff.
+ * The original purpose of this list was to let different archive
+ * format readers expose their general capabilities in terms of
+ * encryption.
+ */
+#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
+#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0)  /* reader can detect encrypted data */
+#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1)  /* reader can detect encryptable metadata (pathname, mtime, etc.) */
+
+/*
+ * Codes returned by archive_read_has_encrypted_entries().
+ *
+ * In case the archive does not support encryption detection at all
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
+ * for some other reason (e.g. not enough bytes read) cannot say if
+ * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
+ * is returned.
+ */
+#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
+#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1
+
 /*-
  * Basic outline for reading an archive:
  *   1) Ask archive_read_new for an archive reader object.
@@ -374,7 +403,15 @@
 __LA_DECL int archive_read_support_format_raw(struct archive *);
 __LA_DECL int archive_read_support_format_tar(struct archive *);
 __LA_DECL int archive_read_support_format_xar(struct archive *);
+/* archive_read_support_format_zip() enables both streamable and seekable
+ * zip readers. */
 __LA_DECL int archive_read_support_format_zip(struct archive *);
+/* Reads Zip archives as stream from beginning to end.  Doesn't
+ * correctly handle SFX ZIP files or ZIP archives that have been modified
+ * in-place. */
+__LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
+/* Reads starting from central directory; requires seekable input. */
+__LA_DECL int archive_read_support_format_zip_seekable(struct archive *);
 
 /* Functions to manually set the format and filters to be used. This is
  * useful to bypass the bidding process when the format and filters to use
@@ -470,6 +507,32 @@
  */
 __LA_DECL __LA_INT64_T		 archive_read_header_position(struct archive *);
 
+/*
+ * Returns 1 if the archive contains at least one encrypted entry.
+ * If the archive format not support encryption at all
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
+ * If for any other reason (e.g. not enough data read so far)
+ * we cannot say whether there are encrypted entries, then
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
+ * In general, this function will return values below zero when the
+ * reader is uncertain or totally uncapable of encryption support.
+ * When this function returns 0 you can be sure that the reader
+ * supports encryption detection but no encrypted entries have
+ * been found yet.
+ *
+ * NOTE: If the metadata/header of an archive is also encrypted, you
+ * cannot rely on the number of encrypted entries. That is why this
+ * function does not return the number of encrypted entries but#
+ * just shows that there are some.
+ */
+__LA_DECL int	archive_read_has_encrypted_entries(struct archive *);
+
+/*
+ * Returns a bitmask of capabilities that are supported by the archive format reader.
+ * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
+ */
+__LA_DECL int		 archive_read_format_capabilities(struct archive *);
+
 /* Read data from the body of an entry.  Similar to read(2). */
 __LA_DECL __LA_SSIZE_T		 archive_read_data(struct archive *,
 				    void *, size_t);
@@ -674,6 +737,7 @@
 /* TODO: int archive_write_set_format_old_tar(struct archive *); */
 __LA_DECL int archive_write_set_format_pax(struct archive *);
 __LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
+__LA_DECL int archive_write_set_format_raw(struct archive *);
 __LA_DECL int archive_write_set_format_shar(struct archive *);
 __LA_DECL int archive_write_set_format_shar_dump(struct archive *);
 __LA_DECL int archive_write_set_format_ustar(struct archive *);
@@ -883,6 +947,10 @@
 		    int (*_metadata_filter_func)(struct archive *, void *,
 		    	struct archive_entry *), void *_client_data);
 
+/* Simplified cleanup interface;
+ * This calls archive_read_free() or archive_write_free() as needed. */
+__LA_DECL int	archive_free(struct archive *);
+
 /*
  * Accessor functions to read/set various information in
  * the struct archive object:
@@ -1029,6 +1097,10 @@
 __LA_DECL int	archive_match_include_gname_w(struct archive *,
 		    const wchar_t *);
 
+/* Utility functions */
+/* Convenience function to sort a NULL terminated list of strings */
+__LA_DECL int archive_utility_string_sort(char **);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.c b/Utilities/cmlibarchive/libarchive/archive_entry.c
index 386e51d..293c701 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.c
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.c
@@ -201,6 +201,9 @@
 	entry2->ae_set = entry->ae_set;
 	archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname);
 
+	/* Copy encryption status */
+	entry2->encryption = entry->encryption;
+	
 	/* Copy ACL data over. */
 	archive_acl_copy(&entry2->acl, &entry->acl);
 
@@ -695,6 +698,24 @@
 	return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc));
 }
 
+int
+archive_entry_is_data_encrypted(struct archive_entry *entry)
+{
+	return ((entry->encryption & AE_ENCRYPTION_DATA) == AE_ENCRYPTION_DATA);
+}
+
+int
+archive_entry_is_metadata_encrypted(struct archive_entry *entry)
+{
+	return ((entry->encryption & AE_ENCRYPTION_METADATA) == AE_ENCRYPTION_METADATA);
+}
+
+int
+archive_entry_is_encrypted(struct archive_entry *entry)
+{
+	return (entry->encryption & (AE_ENCRYPTION_DATA|AE_ENCRYPTION_METADATA));
+}
+
 /*
  * Functions to set archive_entry properties.
  */
@@ -1216,6 +1237,26 @@
 	return (0);
 }
 
+void
+archive_entry_set_is_data_encrypted(struct archive_entry *entry, char is_encrypted)
+{
+	if (is_encrypted) {
+		entry->encryption |= AE_ENCRYPTION_DATA;
+	} else {
+		entry->encryption &= ~AE_ENCRYPTION_DATA;
+	}
+}
+
+void
+archive_entry_set_is_metadata_encrypted(struct archive_entry *entry, char is_encrypted)
+{
+	if (is_encrypted) {
+		entry->encryption |= AE_ENCRYPTION_METADATA;
+	} else {
+		entry->encryption &= ~AE_ENCRYPTION_METADATA;
+	}
+}
+
 int
 _archive_entry_copy_uname_l(struct archive_entry *entry,
     const char *name, size_t len, struct archive_string_conv *sc)
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h
index 85ea885..efc4d73 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.h
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.h
@@ -43,12 +43,8 @@
 #include <stddef.h>  /* for wchar_t */
 #include <time.h>
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <windows.h>
-#endif
-
 /* Get a suitable 64-bit integer type. */
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
 # define	__LA_INT64_T	__int64
 #else
 #include <unistd.h>
@@ -63,7 +59,7 @@
 #if ARCHIVE_VERSION_NUMBER >= 3999000
 /* Switch to plain 'int' for libarchive 4.0.  It's less broken than 'mode_t' */
 # define	__LA_MODE_T	int
-#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__)
+#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
 # define	__LA_MODE_T	unsigned short
 #else
 # define	__LA_MODE_T	mode_t
@@ -235,6 +231,9 @@
 __LA_DECL __LA_INT64_T	 archive_entry_uid(struct archive_entry *);
 __LA_DECL const char	*archive_entry_uname(struct archive_entry *);
 __LA_DECL const wchar_t	*archive_entry_uname_w(struct archive_entry *);
+__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *);
+__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *);
+__LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
 
 /*
  * Set fields in an archive_entry.
@@ -248,7 +247,7 @@
 __LA_DECL void	archive_entry_set_atime(struct archive_entry *, time_t, long);
 __LA_DECL void  archive_entry_unset_atime(struct archive_entry *);
 #if defined(_WIN32) && !defined(__CYGWIN__)
-__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
+__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, struct _BY_HANDLE_FILE_INFORMATION *);
 #endif
 __LA_DECL void	archive_entry_set_birthtime(struct archive_entry *, time_t, long);
 __LA_DECL void  archive_entry_unset_birthtime(struct archive_entry *);
@@ -306,6 +305,8 @@
 __LA_DECL void	archive_entry_copy_uname(struct archive_entry *, const char *);
 __LA_DECL void	archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
 __LA_DECL int	archive_entry_update_uname_utf8(struct archive_entry *, const char *);
+__LA_DECL void	archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted);
+__LA_DECL void	archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted);
 /*
  * Routines to bulk copy fields to/from a platform-native "struct
  * stat."  Libarchive used to just store a struct stat inside of each
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_private.h b/Utilities/cmlibarchive/libarchive/archive_entry_private.h
index e3547c3..c69233e 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_private.h
@@ -154,6 +154,11 @@
 	/* Not used within libarchive; useful for some clients. */
 	struct archive_mstring ae_sourcepath;	/* Path this entry is sourced from. */
 
+#define AE_ENCRYPTION_NONE 0
+#define AE_ENCRYPTION_DATA 1
+#define AE_ENCRYPTION_METADATA 2
+	char encryption;
+	
 	void *mac_metadata;
 	size_t mac_metadata_size;
 
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c b/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
index 10c5447..fed74f5 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
@@ -58,7 +58,7 @@
 	if (offset < 0 || length < 0)
 		/* Invalid value */
 		return;
-	if (offset + length < 0 ||
+	if (offset > INT64_MAX - length ||
 	    offset + length > archive_entry_size(entry))
 		/* A value of "length" parameter is too large. */
 		return;
diff --git a/Utilities/cmlibarchive/libarchive/archive_getdate.c b/Utilities/cmlibarchive/libarchive/archive_getdate.c
index f8b5a28..aaa9d6f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_getdate.c
+++ b/Utilities/cmlibarchive/libarchive/archive_getdate.c
@@ -369,8 +369,8 @@
 	    && gds->tokenp[1].token == tSEC_UNIT) {
 		/* "1 day" */
 		gds->HaveRel++;
-		gds->RelSeconds += gds->tokenp[1].value * gds->tokenp[2].value;
-		gds->tokenp += 3;
+		gds->RelSeconds += gds->tokenp[0].value * gds->tokenp[1].value;
+		gds->tokenp += 2;
 		return 1;
 	}
 	if (gds->tokenp[0].token == '-'
@@ -403,7 +403,7 @@
 		/* "now", "tomorrow" */
 		gds->HaveRel++;
 		gds->RelSeconds += gds->tokenp[0].value;
-		++gds->tokenp;
+		gds->tokenp += 1;
 		return 1;
 	}
 	if (gds->tokenp[0].token == tMONTH_UNIT) {
@@ -1022,10 +1022,11 @@
 main(int argc, char **argv)
 {
     time_t	d;
+    time_t	now = time(NULL);
 
     while (*++argv != NULL) {
 	    (void)printf("Input: %s\n", *argv);
-	    d = get_date(*argv);
+	    d = get_date(now, *argv);
 	    if (d == -1)
 		    (void)printf("Bad format - couldn't convert.\n");
 	    else
diff --git a/Utilities/cmlibarchive/libarchive/archive_match.c b/Utilities/cmlibarchive/libarchive/archive_match.c
index 6b6be9c..6fb8644 100644
--- a/Utilities/cmlibarchive/libarchive/archive_match.c
+++ b/Utilities/cmlibarchive/libarchive/archive_match.c
@@ -1152,7 +1152,7 @@
 {
 	/* NOTE: stat() on Windows cannot handle nano seconds. */
 	HANDLE h;
-	WIN32_FIND_DATA d;
+	WIN32_FIND_DATAA d;
 
 	if (path == NULL || *path == '\0') {
 		archive_set_error(&(a->archive), EINVAL, "pathname is empty");
diff --git a/Utilities/cmlibarchive/libarchive/archive_pack_dev.c b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
new file mode 100644
index 0000000..6b7b472
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
@@ -0,0 +1,329 @@
+/*	$NetBSD: pack_dev.c,v 1.12 2013/06/14 16:28:20 tsutsui Exp $	*/
+
+/*-
+ * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Originally from NetBSD's mknod(8) source. */
+
+#include "archive_platform.h"
+
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if !defined(lint)
+__RCSID("$NetBSD$");
+#endif /* not lint */
+
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "archive_pack_dev.h"
+
+static	pack_t	pack_netbsd;
+static	pack_t	pack_freebsd;
+static	pack_t	pack_8_8;
+static	pack_t	pack_12_20;
+static	pack_t	pack_14_18;
+static	pack_t	pack_8_24;
+static	pack_t	pack_bsdos;
+static	int	compare_format(const void *, const void *);
+
+static const char iMajorError[] = "invalid major number";
+static const char iMinorError[] = "invalid minor number";
+static const char tooManyFields[] = "too many fields for format";
+
+/* This is blatantly stolen from libarchive/archive_entry.c,
+ * in an attempt to get this to play nice on MinGW... */
+#if !defined(HAVE_MAJOR) && !defined(major)
+/* Replacement for major/minor/makedev. */
+#define major(x) ((int)(0x00ff & ((x) >> 8)))
+#define minor(x) ((int)(0xffff00ff & (x)))
+#define makedev(maj,min) ((0xff00 & ((maj)<<8)) | (0xffff00ff & (min)))
+#endif
+
+/* Play games to come up with a suitable makedev() definition. */
+#ifdef __QNXNTO__
+/* QNX.  <sigh> */
+#include <sys/netmgr.h>
+#define apd_makedev(maj, min) makedev(ND_LOCAL_NODE, (maj), (min))
+#elif defined makedev
+/* There's a "makedev" macro. */
+#define apd_makedev(maj, min) makedev((maj), (min))
+#elif defined mkdev || ((defined _WIN32 || defined __WIN32__) && !defined(__CYGWIN__))
+/* Windows. <sigh> */
+#define apd_makedev(maj, min) mkdev((maj), (min))
+#else
+/* There's a "makedev" function. */
+#define apd_makedev(maj, min) makedev((maj), (min))
+#endif
+
+/* exported */
+dev_t
+pack_native(int n, unsigned long numbers[], const char **error)
+{
+	dev_t dev = 0;
+
+	if (n == 2) {
+		dev = apd_makedev(numbers[0], numbers[1]);
+		if ((unsigned long)major(dev) != numbers[0])
+			*error = iMajorError;
+		else if ((unsigned long)minor(dev) != numbers[1])
+			*error = iMinorError;
+	} else
+		*error = tooManyFields;
+	return (dev);
+}
+
+
+static dev_t
+pack_netbsd(int n, unsigned long numbers[], const char **error)
+{
+	dev_t dev = 0;
+
+	if (n == 2) {
+		dev = makedev_netbsd(numbers[0], numbers[1]);
+		if ((unsigned long)major_netbsd(dev) != numbers[0])
+			*error = iMajorError;
+		else if ((unsigned long)minor_netbsd(dev) != numbers[1])
+			*error = iMinorError;
+	} else
+		*error = tooManyFields;
+	return (dev);
+}
+
+
+#define	major_freebsd(x)	((int32_t)(((x) & 0x0000ff00) >> 8))
+#define	minor_freebsd(x)	((int32_t)(((x) & 0xffff00ff) >> 0))
+#define	makedev_freebsd(x,y)	((dev_t)((((x) << 8) & 0x0000ff00) | \
+					 (((y) << 0) & 0xffff00ff)))
+
+static dev_t
+pack_freebsd(int n, unsigned long numbers[], const char **error)
+{
+	dev_t dev = 0;
+
+	if (n == 2) {
+		dev = makedev_freebsd(numbers[0], numbers[1]);
+		if ((unsigned long)major_freebsd(dev) != numbers[0])
+			*error = iMajorError;
+		if ((unsigned long)minor_freebsd(dev) != numbers[1])
+			*error = iMinorError;
+	} else
+		*error = tooManyFields;
+	return (dev);
+}
+
+
+#define	major_8_8(x)		((int32_t)(((x) & 0x0000ff00) >> 8))
+#define	minor_8_8(x)		((int32_t)(((x) & 0x000000ff) >> 0))
+#define	makedev_8_8(x,y)	((dev_t)((((x) << 8) & 0x0000ff00) | \
+					 (((y) << 0) & 0x000000ff)))
+
+static dev_t
+pack_8_8(int n, unsigned long numbers[], const char **error)
+{
+	dev_t dev = 0;
+
+	if (n == 2) {
+		dev = makedev_8_8(numbers[0], numbers[1]);
+		if ((unsigned long)major_8_8(dev) != numbers[0])
+			*error = iMajorError;
+		if ((unsigned long)minor_8_8(dev) != numbers[1])
+			*error = iMinorError;
+	} else
+		*error = tooManyFields;
+	return (dev);
+}
+
+
+#define	major_12_20(x)		((int32_t)(((x) & 0xfff00000) >> 20))
+#define	minor_12_20(x)		((int32_t)(((x) & 0x000fffff) >>  0))
+#define	makedev_12_20(x,y)	((dev_t)((((x) << 20) & 0xfff00000) | \
+					 (((y) <<  0) & 0x000fffff)))
+
+static dev_t
+pack_12_20(int n, unsigned long numbers[], const char **error)
+{
+	dev_t dev = 0;
+
+	if (n == 2) {
+		dev = makedev_12_20(numbers[0], numbers[1]);
+		if ((unsigned long)major_12_20(dev) != numbers[0])
+			*error = iMajorError;
+		if ((unsigned long)minor_12_20(dev) != numbers[1])
+			*error = iMinorError;
+	} else
+		*error = tooManyFields;
+	return (dev);
+}
+
+
+#define	major_14_18(x)		((int32_t)(((x) & 0xfffc0000) >> 18))
+#define	minor_14_18(x)		((int32_t)(((x) & 0x0003ffff) >>  0))
+#define	makedev_14_18(x,y)	((dev_t)((((x) << 18) & 0xfffc0000) | \
+					 (((y) <<  0) & 0x0003ffff)))
+
+static dev_t
+pack_14_18(int n, unsigned long numbers[], const char **error)
+{
+	dev_t dev = 0;
+
+	if (n == 2) {
+		dev = makedev_14_18(numbers[0], numbers[1]);
+		if ((unsigned long)major_14_18(dev) != numbers[0])
+			*error = iMajorError;
+		if ((unsigned long)minor_14_18(dev) != numbers[1])
+			*error = iMinorError;
+	} else
+		*error = tooManyFields;
+	return (dev);
+}
+
+
+#define	major_8_24(x)		((int32_t)(((x) & 0xff000000) >> 24))
+#define	minor_8_24(x)		((int32_t)(((x) & 0x00ffffff) >>  0))
+#define	makedev_8_24(x,y)	((dev_t)((((x) << 24) & 0xff000000) | \
+					 (((y) <<  0) & 0x00ffffff)))
+
+static dev_t
+pack_8_24(int n, unsigned long numbers[], const char **error)
+{
+	dev_t dev = 0;
+
+	if (n == 2) {
+		dev = makedev_8_24(numbers[0], numbers[1]);
+		if ((unsigned long)major_8_24(dev) != numbers[0])
+			*error = iMajorError;
+		if ((unsigned long)minor_8_24(dev) != numbers[1])
+			*error = iMinorError;
+	} else
+		*error = tooManyFields;
+	return (dev);
+}
+
+
+#define	major_12_12_8(x)	((int32_t)(((x) & 0xfff00000) >> 20))
+#define	unit_12_12_8(x)		((int32_t)(((x) & 0x000fff00) >>  8))
+#define	subunit_12_12_8(x)	((int32_t)(((x) & 0x000000ff) >>  0))
+#define	makedev_12_12_8(x,y,z)	((dev_t)((((x) << 20) & 0xfff00000) | \
+					 (((y) <<  8) & 0x000fff00) | \
+					 (((z) <<  0) & 0x000000ff)))
+
+static dev_t
+pack_bsdos(int n, unsigned long numbers[], const char **error)
+{
+	dev_t dev = 0;
+
+	if (n == 2) {
+		dev = makedev_12_20(numbers[0], numbers[1]);
+		if ((unsigned long)major_12_20(dev) != numbers[0])
+			*error = iMajorError;
+		if ((unsigned long)minor_12_20(dev) != numbers[1])
+			*error = iMinorError;
+	} else if (n == 3) {
+		dev = makedev_12_12_8(numbers[0], numbers[1], numbers[2]);
+		if ((unsigned long)major_12_12_8(dev) != numbers[0])
+			*error = iMajorError;
+		if ((unsigned long)unit_12_12_8(dev) != numbers[1])
+			*error = "invalid unit number";
+		if ((unsigned long)subunit_12_12_8(dev) != numbers[2])
+			*error = "invalid subunit number";
+	} else
+		*error = tooManyFields;
+	return (dev);
+}
+
+
+		/* list of formats and pack functions */
+		/* this list must be sorted lexically */
+static struct format {
+	const char	*name;
+	pack_t		*pack;
+} formats[] = {
+	{"386bsd",  pack_8_8},
+	{"4bsd",    pack_8_8},
+	{"bsdos",   pack_bsdos},
+	{"freebsd", pack_freebsd},
+	{"hpux",    pack_8_24},
+	{"isc",     pack_8_8},
+	{"linux",   pack_8_8},
+	{"native",  pack_native},
+	{"netbsd",  pack_netbsd},
+	{"osf1",    pack_12_20},
+	{"sco",     pack_8_8},
+	{"solaris", pack_14_18},
+	{"sunos",   pack_8_8},
+	{"svr3",    pack_8_8},
+	{"svr4",    pack_14_18},
+	{"ultrix",  pack_8_8},
+};
+
+static int
+compare_format(const void *key, const void *element)
+{
+	const char		*name;
+	const struct format	*format;
+
+	name = key;
+	format = element;
+
+	return (strcmp(name, format->name));
+}
+
+
+pack_t *
+pack_find(const char *name)
+{
+	struct format	*format;
+
+	format = bsearch(name, formats,
+	    sizeof(formats)/sizeof(formats[0]),
+	    sizeof(formats[0]), compare_format);
+	if (format == 0)
+		return (NULL);
+	return (format->pack);
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_pack_dev.h b/Utilities/cmlibarchive/libarchive/archive_pack_dev.h
new file mode 100644
index 0000000..749fd3d
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_pack_dev.h
@@ -0,0 +1,49 @@
+/*	$NetBSD: pack_dev.h,v 1.8 2013/06/14 16:28:20 tsutsui Exp $	*/
+
+/*-
+ * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Originally from NetBSD's mknod(8) source. */
+
+#ifndef	_PACK_DEV_H
+#define	_PACK_DEV_H
+
+typedef	dev_t pack_t(int, unsigned long [], const char **);
+
+pack_t	*pack_find(const char *);
+pack_t	 pack_native;
+
+#define	major_netbsd(x)		((int32_t)((((x) & 0x000fff00) >>  8)))
+#define	minor_netbsd(x)		((int32_t)((((x) & 0xfff00000) >> 12) | \
+					   (((x) & 0x000000ff) >>  0)))
+#define	makedev_netbsd(x,y)	((dev_t)((((x) <<  8) & 0x000fff00) | \
+					 (((y) << 12) & 0xfff00000) | \
+					 (((y) <<  0) & 0x000000ff)))
+
+#endif	/* _PACK_DEV_H */
diff --git a/Utilities/cmlibarchive/libarchive/archive_platform.h b/Utilities/cmlibarchive/libarchive/archive_platform.h
index cdd9c7c..cbe08ec 100644
--- a/Utilities/cmlibarchive/libarchive/archive_platform.h
+++ b/Utilities/cmlibarchive/libarchive/archive_platform.h
@@ -66,15 +66,18 @@
  * headers as required.
  */
 
-/* Get a real definition for __FBSDID if we can */
+/* Get a real definition for __FBSDID or __RCSID if we can */
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
 
-/* If not, define it so as to avoid dangling semicolons. */
+/* If not, define them so as to avoid dangling semicolons. */
 #ifndef __FBSDID
 #define	__FBSDID(a)     struct _undefined_hack
 #endif
+#ifndef __RCSID
+#define	__RCSID(a)     struct _undefined_hack
+#endif
 
 /* Old glibc mbsnrtowcs fails assertions in our use case.  */
 #if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 1
diff --git a/Utilities/cmlibarchive/libarchive/archive_read.c b/Utilities/cmlibarchive/libarchive/archive_read.c
index 796d37d..a65b94d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read.c
@@ -747,6 +747,59 @@
 }
 
 /*
+ * Returns 1 if the archive contains at least one encrypted entry.
+ * If the archive format not support encryption at all
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
+ * If for any other reason (e.g. not enough data read so far)
+ * we cannot say whether there are encrypted entries, then
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
+ * In general, this function will return values below zero when the
+ * reader is uncertain or totally uncapable of encryption support.
+ * When this function returns 0 you can be sure that the reader
+ * supports encryption detection but no encrypted entries have
+ * been found yet.
+ *
+ * NOTE: If the metadata/header of an archive is also encrypted, you
+ * cannot rely on the number of encrypted entries. That is why this
+ * function does not return the number of encrypted entries but#
+ * just shows that there are some.
+ */
+int
+archive_read_has_encrypted_entries(struct archive *_a)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	int format_supports_encryption = archive_read_format_capabilities(_a)
+			& (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+
+	if (!_a || !format_supports_encryption) {
+		/* Format in general doesn't support encryption */
+		return ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED;
+	}
+
+	/* A reader potentially has read enough data now. */
+	if (a->format && a->format->has_encrypted_entries) {
+		return (a->format->has_encrypted_entries)(a);
+	}
+
+	/* For any other reason we cannot say how many entries are there. */
+	return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+}
+
+/*
+ * Returns a bitmask of capabilities that are supported by the archive format reader.
+ * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
+ */
+int
+archive_read_format_capabilities(struct archive *_a)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	if (a && a->format && a->format->format_capabilties) {
+		return (a->format->format_capabilties)(a);
+	}
+	return ARCHIVE_READ_FORMAT_CAPS_NONE;
+}
+
+/*
  * Read data from an archive entry, using a read(2)-style interface.
  * This is a convenience routine that just calls
  * archive_read_data_block and copies the results into the client
@@ -1094,7 +1147,9 @@
     int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
     int (*read_data_skip)(struct archive_read *),
     int64_t (*seek_data)(struct archive_read *, int64_t, int),
-    int (*cleanup)(struct archive_read *))
+    int (*cleanup)(struct archive_read *),
+    int (*format_capabilities)(struct archive_read *),
+    int (*has_encrypted_entries)(struct archive_read *))
 {
 	int i, number_slots;
 
@@ -1117,6 +1172,8 @@
 			a->formats[i].cleanup = cleanup;
 			a->formats[i].data = format_data;
 			a->formats[i].name = name;
+			a->formats[i].format_capabilties = format_capabilities;
+			a->formats[i].has_encrypted_entries = has_encrypted_entries;
 			return (ARCHIVE_OK);
 		}
 	}
@@ -1557,10 +1614,9 @@
 			client->dataset[++cursor].begin_position = r;
 		}
 		offset -= client->dataset[cursor].begin_position;
-		if (offset < 0)
-			offset = 0;
-		else if (offset > client->dataset[cursor].total_size - 1)
-			offset = client->dataset[cursor].total_size - 1;
+		if (offset < 0
+		    || offset > client->dataset[cursor].total_size)
+			return ARCHIVE_FATAL;
 		if ((r = client_seek_proxy(filter, offset, SEEK_SET)) < 0)
 			return r;
 		break;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
index e984aaa..e81cbec 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
@@ -399,7 +399,7 @@
 #endif
 
 
-#if defined(HAVE_POSIX_ACL) && defined(ACL_TYPE_NFS4)
+#ifdef HAVE_POSIX_ACL
 static int translate_acl(struct archive_read_disk *a,
     struct archive_entry *entry, acl_t acl, int archive_entry_acl_type);
 
@@ -419,6 +419,7 @@
 
 	archive_entry_acl_clear(entry);
 
+#ifdef ACL_TYPE_NFS4
 	/* Try NFS4 ACL first. */
 	if (*fd >= 0)
 		acl = acl_get_fd(*fd);
@@ -447,6 +448,7 @@
 		acl_free(acl);
 		return (ARCHIVE_OK);
 	}
+#endif
 
 	/* Retrieve access ACL from file. */
 	if (*fd >= 0)
@@ -492,6 +494,7 @@
         {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
         {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
         {ARCHIVE_ENTRY_ACL_READ, ACL_READ},
+#ifdef ACL_TYPE_NFS4
         {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
         {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
         {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
@@ -508,8 +511,10 @@
         {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
         {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
         {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+#endif
 };
 
+#ifdef ACL_TYPE_NFS4
 static struct {
         int archive_inherit;
         int platform_inherit;
@@ -519,21 +524,25 @@
 	{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
 	{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY}
 };
-
+#endif
 static int
 translate_acl(struct archive_read_disk *a,
     struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
 {
 	acl_tag_t	 acl_tag;
+#ifdef ACL_TYPE_NFS4
 	acl_entry_type_t acl_type;
 	acl_flagset_t	 acl_flagset;
+	int brand, r;
+#endif
 	acl_entry_t	 acl_entry;
 	acl_permset_t	 acl_permset;
-	int		 brand, i, r, entry_acl_type;
+	int		 i, entry_acl_type;
 	int		 s, ae_id, ae_tag, ae_perm;
 	const char	*ae_name;
 
 
+#ifdef ACL_TYPE_NFS4
 	// FreeBSD "brands" ACLs as POSIX.1e or NFSv4
 	// Make sure the "brand" on this ACL is consistent
 	// with the default_entry_acl_type bits provided.
@@ -560,6 +569,7 @@
 		return ARCHIVE_FAILED;
 		break;
 	}
+#endif
 
 
 	s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
@@ -592,9 +602,11 @@
 		case ACL_OTHER:
 			ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
 			break;
+#ifdef ACL_TYPE_NFS4
 		case ACL_EVERYONE:
 			ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
 			break;
+#endif
 		default:
 			/* Skip types that libarchive can't support. */
 			s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
@@ -605,6 +617,7 @@
 		// XXX acl_get_entry_type_np on FreeBSD returns EINVAL for
 		// non-NFSv4 ACLs
 		entry_acl_type = default_entry_acl_type;
+#ifdef ACL_TYPE_NFS4
 		r = acl_get_entry_type_np(acl_entry, &acl_type);
 		if (r == 0) {
 			switch (acl_type) {
@@ -634,9 +647,10 @@
 				ae_perm |= acl_inherit_map[i].archive_inherit;
 
                 }
+#endif
 
 		acl_get_permset(acl_entry, &acl_permset);
-                for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
+		for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
 			/*
 			 * acl_get_perm() is spelled differently on different
 			 * platforms; see above.
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
index a13dbbf..94eb5e7 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
@@ -1973,7 +1973,7 @@
 	static volatile int can_dupfd_cloexec = 1;
 
 	if (can_dupfd_cloexec) {
-		new_fd = fcntl(fd, F_DUPFD_CLOEXEC);
+		new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
 		if (new_fd != -1)
 			return (new_fd);
 		/* Linux 2.6.18 - 2.6.23 declare F_DUPFD_CLOEXEC,
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
index 9c5420d..5c0f366 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
@@ -929,7 +929,7 @@
 		else
 			flags |= FILE_FLAG_SEQUENTIAL_SCAN;
 		t->entry_fh = CreateFileW(tree_current_access_path(t),
-		    GENERIC_READ, 0, NULL, OPEN_EXISTING, flags, NULL);
+		    GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, flags, NULL);
 		if (t->entry_fh == INVALID_HANDLE_VALUE) {
 			archive_set_error(&a->archive, errno,
 			    "Couldn't open %ls", tree_current_path(a->tree));
@@ -1886,7 +1886,7 @@
 	
 	if (sim_lstat && tree_current_is_physical_link(t))
 		flag |= FILE_FLAG_OPEN_REPARSE_POINT;
-	h = CreateFileW(tree_current_access_path(t), 0, 0, NULL,
+	h = CreateFileW(tree_current_access_path(t), 0, FILE_SHARE_READ, NULL,
 	    OPEN_EXISTING, flag, NULL);
 	if (h == INVALID_HANDLE_VALUE) {
 		la_dosmaperr(GetLastError());
@@ -2115,7 +2115,7 @@
 			} else
 				desiredAccess = GENERIC_READ;
 
-			h = CreateFileW(path, desiredAccess, 0, NULL,
+			h = CreateFileW(path, desiredAccess, FILE_SHARE_READ, NULL,
 			    OPEN_EXISTING, flag, NULL);
 			if (h == INVALID_HANDLE_VALUE) {
 				la_dosmaperr(GetLastError());
@@ -2162,7 +2162,7 @@
 		if (fd >= 0) {
 			h = (HANDLE)_get_osfhandle(fd);
 		} else {
-			h = CreateFileW(path, GENERIC_READ, 0, NULL,
+			h = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL,
 			    OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
 			if (h == INVALID_HANDLE_VALUE) {
 				la_dosmaperr(GetLastError());
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_extract.c b/Utilities/cmlibarchive/libarchive/archive_read_extract.c
index 795f2ab..ce76a6c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_extract.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_extract.c
@@ -26,146 +26,40 @@
 #include "archive_platform.h"
 __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $");
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
 
 #include "archive.h"
 #include "archive_entry.h"
 #include "archive_private.h"
 #include "archive_read_private.h"
-#include "archive_write_disk_private.h"
-
-struct extract {
-	struct archive *ad; /* archive_write_disk object */
-
-	/* Progress function invoked during extract. */
-	void			(*extract_progress)(void *);
-	void			 *extract_progress_user_data;
-};
 
 static int	archive_read_extract_cleanup(struct archive_read *);
-static int	copy_data(struct archive *ar, struct archive *aw);
-static struct extract *get_extract(struct archive_read *);
-
-static struct extract *
-get_extract(struct archive_read *a)
-{
-	/* If we haven't initialized, do it now. */
-	/* This also sets up a lot of global state. */
-	if (a->extract == NULL) {
-		a->extract = (struct extract *)malloc(sizeof(*a->extract));
-		if (a->extract == NULL) {
-			archive_set_error(&a->archive, ENOMEM, "Can't extract");
-			return (NULL);
-		}
-		memset(a->extract, 0, sizeof(*a->extract));
-		a->extract->ad = archive_write_disk_new();
-		if (a->extract->ad == NULL) {
-			archive_set_error(&a->archive, ENOMEM, "Can't extract");
-			return (NULL);
-		}
-		archive_write_disk_set_standard_lookup(a->extract->ad);
-		a->cleanup_archive_extract = archive_read_extract_cleanup;
-	}
-	return (a->extract);
-}
 
 int
 archive_read_extract(struct archive *_a, struct archive_entry *entry, int flags)
 {
-	struct extract *extract;
+	struct archive_read_extract *extract;
+	struct archive_read * a = (struct archive_read *)_a;
 
-	extract = get_extract((struct archive_read *)_a);
+	extract = __archive_read_get_extract(a);
 	if (extract == NULL)
 		return (ARCHIVE_FATAL);
-	archive_write_disk_set_options(extract->ad, flags);
-	return (archive_read_extract2(_a, entry, extract->ad));
-}
 
-int
-archive_read_extract2(struct archive *_a, struct archive_entry *entry,
-    struct archive *ad)
-{
-	struct archive_read *a = (struct archive_read *)_a;
-	int r, r2;
-
-	/* Set up for this particular entry. */
-	if (a->skip_file_set)
-		archive_write_disk_set_skip_file(ad,
-		    a->skip_file_dev, a->skip_file_ino);
-	r = archive_write_header(ad, entry);
-	if (r < ARCHIVE_WARN)
-		r = ARCHIVE_WARN;
-	if (r != ARCHIVE_OK)
-		/* If _write_header failed, copy the error. */
- 		archive_copy_error(&a->archive, ad);
-	else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0)
-		/* Otherwise, pour data into the entry. */
-		r = copy_data(_a, ad);
-	r2 = archive_write_finish_entry(ad);
-	if (r2 < ARCHIVE_WARN)
-		r2 = ARCHIVE_WARN;
-	/* Use the first message. */
-	if (r2 != ARCHIVE_OK && r == ARCHIVE_OK)
-		archive_copy_error(&a->archive, ad);
-	/* Use the worst error return. */
-	if (r2 < r)
-		r = r2;
-	return (r);
-}
-
-void
-archive_read_extract_set_progress_callback(struct archive *_a,
-    void (*progress_func)(void *), void *user_data)
-{
-	struct archive_read *a = (struct archive_read *)_a;
-	struct extract *extract = get_extract(a);
-	if (extract != NULL) {
-		extract->extract_progress = progress_func;
-		extract->extract_progress_user_data = user_data;
-	}
-}
-
-static int
-copy_data(struct archive *ar, struct archive *aw)
-{
-	int64_t offset;
-	const void *buff;
-	struct extract *extract;
-	size_t size;
-	int r;
-
-	extract = get_extract((struct archive_read *)ar);
-	if (extract == NULL)
-		return (ARCHIVE_FATAL);
-	for (;;) {
-		r = archive_read_data_block(ar, &buff, &size, &offset);
-		if (r == ARCHIVE_EOF)
-			return (ARCHIVE_OK);
-		if (r != ARCHIVE_OK)
-			return (r);
-		r = (int)archive_write_data_block(aw, buff, size, offset);
-		if (r < ARCHIVE_WARN)
-			r = ARCHIVE_WARN;
-		if (r != ARCHIVE_OK) {
-			archive_set_error(ar, archive_errno(aw),
-			    "%s", archive_error_string(aw));
-			return (r);
+	/* If we haven't initialized the archive_write_disk object, do it now. */
+	if (extract->ad == NULL) {
+		extract->ad = archive_write_disk_new();
+		if (extract->ad == NULL) {
+			archive_set_error(&a->archive, ENOMEM, "Can't extract");
+			return (ARCHIVE_FATAL);
 		}
-		if (extract->extract_progress)
-			(extract->extract_progress)
-			    (extract->extract_progress_user_data);
+		archive_write_disk_set_standard_lookup(extract->ad);
+		a->cleanup_archive_extract = archive_read_extract_cleanup;
 	}
+
+	archive_write_disk_set_options(extract->ad, flags);
+	return (archive_read_extract2(&a->archive, entry, extract->ad));
 }
 
 /*
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_extract2.c b/Utilities/cmlibarchive/libarchive/archive_read_extract2.c
new file mode 100644
index 0000000..3c65e80
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_read_extract2.c
@@ -0,0 +1,137 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $");
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+static int	copy_data(struct archive *ar, struct archive *aw);
+
+/* Retrieve an extract object without initialising the associated
+ * archive_write_disk object.
+ */
+struct archive_read_extract *
+__archive_read_get_extract(struct archive_read *a)
+{
+	if (a->extract == NULL) {
+		a->extract = (struct archive_read_extract *)malloc(sizeof(*a->extract));
+		if (a->extract == NULL) {
+			archive_set_error(&a->archive, ENOMEM, "Can't extract");
+			return (NULL);
+		}
+		memset(a->extract, 0, sizeof(*a->extract));
+	}
+	return (a->extract);
+}
+
+int
+archive_read_extract2(struct archive *_a, struct archive_entry *entry,
+    struct archive *ad)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	int r, r2;
+
+	/* Set up for this particular entry. */
+	if (a->skip_file_set)
+		archive_write_disk_set_skip_file(ad,
+		    a->skip_file_dev, a->skip_file_ino);
+	r = archive_write_header(ad, entry);
+	if (r < ARCHIVE_WARN)
+		r = ARCHIVE_WARN;
+	if (r != ARCHIVE_OK)
+		/* If _write_header failed, copy the error. */
+ 		archive_copy_error(&a->archive, ad);
+	else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0)
+		/* Otherwise, pour data into the entry. */
+		r = copy_data(_a, ad);
+	r2 = archive_write_finish_entry(ad);
+	if (r2 < ARCHIVE_WARN)
+		r2 = ARCHIVE_WARN;
+	/* Use the first message. */
+	if (r2 != ARCHIVE_OK && r == ARCHIVE_OK)
+		archive_copy_error(&a->archive, ad);
+	/* Use the worst error return. */
+	if (r2 < r)
+		r = r2;
+	return (r);
+}
+
+void
+archive_read_extract_set_progress_callback(struct archive *_a,
+    void (*progress_func)(void *), void *user_data)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	struct archive_read_extract *extract = __archive_read_get_extract(a);
+	if (extract != NULL) {
+		extract->extract_progress = progress_func;
+		extract->extract_progress_user_data = user_data;
+	}
+}
+
+static int
+copy_data(struct archive *ar, struct archive *aw)
+{
+	int64_t offset;
+	const void *buff;
+	struct archive_read_extract *extract;
+	size_t size;
+	int r;
+
+	extract = __archive_read_get_extract((struct archive_read *)ar);
+	if (extract == NULL)
+		return (ARCHIVE_FATAL);
+	for (;;) {
+		r = archive_read_data_block(ar, &buff, &size, &offset);
+		if (r == ARCHIVE_EOF)
+			return (ARCHIVE_OK);
+		if (r != ARCHIVE_OK)
+			return (r);
+		r = (int)archive_write_data_block(aw, buff, size, offset);
+		if (r < ARCHIVE_WARN)
+			r = ARCHIVE_WARN;
+		if (r != ARCHIVE_OK) {
+			archive_set_error(ar, archive_errno(aw),
+			    "%s", archive_error_string(aw));
+			return (r);
+		}
+		if (extract->extract_progress)
+			(extract->extract_progress)
+			    (extract->extract_progress_user_data);
+	}
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_private.h b/Utilities/cmlibarchive/libarchive/archive_read_private.h
index 8a6c859..27e203b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_read_private.h
@@ -142,6 +142,14 @@
 	struct archive_read_data_node *dataset;
 };
 
+struct archive_read_extract {
+	struct archive *ad; /* archive_write_disk object */
+
+	/* Progress function invoked during extract. */
+	void			(*extract_progress)(void *);
+	void			 *extract_progress_user_data;
+};
+
 struct archive_read {
 	struct archive	archive;
 
@@ -207,26 +215,30 @@
 		int	(*read_data_skip)(struct archive_read *);
 		int64_t	(*seek_data)(struct archive_read *, int64_t, int);
 		int	(*cleanup)(struct archive_read *);
+		int	(*format_capabilties)(struct archive_read *);
+		int	(*has_encrypted_entries)(struct archive_read *);
 	}	formats[16];
 	struct archive_format_descriptor	*format; /* Active format. */
 
 	/*
 	 * Various information needed by archive_extract.
 	 */
-	struct extract		 *extract;
+	struct archive_read_extract		*extract;
 	int			(*cleanup_archive_extract)(struct archive_read *);
 };
 
 int	__archive_read_register_format(struct archive_read *a,
-	    void *format_data,
-	    const char *name,
-	    int (*bid)(struct archive_read *, int),
-	    int (*options)(struct archive_read *, const char *, const char *),
-	    int (*read_header)(struct archive_read *, struct archive_entry *),
-	    int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
-	    int (*read_data_skip)(struct archive_read *),
-	    int64_t (*seek_data)(struct archive_read *, int64_t, int),
-	    int (*cleanup)(struct archive_read *));
+		void *format_data,
+		const char *name,
+		int (*bid)(struct archive_read *, int),
+		int (*options)(struct archive_read *, const char *, const char *),
+		int (*read_header)(struct archive_read *, struct archive_entry *),
+		int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
+		int (*read_data_skip)(struct archive_read *),
+		int64_t (*seek_data)(struct archive_read *, int64_t, int),
+		int (*cleanup)(struct archive_read *),
+		int (*format_capabilities)(struct archive_read *),
+		int (*has_encrypted_entries)(struct archive_read *));
 
 int __archive_read_get_bidder(struct archive_read *a,
     struct archive_read_filter_bidder **bidder);
@@ -241,4 +253,5 @@
 int __archive_read_program(struct archive_read_filter *, const char *);
 void __archive_read_free_filters(struct archive_read *);
 int  __archive_read_close_filters(struct archive_read *);
+struct archive_read_extract *__archive_read_get_extract(struct archive_read *);
 #endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_set_options.3 b/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
index 6fe9f90..1a251ce 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
@@ -193,6 +193,28 @@
 .Cm !rockridge
 to disable.
 .El
+.It Format tar
+.Bl -tag -compact -width indent
+.It Cm compat-2x
+Libarchive 2.x incorrectly encoded Unicode filenames on
+some platforms.
+This option mimics the libarchive 2.x filename handling
+so that such archives can be read correctly.
+.It Cm hdrcharset
+The value is used as a character set name that will be
+used when translating filenames.
+.It Cm mac-ext
+Support Mac OS metadata extension that records data in special
+files beginning with a period and underscore.
+Defaults to enabled on Mac OS, disabled on other platforms.
+Use
+.Cm !mac-ext
+to disable.
+.It Cm read_concatenated_archives
+Ignore zeroed blocks in the archive, which occurs when multiple tar archives
+have been concatenated together.  Without this option, only the contents of
+the first concatenated archive would be read.
+.El
 .El
 .\"
 .Sh ERRORS
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_set_options.c b/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
index 793f8f7..46678b1 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
@@ -78,7 +78,7 @@
 	struct archive_read *a = (struct archive_read *)_a;
 	struct archive_format_descriptor *format;
 	size_t i;
-	int r, rv = ARCHIVE_WARN;
+	int r, rv = ARCHIVE_WARN, matched_modules = 0;
 
 	for (i = 0; i < sizeof(a->formats)/sizeof(a->formats[0]); i++) {
 		format = &a->formats[i];
@@ -86,8 +86,11 @@
 		    format->name == NULL)
 			/* This format does not support option. */
 			continue;
-		if (m != NULL && strcmp(format->name, m) != 0)
-			continue;
+		if (m != NULL) {
+			if (strcmp(format->name, m) != 0)
+				continue;
+			++matched_modules;
+		}
 
 		a->format = format;
 		r = format->options(a, o, v);
@@ -96,16 +99,13 @@
 		if (r == ARCHIVE_FATAL)
 			return (ARCHIVE_FATAL);
 
-		if (m != NULL)
-			return (r);
-
 		if (r == ARCHIVE_OK)
 			rv = ARCHIVE_OK;
 	}
 	/* If the format name didn't match, return a special code for
 	 * _archive_set_option[s]. */
-	if (rv == ARCHIVE_WARN && m != NULL)
-		rv = ARCHIVE_WARN - 1;
+	if (m != NULL && matched_modules == 0)
+		return ARCHIVE_WARN - 1;
 	return (rv);
 }
 
@@ -116,7 +116,7 @@
 	struct archive_read *a = (struct archive_read *)_a;
 	struct archive_read_filter *filter;
 	struct archive_read_filter_bidder *bidder;
-	int r, rv = ARCHIVE_WARN;
+	int r, rv = ARCHIVE_WARN, matched_modules = 0;
 
 	for (filter = a->filter; filter != NULL; filter = filter->upstream) {
 		bidder = filter->bidder;
@@ -125,24 +125,24 @@
 		if (bidder->options == NULL)
 			/* This bidder does not support option */
 			continue;
-		if (m != NULL && strcmp(filter->name, m) != 0)
-			continue;
+		if (m != NULL) {
+			if (strcmp(filter->name, m) != 0)
+				continue;
+			++matched_modules;
+		}
 
 		r = bidder->options(bidder, o, v);
 
 		if (r == ARCHIVE_FATAL)
 			return (ARCHIVE_FATAL);
 
-		if (m != NULL)
-			return (r);
-
 		if (r == ARCHIVE_OK)
 			rv = ARCHIVE_OK;
 	}
 	/* If the filter name didn't match, return a special code for
 	 * _archive_set_option[s]. */
-	if (rv == ARCHIVE_WARN && m != NULL)
-		rv = ARCHIVE_WARN - 1;
+	if (m != NULL && matched_modules == 0)
+		return ARCHIVE_WARN - 1;
 	return (rv);
 }
 
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
index 7958fa5..9ef2054 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
@@ -242,10 +242,11 @@
 
 	if (version >= 0x940) {
 		unsigned level = *p++;
-		if (method == 1 && level == 0) level = 3;
-		if (method == 2 && level == 0) level = 1;
-		if (method == 3 && level == 0) level = 9;
-		if (level < 1 && level > 9) {
+		unsigned default_level[] = {0, 3, 1, 9};
+		if (level == 0)
+			/* Method is 1..3 here due to check above. */
+			level = default_level[method];
+		else if (level > 9) {
 			archive_set_error(&self->archive->archive,
 			    ARCHIVE_ERRNO_MISC, "Invalid level");
 			return (ARCHIVE_FAILED);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
index 15824b1..7bda263 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
@@ -601,7 +601,7 @@
 		return (ARCHIVE_FATAL);
 	}
 	ret = lzma_raw_decoder(&(state->stream), filters);
-#if LZMA_VERSION < 50000030
+#if LZMA_VERSION < 50010000
 	free(filters[0].options);
 #endif
 	if (ret != LZMA_OK) {
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
index 54ea245..8cd241b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
@@ -69,7 +69,11 @@
 #define _7Z_BZ2		0x040202
 #define _7Z_PPMD	0x030401
 #define _7Z_DELTA	0x03
-#define _7Z_CRYPTO	0x06F10701
+#define _7Z_CRYPTO_MAIN_ZIP			0x06F10101 /* Main Zip crypto algo */
+#define _7Z_CRYPTO_RAR_29			0x06F10303 /* Rar29 AES-128 + (modified SHA-1) */
+#define _7Z_CRYPTO_AES_256_SHA_256	0x06F10701 /* AES-256 + SHA-256 */
+
+
 #define _7Z_X86		0x03030103
 #define _7Z_X86_BCJ2	0x0303011B
 #define _7Z_POWERPC	0x03030205
@@ -322,8 +326,13 @@
 	struct archive_string_conv *sconv;
 
 	char			 format_name[64];
+
+	/* Custom value that is non-zero if this archive contains encrypted entries. */
+	int			 has_encrypted_entries;
 };
 
+static int	archive_read_format_7zip_has_encrypted_entries(struct archive_read *);
+static int	archive_read_support_format_7zip_capabilities(struct archive_read *a);
 static int	archive_read_format_7zip_bid(struct archive_read *, int);
 static int	archive_read_format_7zip_cleanup(struct archive_read *);
 static int	archive_read_format_7zip_read_data(struct archive_read *,
@@ -401,6 +410,13 @@
 		return (ARCHIVE_FATAL);
 	}
 
+	/*
+	 * Until enough data has been read, we cannot tell about
+	 * any encrypted entries yet.
+	 */
+	zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+
+
 	r = __archive_read_register_format(a,
 	    zip,
 	    "7zip",
@@ -410,7 +426,9 @@
 	    archive_read_format_7zip_read_data,
 	    archive_read_format_7zip_read_data_skip,
 	    NULL,
-	    archive_read_format_7zip_cleanup);
+	    archive_read_format_7zip_cleanup,
+	    archive_read_support_format_7zip_capabilities,
+	    archive_read_format_7zip_has_encrypted_entries);
 
 	if (r != ARCHIVE_OK)
 		free(zip);
@@ -418,6 +436,27 @@
 }
 
 static int
+archive_read_support_format_7zip_capabilities(struct archive_read * a)
+{
+	(void)a; /* UNUSED */
+	return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA |
+			ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+
+static int
+archive_read_format_7zip_has_encrypted_entries(struct archive_read *_a)
+{
+	if (_a && _a->format) {
+		struct _7zip * zip = (struct _7zip *)_a->format->data;
+		if (zip) {
+			return zip->has_encrypted_entries;
+		}
+	}
+	return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+}
+
+static int
 archive_read_format_7zip_bid(struct archive_read *a, int best_bid)
 {
 	const char *p;
@@ -476,7 +515,7 @@
 	switch ((unsigned char)p[5]) {
 	case 0x1C:
 		if (memcmp(p, _7ZIP_SIGNATURE, 6) != 0)
-			return (6); 
+			return (6);
 		/*
 		 * Test the CRC because its extraction code has 7-Zip
 		 * Magic Code, so we should do this in order not to
@@ -484,15 +523,15 @@
 		 */
 		if (crc32(0, (const unsigned char *)p + 12, 20)
 			!= archive_le32dec(p + 8))
-			return (6); 
+			return (6);
 		/* Hit the header! */
 		return (0);
-	case 0x37: return (5); 
-	case 0x7A: return (4); 
-	case 0xBC: return (3); 
-	case 0xAF: return (2); 
-	case 0x27: return (1); 
-	default: return (6); 
+	case 0x37: return (5);
+	case 0x7A: return (4);
+	case 0xBC: return (3);
+	case 0xAF: return (2);
+	case 0x27: return (1);
+	default: return (6);
 	}
 }
 
@@ -568,6 +607,19 @@
 	struct _7zip *zip = (struct _7zip *)a->format->data;
 	struct _7zip_entry *zip_entry;
 	int r, ret = ARCHIVE_OK;
+	struct _7z_folder *folder = 0;
+	uint64_t fidx = 0;
+
+	/*
+	 * It should be sufficient to call archive_read_next_header() for
+	 * a reader to determine if an entry is encrypted or not. If the
+	 * encryption of an entry is only detectable when calling
+	 * archive_read_data(), so be it. We'll do the same check there
+	 * as well.
+	 */
+	if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+		zip->has_encrypted_entries = 0;
+	}
 
 	a->archive.archive_format = ARCHIVE_FORMAT_7ZIP;
 	if (a->archive.archive_format_name == NULL)
@@ -604,6 +656,32 @@
 			return (ARCHIVE_FATAL);
 	}
 
+	/* Figure out if the entry is encrypted by looking at the folder
+	   that is associated to the current 7zip entry. If the folder
+	   has a coder with a _7Z_CRYPTO codec then the folder is encrypted.
+	   Hence the entry must also be encrypted. */
+	if (zip_entry && zip_entry->folderIndex < zip->si.ci.numFolders) {
+		folder = &(zip->si.ci.folders[zip_entry->folderIndex]);
+		for (fidx=0; folder && fidx<folder->numCoders; fidx++) {
+			switch(folder->coders[fidx].codec) {
+				case _7Z_CRYPTO_MAIN_ZIP:
+				case _7Z_CRYPTO_RAR_29:
+				case _7Z_CRYPTO_AES_256_SHA_256: {
+					archive_entry_set_is_data_encrypted(entry, 1);
+					zip->has_encrypted_entries = 1;
+					break;
+				}
+			}
+		}
+	}
+
+	/* Now that we've checked for encryption, if there were still no
+	 * encrypted entries found we can say for sure that there are none.
+	 */
+	if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+		zip->has_encrypted_entries = 0;
+	}
+
 	if (archive_entry_copy_pathname_l(entry,
 	    (const char *)zip_entry->utf16name,
 	    zip_entry->name_len, zip->sconv) != 0) {
@@ -707,6 +785,10 @@
 
 	zip = (struct _7zip *)(a->format->data);
 
+	if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+		zip->has_encrypted_entries = 0;
+	}
+
 	if (zip->pack_stream_bytes_unconsumed)
 		read_consume(a);
 
@@ -969,7 +1051,7 @@
 	{
 		lzma_options_delta delta_opt;
 		lzma_filter filters[LZMA_FILTERS_MAX];
-#if LZMA_VERSION < 50000030
+#if LZMA_VERSION < 50010000
 		lzma_filter *ff;
 #endif
 		int fi = 0;
@@ -994,7 +1076,7 @@
 		 * for BCJ+LZMA. If we were able to tell the uncompressed
 		 * size to liblzma when using lzma_raw_decoder() liblzma
 		 * could correctly deal with BCJ+LZMA. But unfortunately
-		 * there is no way to do that. 
+		 * there is no way to do that.
 		 * Discussion about this can be found at XZ Utils forum.
 		 */
 		if (coder2 != NULL) {
@@ -1056,7 +1138,7 @@
 		else
 			filters[fi].id = LZMA_FILTER_LZMA1;
 		filters[fi].options = NULL;
-#if LZMA_VERSION < 50000030
+#if LZMA_VERSION < 50010000
 		ff = &filters[fi];
 #endif
 		r = lzma_properties_decode(&filters[fi], NULL,
@@ -1070,7 +1152,7 @@
 		filters[fi].id = LZMA_VLI_UNKNOWN;
 		filters[fi].options = NULL;
 		r = lzma_raw_decoder(&(zip->lzstream), filters);
-#if LZMA_VERSION < 50000030
+#if LZMA_VERSION < 50010000
 		free(ff->options);
 #endif
 		if (r != LZMA_OK) {
@@ -1203,6 +1285,17 @@
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 		    "Unexpected codec ID: %lX", zip->codec);
 		return (ARCHIVE_FAILED);
+	case _7Z_CRYPTO_MAIN_ZIP:
+	case _7Z_CRYPTO_RAR_29:
+	case _7Z_CRYPTO_AES_256_SHA_256:
+		if (a->entry) {
+			archive_entry_set_is_metadata_encrypted(a->entry, 1);
+			archive_entry_set_is_data_encrypted(a->entry, 1);
+			zip->has_encrypted_entries = 1;
+		}
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+		    "Crypto codec not supported yet (ID: 0x%lX)", zip->codec);
+		return (ARCHIVE_FAILED);
 	default:
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 		    "Unknown codec ID: %lX", zip->codec);
@@ -1426,7 +1519,7 @@
 
 		do {
 			int sym;
-			
+
 			sym = __archive_ppmd7_functions.Ppmd7_DecodeSymbol(
 				&(zip->ppmd7_context), &(zip->range_dec.p));
 			if (sym < 0) {
@@ -2755,6 +2848,7 @@
 	zip->header_crc32 = 0;
 	zip->header_is_encoded = 0;
 	zip->header_is_being_read = 1;
+	zip->has_encrypted_entries = 0;
 	check_header_crc = 1;
 
 	if ((p = header_bytes(a, 1)) == NULL) {
@@ -3170,7 +3264,7 @@
 		return (r);
 
 	/*
-	 * Skip the bytes we alrady has skipped in skip_stream(). 
+	 * Skip the bytes we alrady has skipped in skip_stream().
 	 */
 	while (skip_bytes) {
 		ssize_t skipped;
@@ -3235,16 +3329,36 @@
 	 * Check coder types.
 	 */
 	for (i = 0; i < folder->numCoders; i++) {
-		if (folder->coders[i].codec == _7Z_CRYPTO) {
-			archive_set_error(&(a->archive),
-			    ARCHIVE_ERRNO_MISC,
-			    "The %s is encrypted, "
-			    "but currently not supported", cname);
-			return (ARCHIVE_FATAL);
+		switch(folder->coders[i].codec) {
+			case _7Z_CRYPTO_MAIN_ZIP:
+			case _7Z_CRYPTO_RAR_29:
+			case _7Z_CRYPTO_AES_256_SHA_256: {
+				/* For entry that is associated with this folder, mark
+				   it as encrypted (data+metadata). */
+				zip->has_encrypted_entries = 1;
+				if (a->entry) {
+					archive_entry_set_is_data_encrypted(a->entry, 1);
+					archive_entry_set_is_metadata_encrypted(a->entry, 1);
+				}
+				archive_set_error(&(a->archive),
+					ARCHIVE_ERRNO_MISC,
+					"The %s is encrypted, "
+					"but currently not supported", cname);
+				return (ARCHIVE_FATAL);
+			}
+			case _7Z_X86_BCJ2: {
+				found_bcj2++;
+				break;
+			}
 		}
-		if (folder->coders[i].codec == _7Z_X86_BCJ2)
-			found_bcj2++;
 	}
+	/* Now that we've checked for encryption, if there were still no
+	 * encrypted entries found we can say for sure that there are none.
+	 */
+	if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+		zip->has_encrypted_entries = 0;
+	}
+
 	if ((folder->numCoders > 2 && !found_bcj2) || found_bcj2 > 1) {
 		archive_set_error(&(a->archive),
 		    ARCHIVE_ERRNO_MISC,
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c
index 40be18c..82756c9 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c
@@ -122,7 +122,9 @@
 	    archive_read_format_ar_read_data,
 	    archive_read_format_ar_skip,
 	    NULL,
-	    archive_read_format_ar_cleanup);
+	    archive_read_format_ar_cleanup,
+	    NULL,
+	    NULL);
 
 	if (r != ARCHIVE_OK) {
 		free(ar);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
index 4dd38db..6356963 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
@@ -383,7 +383,9 @@
 	    archive_read_format_cab_read_data,
 	    archive_read_format_cab_read_data_skip,
 	    NULL,
-	    archive_read_format_cab_cleanup);
+	    archive_read_format_cab_cleanup,
+	    NULL,
+	    NULL);
 
 	if (r != ARCHIVE_OK)
 		free(cab);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
index 819f4a4..0b69689 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
@@ -243,7 +243,9 @@
 	    archive_read_format_cpio_read_data,
 	    archive_read_format_cpio_skip,
 	    NULL,
-	    archive_read_format_cpio_cleanup);
+	    archive_read_format_cpio_cleanup,
+	    NULL,
+	    NULL);
 
 	if (r != ARCHIVE_OK)
 		free(cpio);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c
index 3660738..c641eb9 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c
@@ -54,6 +54,8 @@
 	    archive_read_format_empty_read_data,
 	    NULL,
 	    NULL,
+	    NULL,
+	    NULL,
 	    NULL);
 
 	return (r);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
index 8147461..2219e61 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
@@ -478,7 +478,9 @@
 	    archive_read_format_iso9660_read_data,
 	    archive_read_format_iso9660_read_data_skip,
 	    NULL,
-	    archive_read_format_iso9660_cleanup);
+	    archive_read_format_iso9660_cleanup,
+	    NULL,
+	    NULL);
 
 	if (r != ARCHIVE_OK) {
 		free(iso9660);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
index f702949..b88731a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
@@ -320,7 +320,9 @@
 	    archive_read_format_lha_read_data,
 	    archive_read_format_lha_read_data_skip,
 	    NULL,
-	    archive_read_format_lha_cleanup);
+	    archive_read_format_lha_cleanup,
+	    NULL,
+	    NULL);
 
 	if (r != ARCHIVE_OK)
 		free(lha);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
index c4e7021..d82d4c1 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
@@ -51,6 +51,7 @@
 #include "archive_private.h"
 #include "archive_read_private.h"
 #include "archive_string.h"
+#include "archive_pack_dev.h"
 
 #ifndef O_BINARY
 #define	O_BINARY 0
@@ -103,6 +104,7 @@
 	struct archive_entry_linkresolver *resolver;
 
 	int64_t			 cur_size;
+	char checkfs;
 };
 
 static int	bid_keycmp(const char *, const char *, ssize_t);
@@ -173,6 +175,29 @@
 #endif
 }
 
+static int
+archive_read_format_mtree_options(struct archive_read *a,
+    const char *key, const char *val)
+{
+	struct mtree *mtree;
+
+	mtree = (struct mtree *)(a->format->data);
+	if (strcmp(key, "checkfs")  == 0) {
+		/* Allows to read information missing from the mtree from the file system */
+		if (val == NULL || val[0] == 0) {
+			mtree->checkfs = 0;
+		} else {
+			mtree->checkfs = 1;
+		}
+		return (ARCHIVE_OK);
+	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
+}
+
 static void
 free_options(struct mtree_option *head)
 {
@@ -205,7 +230,7 @@
 	mtree->fd = -1;
 
 	r = __archive_read_register_format(a, mtree, "mtree",
-	    mtree_bid, NULL, read_header, read_data, skip, NULL, cleanup);
+           mtree_bid, archive_read_format_mtree_options, read_header, read_data, skip, NULL, cleanup, NULL, NULL);
 
 	if (r != ARCHIVE_OK)
 		free(mtree);
@@ -367,7 +392,7 @@
 		"gid", "gname", NULL
 	};
 	static const char *keys_il[] = {
-		"ignore", "link", NULL
+		"ignore", "inode", "link", NULL
 	};
 	static const char *keys_m[] = {
 		"md5", "md5digest", "mode", NULL
@@ -376,7 +401,7 @@
 		"nlink", "nochange", "optional", NULL
 	};
 	static const char *keys_r[] = {
-		"rmd160", "rmd160digest", NULL
+		"resdevice", "rmd160", "rmd160digest", NULL
 	};
 	static const char *keys_s[] = {
 		"sha1", "sha1digest",
@@ -1103,162 +1128,164 @@
 			mtree->current_dir.length = n;
 	}
 
-	/*
-	 * Try to open and stat the file to get the real size
-	 * and other file info.  It would be nice to avoid
-	 * this here so that getting a listing of an mtree
-	 * wouldn't require opening every referenced contents
-	 * file.  But then we wouldn't know the actual
-	 * contents size, so I don't see a really viable way
-	 * around this.  (Also, we may want to someday pull
-	 * other unspecified info from the contents file on
-	 * disk.)
-	 */
-	mtree->fd = -1;
-	if (archive_strlen(&mtree->contents_name) > 0)
-		path = mtree->contents_name.s;
-	else
-		path = archive_entry_pathname(entry);
+	if (mtree->checkfs) {
+		/*
+		 * Try to open and stat the file to get the real size
+		 * and other file info.  It would be nice to avoid
+		 * this here so that getting a listing of an mtree
+		 * wouldn't require opening every referenced contents
+		 * file.  But then we wouldn't know the actual
+		 * contents size, so I don't see a really viable way
+		 * around this.  (Also, we may want to someday pull
+		 * other unspecified info from the contents file on
+		 * disk.)
+		 */
+		mtree->fd = -1;
+		if (archive_strlen(&mtree->contents_name) > 0)
+			path = mtree->contents_name.s;
+		else
+			path = archive_entry_pathname(entry);
 
-	if (archive_entry_filetype(entry) == AE_IFREG ||
-	    archive_entry_filetype(entry) == AE_IFDIR) {
-		mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
-		__archive_ensure_cloexec_flag(mtree->fd);
-		if (mtree->fd == -1 &&
-		    (errno != ENOENT ||
-		     archive_strlen(&mtree->contents_name) > 0)) {
-			archive_set_error(&a->archive, errno,
-			    "Can't open %s", path);
-			r = ARCHIVE_WARN;
-		}
-	}
-
-	st = &st_storage;
-	if (mtree->fd >= 0) {
-		if (fstat(mtree->fd, st) == -1) {
-			archive_set_error(&a->archive, errno,
-			    "Could not fstat %s", path);
-			r = ARCHIVE_WARN;
-			/* If we can't stat it, don't keep it open. */
-			close(mtree->fd);
-			mtree->fd = -1;
-			st = NULL;
-		}
-	} else if (lstat(path, st) == -1) {
-		st = NULL;
-	}
-
-	/*
-	 * Check for a mismatch between the type in the specification and
-	 * the type of the contents object on disk.
-	 */
-	if (st != NULL) {
-		if (
-		    ((st->st_mode & S_IFMT) == S_IFREG &&
-		     archive_entry_filetype(entry) == AE_IFREG)
-#ifdef S_IFLNK
-		    || ((st->st_mode & S_IFMT) == S_IFLNK &&
-			archive_entry_filetype(entry) == AE_IFLNK)
-#endif
-#ifdef S_IFSOCK
-		    || ((st->st_mode & S_IFSOCK) == S_IFSOCK &&
-			archive_entry_filetype(entry) == AE_IFSOCK)
-#endif
-#ifdef S_IFCHR
-		    || ((st->st_mode & S_IFMT) == S_IFCHR &&
-			archive_entry_filetype(entry) == AE_IFCHR)
-#endif
-#ifdef S_IFBLK
-		    || ((st->st_mode & S_IFMT) == S_IFBLK &&
-			archive_entry_filetype(entry) == AE_IFBLK)
-#endif
-		    || ((st->st_mode & S_IFMT) == S_IFDIR &&
-			archive_entry_filetype(entry) == AE_IFDIR)
-#ifdef S_IFIFO
-		    || ((st->st_mode & S_IFMT) == S_IFIFO &&
-			archive_entry_filetype(entry) == AE_IFIFO)
-#endif
-		    ) {
-			/* Types match. */
-		} else {
-			/* Types don't match; bail out gracefully. */
-			if (mtree->fd >= 0)
-				close(mtree->fd);
-			mtree->fd = -1;
-			if (parsed_kws & MTREE_HAS_OPTIONAL) {
-				/* It's not an error for an optional entry
-				   to not match disk. */
-				*use_next = 1;
-			} else if (r == ARCHIVE_OK) {
-				archive_set_error(&a->archive,
-				    ARCHIVE_ERRNO_MISC,
-				    "mtree specification has different type for %s",
-				    archive_entry_pathname(entry));
+		if (archive_entry_filetype(entry) == AE_IFREG ||
+				archive_entry_filetype(entry) == AE_IFDIR) {
+			mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
+			__archive_ensure_cloexec_flag(mtree->fd);
+			if (mtree->fd == -1 &&
+					(errno != ENOENT ||
+					 archive_strlen(&mtree->contents_name) > 0)) {
+				archive_set_error(&a->archive, errno,
+						"Can't open %s", path);
 				r = ARCHIVE_WARN;
 			}
-			return r;
 		}
-	}
 
-	/*
-	 * If there is a contents file on disk, pick some of the metadata
-	 * from that file.  For most of these, we only set it from the contents
-	 * if it wasn't already parsed from the specification.
-	 */
-	if (st != NULL) {
-		if (((parsed_kws & MTREE_HAS_DEVICE) == 0 ||
-		     (parsed_kws & MTREE_HAS_NOCHANGE) != 0) &&
-		    (archive_entry_filetype(entry) == AE_IFCHR ||
-		     archive_entry_filetype(entry) == AE_IFBLK))
-			archive_entry_set_rdev(entry, st->st_rdev);
-		if ((parsed_kws & (MTREE_HAS_GID | MTREE_HAS_GNAME)) == 0 ||
-		    (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
-			archive_entry_set_gid(entry, st->st_gid);
-		if ((parsed_kws & (MTREE_HAS_UID | MTREE_HAS_UNAME)) == 0 ||
-		    (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
-			archive_entry_set_uid(entry, st->st_uid);
-		if ((parsed_kws & MTREE_HAS_MTIME) == 0 ||
-		    (parsed_kws & MTREE_HAS_NOCHANGE) != 0) {
-#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
-			archive_entry_set_mtime(entry, st->st_mtime,
-			    st->st_mtimespec.tv_nsec);
-#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
-			archive_entry_set_mtime(entry, st->st_mtime,
-			    st->st_mtim.tv_nsec);
-#elif HAVE_STRUCT_STAT_ST_MTIME_N
-			archive_entry_set_mtime(entry, st->st_mtime,
-			    st->st_mtime_n);
-#elif HAVE_STRUCT_STAT_ST_UMTIME
-			archive_entry_set_mtime(entry, st->st_mtime,
-			    st->st_umtime*1000);
-#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
-			archive_entry_set_mtime(entry, st->st_mtime,
-			    st->st_mtime_usec*1000);
-#else
-			archive_entry_set_mtime(entry, st->st_mtime, 0);
-#endif
+		st = &st_storage;
+		if (mtree->fd >= 0) {
+			if (fstat(mtree->fd, st) == -1) {
+				archive_set_error(&a->archive, errno,
+						"Could not fstat %s", path);
+				r = ARCHIVE_WARN;
+				/* If we can't stat it, don't keep it open. */
+				close(mtree->fd);
+				mtree->fd = -1;
+				st = NULL;
+			}
+		} else if (lstat(path, st) == -1) {
+			st = NULL;
 		}
-		if ((parsed_kws & MTREE_HAS_NLINK) == 0 ||
-		    (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
-			archive_entry_set_nlink(entry, st->st_nlink);
-		if ((parsed_kws & MTREE_HAS_PERM) == 0 ||
-		    (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
-			archive_entry_set_perm(entry, st->st_mode);
-		if ((parsed_kws & MTREE_HAS_SIZE) == 0 ||
-		    (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
-			archive_entry_set_size(entry, st->st_size);
-		archive_entry_set_ino(entry, st->st_ino);
-		archive_entry_set_dev(entry, st->st_dev);
 
-		archive_entry_linkify(mtree->resolver, &entry, &sparse_entry);
-	} else if (parsed_kws & MTREE_HAS_OPTIONAL) {
 		/*
-		 * Couldn't open the entry, stat it or the on-disk type
-		 * didn't match.  If this entry is optional, just ignore it
-		 * and read the next header entry.
+		 * Check for a mismatch between the type in the specification and
+		 * the type of the contents object on disk.
 		 */
-		*use_next = 1;
-		return ARCHIVE_OK;
+		if (st != NULL) {
+			if (
+					((st->st_mode & S_IFMT) == S_IFREG &&
+					 archive_entry_filetype(entry) == AE_IFREG)
+#ifdef S_IFLNK
+					|| ((st->st_mode & S_IFMT) == S_IFLNK &&
+						archive_entry_filetype(entry) == AE_IFLNK)
+#endif
+#ifdef S_IFSOCK
+					|| ((st->st_mode & S_IFSOCK) == S_IFSOCK &&
+						archive_entry_filetype(entry) == AE_IFSOCK)
+#endif
+#ifdef S_IFCHR
+					|| ((st->st_mode & S_IFMT) == S_IFCHR &&
+						archive_entry_filetype(entry) == AE_IFCHR)
+#endif
+#ifdef S_IFBLK
+					|| ((st->st_mode & S_IFMT) == S_IFBLK &&
+						archive_entry_filetype(entry) == AE_IFBLK)
+#endif
+					|| ((st->st_mode & S_IFMT) == S_IFDIR &&
+						archive_entry_filetype(entry) == AE_IFDIR)
+#ifdef S_IFIFO
+					|| ((st->st_mode & S_IFMT) == S_IFIFO &&
+							archive_entry_filetype(entry) == AE_IFIFO)
+#endif
+					) {
+						/* Types match. */
+					} else {
+						/* Types don't match; bail out gracefully. */
+						if (mtree->fd >= 0)
+							close(mtree->fd);
+						mtree->fd = -1;
+						if (parsed_kws & MTREE_HAS_OPTIONAL) {
+							/* It's not an error for an optional entry
+							   to not match disk. */
+							*use_next = 1;
+						} else if (r == ARCHIVE_OK) {
+							archive_set_error(&a->archive,
+									ARCHIVE_ERRNO_MISC,
+									"mtree specification has different type for %s",
+									archive_entry_pathname(entry));
+							r = ARCHIVE_WARN;
+						}
+						return r;
+					}
+		}
+
+		/*
+		 * If there is a contents file on disk, pick some of the metadata
+		 * from that file.  For most of these, we only set it from the contents
+		 * if it wasn't already parsed from the specification.
+		 */
+		if (st != NULL) {
+			if (((parsed_kws & MTREE_HAS_DEVICE) == 0 ||
+						(parsed_kws & MTREE_HAS_NOCHANGE) != 0) &&
+					(archive_entry_filetype(entry) == AE_IFCHR ||
+					 archive_entry_filetype(entry) == AE_IFBLK))
+				archive_entry_set_rdev(entry, st->st_rdev);
+			if ((parsed_kws & (MTREE_HAS_GID | MTREE_HAS_GNAME)) == 0 ||
+					(parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+				archive_entry_set_gid(entry, st->st_gid);
+			if ((parsed_kws & (MTREE_HAS_UID | MTREE_HAS_UNAME)) == 0 ||
+					(parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+				archive_entry_set_uid(entry, st->st_uid);
+			if ((parsed_kws & MTREE_HAS_MTIME) == 0 ||
+					(parsed_kws & MTREE_HAS_NOCHANGE) != 0) {
+#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
+				archive_entry_set_mtime(entry, st->st_mtime,
+						st->st_mtimespec.tv_nsec);
+#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+				archive_entry_set_mtime(entry, st->st_mtime,
+						st->st_mtim.tv_nsec);
+#elif HAVE_STRUCT_STAT_ST_MTIME_N
+				archive_entry_set_mtime(entry, st->st_mtime,
+						st->st_mtime_n);
+#elif HAVE_STRUCT_STAT_ST_UMTIME
+				archive_entry_set_mtime(entry, st->st_mtime,
+						st->st_umtime*1000);
+#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
+				archive_entry_set_mtime(entry, st->st_mtime,
+						st->st_mtime_usec*1000);
+#else
+				archive_entry_set_mtime(entry, st->st_mtime, 0);
+#endif
+			}
+			if ((parsed_kws & MTREE_HAS_NLINK) == 0 ||
+					(parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+				archive_entry_set_nlink(entry, st->st_nlink);
+			if ((parsed_kws & MTREE_HAS_PERM) == 0 ||
+					(parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+				archive_entry_set_perm(entry, st->st_mode);
+			if ((parsed_kws & MTREE_HAS_SIZE) == 0 ||
+					(parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+				archive_entry_set_size(entry, st->st_size);
+			archive_entry_set_ino(entry, st->st_ino);
+			archive_entry_set_dev(entry, st->st_dev);
+
+			archive_entry_linkify(mtree->resolver, &entry, &sparse_entry);
+		} else if (parsed_kws & MTREE_HAS_OPTIONAL) {
+			/*
+			 * Couldn't open the entry, stat it or the on-disk type
+			 * didn't match.  If this entry is optional, just ignore it
+			 * and read the next header entry.
+			 */
+			*use_next = 1;
+			return ARCHIVE_OK;
+		}
 	}
 
 	mtree->cur_size = archive_entry_size(entry);
@@ -1292,33 +1319,82 @@
 
 /*
  * Device entries have one of the following forms:
- * raw dev_t
- * format,major,minor[,subdevice]
- *
- * Just use major and minor, no translation etc is done
- * between formats.
+ *  - raw dev_t
+ *  - format,major,minor[,subdevice]
+ * When parsing succeeded, `pdev' will contain the appropriate dev_t value.
  */
-static int
-parse_device(struct archive *a, struct archive_entry *entry, char *val)
-{
-	char *comma1, *comma2;
 
-	comma1 = strchr(val, ',');
-	if (comma1 == NULL) {
-		archive_entry_set_dev(entry, (dev_t)mtree_atol10(&val));
-		return (ARCHIVE_OK);
+/* strsep() is not in C90, but strcspn() is. */
+/* Taken from http://unixpapa.com/incnote/string.html */
+static char *
+la_strsep(char **sp, char *sep)
+{
+	char *p, *s;
+	if (sp == NULL || *sp == NULL || **sp == '\0')
+		return(NULL);
+	s = *sp;
+	p = s + strcspn(s, sep);
+	if (*p != '\0')
+		*p++ = '\0';
+	*sp = p;
+	return(s);
+}
+
+static int
+parse_device(dev_t *pdev, struct archive *a, char *val)
+{
+#define MAX_PACK_ARGS 3
+	unsigned long numbers[MAX_PACK_ARGS];
+	char *p, *dev;
+	int argc;
+	pack_t *pack;
+	dev_t result;
+	const char *error = NULL;
+
+	memset(pdev, 0, sizeof(*pdev));
+	if ((dev = strchr(val, ',')) != NULL) {
+		/*
+		 * Device's major/minor are given in a specified format.
+		 * Decode and pack it accordingly.
+		 */
+		*dev++ = '\0';
+		if ((pack = pack_find(val)) == NULL) {
+			archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Unknown format `%s'", val);
+			return ARCHIVE_WARN;
+		}
+		argc = 0;
+		while ((p = la_strsep(&dev, ",")) != NULL) {
+			if (*p == '\0') {
+				archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+				    "Missing number");
+				return ARCHIVE_WARN;
+			}
+			numbers[argc++] = mtree_atol(&p);
+			if (argc > MAX_PACK_ARGS) {
+				archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+				    "Too many arguments");
+				return ARCHIVE_WARN;
+			}
+		}
+		if (argc < 2) {
+			archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Not enough arguments");
+			return ARCHIVE_WARN;
+		}
+		result = (*pack)(argc, numbers, &error);
+		if (error != NULL) {
+			archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "%s", error);
+			return ARCHIVE_WARN;
+		}
+	} else {
+		/* file system raw value. */
+		result = (dev_t)mtree_atol(&val);
 	}
-	++comma1;
-	comma2 = strchr(comma1, ',');
-	if (comma2 == NULL) {
-		archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Malformed device attribute");
-		return (ARCHIVE_WARN);
-	}
-	++comma2;
-	archive_entry_set_rdevmajor(entry, (dev_t)mtree_atol(&comma1));
-	archive_entry_set_rdevminor(entry, (dev_t)mtree_atol(&comma2));
-	return (ARCHIVE_OK);
+	*pdev = result;
+	return ARCHIVE_OK;
+#undef MAX_PACK_ARGS
 }
 
 /*
@@ -1374,8 +1450,16 @@
 			break;
 	case 'd':
 		if (strcmp(key, "device") == 0) {
+			/* stat(2) st_rdev field, e.g. the major/minor IDs
+			 * of a char/block special file */
+			int r;
+			dev_t dev;
+
 			*parsed_kws |= MTREE_HAS_DEVICE;
-			return parse_device(&a->archive, entry, val);
+			r = parse_device(&dev, &a->archive, val);
+			if (r == ARCHIVE_OK)
+				archive_entry_set_rdev(entry, dev);
+			return r;
 		}
 	case 'f':
 		if (strcmp(key, "flags") == 0) {
@@ -1394,6 +1478,11 @@
 			archive_entry_copy_gname(entry, val);
 			break;
 		}
+	case 'i':
+		if (strcmp(key, "inode") == 0) {
+			archive_entry_set_ino(entry, mtree_atol10(&val));
+			break;
+		}
 	case 'l':
 		if (strcmp(key, "link") == 0) {
 			archive_entry_copy_symlink(entry, val);
@@ -1423,6 +1512,17 @@
 			break;
 		}
 	case 'r':
+		if (strcmp(key, "resdevice") == 0) {
+			/* stat(2) st_dev field, e.g. the device ID where the
+			 * inode resides */
+			int r;
+			dev_t dev;
+
+			r = parse_device(&dev, &a->archive, val);
+			if (r == ARCHIVE_OK)
+				archive_entry_set_dev(entry, dev);
+			return r;
+		}
 		if (strcmp(key, "rmd160") == 0 ||
 		    strcmp(key, "rmd160digest") == 0)
 			break;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
index dc1563d..4c56834 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
@@ -304,8 +304,15 @@
     ssize_t		 avail_in;
     const unsigned char *next_in;
   } br;
+
+  /*
+   * Custom field to denote that this archive contains encrypted entries
+   */
+  int has_encrypted_entries;
 };
 
+static int archive_read_support_format_rar_capabilities(struct archive_read *);
+static int archive_read_format_rar_has_encrypted_entries(struct archive_read *);
 static int archive_read_format_rar_bid(struct archive_read *, int);
 static int archive_read_format_rar_options(struct archive_read *,
     const char *, const char *);
@@ -646,6 +653,12 @@
   }
   memset(rar, 0, sizeof(*rar));
 
+	/*
+	 * Until enough data has been read, we cannot tell about
+	 * any encrypted entries yet.
+	 */
+	rar->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+
   r = __archive_read_register_format(a,
                                      rar,
                                      "rar",
@@ -655,7 +668,9 @@
                                      archive_read_format_rar_read_data,
                                      archive_read_format_rar_read_data_skip,
                                      archive_read_format_rar_seek_data,
-                                     archive_read_format_rar_cleanup);
+                                     archive_read_format_rar_cleanup,
+                                     archive_read_support_format_rar_capabilities,
+                                     archive_read_format_rar_has_encrypted_entries);
 
   if (r != ARCHIVE_OK)
     free(rar);
@@ -663,6 +678,27 @@
 }
 
 static int
+archive_read_support_format_rar_capabilities(struct archive_read * a)
+{
+	(void)a; /* UNUSED */
+	return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA
+			| ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+static int
+archive_read_format_rar_has_encrypted_entries(struct archive_read *_a)
+{
+	if (_a && _a->format) {
+		struct rar * rar = (struct rar *)_a->format->data;
+		if (rar) {
+			return rar->has_encrypted_entries;
+		}
+	}
+	return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+}
+
+
+static int
 archive_read_format_rar_bid(struct archive_read *a, int best_bid)
 {
   const char *p;
@@ -755,7 +791,7 @@
 {
   struct rar *rar;
   int ret = ARCHIVE_FAILED;
-        
+
   rar = (struct rar *)(a->format->data);
   if (strcmp(key, "hdrcharset")  == 0) {
     if (val == NULL || val[0] == 0)
@@ -797,6 +833,17 @@
 
   rar = (struct rar *)(a->format->data);
 
+  /*
+   * It should be sufficient to call archive_read_next_header() for
+   * a reader to determine if an entry is encrypted or not. If the
+   * encryption of an entry is only detectable when calling
+   * archive_read_data(), so be it. We'll do the same check there
+   * as well.
+   */
+  if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+	  rar->has_encrypted_entries = 0;
+  }
+
   /* RAR files can be generated without EOF headers, so return ARCHIVE_EOF if
   * this fails.
   */
@@ -857,9 +904,14 @@
                             sizeof(rar->reserved2));
       }
 
+      /* Main header is password encrytped, so we cannot read any
+         file names or any other info about files from the header. */
       if (rar->main_flags & MHD_PASSWORD)
       {
-        archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+        archive_entry_set_is_metadata_encrypted(entry, 1);
+        archive_entry_set_is_data_encrypted(entry, 1);
+        rar->has_encrypted_entries = 1;
+         archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                           "RAR encryption support unavailable.");
         return (ARCHIVE_FATAL);
       }
@@ -938,6 +990,10 @@
   struct rar *rar = (struct rar *)(a->format->data);
   int ret;
 
+  if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+	  rar->has_encrypted_entries = 0;
+  }
+
   if (rar->bytes_unconsumed > 0) {
       /* Consume as much as the decompressor actually used. */
       __archive_read_consume(a, rar->bytes_unconsumed);
@@ -957,7 +1013,7 @@
   {
   case COMPRESS_METHOD_STORE:
     ret = read_data_stored(a, buff, size, offset);
-    break; 
+    break;
 
   case COMPRESS_METHOD_FASTEST:
   case COMPRESS_METHOD_FAST:
@@ -967,13 +1023,13 @@
     ret = read_data_compressed(a, buff, size, offset);
     if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN)
       __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context, &g_szalloc);
-    break; 
+    break;
 
   default:
     archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                       "Unsupported compression method for RAR file.");
     ret = ARCHIVE_FATAL;
-    break; 
+    break;
   }
   return (ret);
 }
@@ -1290,9 +1346,14 @@
 
   if (rar->file_flags & FHD_PASSWORD)
   {
+	archive_entry_set_is_data_encrypted(entry, 1);
+	rar->has_encrypted_entries = 1;
     archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                       "RAR encryption support unavailable.");
-    return (ARCHIVE_FATAL);
+    /* Since it is only the data part itself that is encrypted we can at least
+       extract information about the currently processed entry and don't need
+       to return ARCHIVE_FATAL here. */
+    /*return (ARCHIVE_FATAL);*/
   }
 
   if (rar->file_flags & FHD_LARGE)
@@ -1377,7 +1438,7 @@
           flagbyte = *(p + offset++);
           flagbits = 8;
         }
-	
+
         flagbits -= 2;
         switch((flagbyte >> flagbits) & 3)
         {
@@ -2611,7 +2672,7 @@
     if ((symbol = read_next_symbol(a, &rar->maincode)) < 0)
       return (ARCHIVE_FATAL);
     rar->output_last_match = 0;
-    
+
     if (symbol < 256)
     {
       lzss_emit_literal(rar, symbol);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c
index 8434978..efa2c6a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c
@@ -78,7 +78,9 @@
 	    archive_read_format_raw_read_data,
 	    archive_read_format_raw_read_data_skip,
 	    NULL,
-	    archive_read_format_raw_cleanup);
+	    archive_read_format_raw_cleanup,
+	    NULL,
+	    NULL);
 	if (r != ARCHIVE_OK)
 		free(info);
 	return (r);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
index c7c808f..734424d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
@@ -151,6 +151,8 @@
 	struct archive_string_conv *sconv_default;
 	int			 init_default_conversion;
 	int			 compat_2x;
+	int			 process_mac_extensions;
+	int			 read_concatenated_archives;
 };
 
 static int	archive_block_is_null(const char *p);
@@ -241,6 +243,10 @@
 	    ARCHIVE_STATE_NEW, "archive_read_support_format_tar");
 
 	tar = (struct tar *)calloc(1, sizeof(*tar));
+#ifdef HAVE_COPYFILE_H
+	/* Set this by default on Mac OS. */
+	tar->process_mac_extensions = 1;
+#endif
 	if (tar == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
 		    "Can't allocate tar data");
@@ -254,7 +260,9 @@
 	    archive_read_format_tar_read_data,
 	    archive_read_format_tar_skip,
 	    NULL,
-	    archive_read_format_tar_cleanup);
+	    archive_read_format_tar_cleanup,
+	    NULL,
+	    NULL);
 
 	if (r != ARCHIVE_OK)
 		free(tar);
@@ -368,7 +376,7 @@
 	tar = (struct tar *)(a->format->data);
 	if (strcmp(key, "compat-2x")  == 0) {
 		/* Handle UTF-8 filnames as libarchive 2.x */
-		tar->compat_2x = (val != NULL)?1:0;
+		tar->compat_2x = (val != NULL && val[0] != 0);
 		tar->init_default_conversion = tar->compat_2x;
 		return (ARCHIVE_OK);
 	} else if (strcmp(key, "hdrcharset")  == 0) {
@@ -385,6 +393,12 @@
 				ret = ARCHIVE_FATAL;
 		}
 		return (ret);
+	} else if (strcmp(key, "mac-ext") == 0) {
+		tar->process_mac_extensions = (val != NULL && val[0] != 0);
+		return (ARCHIVE_OK);
+	} else if (strcmp(key, "read_concatenated_archives") == 0) {
+		tar->read_concatenated_archives = (val != NULL && val[0] != 0);
+		return (ARCHIVE_OK);
 	}
 
 	/* Note: The "warn" return is just to inform the options
@@ -397,7 +411,7 @@
  * how much unconsumed data we have floating around, and to consume
  * anything outstanding since we're going to do read_aheads
  */
-static void 
+static void
 tar_flush_unconsumed(struct archive_read *a, size_t *unconsumed)
 {
 	if (*unconsumed) {
@@ -590,7 +604,7 @@
 	tar = (struct tar *)(a->format->data);
 
 	bytes_skipped = __archive_read_consume(a,
-	    tar->entry_bytes_remaining + tar->entry_padding + 
+	    tar->entry_bytes_remaining + tar->entry_padding +
 	    tar->entry_bytes_unconsumed);
 	if (bytes_skipped < 0)
 		return (ARCHIVE_FATAL);
@@ -619,36 +633,50 @@
 	const struct archive_entry_header_ustar *header;
 	const struct archive_entry_header_gnutar *gnuheader;
 
-	tar_flush_unconsumed(a, unconsumed);
-
-	/* Read 512-byte header record */
-	h = __archive_read_ahead(a, 512, &bytes);
-	if (bytes < 0)
-		return ((int)bytes);
-	if (bytes == 0) { /* EOF at a block boundary. */
-		/* Some writers do omit the block of nulls. <sigh> */
-		return (ARCHIVE_EOF);
-	}
-	if (bytes < 512) {  /* Short block at EOF; this is bad. */
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Truncated tar archive");
-		return (ARCHIVE_FATAL);
-	}
-	*unconsumed = 512;
-
-	/* Check for end-of-archive mark. */
-	if (h[0] == 0 && archive_block_is_null(h)) {
-		/* Try to consume a second all-null record, as well. */
+	/* Loop until we find a workable header record. */
+	for (;;) {
 		tar_flush_unconsumed(a, unconsumed);
-		h = __archive_read_ahead(a, 512, NULL);
-		if (h != NULL)
-			__archive_read_consume(a, 512);
-		archive_clear_error(&a->archive);
+
+		/* Read 512-byte header record */
+		h = __archive_read_ahead(a, 512, &bytes);
+		if (bytes < 0)
+			return ((int)bytes);
+		if (bytes == 0) { /* EOF at a block boundary. */
+			/* Some writers do omit the block of nulls. <sigh> */
+			return (ARCHIVE_EOF);
+		}
+		if (bytes < 512) {  /* Short block at EOF; this is bad. */
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Truncated tar archive");
+			return (ARCHIVE_FATAL);
+		}
+		*unconsumed = 512;
+
+		/* Header is workable if it's not an end-of-archive mark. */
+		if (h[0] != 0 || !archive_block_is_null(h))
+			break;
+
+		/* Ensure format is set for archives with only null blocks. */
 		if (a->archive.archive_format_name == NULL) {
 			a->archive.archive_format = ARCHIVE_FORMAT_TAR;
 			a->archive.archive_format_name = "tar";
 		}
-		return (ARCHIVE_EOF);
+
+		if (!tar->read_concatenated_archives) {
+			/* Try to consume a second all-null record, as well. */
+			tar_flush_unconsumed(a, unconsumed);
+			h = __archive_read_ahead(a, 512, NULL);
+			if (h != NULL && h[0] == 0 && archive_block_is_null(h))
+				__archive_read_consume(a, 512);
+			archive_clear_error(&a->archive);
+			return (ARCHIVE_EOF);
+		}
+
+		/*
+		 * We're reading concatenated archives, ignore this block and
+		 * loop to get the next.
+		 */
 	}
 
 	/*
@@ -683,6 +711,8 @@
 		a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
 		a->archive.archive_format_name = "POSIX pax interchange format";
 		err = header_pax_global(a, tar, entry, h, unconsumed);
+		if (err == ARCHIVE_EOF)
+			return (err);
 		break;
 	case 'K': /* Long link name (GNU tar, others) */
 		err = header_longlink(a, tar, entry, h, unconsumed);
@@ -735,9 +765,9 @@
 	 * extensions for both the AppleDouble extension entry and the
 	 * regular entry.
 	 */
-	/* TODO: Should this be disabled on non-Mac platforms? */
 	if ((err == ARCHIVE_WARN || err == ARCHIVE_OK) &&
-	    tar->header_recursion_depth == 0) {
+	    tar->header_recursion_depth == 0 &&
+	    tar->process_mac_extensions) {
 		int err2 = read_mac_metadata_blob(a, tar, entry, h, unconsumed);
 		if (err2 < err)
 			err = err2;
@@ -780,12 +810,20 @@
 {
 	const unsigned char *bytes;
 	const struct archive_entry_header_ustar	*header;
-	int check, i, sum;
+	int check, sum;
+	size_t i;
 
 	(void)a; /* UNUSED */
 	bytes = (const unsigned char *)h;
 	header = (const struct archive_entry_header_ustar *)h;
 
+	/* Checksum field must hold an octal number */
+	for (i = 0; i < sizeof(header->checksum); ++i) {
+		char c = header->checksum[i];
+		if (c != ' ' && c != '\0' && (c < '0' || c > '7'))
+			return 0;
+	}
+
 	/*
 	 * Test the checksum.  Note that POSIX specifies _unsigned_
 	 * bytes for this calculation.
@@ -1277,7 +1315,7 @@
 			if (wp[0] == '/' && wp[1] != L'\0')
 				wname = wp + 1;
 		}
-		/* 
+		/*
 		 * If last path element starts with "._", then
 		 * this is a Mac extension.
 		 */
@@ -1292,7 +1330,7 @@
 			if (p[0] == '/' && p[1] != '\0')
 				name = p + 1;
 		}
-		/* 
+		/*
 		 * If last path element starts with "._", then
 		 * this is a Mac extension.
 		 */
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
index 2530e34..af89ded 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
@@ -468,7 +468,9 @@
 	    xar_read_data,
 	    xar_read_data_skip,
 	    NULL,
-	    xar_cleanup);
+	    xar_cleanup,
+	    NULL,
+	    NULL);
 	if (r != ARCHIVE_OK)
 		free(xar);
 	return (r);
@@ -967,10 +969,14 @@
 				return ((int)step);
 			xar->offset += step;
 		} else {
-			archive_set_error(&(a->archive),
-			    ARCHIVE_ERRNO_MISC,
-			    "Cannot seek.");
-			return (ARCHIVE_FAILED);
+			int64_t pos = __archive_read_seek(a, offset, SEEK_SET);
+			if (pos == ARCHIVE_FAILED) {
+				archive_set_error(&(a->archive),
+				    ARCHIVE_ERRNO_MISC,
+				    "Cannot seek.");
+				return (ARCHIVE_FAILED);
+			}
+			xar->offset = pos;
 		}
 	}
 	return (ARCHIVE_OK);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
index 2fdc08b..5ef2952 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
@@ -1,6 +1,7 @@
 /*-
- * Copyright (c) 2004 Tim Kientzle
+ * Copyright (c) 2004-2013 Tim Kientzle
  * Copyright (c) 2011-2012 Michihiro NAKAJIMA
+ * Copyright (c) 2013 Konrad Kleine
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,6 +28,20 @@
 #include "archive_platform.h"
 __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102 2009-12-28 03:11:36Z kientzle $");
 
+/*
+ * The definitive documentation of the Zip file format is:
+ *   http://www.pkware.com/documents/casestudies/APPNOTE.TXT
+ *
+ * The Info-Zip project has pioneered various extensions to better
+ * support Zip on Unix, including the 0x5455 "UT", 0x5855 "UX", 0x7855
+ * "Ux", and 0x7875 "ux" extensions for time and ownership
+ * information.
+ *
+ * History of this code: The streaming Zip reader was first added to
+ * libarchive in January 2005.  Support for seekable input sources was
+ * added in Nov 2011.
+ */
+
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -49,44 +64,61 @@
 #include "archive_crc32.h"
 #endif
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# define snprintf _snprintf
+#endif
+
 struct zip_entry {
 	struct archive_rb_node	node;
+	struct zip_entry	*next;
 	int64_t			local_header_offset;
 	int64_t			compressed_size;
 	int64_t			uncompressed_size;
 	int64_t			gid;
 	int64_t			uid;
-	struct archive_entry	*entry;
 	struct archive_string	rsrcname;
 	time_t			mtime;
 	time_t			atime;
 	time_t			ctime;
 	uint32_t		crc32;
 	uint16_t		mode;
-	uint16_t		flags;
-	char			compression;
-	char			system;
+	uint16_t		zip_flags; /* From GP Flags Field */
+	unsigned char		compression;
+	unsigned char		system; /* From "version written by" */
+	unsigned char		flags; /* Our extra markers. */
 };
 
+/* Bits used in zip_flags. */
+#define ZIP_ENCRYPTED	(1 << 0)
+#define ZIP_LENGTH_AT_END	(1 << 3)
+#define ZIP_STRONG_ENCRYPTED	(1 << 6)
+#define ZIP_UTF8_NAME	(1 << 11)
+/* See "7.2 Single Password Symmetric Encryption Method"
+   in http://www.pkware.com/documents/casestudies/APPNOTE.TXT */
+#define ZIP_CENTRAL_DIRECTORY_ENCRYPTED	(1 << 13)
+
+/* Bits used in flags. */
+#define LA_USED_ZIP64	(1 << 0)
+#define LA_FROM_CENTRAL_DIRECTORY (1 << 1)
+
 struct zip {
 	/* Structural information about the archive. */
-	int64_t			end_of_central_directory_offset;
+	char			format_name[64];
 	int64_t			central_directory_offset;
-	size_t			central_directory_size;
-	size_t			central_directory_entries;
-	char			have_central_directory;
-	int64_t			offset;
+	size_t			central_directory_entries_total;
+	size_t			central_directory_entries_on_this_disk;
+	int			has_encrypted_entries;
 
 	/* List of entries (seekable Zip only) */
-	size_t			entries_remaining;
 	struct zip_entry	*zip_entries;
-	struct zip_entry	*entry;
 	struct archive_rb_tree	tree;
 	struct archive_rb_tree	tree_rsrc;
 
+	/* Bytes read but not yet consumed via __archive_read_consume() */
 	size_t			unconsumed;
 
-	/* entry_bytes_remaining is the number of bytes we expect. */
+	/* Information about entry we're currently reading. */
+	struct zip_entry	*entry;
 	int64_t			entry_bytes_remaining;
 
 	/* These count the number of bytes actually read for the entry. */
@@ -95,852 +127,364 @@
 
 	/* Running CRC32 of the decompressed data */
 	unsigned long		entry_crc32;
+	unsigned long		(*crc32func)(unsigned long, const void *, size_t);
+	char			ignore_crc32;
 
 	/* Flags to mark progress of decompression. */
 	char			decompress_init;
 	char			end_of_entry;
 
-	ssize_t			filename_length;
-	ssize_t			extra_length;
-
+#ifdef HAVE_ZLIB_H
 	unsigned char 		*uncompressed_buffer;
 	size_t 			uncompressed_buffer_size;
-#ifdef HAVE_ZLIB_H
 	z_stream		stream;
 	char			stream_valid;
 #endif
 
-	struct archive_string	extra;
 	struct archive_string_conv *sconv;
 	struct archive_string_conv *sconv_default;
 	struct archive_string_conv *sconv_utf8;
 	int			init_default_conversion;
-	char	format_name[64];
+	int			process_mac_extensions;
 };
 
-#define ZIP_LENGTH_AT_END	8
-#define ZIP_ENCRYPTED		(1<<0)	
-#define ZIP_STRONG_ENCRYPTED	(1<<6)	
-#define ZIP_UTF8_NAME		(1<<11)	
+/* Many systems define min or MIN, but not all. */
+#define	zipmin(a,b) ((a) < (b) ? (a) : (b))
 
-static int	archive_read_format_zip_streamable_bid(struct archive_read *,
-		    int);
-static int	archive_read_format_zip_seekable_bid(struct archive_read *,
-		    int);
-static int	archive_read_format_zip_options(struct archive_read *,
-		    const char *, const char *);
-static int	archive_read_format_zip_cleanup(struct archive_read *);
-static int	archive_read_format_zip_read_data(struct archive_read *,
-		    const void **, size_t *, int64_t *);
-static int	archive_read_format_zip_read_data_skip(struct archive_read *a);
-static int	archive_read_format_zip_seekable_read_header(
-		    struct archive_read *, struct archive_entry *);
-static int	archive_read_format_zip_streamable_read_header(
-		    struct archive_read *, struct archive_entry *);
-static ssize_t	zip_get_local_file_header_size(struct archive_read *, size_t);
-#ifdef HAVE_ZLIB_H
-static int	zip_deflate_init(struct archive_read *, struct zip *);
-static int	zip_read_data_deflate(struct archive_read *a, const void **buff,
-		    size_t *size, int64_t *offset);
-#endif
-static int	zip_read_data_none(struct archive_read *a, const void **buff,
-		    size_t *size, int64_t *offset);
-static int	zip_read_local_file_header(struct archive_read *a,
-		    struct archive_entry *entry, struct zip *);
-static time_t	zip_time(const char *);
-static const char *compression_name(int compression);
-static void	process_extra(const char *, size_t, struct zip_entry *);
+/* ------------------------------------------------------------------------ */
 
-int	archive_read_support_format_zip_streamable(struct archive *);
-int	archive_read_support_format_zip_seekable(struct archive *);
+/*
+ * Common code for streaming or seeking modes.
+ *
+ * Includes code to read local file headers, decompress data
+ * from entry bodies, and common API.
+ */
 
-int
-archive_read_support_format_zip_streamable(struct archive *_a)
+static unsigned long
+real_crc32(unsigned long crc, const void *buff, size_t len)
 {
-	struct archive_read *a = (struct archive_read *)_a;
-	struct zip *zip;
-	int r;
-
-	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
-	    ARCHIVE_STATE_NEW, "archive_read_support_format_zip");
-
-	zip = (struct zip *)malloc(sizeof(*zip));
-	if (zip == NULL) {
-		archive_set_error(&a->archive, ENOMEM,
-		    "Can't allocate zip data");
-		return (ARCHIVE_FATAL);
-	}
-	memset(zip, 0, sizeof(*zip));
-
-	r = __archive_read_register_format(a,
-	    zip,
-	    "zip",
-	    archive_read_format_zip_streamable_bid,
-	    archive_read_format_zip_options,
-	    archive_read_format_zip_streamable_read_header,
-	    archive_read_format_zip_read_data,
-	    archive_read_format_zip_read_data_skip,
-	    NULL,
-	    archive_read_format_zip_cleanup);
-
-	if (r != ARCHIVE_OK)
-		free(zip);
-	return (ARCHIVE_OK);
+	return crc32(crc, buff, len);
 }
 
-int
-archive_read_support_format_zip_seekable(struct archive *_a)
+static unsigned long
+fake_crc32(unsigned long crc, const void *buff, size_t len)
 {
-	struct archive_read *a = (struct archive_read *)_a;
-	struct zip *zip;
-	int r;
-
-	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
-	    ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable");
-
-	zip = (struct zip *)malloc(sizeof(*zip));
-	if (zip == NULL) {
-		archive_set_error(&a->archive, ENOMEM,
-		    "Can't allocate zip data");
-		return (ARCHIVE_FATAL);
-	}
-	memset(zip, 0, sizeof(*zip));
-
-	r = __archive_read_register_format(a,
-	    zip,
-	    "zip",
-	    archive_read_format_zip_seekable_bid,
-	    archive_read_format_zip_options,
-	    archive_read_format_zip_seekable_read_header,
-	    archive_read_format_zip_read_data,
-	    archive_read_format_zip_read_data_skip,
-	    NULL,
-	    archive_read_format_zip_cleanup);
-
-	if (r != ARCHIVE_OK)
-		free(zip);
-	return (ARCHIVE_OK);
+	(void)crc; /* UNUSED */
+	(void)buff; /* UNUSED */
+	(void)len; /* UNUSED */
+	return 0;
 }
 
-int
-archive_read_support_format_zip(struct archive *a)
+static struct {
+	int id;
+	const char * name;
+} compression_methods[] = {
+	{0, "uncompressed"}, /* The file is stored (no compression) */
+	{1, "shrinking"}, /* The file is Shrunk */
+	{2, "reduced-1"}, /* The file is Reduced with compression factor 1 */
+	{3, "reduced-2"}, /* The file is Reduced with compression factor 2 */
+	{4, "reduced-3"}, /* The file is Reduced with compression factor 3 */
+	{5, "reduced-4"}, /* The file is Reduced with compression factor 4 */
+	{6, "imploded"}, /* The file is Imploded */
+	{7, "reserved"}, /* Reserved for Tokenizing compression algorithm */
+	{8, "deflation"}, /* The file is Deflated */
+	{9, "deflation-64-bit"}, /* Enhanced Deflating using Deflate64(tm) */
+	{10, "ibm-terse"}, /* PKWARE Data Compression Library Imploding (old IBM TERSE) */
+	{11, "reserved"}, /* Reserved by PKWARE */
+	{12, "bzip"}, /* File is compressed using BZIP2 algorithm */
+	{13, "reserved"}, /* Reserved by PKWARE */
+	{14, "lzma"}, /* LZMA (EFS) */
+	{15, "reserved"}, /* Reserved by PKWARE */
+	{16, "reserved"}, /* Reserved by PKWARE */
+	{17, "reserved"}, /* Reserved by PKWARE */
+	{18, "ibm-terse-new"}, /* File is compressed using IBM TERSE (new) */
+	{19, "ibm-lz777"}, /* IBM LZ77 z Architecture (PFS) */
+	{97, "wav-pack"}, /* WavPack compressed data */
+	{98, "ppmd-1"} /* PPMd version I, Rev 1 */
+};
+
+static const char *
+compression_name(const int compression)
 {
-	int r;
-	r = archive_read_support_format_zip_streamable(a);
-	if (r != ARCHIVE_OK)
-		return r;
-	return (archive_read_support_format_zip_seekable(a));
+	static const int num_compression_methods = sizeof(compression_methods)/sizeof(compression_methods[0]);
+	int i=0;
+	while(compression >= 0 && i < num_compression_methods) {
+		if (compression_methods[i].id == compression) {
+			return compression_methods[i].name;
+		}
+		i++;
+	}
+	return "??";
+}
+
+/* Convert an MSDOS-style date/time into Unix-style time. */
+static time_t
+zip_time(const char *p)
+{
+	int msTime, msDate;
+	struct tm ts;
+
+	msTime = (0xff & (unsigned)p[0]) + 256 * (0xff & (unsigned)p[1]);
+	msDate = (0xff & (unsigned)p[2]) + 256 * (0xff & (unsigned)p[3]);
+
+	memset(&ts, 0, sizeof(ts));
+	ts.tm_year = ((msDate >> 9) & 0x7f) + 80; /* Years since 1900. */
+	ts.tm_mon = ((msDate >> 5) & 0x0f) - 1; /* Month number. */
+	ts.tm_mday = msDate & 0x1f; /* Day of month. */
+	ts.tm_hour = (msTime >> 11) & 0x1f;
+	ts.tm_min = (msTime >> 5) & 0x3f;
+	ts.tm_sec = (msTime << 1) & 0x3e;
+	ts.tm_isdst = -1;
+	return mktime(&ts);
 }
 
 /*
- * TODO: This is a performance sink because it forces the read core to
- * drop buffered data from the start of file, which will then have to
- * be re-read again if this bidder loses.
- *
- * We workaround this a little by passing in the best bid so far so
- * that later bidders can do nothing if they know they'll never
- * outbid.  But we can certainly do better...
+ * The extra data is stored as a list of
+ *	id1+size1+data1 + id2+size2+data2 ...
+ *  triplets.  id and size are 2 bytes each.
  */
-static int
-archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
-{
-	struct zip *zip = (struct zip *)a->format->data;
-	int64_t filesize;
-	const char *p;
-
-	/* If someone has already bid more than 32, then avoid
-	   trashing the look-ahead buffers with a seek. */
-	if (best_bid > 32)
-		return (-1);
-
-	filesize = __archive_read_seek(a, -22, SEEK_END);
-	/* If we can't seek, then we can't bid. */
-	if (filesize <= 0)
-		return 0;
-
-	/* TODO: More robust search for end of central directory record. */
-	if ((p = __archive_read_ahead(a, 22, NULL)) == NULL)
-		return 0;
-	/* First four bytes are signature for end of central directory
-	   record.  Four zero bytes ensure this isn't a multi-volume
-	   Zip file (which we don't yet support). */
-	if (memcmp(p, "PK\005\006\000\000\000\000", 8) != 0) {
-		int64_t i, tail;
-		int found;
-
-		/*
-		 * If there is a comment in end of central directory
-		 * record, 22 bytes are too short. we have to read more
-		 * to properly detect the record. Hopefully, a length
-		 * of the comment is not longer than 16362 bytes(16K-22).
-		 */
-		if (filesize + 22 > 1024 * 16) {
-			tail = 1024 * 16;
-			filesize = __archive_read_seek(a, tail * -1, SEEK_END);
-		} else {
-			tail = filesize + 22;
-			filesize = __archive_read_seek(a, 0, SEEK_SET);
-		}
-		if (filesize < 0)
-			return 0;
-		if ((p = __archive_read_ahead(a, (size_t)tail, NULL)) == NULL)
-			return 0;
-		for (found = 0, i = 0;!found && i < tail - 22;) {
-			switch (p[i]) {
-			case 'P':
-				if (memcmp(p+i,
-				    "PK\005\006\000\000\000\000", 8) == 0) {
-					p += i;
-					filesize += tail -
-					    (22 + archive_le16dec(p+20));
-					found = 1;
-				} else
-					i += 8;
-				break;
-			case 'K': i += 7; break;
-			case 005: i += 6; break;
-			case 006: i += 5; break;
-			default: i += 1; break;
-			}
-		}
-		if (!found)
-			return 0;
-	}
-
-	/* Since we've already done the hard work of finding the
-	   end of central directory record, let's save the important
-	   information. */
-	zip->central_directory_entries = archive_le16dec(p + 10);
-	zip->central_directory_size = archive_le32dec(p + 12);
-	zip->central_directory_offset = archive_le32dec(p + 16);
-	zip->end_of_central_directory_offset = filesize;
-
-	/* Just one volume, so central dir must all be on this volume. */
-	if (zip->central_directory_entries != archive_le16dec(p + 8))
-		return 0;
-	/* Central directory can't extend beyond end of this file. */
-	if (zip->central_directory_offset +
-	    (int64_t)zip->central_directory_size > filesize)
-		return 0;
-
-	/* This is just a tiny bit higher than the maximum returned by
-	   the streaming Zip bidder.  This ensures that the more accurate
-	   seeking Zip parser wins whenever seek is available. */
-	return 32;
-}
-
-static int
-cmp_node(const struct archive_rb_node *n1, const struct archive_rb_node *n2)
-{
-	const struct zip_entry *e1 = (const struct zip_entry *)n1;
-	const struct zip_entry *e2 = (const struct zip_entry *)n2;
-
-	return ((int)(e2->local_header_offset - e1->local_header_offset));
-}
-
-static int
-cmp_key(const struct archive_rb_node *n, const void *key)
-{
-	/* This function won't be called */
-	(void)n; /* UNUSED */
-	(void)key; /* UNUSED */
-	return 1;
-}
-
-static int
-rsrc_cmp_node(const struct archive_rb_node *n1,
-    const struct archive_rb_node *n2)
-{
-	const struct zip_entry *e1 = (const struct zip_entry *)n1;
-	const struct zip_entry *e2 = (const struct zip_entry *)n2;
-
-	return (strcmp(e2->rsrcname.s, e1->rsrcname.s));
-}
-
-static int
-rsrc_cmp_key(const struct archive_rb_node *n, const void *key)
-{
-	const struct zip_entry *e = (const struct zip_entry *)n;
-	return (strcmp((const char *)key, e->rsrcname.s));
-}
-
-static const char *
-rsrc_basename(const char *name, size_t name_length)
-{
-	const char *s, *r;
-
-	r = s = name;
-	for (;;) {
-		s = memchr(s, '/', name_length - (s - name));
-		if (s == NULL)
-			break;
-		r = ++s;
-	}
-	return (r);
-}
-
 static void
-expose_parent_dirs(struct zip *zip, const char *name, size_t name_length)
+process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
 {
-	struct archive_string str;
-	struct zip_entry *dir;
-	char *s;
+	unsigned offset = 0;
 
-	archive_string_init(&str);
-	archive_strncpy(&str, name, name_length);
-	for (;;) {
-		s = strrchr(str.s, '/');
-		if (s == NULL)
+	while (offset < extra_length - 4)
+	{
+		unsigned short headerid = archive_le16dec(p + offset);
+		unsigned short datasize = archive_le16dec(p + offset + 2);
+		offset += 4;
+		if (offset + datasize > extra_length)
 			break;
-		*s = '\0';
-		/* Transfer the parent directory from zip->tree_rsrc RB
-		 * tree to zip->tree RB tree to expose. */
-		dir = (struct zip_entry *)
-		    __archive_rb_tree_find_node(&zip->tree_rsrc, str.s);
-		if (dir == NULL)
-			break;
-		__archive_rb_tree_remove_node(&zip->tree_rsrc, &dir->node);
-		archive_string_free(&dir->rsrcname);
-		__archive_rb_tree_insert_node(&zip->tree, &dir->node);
-	}
-	archive_string_free(&str);
-}
-
-static int
-slurp_central_directory(struct archive_read *a, struct zip *zip)
-{
-	unsigned i;
-	int64_t correction;
-	static const struct archive_rb_tree_ops rb_ops = {
-		&cmp_node, &cmp_key
-	};
-	static const struct archive_rb_tree_ops rb_rsrc_ops = {
-		&rsrc_cmp_node, &rsrc_cmp_key
-	};
-
-	/*
-	 * Consider the archive file we are reading may be SFX.
-	 * So we have to calculate a SFX header size to revise
-	 * ZIP header offsets.
-	 */
-	correction = zip->end_of_central_directory_offset -
-	    (zip->central_directory_offset + zip->central_directory_size);
-	/* The central directory offset is relative value, and so
-	 * we revise this offset for SFX. */
-	zip->central_directory_offset += correction;
-
-	__archive_read_seek(a, zip->central_directory_offset, SEEK_SET);
-	zip->offset = zip->central_directory_offset;
-	__archive_rb_tree_init(&zip->tree, &rb_ops);
-	__archive_rb_tree_init(&zip->tree_rsrc, &rb_rsrc_ops);
-
-	zip->zip_entries = calloc(zip->central_directory_entries,
-				sizeof(struct zip_entry));
-	for (i = 0; i < zip->central_directory_entries; ++i) {
-		struct zip_entry *zip_entry = &zip->zip_entries[i];
-		size_t filename_length, extra_length, comment_length;
-		uint32_t external_attributes;
-		const char *name, *p, *r;
-
-		if ((p = __archive_read_ahead(a, 46, NULL)) == NULL)
-			return ARCHIVE_FATAL;
-		if (memcmp(p, "PK\001\002", 4) != 0) {
-			archive_set_error(&a->archive,
-			    -1, "Invalid central directory signature");
-			return ARCHIVE_FATAL;
-		}
-		zip->have_central_directory = 1;
-		/* version = p[4]; */
-		zip_entry->system = p[5];
-		/* version_required = archive_le16dec(p + 6); */
-		zip_entry->flags = archive_le16dec(p + 8);
-		zip_entry->compression = (char)archive_le16dec(p + 10);
-		zip_entry->mtime = zip_time(p + 12);
-		zip_entry->crc32 = archive_le32dec(p + 16);
-		zip_entry->compressed_size = archive_le32dec(p + 20);
-		zip_entry->uncompressed_size = archive_le32dec(p + 24);
-		filename_length = archive_le16dec(p + 28);
-		extra_length = archive_le16dec(p + 30);
-		comment_length = archive_le16dec(p + 32);
-		/* disk_start = archive_le16dec(p + 34); */ /* Better be zero. */
-		/* internal_attributes = archive_le16dec(p + 36); */ /* text bit */
-		external_attributes = archive_le32dec(p + 38);
-		zip_entry->local_header_offset =
-		    archive_le32dec(p + 42) + correction;
-
-		/* If we can't guess the mode, leave it zero here;
-		   when we read the local file header we might get
-		   more information. */
-		zip_entry->mode = 0;
-		if (zip_entry->system == 3) {
-			zip_entry->mode = external_attributes >> 16;
-		}
-
-		/*
-		 * Mac resource fork files are stored under the
-		 * "__MACOSX/" directory, so we should check if
-		 * it is.
-		 */
-		/* Make sure we have the file name. */
-		if ((p = __archive_read_ahead(a, 46 + filename_length, NULL))
-		    == NULL)
-			return ARCHIVE_FATAL;
-		name = p + 46;
-		r = rsrc_basename(name, filename_length);
-		if (filename_length >= 9 &&
-		    strncmp("__MACOSX/", name, 9) == 0) {
-			/* If this file is not a resource fork nor
-			 * a directory. We should treat it as a non
-			 * resource fork file to expose it. */
-			if (name[filename_length-1] != '/' &&
-			    (r - name < 3 || r[0] != '.' || r[1] != '_')) {
-				__archive_rb_tree_insert_node(&zip->tree,
-				    &zip_entry->node);
-				/* Expose its parent directories. */
-				expose_parent_dirs(zip, name, filename_length);
-			} else {
-				/* This file is a resource fork file or
-				 * a directory. */
-				archive_strncpy(&(zip_entry->rsrcname), name,
-				    filename_length);
-				__archive_rb_tree_insert_node(&zip->tree_rsrc,
-				    &zip_entry->node);
-			}
-		} else {
-			/* Generate resource fork name to find its resource
-			 * file at zip->tree_rsrc. */
-			archive_strcpy(&(zip_entry->rsrcname), "__MACOSX/");
-			archive_strncat(&(zip_entry->rsrcname), name, r - name);
-			archive_strcat(&(zip_entry->rsrcname), "._");
-			archive_strncat(&(zip_entry->rsrcname),
-			    name + (r - name), filename_length - (r - name));
-			/* Register an entry to RB tree to sort it by
-			 * file offset. */
-			__archive_rb_tree_insert_node(&zip->tree,
-			    &zip_entry->node);
-		}
-
-		/* We don't read the filename until we get to the
-		   local file header.  Reading it here would speed up
-		   table-of-contents operations (removing the need to
-		   find and read local file header to get the
-		   filename) at the cost of requiring a lot of extra
-		   space. */
-		/* We don't read the extra block here.  We assume it
-		   will be duplicated at the local file header. */
-		__archive_read_consume(a,
-		    46 + filename_length + extra_length + comment_length);
-	}
-
-	return ARCHIVE_OK;
-}
-
-static int64_t
-zip_read_consume(struct archive_read *a, int64_t bytes)
-{
-	struct zip *zip = (struct zip *)a->format->data;
-	int64_t skip;
-
-	skip = __archive_read_consume(a, bytes);
-	if (skip > 0)
-		zip->offset += skip;
-	return (skip);
-}
-
-static int
-zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry,
-    struct zip_entry *rsrc)
-{
-	struct zip *zip = (struct zip *)a->format->data;
-	unsigned char *metadata, *mp;
-	int64_t offset = zip->offset;
-	size_t remaining_bytes, metadata_bytes;
-	ssize_t hsize;
-	int ret = ARCHIVE_OK, eof;
-
-	switch(rsrc->compression) {
-	case 0:  /* No compression. */
-#ifdef HAVE_ZLIB_H
-	case 8: /* Deflate compression. */
+#ifdef DEBUG
+		fprintf(stderr, "Header id 0x%x, length %d\n",
+		    headerid, datasize);
 #endif
-		break;
-	default: /* Unsupported compression. */
-		/* Return a warning. */
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Unsupported ZIP compression method (%s)",
-		    compression_name(rsrc->compression));
-		/* We can't decompress this entry, but we will
-		 * be able to skip() it and try the next entry. */
-		return (ARCHIVE_WARN);
-	}
-
-	if (rsrc->uncompressed_size > (128 * 1024)) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Mac metadata is too large: %jd > 128K bytes",
-		    (intmax_t)rsrc->uncompressed_size);
-		return (ARCHIVE_WARN);
-	}
-
-	metadata = malloc((size_t)rsrc->uncompressed_size);
-	if (metadata == NULL) {
-		archive_set_error(&a->archive, ENOMEM,
-		    "Can't allocate memory for Mac metadata");
-		return (ARCHIVE_FATAL);
-	}
-
-	if (zip->offset < rsrc->local_header_offset)
-		zip_read_consume(a, rsrc->local_header_offset - zip->offset);
-	else if (zip->offset != rsrc->local_header_offset) {
-		__archive_read_seek(a, rsrc->local_header_offset, SEEK_SET);
-		zip->offset = zip->entry->local_header_offset;
-	}
-
-	hsize = zip_get_local_file_header_size(a, 0);
-	zip_read_consume(a, hsize);
-
-	remaining_bytes = (size_t)rsrc->compressed_size;
-	metadata_bytes = (size_t)rsrc->uncompressed_size;
-	mp = metadata;
-	eof = 0;
-	while (!eof && remaining_bytes) {
-		const unsigned char *p;
-		ssize_t bytes_avail;
-		size_t bytes_used;
-
-		p = __archive_read_ahead(a, 1, &bytes_avail);
-		if (p == NULL) {
-			archive_set_error(&a->archive,
-			    ARCHIVE_ERRNO_FILE_FORMAT,
-			    "Truncated ZIP file header");
-			ret = ARCHIVE_WARN;
-			goto exit_mac_metadata;
-		}
-		if ((size_t)bytes_avail > remaining_bytes)
-			bytes_avail = remaining_bytes;
-		switch(rsrc->compression) {
-		case 0:  /* No compression. */
-			memcpy(mp, p, bytes_avail);
-			bytes_used = (size_t)bytes_avail;
-			metadata_bytes -= bytes_used;
-			mp += bytes_used;
-			if (metadata_bytes == 0)
-				eof = 1;
+		switch (headerid) {
+		case 0x0001:
+			/* Zip64 extended information extra field. */
+			zip_entry->flags |= LA_USED_ZIP64;
+			if (zip_entry->uncompressed_size == 0xffffffff) {
+				if (datasize < 8)
+					break;
+				zip_entry->uncompressed_size =
+				    archive_le64dec(p + offset);
+				offset += 8;
+				datasize -= 8;
+			}
+			if (zip_entry->compressed_size == 0xffffffff) {
+				if (datasize < 8)
+					break;
+				zip_entry->compressed_size =
+				    archive_le64dec(p + offset);
+				offset += 8;
+				datasize -= 8;
+			}
+			if (zip_entry->local_header_offset == 0xffffffff) {
+				if (datasize < 8)
+					break;
+				zip_entry->local_header_offset =
+				    archive_le64dec(p + offset);
+				offset += 8;
+				datasize -= 8;
+			}
+			/* archive_le32dec(p + offset) gives disk
+			 * on which file starts, but we don't handle
+			 * multi-volume Zip files. */
 			break;
-#ifdef HAVE_ZLIB_H
-		case 8: /* Deflate compression. */
+		case 0x5455:
 		{
-			int r;
-
-			ret = zip_deflate_init(a, zip);
-			if (ret != ARCHIVE_OK)
-				goto exit_mac_metadata;
-			zip->stream.next_in =
-			    (Bytef *)(uintptr_t)(const void *)p;
-			zip->stream.avail_in = (uInt)bytes_avail;
-			zip->stream.total_in = 0;
-			zip->stream.next_out = mp;
-			zip->stream.avail_out = (uInt)metadata_bytes;
-			zip->stream.total_out = 0;
-
-			r = inflate(&zip->stream, 0);
-			switch (r) {
-			case Z_OK:
-				break;
-			case Z_STREAM_END:
-				eof = 1;
-				break;
-			case Z_MEM_ERROR:
-				archive_set_error(&a->archive, ENOMEM,
-				    "Out of memory for ZIP decompression");
-				ret = ARCHIVE_FATAL;
-				goto exit_mac_metadata;
-			default:
-				archive_set_error(&a->archive,
-				    ARCHIVE_ERRNO_MISC,
-				    "ZIP decompression failed (%d)", r);
-				ret = ARCHIVE_FATAL;
-				goto exit_mac_metadata;
-			}
-			bytes_used = zip->stream.total_in;
-			metadata_bytes -= zip->stream.total_out;
-			mp += zip->stream.total_out;
-			break;
-		}
+			/* Extended time field "UT". */
+			int flags = p[offset];
+			offset++;
+			datasize--;
+			/* Flag bits indicate which dates are present. */
+			if (flags & 0x01)
+			{
+#ifdef DEBUG
+				fprintf(stderr, "mtime: %lld -> %d\n",
+				    (long long)zip_entry->mtime,
+				    archive_le32dec(p + offset));
 #endif
-		default:
-			bytes_used = 0;
+				if (datasize < 4)
+					break;
+				zip_entry->mtime = archive_le32dec(p + offset);
+				offset += 4;
+				datasize -= 4;
+			}
+			if (flags & 0x02)
+			{
+				if (datasize < 4)
+					break;
+				zip_entry->atime = archive_le32dec(p + offset);
+				offset += 4;
+				datasize -= 4;
+			}
+			if (flags & 0x04)
+			{
+				if (datasize < 4)
+					break;
+				zip_entry->ctime = archive_le32dec(p + offset);
+				offset += 4;
+				datasize -= 4;
+			}
 			break;
 		}
-		zip_read_consume(a, bytes_used);
-		remaining_bytes -= bytes_used;
-	}
-	archive_entry_copy_mac_metadata(entry, metadata,
-	    (size_t)rsrc->uncompressed_size - metadata_bytes);
-
-	__archive_read_seek(a, offset, SEEK_SET);
-	zip->offset = offset;
-exit_mac_metadata:
-	zip->decompress_init = 0;
-	free(metadata);
-	return (ret);
-}
-
-static int
-archive_read_format_zip_seekable_read_header(struct archive_read *a,
-	struct archive_entry *entry)
-{
-	struct zip *zip = (struct zip *)a->format->data;
-	struct zip_entry *rsrc;
-	int r, ret = ARCHIVE_OK;
-
-	a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
-	if (a->archive.archive_format_name == NULL)
-		a->archive.archive_format_name = "ZIP";
-
-	if (zip->zip_entries == NULL) {
-		r = slurp_central_directory(a, zip);
-		zip->entries_remaining = zip->central_directory_entries;
-		if (r != ARCHIVE_OK)
-			return r;
-		/* Get first entry whose local header offset is lower than
-		 * other entries in the archive file. */
-		zip->entry =
-		    (struct zip_entry *)ARCHIVE_RB_TREE_MIN(&zip->tree);
-	} else if (zip->entry != NULL) {
-		/* Get next entry in local header offset order. */
-		zip->entry = (struct zip_entry *)__archive_rb_tree_iterate(
-		    &zip->tree, &zip->entry->node, ARCHIVE_RB_DIR_RIGHT);
-	}
-
-	if (zip->entries_remaining <= 0 || zip->entry == NULL)
-		return ARCHIVE_EOF;
-	--zip->entries_remaining;
-
-	if (zip->entry->rsrcname.s)
-		rsrc = (struct zip_entry *)__archive_rb_tree_find_node(
-		    &zip->tree_rsrc, zip->entry->rsrcname.s);
-	else
-		rsrc = NULL;
-
-	/* File entries are sorted by the header offset, we should mostly
-	 * use zip_read_consume to advance a read point to avoid redundant
-	 * data reading.  */
-	if (zip->offset < zip->entry->local_header_offset)
-		zip_read_consume(a,
-		    zip->entry->local_header_offset - zip->offset);
-	else if (zip->offset != zip->entry->local_header_offset) {
-		__archive_read_seek(a, zip->entry->local_header_offset,
-			SEEK_SET);
-		zip->offset = zip->entry->local_header_offset;
-	}
-	zip->unconsumed = 0;
-	r = zip_read_local_file_header(a, entry, zip);
-	if (r != ARCHIVE_OK)
-		return r;
-	if ((zip->entry->mode & AE_IFMT) == AE_IFLNK) {
-		const void *p;
-		struct archive_string_conv *sconv;
-		size_t linkname_length = (size_t)archive_entry_size(entry);
-
-		archive_entry_set_size(entry, 0);
-		p = __archive_read_ahead(a, linkname_length, NULL);
-		if (p == NULL) {
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "Truncated Zip file");
-			return ARCHIVE_FATAL;
-		}
-
-		sconv = zip->sconv;
-		if (sconv == NULL && (zip->entry->flags & ZIP_UTF8_NAME))
-			sconv = zip->sconv_utf8;
-		if (sconv == NULL)
-			sconv = zip->sconv_default;
-		if (archive_entry_copy_symlink_l(entry, p, linkname_length,
-		    sconv) != 0) {
-			if (errno != ENOMEM && sconv == zip->sconv_utf8 &&
-			    (zip->entry->flags & ZIP_UTF8_NAME))
-			    archive_entry_copy_symlink_l(entry, p,
-				linkname_length, NULL);
-			if (errno == ENOMEM) {
-				archive_set_error(&a->archive, ENOMEM,
-				    "Can't allocate memory for Symlink");
-				return (ARCHIVE_FATAL);
+		case 0x5855:
+		{
+			/* Info-ZIP Unix Extra Field (old version) "UX". */
+			if (datasize >= 8) {
+				zip_entry->atime = archive_le32dec(p + offset);
+				zip_entry->mtime =
+				    archive_le32dec(p + offset + 4);
 			}
+			if (datasize >= 12) {
+				zip_entry->uid =
+				    archive_le16dec(p + offset + 8);
+				zip_entry->gid =
+				    archive_le16dec(p + offset + 10);
+			}
+			break;
+		}
+		case 0x6c65:
+		{
+			/* Experimental 'el' field */
 			/*
-			 * Since there is no character-set regulation for
-			 * symlink name, do not report the conversion error
-			 * in an automatic conversion.
+			 * Introduced Dec 2013 to provide a way to
+			 * include external file attributes in local file
+			 * header.  This provides file type and permission
+			 * information necessary to support full streaming
+			 * extraction.  Currently being discussed with
+			 * other Zip developers... subject to change.
 			 */
-			if (sconv != zip->sconv_utf8 ||
-			    (zip->entry->flags & ZIP_UTF8_NAME) == 0) {
-				archive_set_error(&a->archive,
-				    ARCHIVE_ERRNO_FILE_FORMAT,
-				    "Symlink cannot be converted "
-				    "from %s to current locale.",
-				    archive_string_conversion_charset_name(
-					sconv));
-				ret = ARCHIVE_WARN;
+			int bitmap, bitmap_last;
+
+			if (datasize < 1)
+				break;
+			bitmap_last = bitmap = 0xff & p[offset];
+			offset += 1;
+			datasize -= 1;
+
+			/* We only support first 7 bits of bitmap; skip rest. */
+			while ((bitmap_last & 0x80) != 0
+			    && datasize >= 1) {
+				bitmap_last = p[offset];
+				offset += 1;
+				datasize -= 1;
 			}
-		}
-	}
-	if (rsrc) {
-		int ret2 = zip_read_mac_metadata(a, entry, rsrc);
-		if (ret2 < ret)
-			ret = ret2;
-	}
-	return (ret);
-}
 
-static int
-archive_read_format_zip_streamable_bid(struct archive_read *a, int best_bid)
-{
-	const char *p;
-
-	(void)best_bid; /* UNUSED */
-
-	if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
-		return (-1);
-
-	/*
-	 * Bid of 30 here is: 16 bits for "PK",
-	 * next 16-bit field has four options (-2 bits).
-	 * 16 + 16-2 = 30.
-	 */
-	if (p[0] == 'P' && p[1] == 'K') {
-		if ((p[2] == '\001' && p[3] == '\002')
-		    || (p[2] == '\003' && p[3] == '\004')
-		    || (p[2] == '\005' && p[3] == '\006')
-		    || (p[2] == '\007' && p[3] == '\010')
-		    || (p[2] == '0' && p[3] == '0'))
-			return (30);
-	}
-
-	/* TODO: It's worth looking ahead a little bit for a valid
-	 * PK signature.  In particular, that would make it possible
-	 * to read some UUEncoded SFX files or SFX files coming from
-	 * a network socket. */
-
-	return (0);
-}
-
-static int
-archive_read_format_zip_options(struct archive_read *a,
-    const char *key, const char *val)
-{
-	struct zip *zip;
-	int ret = ARCHIVE_FAILED;
-
-	zip = (struct zip *)(a->format->data);
-	if (strcmp(key, "compat-2x")  == 0) {
-		/* Handle filnames as libarchive 2.x */
-		zip->init_default_conversion = (val != NULL) ? 1 : 0;
-		return (ARCHIVE_OK);
-	} else if (strcmp(key, "hdrcharset")  == 0) {
-		if (val == NULL || val[0] == 0)
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "zip: hdrcharset option needs a character-set name"
-			);
-		else {
-			zip->sconv = archive_string_conversion_from_charset(
-			    &a->archive, val, 0);
-			if (zip->sconv != NULL) {
-				if (strcmp(val, "UTF-8") == 0)
-					zip->sconv_utf8 = zip->sconv;
-				ret = ARCHIVE_OK;
-			} else
-				ret = ARCHIVE_FATAL;
-		}
-		return (ret);
-	}
-
-	/* Note: The "warn" return is just to inform the options
-	 * supervisor that we didn't handle it.  It will generate
-	 * a suitable error if no one used this option. */
-	return (ARCHIVE_WARN);
-}
-
-static int
-archive_read_format_zip_streamable_read_header(struct archive_read *a,
-    struct archive_entry *entry)
-{
-	struct zip *zip;
-
-	a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
-	if (a->archive.archive_format_name == NULL)
-		a->archive.archive_format_name = "ZIP";
-
-	zip = (struct zip *)(a->format->data);
-
-	/* Make sure we have a zip_entry structure to use. */
-	if (zip->zip_entries == NULL) {
-		zip->zip_entries = malloc(sizeof(struct zip_entry));
-		if (zip->zip_entries == NULL) {
-			archive_set_error(&a->archive, ENOMEM,
-			    "Out  of memory");
-			return ARCHIVE_FATAL;
-		}
-	}
-	zip->entry = zip->zip_entries;
-	memset(zip->entry, 0, sizeof(struct zip_entry));
-
-	/* Search ahead for the next local file header. */
-	zip_read_consume(a, zip->unconsumed);
-	zip->unconsumed = 0;
-	for (;;) {
-		int64_t skipped = 0;
-		const char *p, *end;
-		ssize_t bytes;
-
-		p = __archive_read_ahead(a, 4, &bytes);
-		if (p == NULL)
-			return (ARCHIVE_FATAL);
-		end = p + bytes;
-
-		while (p + 4 <= end) {
-			if (p[0] == 'P' && p[1] == 'K') {
-				if (p[2] == '\001' && p[3] == '\002')
-					/* Beginning of central directory. */
-					return (ARCHIVE_EOF);
-
-				if (p[2] == '\003' && p[3] == '\004') {
-					/* Regular file entry. */
-					zip_read_consume(a, skipped);
-					return zip_read_local_file_header(a,
-					    entry, zip);
+			if (bitmap & 1) {
+				// 2 byte "version made by"
+				if (datasize < 2)
+					break;
+				zip_entry->system
+				    = archive_le16dec(p + offset) >> 8;
+				offset += 2;
+				datasize -= 2;
+			}
+			if (bitmap & 2) {
+				// 2 byte "internal file attributes"
+				uint32_t internal_attributes;
+				if (datasize < 2)
+					break;
+				internal_attributes
+				    = archive_le16dec(p + offset);
+				// Not used by libarchive at present.
+				(void)internal_attributes; /* UNUSED */
+				offset += 2;
+				datasize -= 2;
+			}
+			if (bitmap & 4) {
+				// 4 byte "external file attributes"
+				uint32_t external_attributes;
+				if (datasize < 4)
+					break;
+				external_attributes
+				    = archive_le32dec(p + offset);
+				if (zip_entry->system == 3) {
+					zip_entry->mode
+					    = external_attributes >> 16;
 				}
-
-				if (p[2] == '\005' && p[3] == '\006')
-					/* End of central directory. */
-					return (ARCHIVE_EOF);
+				offset += 4;
+				datasize -= 4;
 			}
-			++p;
-			++skipped;
+			if (bitmap & 8) {
+				// 2 byte comment length + comment
+				uint32_t comment_length;
+				if (datasize < 2)
+					break;
+				comment_length
+				    = archive_le16dec(p + offset);
+				offset += 2;
+				datasize -= 2;
+
+				if (datasize < comment_length)
+					break;
+				// Comment is not supported by libarchive
+				offset += comment_length;
+				datasize -= comment_length;
+			}
+			break;
 		}
-		zip_read_consume(a, skipped);
+		case 0x7855:
+			/* Info-ZIP Unix Extra Field (type 2) "Ux". */
+#ifdef DEBUG
+			fprintf(stderr, "uid %d gid %d\n",
+			    archive_le16dec(p + offset),
+			    archive_le16dec(p + offset + 2));
+#endif
+			if (datasize >= 2)
+				zip_entry->uid = archive_le16dec(p + offset);
+			if (datasize >= 4)
+				zip_entry->gid =
+				    archive_le16dec(p + offset + 2);
+			break;
+		case 0x7875:
+		{
+			/* Info-Zip Unix Extra Field (type 3) "ux". */
+			int uidsize = 0, gidsize = 0;
+
+			/* TODO: support arbitrary uidsize/gidsize. */
+			if (datasize >= 1 && p[offset] == 1) {/* version=1 */
+				if (datasize >= 4) {
+					/* get a uid size. */
+					uidsize = p[offset+1];
+					if (uidsize == 2)
+						zip_entry->uid =
+						    archive_le16dec(
+						        p + offset + 2);
+					else if (uidsize == 4 && datasize >= 6)
+						zip_entry->uid =
+						    archive_le32dec(
+						        p + offset + 2);
+				}
+				if (datasize >= (2 + uidsize + 3)) {
+					/* get a gid size. */
+					gidsize = p[offset+2+uidsize];
+					if (gidsize == 2)
+						zip_entry->gid =
+						    archive_le16dec(
+						        p+offset+2+uidsize+1);
+					else if (gidsize == 4 &&
+					    datasize >= (2 + uidsize + 5))
+						zip_entry->gid =
+						    archive_le32dec(
+						        p+offset+2+uidsize+1);
+				}
+			}
+			break;
+		}
+		default:
+			break;
+		}
+		offset += datasize;
 	}
-}
-
-static ssize_t
-zip_get_local_file_header_size(struct archive_read *a, size_t extra)
-{
-	const char *p;
-	ssize_t filename_length, extra_length;
-
-	if ((p = __archive_read_ahead(a, extra + 30, NULL)) == NULL) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Truncated ZIP file header");
-		return (ARCHIVE_WARN);
+#ifdef DEBUG
+	if (offset != extra_length)
+	{
+		fprintf(stderr,
+		    "Extra data field contents do not match reported size!\n");
 	}
-	p += extra;
-
-	if (memcmp(p, "PK\003\004", 4) != 0) {
-		archive_set_error(&a->archive, -1, "Damaged Zip archive");
-		return ARCHIVE_WARN;
-	}
-	filename_length = archive_le16dec(p + 26);
-	extra_length = archive_le16dec(p + 28);
-
-	return (30 + filename_length + extra_length);
+#endif
 }
 
 /*
@@ -957,16 +501,18 @@
 	size_t len, filename_length, extra_length;
 	struct archive_string_conv *sconv;
 	struct zip_entry *zip_entry = zip->entry;
-	uint32_t local_crc32;
-	int64_t compressed_size, uncompressed_size;
+	struct zip_entry zip_entry_central_dir;
 	int ret = ARCHIVE_OK;
 	char version;
 
+	/* Save a copy of the original for consistency checks. */
+	zip_entry_central_dir = *zip_entry;
+
 	zip->decompress_init = 0;
 	zip->end_of_entry = 0;
 	zip->entry_uncompressed_bytes_read = 0;
 	zip->entry_compressed_bytes_read = 0;
-	zip->entry_crc32 = crc32(0, NULL, 0);
+	zip->entry_crc32 = zip->crc32func(0, NULL, 0);
 
 	/* Setup default conversion. */
 	if (zip->sconv == NULL && !zip->init_default_conversion) {
@@ -987,52 +533,26 @@
 	}
 	version = p[4];
 	zip_entry->system = p[5];
-	zip_entry->flags = archive_le16dec(p + 6);
+	zip_entry->zip_flags = archive_le16dec(p + 6);
+	if (zip_entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
+		zip->has_encrypted_entries = 1;
+		archive_entry_set_is_data_encrypted(entry, 1);
+		if (zip_entry->zip_flags & ZIP_CENTRAL_DIRECTORY_ENCRYPTED &&
+			zip_entry->zip_flags & ZIP_ENCRYPTED &&
+			zip_entry->zip_flags & ZIP_STRONG_ENCRYPTED) {
+			archive_entry_set_is_metadata_encrypted(entry, 1);
+			return ARCHIVE_FATAL;
+		}
+	}
 	zip_entry->compression = (char)archive_le16dec(p + 8);
 	zip_entry->mtime = zip_time(p + 10);
-	local_crc32 = archive_le32dec(p + 14);
-	compressed_size = archive_le32dec(p + 18);
-	uncompressed_size = archive_le32dec(p + 22);
+	zip_entry->crc32 = archive_le32dec(p + 14);
+	zip_entry->compressed_size = archive_le32dec(p + 18);
+	zip_entry->uncompressed_size = archive_le32dec(p + 22);
 	filename_length = archive_le16dec(p + 26);
 	extra_length = archive_le16dec(p + 28);
 
-	zip_read_consume(a, 30);
-
-	if (zip->have_central_directory) {
-		/* If we read the central dir entry, we must have size
-		 * information as well, so ignore the length-at-end flag. */
-		zip_entry->flags &= ~ZIP_LENGTH_AT_END;
-		/* If we have values from both the local file header
-		   and the central directory, warn about mismatches
-		   which might indicate a damaged file.  But some
-		   writers always put zero in the local header; don't
-		   bother warning about that. */
-		if (local_crc32 != 0 && local_crc32 != zip_entry->crc32) {
-			archive_set_error(&a->archive,
-			    ARCHIVE_ERRNO_FILE_FORMAT,
-			    "Inconsistent CRC32 values");
-			ret = ARCHIVE_WARN;
-		}
-		if (compressed_size != 0
-		    && compressed_size != zip_entry->compressed_size) {
-			archive_set_error(&a->archive,
-			    ARCHIVE_ERRNO_FILE_FORMAT,
-			    "Inconsistent compressed size");
-			ret = ARCHIVE_WARN;
-		}
-		if (uncompressed_size != 0
-		    && uncompressed_size != zip_entry->uncompressed_size) {
-			archive_set_error(&a->archive,
-			    ARCHIVE_ERRNO_FILE_FORMAT,
-			    "Inconsistent uncompressed size");
-			ret = ARCHIVE_WARN;
-		}
-	} else {
-		/* If we don't have the CD info, use whatever we do have. */
-		zip_entry->crc32 = local_crc32;
-		zip_entry->compressed_size = compressed_size;
-		zip_entry->uncompressed_size = uncompressed_size;
-	}
+	__archive_read_consume(a, 30);
 
 	/* Read the filename. */
 	if ((h = __archive_read_ahead(a, filename_length, NULL)) == NULL) {
@@ -1040,7 +560,7 @@
 		    "Truncated ZIP file header");
 		return (ARCHIVE_FATAL);
 	}
-	if (zip_entry->flags & ZIP_UTF8_NAME) {
+	if (zip_entry->zip_flags & ZIP_UTF8_NAME) {
 		/* The filename is stored to be UTF-8. */
 		if (zip->sconv_utf8 == NULL) {
 			zip->sconv_utf8 =
@@ -1069,26 +589,38 @@
 		    archive_string_conversion_charset_name(sconv));
 		ret = ARCHIVE_WARN;
 	}
-	zip_read_consume(a, filename_length);
+	__archive_read_consume(a, filename_length);
 
-	if (zip_entry->mode == 0) {
+	/* Work around a bug in Info-Zip: When reading from a pipe, it
+	 * stats the pipe instead of synthesizing a file entry. */
+	if ((zip_entry->mode & AE_IFMT) == AE_IFIFO) {
+		zip_entry->mode &= ~ AE_IFMT;
+		zip_entry->mode |= AE_IFREG;
+	}
+
+	if ((zip_entry->mode & AE_IFMT) == 0) {
 		/* Especially in streaming mode, we can end up
-		   here without having seen any mode information.
+		   here without having seen proper mode information.
 		   Guess from the filename. */
 		wp = archive_entry_pathname_w(entry);
 		if (wp != NULL) {
 			len = wcslen(wp);
 			if (len > 0 && wp[len - 1] == L'/')
-				zip_entry->mode = AE_IFDIR | 0777;
+				zip_entry->mode |= AE_IFDIR;
 			else
-				zip_entry->mode = AE_IFREG | 0666;
+				zip_entry->mode |= AE_IFREG;
 		} else {
 			cp = archive_entry_pathname(entry);
 			len = (cp != NULL)?strlen(cp):0;
 			if (len > 0 && cp[len - 1] == '/')
-				zip_entry->mode = AE_IFDIR | 0777;
+				zip_entry->mode |= AE_IFDIR;
 			else
-				zip_entry->mode = AE_IFREG | 0666;
+				zip_entry->mode |= AE_IFREG;
+		}
+		if (zip_entry->mode == AE_IFDIR) {
+			zip_entry->mode |= 0775;
+		} else if (zip_entry->mode == AE_IFREG) {
+			zip_entry->mode |= 0664;
 		}
 	}
 
@@ -1098,8 +630,53 @@
 		    "Truncated ZIP file header");
 		return (ARCHIVE_FATAL);
 	}
+
 	process_extra(h, extra_length, zip_entry);
-	zip_read_consume(a, extra_length);
+	__archive_read_consume(a, extra_length);
+
+	if (zip_entry->flags & LA_FROM_CENTRAL_DIRECTORY) {
+		/* If this came from the central dir, it's size info
+		 * is definitive, so ignore the length-at-end flag. */
+		zip_entry->zip_flags &= ~ZIP_LENGTH_AT_END;
+		/* If local header is missing a value, use the one from
+		   the central directory.  If both have it, warn about
+		   mismatches. */
+		if (zip_entry->crc32 == 0) {
+			zip_entry->crc32 = zip_entry_central_dir.crc32;
+		} else if (!zip->ignore_crc32
+		    && zip_entry->crc32 != zip_entry_central_dir.crc32) {
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Inconsistent CRC32 values");
+			ret = ARCHIVE_WARN;
+		}
+		if (zip_entry->compressed_size == 0) {
+			zip_entry->compressed_size
+			    = zip_entry_central_dir.compressed_size;
+		} else if (zip_entry->compressed_size
+		    != zip_entry_central_dir.compressed_size) {
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Inconsistent compressed size: "
+			    "%jd in central directory, %jd in local header",
+			    (intmax_t)zip_entry_central_dir.compressed_size,
+			    (intmax_t)zip_entry->compressed_size);
+			ret = ARCHIVE_WARN;
+		}
+		if (zip_entry->uncompressed_size == 0) {
+			zip_entry->uncompressed_size
+			    = zip_entry_central_dir.uncompressed_size;
+		} else if (zip_entry->uncompressed_size
+		    != zip_entry_central_dir.uncompressed_size) {
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Inconsistent uncompressed size: "
+			    "%jd in central directory, %jd in local header",
+			    (intmax_t)zip_entry_central_dir.uncompressed_size,
+			    (intmax_t)zip_entry->uncompressed_size);
+			ret = ARCHIVE_WARN;
+		}
+	}
 
 	/* Populate some additional entry fields: */
 	archive_entry_set_mode(entry, zip_entry->mode);
@@ -1108,19 +685,70 @@
 	archive_entry_set_mtime(entry, zip_entry->mtime, 0);
 	archive_entry_set_ctime(entry, zip_entry->ctime, 0);
 	archive_entry_set_atime(entry, zip_entry->atime, 0);
-	/* Set the size only if it's meaningful. */
-	if (0 == (zip_entry->flags & ZIP_LENGTH_AT_END))
-		archive_entry_set_size(entry, zip_entry->uncompressed_size);
 
+	if ((zip->entry->mode & AE_IFMT) == AE_IFLNK) {
+		size_t linkname_length = zip_entry->compressed_size;
+
+		archive_entry_set_size(entry, 0);
+		p = __archive_read_ahead(a, linkname_length, NULL);
+		if (p == NULL) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "Truncated Zip file");
+			return ARCHIVE_FATAL;
+		}
+		if (__archive_read_consume(a, linkname_length) < 0) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "Read error skipping symlink target name");
+			return ARCHIVE_FATAL;
+		}
+
+		sconv = zip->sconv;
+		if (sconv == NULL && (zip->entry->zip_flags & ZIP_UTF8_NAME))
+			sconv = zip->sconv_utf8;
+		if (sconv == NULL)
+			sconv = zip->sconv_default;
+		if (archive_entry_copy_symlink_l(entry, p, linkname_length,
+		    sconv) != 0) {
+			if (errno != ENOMEM && sconv == zip->sconv_utf8 &&
+			    (zip->entry->zip_flags & ZIP_UTF8_NAME))
+			    archive_entry_copy_symlink_l(entry, p,
+				linkname_length, NULL);
+			if (errno == ENOMEM) {
+				archive_set_error(&a->archive, ENOMEM,
+				    "Can't allocate memory for Symlink");
+				return (ARCHIVE_FATAL);
+			}
+			/*
+			 * Since there is no character-set regulation for
+			 * symlink name, do not report the conversion error
+			 * in an automatic conversion.
+			 */
+			if (sconv != zip->sconv_utf8 ||
+			    (zip->entry->zip_flags & ZIP_UTF8_NAME) == 0) {
+				archive_set_error(&a->archive,
+				    ARCHIVE_ERRNO_FILE_FORMAT,
+				    "Symlink cannot be converted "
+				    "from %s to current locale.",
+				    archive_string_conversion_charset_name(
+					sconv));
+				ret = ARCHIVE_WARN;
+			}
+		}
+		zip_entry->uncompressed_size = zip_entry->compressed_size = 0;
+	} else if (0 == (zip_entry->zip_flags & ZIP_LENGTH_AT_END)
+	    || zip_entry->uncompressed_size > 0) {
+		/* Set the size only if it's meaningful. */
+		archive_entry_set_size(entry, zip_entry->uncompressed_size);
+	}
 	zip->entry_bytes_remaining = zip_entry->compressed_size;
 
 	/* If there's no body, force read_data() to return EOF immediately. */
-	if (0 == (zip_entry->flags & ZIP_LENGTH_AT_END)
+	if (0 == (zip_entry->zip_flags & ZIP_LENGTH_AT_END)
 	    && zip->entry_bytes_remaining < 1)
 		zip->end_of_entry = 1;
 
 	/* Set up a more descriptive format name. */
-	sprintf(zip->format_name, "ZIP %d.%d (%s)",
+	snprintf(zip->format_name, sizeof(zip->format_name), "ZIP %d.%d (%s)",
 	    version / 10, version % 10,
 	    compression_name(zip->entry->compression));
 	a->archive.archive_format_name = zip->format_name;
@@ -1128,138 +756,6 @@
 	return (ret);
 }
 
-static const char *
-compression_name(int compression)
-{
-	static const char *compression_names[] = {
-		"uncompressed",
-		"shrinking",
-		"reduced-1",
-		"reduced-2",
-		"reduced-3",
-		"reduced-4",
-		"imploded",
-		"reserved",
-		"deflation"
-	};
-
-	if (0 <= compression && compression <
-	    (int)(sizeof(compression_names)/sizeof(compression_names[0])))
-		return compression_names[compression];
-	else
-		return "??";
-}
-
-/* Convert an MSDOS-style date/time into Unix-style time. */
-static time_t
-zip_time(const char *p)
-{
-	int msTime, msDate;
-	struct tm ts;
-
-	msTime = (0xff & (unsigned)p[0]) + 256 * (0xff & (unsigned)p[1]);
-	msDate = (0xff & (unsigned)p[2]) + 256 * (0xff & (unsigned)p[3]);
-
-	memset(&ts, 0, sizeof(ts));
-	ts.tm_year = ((msDate >> 9) & 0x7f) + 80; /* Years since 1900. */
-	ts.tm_mon = ((msDate >> 5) & 0x0f) - 1; /* Month number. */
-	ts.tm_mday = msDate & 0x1f; /* Day of month. */
-	ts.tm_hour = (msTime >> 11) & 0x1f;
-	ts.tm_min = (msTime >> 5) & 0x3f;
-	ts.tm_sec = (msTime << 1) & 0x3e;
-	ts.tm_isdst = -1;
-	return mktime(&ts);
-}
-
-static int
-archive_read_format_zip_read_data(struct archive_read *a,
-    const void **buff, size_t *size, int64_t *offset)
-{
-	int r;
-	struct zip *zip = (struct zip *)(a->format->data);
-
-	*offset = zip->entry_uncompressed_bytes_read;
-	*size = 0;
-	*buff = NULL;
-
-	/* If we hit end-of-entry last time, return ARCHIVE_EOF. */
-	if (zip->end_of_entry)
-		return (ARCHIVE_EOF);
-
-	/* Return EOF immediately if this is a non-regular file. */
-	if (AE_IFREG != (zip->entry->mode & AE_IFMT))
-		return (ARCHIVE_EOF);
-
-	if (zip->entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Encrypted file is unsupported");
-		return (ARCHIVE_FAILED);
-	}
-
-	zip_read_consume(a, zip->unconsumed);
-	zip->unconsumed = 0;
-
-	switch(zip->entry->compression) {
-	case 0:  /* No compression. */
-		r =  zip_read_data_none(a, buff, size, offset);
-		break;
-#ifdef HAVE_ZLIB_H
-	case 8: /* Deflate compression. */
-		r =  zip_read_data_deflate(a, buff, size, offset);
-		break;
-#endif
-	default: /* Unsupported compression. */
-		/* Return a warning. */
-		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
-		    "Unsupported ZIP compression method (%s)",
-		    compression_name(zip->entry->compression));
-		/* We can't decompress this entry, but we will
-		 * be able to skip() it and try the next entry. */
-		return (ARCHIVE_FAILED);
-		break;
-	}
-	if (r != ARCHIVE_OK)
-		return (r);
-	/* Update checksum */
-	if (*size)
-		zip->entry_crc32 = crc32(zip->entry_crc32, *buff,
-		    (unsigned)*size);
-	/* If we hit the end, swallow any end-of-data marker. */
-	if (zip->end_of_entry) {
-		/* Check file size, CRC against these values. */
-		if (zip->entry->compressed_size !=
-		    zip->entry_compressed_bytes_read) {
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "ZIP compressed data is wrong size "
-			    "(read %jd, expected %jd)",
-			    (intmax_t)zip->entry_compressed_bytes_read,
-			    (intmax_t)zip->entry->compressed_size);
-			return (ARCHIVE_WARN);
-		}
-		/* Size field only stores the lower 32 bits of the actual
-		 * size. */
-		if ((zip->entry->uncompressed_size & UINT32_MAX)
-		    != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) {
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "ZIP uncompressed data is wrong size "
-			    "(read %jd, expected %jd)",
-			    (intmax_t)zip->entry_uncompressed_bytes_read,
-			    (intmax_t)zip->entry->uncompressed_size);
-			return (ARCHIVE_WARN);
-		}
-		/* Check computed CRC against header */
-		if (zip->entry->crc32 != zip->entry_crc32) {
-			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-			    "ZIP bad CRC: 0x%lx should be 0x%lx",
-			    (unsigned long)zip->entry_crc32,
-			    (unsigned long)zip->entry->crc32);
-			return (ARCHIVE_WARN);
-		}
-	}
-
-	return (ARCHIVE_OK);
-}
-
 /*
  * Read "uncompressed" data.  There are three cases:
  *  1) We know the size of the data.  This is always true for the
@@ -1276,9 +772,10 @@
  * TODO: Technically, the PK\007\010 signature is optional.
  * In the original spec, the data descriptor contained CRC
  * and size fields but had no leading signature.  In practice,
- * newer writers seem to provide the signature pretty consistently,
- * but we might need to do something more complex here if
- * we want to handle older archives that lack that signature.
+ * newer writers seem to provide the signature pretty consistently.
+ *
+ * For uncompressed data, the PK\007\010 marker seems essential
+ * to be sure we've actually seen the end of the entry.
  *
  * Returns ARCHIVE_OK if successful, ARCHIVE_FATAL otherwise, sets
  * zip->end_of_entry if it consumes all of the data.
@@ -1295,35 +792,40 @@
 
 	zip = (struct zip *)(a->format->data);
 
-	if (zip->entry->flags & ZIP_LENGTH_AT_END) {
+	if (zip->entry->zip_flags & ZIP_LENGTH_AT_END) {
 		const char *p;
 
-		/* Grab at least 16 bytes. */
-		buff = __archive_read_ahead(a, 16, &bytes_avail);
-		if (bytes_avail < 16) {
+		/* Grab at least 24 bytes. */
+		buff = __archive_read_ahead(a, 24, &bytes_avail);
+		if (bytes_avail < 24) {
 			/* Zip archives have end-of-archive markers
 			   that are longer than this, so a failure to get at
-			   least 16 bytes really does indicate a truncated
+			   least 24 bytes really does indicate a truncated
 			   file. */
 			archive_set_error(&a->archive,
 			    ARCHIVE_ERRNO_FILE_FORMAT,
 			    "Truncated ZIP file data");
 			return (ARCHIVE_FATAL);
 		}
-		/* Check for a complete PK\007\010 signature. */
+		/* Check for a complete PK\007\010 signature, followed
+		 * by the correct 4-byte CRC. */
 		p = buff;
-		if (p[0] == 'P' && p[1] == 'K' 
+		if (p[0] == 'P' && p[1] == 'K'
 		    && p[2] == '\007' && p[3] == '\010'
-		    && archive_le32dec(p + 4) == zip->entry_crc32
-		    && archive_le32dec(p + 8) ==
-			    zip->entry_compressed_bytes_read
-		    && archive_le32dec(p + 12) ==
-			    zip->entry_uncompressed_bytes_read) {
-			zip->entry->crc32 = archive_le32dec(p + 4);
-			zip->entry->compressed_size = archive_le32dec(p + 8);
-			zip->entry->uncompressed_size = archive_le32dec(p + 12);
+		    && (archive_le32dec(p + 4) == zip->entry_crc32
+			|| zip->ignore_crc32)) {
+			if (zip->entry->flags & LA_USED_ZIP64) {
+				zip->entry->crc32 = archive_le32dec(p + 4);
+				zip->entry->compressed_size = archive_le64dec(p + 8);
+				zip->entry->uncompressed_size = archive_le64dec(p + 16);
+				zip->unconsumed = 24;
+			} else {
+				zip->entry->crc32 = archive_le32dec(p + 4);
+				zip->entry->compressed_size = archive_le32dec(p + 8);
+				zip->entry->uncompressed_size = archive_le32dec(p + 12);
+				zip->unconsumed = 16;
+			}
 			zip->end_of_entry = 1;
-			zip->unconsumed = 16;
 			return (ARCHIVE_OK);
 		}
 		/* If not at EOF, ensure we consume at least one byte. */
@@ -1430,7 +932,7 @@
 	 * decompressor to combine reads by copying data.
 	 */
 	compressed_buff = __archive_read_ahead(a, 1, &bytes_avail);
-	if (0 == (zip->entry->flags & ZIP_LENGTH_AT_END)
+	if (0 == (zip->entry->zip_flags & ZIP_LENGTH_AT_END)
 	    && bytes_avail > zip->entry_bytes_remaining) {
 		bytes_avail = (ssize_t)zip->entry_bytes_remaining;
 	}
@@ -1472,7 +974,7 @@
 
 	/* Consume as much as the compressor actually used. */
 	bytes_avail = zip->stream.total_in;
-	zip_read_consume(a, bytes_avail);
+	__archive_read_consume(a, bytes_avail);
 	zip->entry_bytes_remaining -= bytes_avail;
 	zip->entry_compressed_bytes_read += bytes_avail;
 
@@ -1480,10 +982,10 @@
 	zip->entry_uncompressed_bytes_read += zip->stream.total_out;
 	*buff = zip->uncompressed_buffer;
 
-	if (zip->end_of_entry && (zip->entry->flags & ZIP_LENGTH_AT_END)) {
+	if (zip->end_of_entry && (zip->entry->zip_flags & ZIP_LENGTH_AT_END)) {
 		const char *p;
 
-		if (NULL == (p = __archive_read_ahead(a, 16, NULL))) {
+		if (NULL == (p = __archive_read_ahead(a, 24, NULL))) {
 			archive_set_error(&a->archive,
 			    ARCHIVE_ERRNO_FILE_FORMAT,
 			    "Truncated ZIP end-of-file record");
@@ -1492,10 +994,19 @@
 		/* Consume the optional PK\007\010 marker. */
 		if (p[0] == 'P' && p[1] == 'K' &&
 		    p[2] == '\007' && p[3] == '\010') {
-			zip->entry->crc32 = archive_le32dec(p + 4);
-			zip->entry->compressed_size = archive_le32dec(p + 8);
-			zip->entry->uncompressed_size = archive_le32dec(p + 12);
-			zip->unconsumed = 16;
+			p += 4;
+			zip->unconsumed = 4;
+		}
+		if (zip->entry->flags & LA_USED_ZIP64) {
+			zip->entry->crc32 = archive_le32dec(p);
+			zip->entry->compressed_size = archive_le64dec(p + 4);
+			zip->entry->uncompressed_size = archive_le64dec(p + 12);
+			zip->unconsumed += 20;
+		} else {
+			zip->entry->crc32 = archive_le32dec(p);
+			zip->entry->compressed_size = archive_le32dec(p + 4);
+			zip->entry->uncompressed_size = archive_le32dec(p + 8);
+			zip->unconsumed += 12;
 		}
 	}
 
@@ -1504,24 +1015,357 @@
 #endif
 
 static int
-archive_read_format_zip_read_data_skip(struct archive_read *a)
+archive_read_format_zip_read_data(struct archive_read *a,
+    const void **buff, size_t *size, int64_t *offset)
+{
+	int r;
+	struct zip *zip = (struct zip *)(a->format->data);
+
+	if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+		zip->has_encrypted_entries = 0;
+	}
+
+	*offset = zip->entry_uncompressed_bytes_read;
+	*size = 0;
+	*buff = NULL;
+
+	/* If we hit end-of-entry last time, return ARCHIVE_EOF. */
+	if (zip->end_of_entry)
+		return (ARCHIVE_EOF);
+
+	/* Return EOF immediately if this is a non-regular file. */
+	if (AE_IFREG != (zip->entry->mode & AE_IFMT))
+		return (ARCHIVE_EOF);
+
+	if (zip->entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
+		zip->has_encrypted_entries = 1;
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Encrypted file is unsupported");
+		return (ARCHIVE_FAILED);
+	}
+
+	__archive_read_consume(a, zip->unconsumed);
+	zip->unconsumed = 0;
+
+	switch(zip->entry->compression) {
+	case 0:  /* No compression. */
+		r =  zip_read_data_none(a, buff, size, offset);
+		break;
+#ifdef HAVE_ZLIB_H
+	case 8: /* Deflate compression. */
+		r =  zip_read_data_deflate(a, buff, size, offset);
+		break;
+#endif
+	default: /* Unsupported compression. */
+		/* Return a warning. */
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Unsupported ZIP compression method (%s)",
+		    compression_name(zip->entry->compression));
+		/* We can't decompress this entry, but we will
+		 * be able to skip() it and try the next entry. */
+		return (ARCHIVE_FAILED);
+		break;
+	}
+	if (r != ARCHIVE_OK)
+		return (r);
+	/* Update checksum */
+	if (*size)
+		zip->entry_crc32 = zip->crc32func(zip->entry_crc32, *buff,
+		    (unsigned)*size);
+	/* If we hit the end, swallow any end-of-data marker. */
+	if (zip->end_of_entry) {
+		/* Check file size, CRC against these values. */
+		if (zip->entry->compressed_size !=
+		    zip->entry_compressed_bytes_read) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "ZIP compressed data is wrong size "
+			    "(read %jd, expected %jd)",
+			    (intmax_t)zip->entry_compressed_bytes_read,
+			    (intmax_t)zip->entry->compressed_size);
+			return (ARCHIVE_WARN);
+		}
+		/* Size field only stores the lower 32 bits of the actual
+		 * size. */
+		if ((zip->entry->uncompressed_size & UINT32_MAX)
+		    != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "ZIP uncompressed data is wrong size "
+			    "(read %jd, expected %jd)\n",
+			    (intmax_t)zip->entry_uncompressed_bytes_read,
+			    (intmax_t)zip->entry->uncompressed_size);
+			return (ARCHIVE_WARN);
+		}
+		/* Check computed CRC against header */
+		if (zip->entry->crc32 != zip->entry_crc32
+		    && !zip->ignore_crc32) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "ZIP bad CRC: 0x%lx should be 0x%lx",
+			    (unsigned long)zip->entry_crc32,
+			    (unsigned long)zip->entry->crc32);
+			return (ARCHIVE_WARN);
+		}
+	}
+
+	return (ARCHIVE_OK);
+}
+
+static int
+archive_read_format_zip_cleanup(struct archive_read *a)
+{
+	struct zip *zip;
+	struct zip_entry *zip_entry, *next_zip_entry;
+
+	zip = (struct zip *)(a->format->data);
+#ifdef HAVE_ZLIB_H
+	if (zip->stream_valid)
+		inflateEnd(&zip->stream);
+	free(zip->uncompressed_buffer);
+#endif
+	if (zip->zip_entries) {
+		zip_entry = zip->zip_entries;
+		while (zip_entry != NULL) {
+			next_zip_entry = zip_entry->next;
+			archive_string_free(&zip_entry->rsrcname);
+			free(zip_entry);
+			zip_entry = next_zip_entry;
+		}
+	}
+	free(zip);
+	(a->format->data) = NULL;
+	return (ARCHIVE_OK);
+}
+
+static int
+archive_read_format_zip_has_encrypted_entries(struct archive_read *_a)
+{
+	if (_a && _a->format) {
+		struct zip * zip = (struct zip *)_a->format->data;
+		if (zip) {
+			return zip->has_encrypted_entries;
+		}
+	}
+	return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+}
+
+static int
+archive_read_format_zip_options(struct archive_read *a,
+    const char *key, const char *val)
+{
+	struct zip *zip;
+	int ret = ARCHIVE_FAILED;
+
+	zip = (struct zip *)(a->format->data);
+	if (strcmp(key, "compat-2x")  == 0) {
+		/* Handle filenames as libarchive 2.x */
+		zip->init_default_conversion = (val != NULL) ? 1 : 0;
+		return (ARCHIVE_OK);
+	} else if (strcmp(key, "hdrcharset")  == 0) {
+		if (val == NULL || val[0] == 0)
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "zip: hdrcharset option needs a character-set name"
+			);
+		else {
+			zip->sconv = archive_string_conversion_from_charset(
+			    &a->archive, val, 0);
+			if (zip->sconv != NULL) {
+				if (strcmp(val, "UTF-8") == 0)
+					zip->sconv_utf8 = zip->sconv;
+				ret = ARCHIVE_OK;
+			} else
+				ret = ARCHIVE_FATAL;
+		}
+		return (ret);
+	} else if (strcmp(key, "ignorecrc32") == 0) {
+		/* Mostly useful for testing. */
+		if (val == NULL || val[0] == 0) {
+			zip->crc32func = real_crc32;
+			zip->ignore_crc32 = 0;
+		} else {
+			zip->crc32func = fake_crc32;
+			zip->ignore_crc32 = 1;
+		}
+		return (ARCHIVE_OK);
+	} else if (strcmp(key, "mac-ext") == 0) {
+		zip->process_mac_extensions = (val != NULL && val[0] != 0);
+		return (ARCHIVE_OK);
+	}
+
+	/* Note: The "warn" return is just to inform the options
+	 * supervisor that we didn't handle it.  It will generate
+	 * a suitable error if no one used this option. */
+	return (ARCHIVE_WARN);
+}
+
+int
+archive_read_support_format_zip(struct archive *a)
+{
+	int r;
+	r = archive_read_support_format_zip_streamable(a);
+	if (r != ARCHIVE_OK)
+		return r;
+	return (archive_read_support_format_zip_seekable(a));
+}
+
+/* ------------------------------------------------------------------------ */
+
+/*
+ * Streaming-mode support
+ */
+
+
+static int
+archive_read_support_format_zip_capabilities_streamable(struct archive_read * a)
+{
+	(void)a; /* UNUSED */
+	return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+static int
+archive_read_format_zip_streamable_bid(struct archive_read *a, int best_bid)
+{
+	const char *p;
+
+	(void)best_bid; /* UNUSED */
+
+	if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
+		return (-1);
+
+	/*
+	 * Bid of 29 here comes from:
+	 *  + 16 bits for "PK",
+	 *  + next 16-bit field has 6 options so contributes
+	 *    about 16 - log_2(6) ~= 16 - 2.6 ~= 13 bits
+	 *
+	 * So we've effectively verified ~29 total bits of check data.
+	 */
+	if (p[0] == 'P' && p[1] == 'K') {
+		if ((p[2] == '\001' && p[3] == '\002')
+		    || (p[2] == '\003' && p[3] == '\004')
+		    || (p[2] == '\005' && p[3] == '\006')
+		    || (p[2] == '\006' && p[3] == '\006')
+		    || (p[2] == '\007' && p[3] == '\010')
+		    || (p[2] == '0' && p[3] == '0'))
+			return (29);
+	}
+
+	/* TODO: It's worth looking ahead a little bit for a valid
+	 * PK signature.  In particular, that would make it possible
+	 * to read some UUEncoded SFX files or SFX files coming from
+	 * a network socket. */
+
+	return (0);
+}
+
+static int
+archive_read_format_zip_streamable_read_header(struct archive_read *a,
+    struct archive_entry *entry)
 {
 	struct zip *zip;
 
+	a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
+	if (a->archive.archive_format_name == NULL)
+		a->archive.archive_format_name = "ZIP";
+
 	zip = (struct zip *)(a->format->data);
 
+	/*
+	 * It should be sufficient to call archive_read_next_header() for
+	 * a reader to determine if an entry is encrypted or not. If the
+	 * encryption of an entry is only detectable when calling
+	 * archive_read_data(), so be it. We'll do the same check there
+	 * as well.
+	 */
+	if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+		zip->has_encrypted_entries = 0;
+	}
+
+	/* Make sure we have a zip_entry structure to use. */
+	if (zip->zip_entries == NULL) {
+		zip->zip_entries = malloc(sizeof(struct zip_entry));
+		if (zip->zip_entries == NULL) {
+			archive_set_error(&a->archive, ENOMEM,
+			    "Out  of memory");
+			return ARCHIVE_FATAL;
+		}
+	}
+	zip->entry = zip->zip_entries;
+	memset(zip->entry, 0, sizeof(struct zip_entry));
+
+	/* Search ahead for the next local file header. */
+	__archive_read_consume(a, zip->unconsumed);
+	zip->unconsumed = 0;
+	for (;;) {
+		int64_t skipped = 0;
+		const char *p, *end;
+		ssize_t bytes;
+
+		p = __archive_read_ahead(a, 4, &bytes);
+		if (p == NULL)
+			return (ARCHIVE_FATAL);
+		end = p + bytes;
+
+		while (p + 4 <= end) {
+			if (p[0] == 'P' && p[1] == 'K') {
+				if (p[2] == '\003' && p[3] == '\004') {
+					/* Regular file entry. */
+					__archive_read_consume(a, skipped);
+					return zip_read_local_file_header(a,
+					    entry, zip);
+				}
+
+                              /*
+                               * TODO: We cannot restore permissions
+                               * based only on the local file headers.
+                               * Consider scanning the central
+                               * directory and returning additional
+                               * entries for at least directories.
+                               * This would allow us to properly set
+                               * directory permissions.
+			       *
+			       * This won't help us fix symlinks
+			       * and may not help with regular file
+			       * permissions, either.  <sigh>
+                               */
+                              if (p[2] == '\001' && p[3] == '\002') {
+                                      return (ARCHIVE_EOF);
+                              }
+
+                              /* End of central directory?  Must be an
+                               * empty archive. */
+                              if ((p[2] == '\005' && p[3] == '\006')
+                                  || (p[2] == '\006' && p[3] == '\006'))
+                                      return (ARCHIVE_EOF);
+			}
+			++p;
+			++skipped;
+		}
+		__archive_read_consume(a, skipped);
+	}
+}
+
+static int
+archive_read_format_zip_read_data_skip_streamable(struct archive_read *a)
+{
+	struct zip *zip;
+	int64_t bytes_skipped;
+
+	zip = (struct zip *)(a->format->data);
+	bytes_skipped = __archive_read_consume(a, zip->unconsumed);
+	zip->unconsumed = 0;
+	if (bytes_skipped < 0)
+		return (ARCHIVE_FATAL);
+
 	/* If we've already read to end of data, we're done. */
 	if (zip->end_of_entry)
 		return (ARCHIVE_OK);
 
 	/* So we know we're streaming... */
-	if (0 == (zip->entry->flags & ZIP_LENGTH_AT_END)) {
+	if (0 == (zip->entry->zip_flags & ZIP_LENGTH_AT_END)
+	    || zip->entry->compressed_size > 0) {
 		/* We know the compressed length, so we can just skip. */
-		int64_t bytes_skipped = zip_read_consume(a,
-		    zip->entry_bytes_remaining + zip->unconsumed);
+		bytes_skipped = __archive_read_consume(a, zip->entry_bytes_remaining);
 		if (bytes_skipped < 0)
 			return (ARCHIVE_FATAL);
-		zip->unconsumed = 0;
 		return (ARCHIVE_OK);
 	}
 
@@ -1544,8 +1388,6 @@
 #endif
 	default: /* Uncompressed or unknown. */
 		/* Scan for a PK\007\010 signature. */
-		zip_read_consume(a, zip->unconsumed);
-		zip->unconsumed = 0;
 		for (;;) {
 			const char *p, *buff;
 			ssize_t bytes_avail;
@@ -1563,180 +1405,772 @@
 				else if (p[3] == '\007') { p += 1; }
 				else if (p[3] == '\010' && p[2] == '\007'
 				    && p[1] == 'K' && p[0] == 'P') {
-					zip_read_consume(a, p - buff + 16);
+					if (zip->entry->flags & LA_USED_ZIP64)
+						__archive_read_consume(a, p - buff + 24);
+					else
+						__archive_read_consume(a, p - buff + 16);
 					return ARCHIVE_OK;
 				} else { p += 4; }
 			}
-			zip_read_consume(a, p - buff);
+			__archive_read_consume(a, p - buff);
 		}
 	}
 }
 
-static int
-archive_read_format_zip_cleanup(struct archive_read *a)
+int
+archive_read_support_format_zip_streamable(struct archive *_a)
 {
+	struct archive_read *a = (struct archive_read *)_a;
 	struct zip *zip;
+	int r;
 
-	zip = (struct zip *)(a->format->data);
-#ifdef HAVE_ZLIB_H
-	if (zip->stream_valid)
-		inflateEnd(&zip->stream);
-#endif
-	if (zip->zip_entries && zip->central_directory_entries) {
-		unsigned i;
-		for (i = 0; i < zip->central_directory_entries; i++)
-			archive_string_free(&(zip->zip_entries[i].rsrcname));
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_zip");
+
+	zip = (struct zip *)malloc(sizeof(*zip));
+	if (zip == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate zip data");
+		return (ARCHIVE_FATAL);
 	}
-	free(zip->zip_entries);
-	free(zip->uncompressed_buffer);
-	archive_string_free(&(zip->extra));
-	free(zip);
-	(a->format->data) = NULL;
+	memset(zip, 0, sizeof(*zip));
+
+	/* Streamable reader doesn't support mac extensions. */
+	zip->process_mac_extensions = 0;
+
+	/*
+	 * Until enough data has been read, we cannot tell about
+	 * any encrypted entries yet.
+	 */
+	zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+	zip->crc32func = real_crc32;
+
+	r = __archive_read_register_format(a,
+	    zip,
+	    "zip",
+	    archive_read_format_zip_streamable_bid,
+	    archive_read_format_zip_options,
+	    archive_read_format_zip_streamable_read_header,
+	    archive_read_format_zip_read_data,
+	    archive_read_format_zip_read_data_skip_streamable,
+	    NULL,
+	    archive_read_format_zip_cleanup,
+	    archive_read_support_format_zip_capabilities_streamable,
+	    archive_read_format_zip_has_encrypted_entries);
+
+	if (r != ARCHIVE_OK)
+		free(zip);
 	return (ARCHIVE_OK);
 }
 
+/* ------------------------------------------------------------------------ */
+
 /*
- * The extra data is stored as a list of
- *	id1+size1+data1 + id2+size2+data2 ...
- *  triplets.  id and size are 2 bytes each.
+ * Seeking-mode support
  */
-static void
-process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
+
+static int
+archive_read_support_format_zip_capabilities_seekable(struct archive_read * a)
 {
-	unsigned offset = 0;
+	(void)a; /* UNUSED */
+	return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
 
-	while (offset < extra_length - 4)
-	{
-		unsigned short headerid = archive_le16dec(p + offset);
-		unsigned short datasize = archive_le16dec(p + offset + 2);
-		offset += 4;
-		if (offset + datasize > extra_length)
-			break;
-#ifdef DEBUG
-		fprintf(stderr, "Header id 0x%x, length %d\n",
-		    headerid, datasize);
-#endif
-		switch (headerid) {
-		case 0x0001:
-			/* Zip64 extended information extra field. */
-			if (datasize >= 8)
-				zip_entry->uncompressed_size =
-				    archive_le64dec(p + offset);
-			if (datasize >= 16)
-				zip_entry->compressed_size =
-				    archive_le64dec(p + offset + 8);
-			break;
-		case 0x5455:
-		{
-			/* Extended time field "UT". */
-			int flags = p[offset];
-			offset++;
-			datasize--;
-			/* Flag bits indicate which dates are present. */
-			if (flags & 0x01)
-			{
-#ifdef DEBUG
-				fprintf(stderr, "mtime: %lld -> %d\n",
-				    (long long)zip_entry->mtime,
-				    archive_le32dec(p + offset));
-#endif
-				if (datasize < 4)
-					break;
-				zip_entry->mtime = archive_le32dec(p + offset);
-				offset += 4;
-				datasize -= 4;
-			}
-			if (flags & 0x02)
-			{
-				if (datasize < 4)
-					break;
-				zip_entry->atime = archive_le32dec(p + offset);
-				offset += 4;
-				datasize -= 4;
-			}
-			if (flags & 0x04)
-			{
-				if (datasize < 4)
-					break;
-				zip_entry->ctime = archive_le32dec(p + offset);
-				offset += 4;
-				datasize -= 4;
-			}
-			break;
-		}
-		case 0x5855:
-		{
-			/* Info-ZIP Unix Extra Field (old version) "UX". */
-			if (datasize >= 8) {
-				zip_entry->atime = archive_le32dec(p + offset);
-				zip_entry->mtime =
-				    archive_le32dec(p + offset + 4);
-			}
-			if (datasize >= 12) {
-				zip_entry->uid =
-				    archive_le16dec(p + offset + 8);
-				zip_entry->gid =
-				    archive_le16dec(p + offset + 10);
-			}
-			break;
-		}
-		case 0x7855:
-			/* Info-ZIP Unix Extra Field (type 2) "Ux". */
-#ifdef DEBUG
-			fprintf(stderr, "uid %d gid %d\n",
-			    archive_le16dec(p + offset),
-			    archive_le16dec(p + offset + 2));
-#endif
-			if (datasize >= 2)
-				zip_entry->uid = archive_le16dec(p + offset);
-			if (datasize >= 4)
-				zip_entry->gid =
-				    archive_le16dec(p + offset + 2);
-			break;
-		case 0x7875:
-		{
-			/* Info-Zip Unix Extra Field (type 3) "ux". */
-			int uidsize = 0, gidsize = 0;
+/*
+ * TODO: This is a performance sink because it forces the read core to
+ * drop buffered data from the start of file, which will then have to
+ * be re-read again if this bidder loses.
+ *
+ * We workaround this a little by passing in the best bid so far so
+ * that later bidders can do nothing if they know they'll never
+ * outbid.  But we can certainly do better...
+ */
+static int
+read_eocd(struct zip *zip, const char *p, int64_t current_offset)
+{
+	/* Sanity-check the EOCD we've found. */
 
-			if (datasize >= 1 && p[offset] == 1) {/* version=1 */
-				if (datasize >= 4) {
-					/* get a uid size. */
-					uidsize = p[offset+1];
-					if (uidsize == 2)
-						zip_entry->uid =
-						    archive_le16dec(
-						        p + offset + 2);
-					else if (uidsize == 4 && datasize >= 6)
-						zip_entry->uid =
-						    archive_le32dec(
-						        p + offset + 2);
-				}
-				if (datasize >= (2 + uidsize + 3)) {
-					/* get a gid size. */
-					gidsize = p[offset+2+uidsize];
-					if (gidsize == 2)
-						zip_entry->gid =
-						    archive_le16dec(
-						        p+offset+2+uidsize+1);
-					else if (gidsize == 4 &&
-					    datasize >= (2 + uidsize + 5))
-						zip_entry->gid =
-						    archive_le32dec(
-						        p+offset+2+uidsize+1);
-				}
+	/* This must be the first volume. */
+	if (archive_le16dec(p + 4) != 0)
+		return 0;
+	/* Central directory must be on this volume. */
+	if (archive_le16dec(p + 4) != archive_le16dec(p + 6))
+		return 0;
+	/* All central directory entries must be on this volume. */
+	if (archive_le16dec(p + 10) != archive_le16dec(p + 8))
+		return 0;
+	/* Central directory can't extend beyond start of EOCD record. */
+	if (archive_le32dec(p + 16) + archive_le32dec(p + 12)
+	    > current_offset)
+		return 0;
+
+	/* Save the central directory location for later use. */
+	zip->central_directory_offset = archive_le32dec(p + 16);
+
+	/* This is just a tiny bit higher than the maximum
+	   returned by the streaming Zip bidder.  This ensures
+	   that the more accurate seeking Zip parser wins
+	   whenever seek is available. */
+	return 32;
+}
+
+static int
+read_zip64_eocd(struct archive_read *a, struct zip *zip, const char *p)
+{
+	int64_t eocd64_offset;
+	int64_t eocd64_size;
+
+	/* Sanity-check the locator record. */
+
+	/* Central dir must be on first volume. */
+	if (archive_le32dec(p + 4) != 0)
+		return 0;
+	/* Must be only a single volume. */
+	if (archive_le32dec(p + 16) != 1)
+		return 0;
+
+	/* Find the Zip64 EOCD record. */
+	eocd64_offset = archive_le64dec(p + 8);
+	if (__archive_read_seek(a, eocd64_offset, SEEK_SET) < 0)
+		return 0;
+	if ((p = __archive_read_ahead(a, 56, NULL)) == NULL)
+		return 0;
+	/* Make sure we can read all of it. */
+	eocd64_size = archive_le64dec(p + 4) + 12;
+	if (eocd64_size < 56 || eocd64_size > 16384)
+		return 0;
+	if ((p = __archive_read_ahead(a, eocd64_size, NULL)) == NULL)
+		return 0;
+
+	/* Sanity-check the EOCD64 */
+	if (archive_le32dec(p + 16) != 0) /* Must be disk #0 */
+		return 0;
+	if (archive_le32dec(p + 20) != 0) /* CD must be on disk #0 */
+		return 0;
+	/* CD can't be split. */
+	if (archive_le64dec(p + 24) != archive_le64dec(p + 32))
+		return 0;
+
+	/* Save the central directory offset for later use. */
+	zip->central_directory_offset = archive_le64dec(p + 48);
+
+	return 32;
+}
+
+static int
+archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
+{
+	struct zip *zip = (struct zip *)a->format->data;
+	int64_t file_size, current_offset;
+	const char *p;
+	int i, tail;
+
+	/* If someone has already bid more than 32, then avoid
+	   trashing the look-ahead buffers with a seek. */
+	if (best_bid > 32)
+		return (-1);
+
+	file_size = __archive_read_seek(a, 0, SEEK_END);
+	if (file_size <= 0)
+		return 0;
+
+	/* Search last 16k of file for end-of-central-directory
+	 * record (which starts with PK\005\006) or Zip64 locator
+	 * record (which begins with PK\006\007) */
+	tail = zipmin(1024 * 16, file_size);
+	current_offset = __archive_read_seek(a, -tail, SEEK_END);
+	if (current_offset < 0)
+		return 0;
+	if ((p = __archive_read_ahead(a, (size_t)tail, NULL)) == NULL)
+		return 0;
+	/* TODO: Rework this to search backwards from the end.  We
+	 * normally expect the EOCD record to be at the very end, so
+	 * that should be significantly faster.  Tricky part: Make
+	 * sure we still prefer the Zip64 locator if it's present. */
+	for (i = 0; i <= tail - 22;) {
+		switch (p[i + 3]) {
+		case 'P': i += 3; break;
+		case 'K': i += 2; break;
+		case 005: i += 1; break;
+		case 006:
+			if (memcmp(p + i, "PK\005\006", 4) == 0) {
+				int ret = read_eocd(zip, p + i, current_offset + i);
+				if (ret > 0)
+					return (ret);
 			}
+			i += 1; /* Look for PK\006\007 next */
+			break;
+		case 007:
+			if (memcmp(p + i, "PK\006\007", 4) == 0) {
+				int ret = read_zip64_eocd(a, zip, p + i);
+				if (ret > 0)
+					return (ret);
+			}
+			i += 4;
+			break;
+		default: i += 4; break;
+		}
+	}
+	return 0;
+}
+
+/* The red-black trees are only used in seeking mode to manage
+ * the in-memory copy of the central directory. */
+
+static int
+cmp_node(const struct archive_rb_node *n1, const struct archive_rb_node *n2)
+{
+	const struct zip_entry *e1 = (const struct zip_entry *)n1;
+	const struct zip_entry *e2 = (const struct zip_entry *)n2;
+
+	if (e1->local_header_offset > e2->local_header_offset)
+		return -1;
+	if (e1->local_header_offset < e2->local_header_offset)
+		return 1;
+	return 0;
+}
+
+static int
+cmp_key(const struct archive_rb_node *n, const void *key)
+{
+	/* This function won't be called */
+	(void)n; /* UNUSED */
+	(void)key; /* UNUSED */
+	return 1;
+}
+
+static const struct archive_rb_tree_ops rb_ops = {
+	&cmp_node, &cmp_key
+};
+
+static int
+rsrc_cmp_node(const struct archive_rb_node *n1,
+    const struct archive_rb_node *n2)
+{
+	const struct zip_entry *e1 = (const struct zip_entry *)n1;
+	const struct zip_entry *e2 = (const struct zip_entry *)n2;
+
+	return (strcmp(e2->rsrcname.s, e1->rsrcname.s));
+}
+
+static int
+rsrc_cmp_key(const struct archive_rb_node *n, const void *key)
+{
+	const struct zip_entry *e = (const struct zip_entry *)n;
+	return (strcmp((const char *)key, e->rsrcname.s));
+}
+
+static const struct archive_rb_tree_ops rb_rsrc_ops = {
+	&rsrc_cmp_node, &rsrc_cmp_key
+};
+
+static const char *
+rsrc_basename(const char *name, size_t name_length)
+{
+	const char *s, *r;
+
+	r = s = name;
+	for (;;) {
+		s = memchr(s, '/', name_length - (s - name));
+		if (s == NULL)
+			break;
+		r = ++s;
+	}
+	return (r);
+}
+
+static void
+expose_parent_dirs(struct zip *zip, const char *name, size_t name_length)
+{
+	struct archive_string str;
+	struct zip_entry *dir;
+	char *s;
+
+	archive_string_init(&str);
+	archive_strncpy(&str, name, name_length);
+	for (;;) {
+		s = strrchr(str.s, '/');
+		if (s == NULL)
+			break;
+		*s = '\0';
+		/* Transfer the parent directory from zip->tree_rsrc RB
+		 * tree to zip->tree RB tree to expose. */
+		dir = (struct zip_entry *)
+		    __archive_rb_tree_find_node(&zip->tree_rsrc, str.s);
+		if (dir == NULL)
+			break;
+		__archive_rb_tree_remove_node(&zip->tree_rsrc, &dir->node);
+		archive_string_free(&dir->rsrcname);
+		__archive_rb_tree_insert_node(&zip->tree, &dir->node);
+	}
+	archive_string_free(&str);
+}
+
+static int
+slurp_central_directory(struct archive_read *a, struct zip *zip)
+{
+	ssize_t i;
+	unsigned found;
+	int64_t correction;
+	ssize_t bytes_avail;
+	const char *p;
+
+	/*
+	 * Find the start of the central directory.  The end-of-CD
+	 * record has our starting point, but there are lots of
+	 * Zip archives which have had other data prepended to the
+	 * file, which makes the recorded offsets all too small.
+	 * So we search forward from the specified offset until we
+	 * find the real start of the central directory.  Then we
+	 * know the correction we need to apply to account for leading
+	 * padding.
+	 */
+	if (__archive_read_seek(a, zip->central_directory_offset, SEEK_SET) < 0)
+		return ARCHIVE_FATAL;
+
+	found = 0;
+	while (!found) {
+		if ((p = __archive_read_ahead(a, 20, &bytes_avail)) == NULL)
+			return ARCHIVE_FATAL;
+		for (found = 0, i = 0; !found && i < bytes_avail - 4;) {
+			switch (p[i + 3]) {
+			case 'P': i += 3; break;
+			case 'K': i += 2; break;
+			case 001: i += 1; break;
+			case 002:
+				if (memcmp(p + i, "PK\001\002", 4) == 0) {
+					p += i;
+					found = 1;
+				} else
+					i += 4;
+				break;
+			case 005: i += 1; break;
+			case 006:
+				if (memcmp(p + i, "PK\005\006", 4) == 0) {
+					p += i;
+					found = 1;
+				} else if (memcmp(p + i, "PK\006\006", 4) == 0) {
+					p += i;
+					found = 1;
+				} else
+					i += 1;
+				break;
+			default: i += 4; break;
+			}
+		}
+		__archive_read_consume(a, i);
+	}
+	correction = archive_filter_bytes(&a->archive, 0) - zip->central_directory_offset;
+
+	__archive_rb_tree_init(&zip->tree, &rb_ops);
+	__archive_rb_tree_init(&zip->tree_rsrc, &rb_rsrc_ops);
+
+	zip->central_directory_entries_total = 0;
+	while (1) {
+		struct zip_entry *zip_entry;
+		size_t filename_length, extra_length, comment_length;
+		uint32_t external_attributes;
+		const char *name, *r;
+
+		if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
+			return ARCHIVE_FATAL;
+		if (memcmp(p, "PK\006\006", 4) == 0
+		    || memcmp(p, "PK\005\006", 4) == 0) {
+			break;
+		} else if (memcmp(p, "PK\001\002", 4) != 0) {
+			archive_set_error(&a->archive,
+			    -1, "Invalid central directory signature");
+			return ARCHIVE_FATAL;
+		}
+		if ((p = __archive_read_ahead(a, 46, NULL)) == NULL)
+			return ARCHIVE_FATAL;
+
+		zip_entry = calloc(1, sizeof(struct zip_entry));
+		zip_entry->next = zip->zip_entries;
+		zip_entry->flags |= LA_FROM_CENTRAL_DIRECTORY;
+		zip->zip_entries = zip_entry;
+		zip->central_directory_entries_total++;
+
+		/* version = p[4]; */
+		zip_entry->system = p[5];
+		/* version_required = archive_le16dec(p + 6); */
+		zip_entry->zip_flags = archive_le16dec(p + 8);
+		if (zip_entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)){
+			zip->has_encrypted_entries = 1;
+		}
+		zip_entry->compression = (char)archive_le16dec(p + 10);
+		zip_entry->mtime = zip_time(p + 12);
+		zip_entry->crc32 = archive_le32dec(p + 16);
+		zip_entry->compressed_size = archive_le32dec(p + 20);
+		zip_entry->uncompressed_size = archive_le32dec(p + 24);
+		filename_length = archive_le16dec(p + 28);
+		extra_length = archive_le16dec(p + 30);
+		comment_length = archive_le16dec(p + 32);
+		/* disk_start = archive_le16dec(p + 34); */ /* Better be zero. */
+		/* internal_attributes = archive_le16dec(p + 36); */ /* text bit */
+		external_attributes = archive_le32dec(p + 38);
+		zip_entry->local_header_offset =
+		    archive_le32dec(p + 42) + correction;
+
+		/* If we can't guess the mode, leave it zero here;
+		   when we read the local file header we might get
+		   more information. */
+		zip_entry->mode = 0;
+		if (zip_entry->system == 3) {
+			zip_entry->mode = external_attributes >> 16;
+		}
+
+		/* We're done with the regular data; get the filename and
+		 * extra data. */
+		__archive_read_consume(a, 46);
+		if ((p = __archive_read_ahead(a, filename_length + extra_length, NULL))
+		    == NULL) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Truncated ZIP file header");
+			return ARCHIVE_FATAL;
+		}
+		process_extra(p + filename_length, extra_length, zip_entry);
+
+		/*
+		 * Mac resource fork files are stored under the
+		 * "__MACOSX/" directory, so we should check if
+		 * it is.
+		 */
+		if (!zip->process_mac_extensions) {
+			/* Treat every entry as a regular entry. */
+			__archive_rb_tree_insert_node(&zip->tree,
+			    &zip_entry->node);
+		} else {
+			name = p;
+			r = rsrc_basename(name, filename_length);
+			if (filename_length >= 9 &&
+			    strncmp("__MACOSX/", name, 9) == 0) {
+				/* If this file is not a resource fork nor
+				 * a directory. We should treat it as a non
+				 * resource fork file to expose it. */
+				if (name[filename_length-1] != '/' &&
+				    (r - name < 3 || r[0] != '.' || r[1] != '_')) {
+					__archive_rb_tree_insert_node(&zip->tree,
+					    &zip_entry->node);
+					/* Expose its parent directories. */
+					expose_parent_dirs(zip, name, filename_length);
+				} else {
+					/* This file is a resource fork file or
+					 * a directory. */
+					archive_strncpy(&(zip_entry->rsrcname), name,
+					    filename_length);
+					__archive_rb_tree_insert_node(&zip->tree_rsrc,
+					    &zip_entry->node);
+				}
+			} else {
+				/* Generate resource fork name to find its resource
+				 * file at zip->tree_rsrc. */
+				archive_strcpy(&(zip_entry->rsrcname), "__MACOSX/");
+				archive_strncat(&(zip_entry->rsrcname), name, r - name);
+				archive_strcat(&(zip_entry->rsrcname), "._");
+				archive_strncat(&(zip_entry->rsrcname),
+				    name + (r - name), filename_length - (r - name));
+				/* Register an entry to RB tree to sort it by
+				 * file offset. */
+				__archive_rb_tree_insert_node(&zip->tree,
+				    &zip_entry->node);
+			}
+		}
+
+		/* Skip the comment too ... */
+		__archive_read_consume(a,
+		    filename_length + extra_length + comment_length);
+	}
+
+	return ARCHIVE_OK;
+}
+
+static ssize_t
+zip_get_local_file_header_size(struct archive_read *a, size_t extra)
+{
+	const char *p;
+	ssize_t filename_length, extra_length;
+
+	if ((p = __archive_read_ahead(a, extra + 30, NULL)) == NULL) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Truncated ZIP file header");
+		return (ARCHIVE_WARN);
+	}
+	p += extra;
+
+	if (memcmp(p, "PK\003\004", 4) != 0) {
+		archive_set_error(&a->archive, -1, "Damaged Zip archive");
+		return ARCHIVE_WARN;
+	}
+	filename_length = archive_le16dec(p + 26);
+	extra_length = archive_le16dec(p + 28);
+
+	return (30 + filename_length + extra_length);
+}
+
+static int
+zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry,
+    struct zip_entry *rsrc)
+{
+	struct zip *zip = (struct zip *)a->format->data;
+	unsigned char *metadata, *mp;
+	int64_t offset = archive_filter_bytes(&a->archive, 0);
+	size_t remaining_bytes, metadata_bytes;
+	ssize_t hsize;
+	int ret = ARCHIVE_OK, eof;
+
+	switch(rsrc->compression) {
+	case 0:  /* No compression. */
+#ifdef HAVE_ZLIB_H
+	case 8: /* Deflate compression. */
+#endif
+		break;
+	default: /* Unsupported compression. */
+		/* Return a warning. */
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Unsupported ZIP compression method (%s)",
+		    compression_name(rsrc->compression));
+		/* We can't decompress this entry, but we will
+		 * be able to skip() it and try the next entry. */
+		return (ARCHIVE_WARN);
+	}
+
+	if (rsrc->uncompressed_size > (4 * 1024 * 1024)) {
+		archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+		    "Mac metadata is too large: %jd > 4M bytes",
+		    (intmax_t)rsrc->uncompressed_size);
+		return (ARCHIVE_WARN);
+	}
+
+	metadata = malloc((size_t)rsrc->uncompressed_size);
+	if (metadata == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate memory for Mac metadata");
+		return (ARCHIVE_FATAL);
+	}
+
+	if (offset < rsrc->local_header_offset)
+		__archive_read_consume(a, rsrc->local_header_offset - offset);
+	else if (offset != rsrc->local_header_offset) {
+		__archive_read_seek(a, rsrc->local_header_offset, SEEK_SET);
+	}
+
+	hsize = zip_get_local_file_header_size(a, 0);
+	__archive_read_consume(a, hsize);
+
+	remaining_bytes = (size_t)rsrc->compressed_size;
+	metadata_bytes = (size_t)rsrc->uncompressed_size;
+	mp = metadata;
+	eof = 0;
+	while (!eof && remaining_bytes) {
+		const unsigned char *p;
+		ssize_t bytes_avail;
+		size_t bytes_used;
+
+		p = __archive_read_ahead(a, 1, &bytes_avail);
+		if (p == NULL) {
+			archive_set_error(&a->archive,
+			    ARCHIVE_ERRNO_FILE_FORMAT,
+			    "Truncated ZIP file header");
+			ret = ARCHIVE_WARN;
+			goto exit_mac_metadata;
+		}
+		if ((size_t)bytes_avail > remaining_bytes)
+			bytes_avail = remaining_bytes;
+		switch(rsrc->compression) {
+		case 0:  /* No compression. */
+			memcpy(mp, p, bytes_avail);
+			bytes_used = (size_t)bytes_avail;
+			metadata_bytes -= bytes_used;
+			mp += bytes_used;
+			if (metadata_bytes == 0)
+				eof = 1;
+			break;
+#ifdef HAVE_ZLIB_H
+		case 8: /* Deflate compression. */
+		{
+			int r;
+
+			ret = zip_deflate_init(a, zip);
+			if (ret != ARCHIVE_OK)
+				goto exit_mac_metadata;
+			zip->stream.next_in =
+			    (Bytef *)(uintptr_t)(const void *)p;
+			zip->stream.avail_in = (uInt)bytes_avail;
+			zip->stream.total_in = 0;
+			zip->stream.next_out = mp;
+			zip->stream.avail_out = (uInt)metadata_bytes;
+			zip->stream.total_out = 0;
+
+			r = inflate(&zip->stream, 0);
+			switch (r) {
+			case Z_OK:
+				break;
+			case Z_STREAM_END:
+				eof = 1;
+				break;
+			case Z_MEM_ERROR:
+				archive_set_error(&a->archive, ENOMEM,
+				    "Out of memory for ZIP decompression");
+				ret = ARCHIVE_FATAL;
+				goto exit_mac_metadata;
+			default:
+				archive_set_error(&a->archive,
+				    ARCHIVE_ERRNO_MISC,
+				    "ZIP decompression failed (%d)", r);
+				ret = ARCHIVE_FATAL;
+				goto exit_mac_metadata;
+			}
+			bytes_used = zip->stream.total_in;
+			metadata_bytes -= zip->stream.total_out;
+			mp += zip->stream.total_out;
 			break;
 		}
+#endif
 		default:
+			bytes_used = 0;
 			break;
 		}
-		offset += datasize;
+		__archive_read_consume(a, bytes_used);
+		remaining_bytes -= bytes_used;
 	}
-#ifdef DEBUG
-	if (offset != extra_length)
-	{
-		fprintf(stderr,
-		    "Extra data field contents do not match reported size!\n");
+	archive_entry_copy_mac_metadata(entry, metadata,
+	    (size_t)rsrc->uncompressed_size - metadata_bytes);
+
+exit_mac_metadata:
+	__archive_read_seek(a, offset, SEEK_SET);
+	zip->decompress_init = 0;
+	free(metadata);
+	return (ret);
+}
+
+static int
+archive_read_format_zip_seekable_read_header(struct archive_read *a,
+	struct archive_entry *entry)
+{
+	struct zip *zip = (struct zip *)a->format->data;
+	struct zip_entry *rsrc;
+	int64_t offset;
+	int r, ret = ARCHIVE_OK;
+
+	/*
+	 * It should be sufficient to call archive_read_next_header() for
+	 * a reader to determine if an entry is encrypted or not. If the
+	 * encryption of an entry is only detectable when calling
+	 * archive_read_data(), so be it. We'll do the same check there
+	 * as well.
+	 */
+	if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+		zip->has_encrypted_entries = 0;
 	}
+
+	a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
+	if (a->archive.archive_format_name == NULL)
+		a->archive.archive_format_name = "ZIP";
+
+	if (zip->zip_entries == NULL) {
+		r = slurp_central_directory(a, zip);
+		if (r != ARCHIVE_OK)
+			return r;
+		/* Get first entry whose local header offset is lower than
+		 * other entries in the archive file. */
+		zip->entry =
+		    (struct zip_entry *)ARCHIVE_RB_TREE_MIN(&zip->tree);
+	} else if (zip->entry != NULL) {
+		/* Get next entry in local header offset order. */
+		zip->entry = (struct zip_entry *)__archive_rb_tree_iterate(
+		    &zip->tree, &zip->entry->node, ARCHIVE_RB_DIR_RIGHT);
+	}
+
+	if (zip->entry == NULL)
+		return ARCHIVE_EOF;
+
+	if (zip->entry->rsrcname.s)
+		rsrc = (struct zip_entry *)__archive_rb_tree_find_node(
+		    &zip->tree_rsrc, zip->entry->rsrcname.s);
+	else
+		rsrc = NULL;
+
+	/* File entries are sorted by the header offset, we should mostly
+	 * use __archive_read_consume to advance a read point to avoid redundant
+	 * data reading.  */
+	offset = archive_filter_bytes(&a->archive, 0);
+	if (offset < zip->entry->local_header_offset)
+		__archive_read_consume(a,
+		    zip->entry->local_header_offset - offset);
+	else if (offset != zip->entry->local_header_offset) {
+		__archive_read_seek(a, zip->entry->local_header_offset, SEEK_SET);
+	}
+	zip->unconsumed = 0;
+	r = zip_read_local_file_header(a, entry, zip);
+	if (r != ARCHIVE_OK)
+		return r;
+	if (rsrc) {
+		int ret2 = zip_read_mac_metadata(a, entry, rsrc);
+		if (ret2 < ret)
+			ret = ret2;
+	}
+	return (ret);
+}
+
+/*
+ * We're going to seek for the next header anyway, so we don't
+ * need to bother doing anything here.
+ */
+static int
+archive_read_format_zip_read_data_skip_seekable(struct archive_read *a)
+{
+	struct zip *zip;
+	zip = (struct zip *)(a->format->data);
+
+	zip->unconsumed = 0;
+	return (ARCHIVE_OK);
+}
+
+int
+archive_read_support_format_zip_seekable(struct archive *_a)
+{
+	struct archive_read *a = (struct archive_read *)_a;
+	struct zip *zip;
+	int r;
+
+	archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable");
+
+	zip = (struct zip *)malloc(sizeof(*zip));
+	if (zip == NULL) {
+		archive_set_error(&a->archive, ENOMEM,
+		    "Can't allocate zip data");
+		return (ARCHIVE_FATAL);
+	}
+	memset(zip, 0, sizeof(*zip));
+
+#ifdef HAVE_COPYFILE_H
+	/* Set this by default on Mac OS. */
+	zip->process_mac_extensions = 1;
 #endif
+
+	/*
+	 * Until enough data has been read, we cannot tell about
+	 * any encrypted entries yet.
+	 */
+	zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+	zip->crc32func = real_crc32;
+
+	r = __archive_read_register_format(a,
+	    zip,
+	    "zip",
+	    archive_read_format_zip_seekable_bid,
+	    archive_read_format_zip_options,
+	    archive_read_format_zip_seekable_read_header,
+	    archive_read_format_zip_read_data,
+	    archive_read_format_zip_read_data_skip_seekable,
+	    NULL,
+	    archive_read_format_zip_cleanup,
+	    archive_read_support_format_zip_capabilities_seekable,
+	    archive_read_format_zip_has_encrypted_entries);
+
+	if (r != ARCHIVE_OK)
+		free(zip);
+	return (ARCHIVE_OK);
 }
diff --git a/Utilities/cmlibarchive/libarchive/archive_util.c b/Utilities/cmlibarchive/libarchive/archive_util.c
index 34d8081..b53beca 100644
--- a/Utilities/cmlibarchive/libarchive/archive_util.c
+++ b/Utilities/cmlibarchive/libarchive/archive_util.c
@@ -45,6 +45,15 @@
 #if defined(HAVE_WINCRYPT_H) && !defined(__CYGWIN__)
 #include <wincrypt.h>
 #endif
+#ifdef HAVE_ZLIB_H
+#include <cm_zlib.h>
+#endif
+#ifdef HAVE_LZMA_H
+#include <lzma.h>
+#endif
+#ifdef HAVE_BZLIB_H
+#include <cm_bzlib.h>
+#endif
 
 #include "archive.h"
 #include "archive_private.h"
@@ -54,6 +63,8 @@
 #define O_CLOEXEC	0
 #endif
 
+static int archive_utility_string_sort_helper(char **, unsigned int);
+
 /* Generic initialization of 'struct archive' objects. */
 int
 __archive_clean(struct archive *a)
@@ -74,6 +85,38 @@
 	return (ARCHIVE_VERSION_STRING);
 }
 
+const char *
+archive_version_details(void)
+{
+	static struct archive_string str;
+	static int init = 0;
+
+	if (!init) {
+		archive_string_init(&str);
+
+		archive_strcat(&str, ARCHIVE_VERSION_STRING);
+#ifdef HAVE_ZLIB_H
+		archive_strcat(&str, " zlib/");
+		archive_strcat(&str, ZLIB_VERSION);
+#endif
+#ifdef HAVE_LZMA_H
+		archive_strcat(&str, " liblzma/");
+		archive_strcat(&str, LZMA_VERSION_STRING);
+#endif
+#ifdef HAVE_BZLIB_H
+		{
+			const char *p = BZ2_bzlibVersion();
+			const char *sep = strchr(p, ',');
+			if (sep == NULL)
+				sep = p + strlen(p);
+			archive_strcat(&str, " bz2lib/");
+			archive_strncat(&str, p, sep - p);
+		}
+#endif
+	    }
+	return str.s;
+}
+
 int
 archive_errno(struct archive *a)
 {
@@ -499,3 +542,69 @@
 	}
 #endif
 }
+
+/*
+ * Utility function to sort a group of strings using quicksort.
+ */
+static int
+archive_utility_string_sort_helper(char **strings, unsigned int n)
+{
+  unsigned int i, lesser_count, greater_count;
+  char **lesser, **greater, **tmp, *pivot;
+  int retval1, retval2;
+
+  /* A list of 0 or 1 elements is already sorted */
+  if (n <= 1)
+    return (ARCHIVE_OK);
+
+  lesser_count = greater_count = 0;
+  lesser = greater = NULL;
+  pivot = strings[0];
+  for (i = 1; i < n; i++)
+  {
+    if (strcmp(strings[i], pivot) < 0)
+    {
+      lesser_count++;
+      tmp = (char **)realloc(lesser, lesser_count * sizeof(char *));
+      if (!tmp)
+        return (ARCHIVE_FATAL);
+      lesser = tmp;
+      lesser[lesser_count - 1] = strings[i];
+    }
+    else
+    {
+      greater_count++;
+      tmp = (char **)realloc(greater, greater_count * sizeof(char *));
+      if (!tmp)
+        return (ARCHIVE_FATAL);
+      greater = tmp;
+      greater[greater_count - 1] = strings[i];
+    }
+  }
+
+  /* quicksort(lesser) */
+  retval1 = archive_utility_string_sort_helper(lesser, lesser_count);
+  for (i = 0; i < lesser_count; i++)
+    strings[i] = lesser[i];
+  free(lesser);
+
+  /* pivot */
+  strings[lesser_count] = pivot;
+
+  /* quicksort(greater) */
+  retval2 = archive_utility_string_sort_helper(greater, greater_count);
+  for (i = 0; i < greater_count; i++)
+    strings[lesser_count + 1 + i] = greater[i];
+  free(greater);
+
+  return (retval1 < retval2) ? retval1 : retval2;
+}
+
+int
+archive_utility_string_sort(char **strings)
+{
+  unsigned int size = 0;
+  while (strings[size] != NULL)
+    size++;
+  return archive_utility_string_sort_helper(strings, size);
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_virtual.c b/Utilities/cmlibarchive/libarchive/archive_virtual.c
index 0c4155f..de2595a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_virtual.c
+++ b/Utilities/cmlibarchive/libarchive/archive_virtual.c
@@ -55,6 +55,14 @@
 }
 
 int
+archive_free(struct archive *a)
+{
+	if (a == NULL)
+		return (ARCHIVE_OK);
+	return ((a->vtable->archive_free)(a));
+}
+
+int
 archive_write_close(struct archive *a)
 {
 	return ((a->vtable->archive_close)(a));
@@ -76,9 +84,7 @@
 int
 archive_write_free(struct archive *a)
 {
-	if (a == NULL)
-		return (ARCHIVE_OK);
-	return ((a->vtable->archive_free)(a));
+	return archive_free(a);
 }
 
 #if ARCHIVE_VERSION_NUMBER < 4000000
@@ -93,9 +99,7 @@
 int
 archive_read_free(struct archive *a)
 {
-	if (a == NULL)
-		return (ARCHIVE_OK);
-	return ((a->vtable->archive_free)(a));
+	return archive_free(a);
 }
 
 #if ARCHIVE_VERSION_NUMBER < 4000000
diff --git a/Utilities/cmlibarchive/libarchive/archive_windows.c b/Utilities/cmlibarchive/libarchive/archive_windows.c
index d3bf758..d4e93fe 100644
--- a/Utilities/cmlibarchive/libarchive/archive_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_windows.c
@@ -301,7 +301,7 @@
 	ws = NULL;
 	if ((flags & ~O_BINARY) == O_RDONLY) {
 		/*
-		 * When we open a directory, _open function returns 
+		 * When we open a directory, _open function returns
 		 * "Permission denied" error.
 		 */
 		attr = GetFileAttributesA(path);
@@ -515,9 +515,9 @@
 	else
 		mode |= S_IFREG;
 	st->st_mode = mode;
-	
+
 	fileTimeToUTC(&info.ftLastAccessTime, &t, &ns);
-	st->st_atime = t; 
+	st->st_atime = t;
 	st->st_atime_nsec = ns;
 	fileTimeToUTC(&info.ftLastWriteTime, &t, &ns);
 	st->st_mtime = t;
@@ -525,7 +525,7 @@
 	fileTimeToUTC(&info.ftCreationTime, &t, &ns);
 	st->st_ctime = t;
 	st->st_ctime_nsec = ns;
-	st->st_size = 
+	st->st_size =
 	    ((int64_t)(info.nFileSizeHigh) * ((int64_t)MAXDWORD + 1))
 		+ (int64_t)(info.nFileSizeLow);
 #ifdef SIMULATE_WIN_STAT
@@ -599,7 +599,7 @@
 	struct ustat u;
 	int ret;
 
-	handle = la_CreateFile(path, 0, 0, NULL, OPEN_EXISTING,
+	handle = la_CreateFile(path, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING,
 		FILE_FLAG_BACKUP_SEMANTICS,
 		NULL);
 	if (handle == INVALID_HANDLE_VALUE) {
diff --git a/Utilities/cmlibarchive/libarchive/archive_windows.h b/Utilities/cmlibarchive/libarchive/archive_windows.h
index 620810c..9a19cdf 100644
--- a/Utilities/cmlibarchive/libarchive/archive_windows.h
+++ b/Utilities/cmlibarchive/libarchive/archive_windows.h
@@ -93,7 +93,7 @@
 
 /* Alias the Windows _function to the POSIX equivalent. */
 #define	close		_close
-#define	fcntl(fd, cmd, flg)	/* No operation. */		
+#define	fcntl(fd, cmd, flg)	/* No operation. */
 #ifndef fileno
 #define	fileno		_fileno
 #endif
@@ -113,13 +113,14 @@
 #define	lstat		__la_stat
 #define	open		__la_open
 #define	read		__la_read
-#if !defined(__BORLANDC__)
+#if !defined(__BORLANDC__) && !defined(__WATCOMC__)
 #define setmode		_setmode
 #endif
 #ifdef stat
 #undef stat
 #endif
 #define	stat(path,stref)		__la_stat(path,stref)
+#if !defined(__WATCOMC__)
 #if !defined(__BORLANDC__)
 #define	strdup		_strdup
 #endif
@@ -127,9 +128,12 @@
 #if !defined(__BORLANDC__)
 #define	umask		_umask
 #endif
+#endif
 #define	waitpid		__la_waitpid
 #define	write		__la_write
 
+#if !defined(__WATCOMC__)
+
 #ifndef O_RDONLY
 #define	O_RDONLY	_O_RDONLY
 #define	O_WRONLY	_O_WRONLY
@@ -188,6 +192,7 @@
 #define	S_ISDIR(m)	(((m) & S_IFMT) == S_IFDIR)	/* directory */
 #define	S_ISREG(m)	(((m) & S_IFMT) == S_IFREG)	/* regular file */
 #endif
+
 #define	S_ISLNK(m)  (((m) & S_IFMT) == S_IFLNK) /* Symbolic link */
 #define	S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) /* Socket */
 
@@ -207,7 +212,7 @@
 #define	_S_IXGRP        (_S_IXUSR >> 3) /* read permission, group */
 #define	_S_IWGRP        (_S_IWUSR >> 3) /* write permission, group */
 #define	_S_IRGRP        (_S_IRUSR >> 3) /* execute/search permission, group */
-#define	_S_IRWXO        (_S_IRWXG >> 3) 
+#define	_S_IRWXO        (_S_IRWXG >> 3)
 #define	_S_IXOTH        (_S_IXGRP >> 3) /* read permission, other */
 #define	_S_IWOTH        (_S_IWGRP >> 3) /* write permission, other */
 #define	_S_IROTH        (_S_IRGRP  >> 3) /* execute/search permission, other */
@@ -227,6 +232,8 @@
 #define	S_IWOTH        _S_IWOTH
 #define	S_IROTH        _S_IROTH
 
+#endif
+
 #define	F_DUPFD	  	0	/* Duplicate file descriptor.  */
 #define	F_GETFD		1	/* Get file descriptor flags.  */
 #define	F_SETFD		2	/* Set file descriptor flags.  */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write.c b/Utilities/cmlibarchive/libarchive/archive_write.c
index b296069..8997193 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write.c
@@ -503,8 +503,9 @@
 
 	archive_clear_error(&a->archive);
 
-	/* Finish the last entry. */
-	if (a->archive.state == ARCHIVE_STATE_DATA)
+	/* Finish the last entry if a finish callback is specified */
+	if (a->archive.state == ARCHIVE_STATE_DATA
+	    && a->format_finish_entry != NULL)
 		r = ((a->format_finish_entry)(a));
 
 	/* Finish off the archive. */
@@ -638,6 +639,9 @@
 
 	/* Format and write header. */
 	r2 = ((a->format_write_header)(a, entry));
+	if (r2 == ARCHIVE_FAILED) {
+		return (ARCHIVE_FAILED);
+	}
 	if (r2 == ARCHIVE_FATAL) {
 		a->archive.state = ARCHIVE_STATE_FATAL;
 		return (ARCHIVE_FATAL);
@@ -658,7 +662,8 @@
 	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
 	    "archive_write_finish_entry");
-	if (a->archive.state & ARCHIVE_STATE_DATA)
+	if (a->archive.state & ARCHIVE_STATE_DATA
+	    && a->format_finish_entry != NULL)
 		ret = (a->format_finish_entry)(a);
 	a->archive.state = ARCHIVE_STATE_HEADER;
 	return (ret);
@@ -671,8 +676,13 @@
 _archive_write_data(struct archive *_a, const void *buff, size_t s)
 {
 	struct archive_write *a = (struct archive_write *)_a;
+	const size_t max_write = INT_MAX;
+
 	archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
 	    ARCHIVE_STATE_DATA, "archive_write_data");
+	/* In particular, this catches attempts to pass negative values. */
+	if (s > max_write)
+		s = max_write;
 	archive_clear_error(&a->archive);
 	return ((a->format_write_data)(a, buff, s));
 }
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
index 85fdf6a..da1cf5e 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
@@ -44,7 +44,7 @@
 struct write_lrzip {
 	struct archive_write_program_data *pdata;
 	int	compression_level;
-	enum { lzma = 0, bzip2, gzip, lzo, zpaq } compression;
+	enum { lzma = 0, bzip2, gzip, lzo, none, zpaq } compression;
 };
 
 static int archive_write_lrzip_open(struct archive_write_filter *);
@@ -107,6 +107,8 @@
 			data->compression = gzip;
 		else if (strcmp(value, "lzo") == 0)
 			data->compression = lzo;
+		else if (strcmp(value, "none") == 0)
+			data->compression = none;
 		else if (strcmp(value, "zpaq") == 0)
 			data->compression = zpaq;
 		else
@@ -148,6 +150,9 @@
 	case lzo:
 		archive_strcat(&as, " -l");
 		break;
+	case none:
+		archive_strcat(&as, " -n");
+		break;
 	case zpaq:
 		archive_strcat(&as, " -z");
 		break;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c
index 9797203..5cbba54 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c
@@ -43,7 +43,7 @@
 #include "archive_acl_private.h"
 #include "archive_write_disk_private.h"
 
-#if !defined(HAVE_POSIX_ACL) || !defined(ACL_TYPE_NFS4)
+#ifndef HAVE_POSIX_ACL
 /* Default empty function body to satisfy mainline code. */
 int
 archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
@@ -79,10 +79,12 @@
 		ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_DEFAULT,
 		    ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
 		return (ret);
+#ifdef ACL_TYPE_NFS4
 	} else if (archive_acl_count(abstract_acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4) > 0) {
 		ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_NFS4,
 		    ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
 		return (ret);
+#endif
 	} else
 		return ARCHIVE_OK;
 }
@@ -94,6 +96,7 @@
 	{ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
 	{ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
 	{ARCHIVE_ENTRY_ACL_READ, ACL_READ},
+#ifdef ACL_TYPE_NFS4
 	{ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
 	{ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
 	{ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
@@ -110,8 +113,10 @@
 	{ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
 	{ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
 	{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+#endif
 };
 
+#ifdef ACL_TYPE_NFS4
 static struct {
 	int archive_inherit;
 	int platform_inherit;
@@ -121,6 +126,7 @@
 	{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
 	{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY}
 };
+#endif
 
 static int
 set_acl(struct archive *a, int fd, const char *name,
@@ -130,7 +136,9 @@
 	acl_t		 acl;
 	acl_entry_t	 acl_entry;
 	acl_permset_t	 acl_permset;
+#ifdef ACL_TYPE_NFS4
 	acl_flagset_t	 acl_flagset;
+#endif
 	int		 ret;
 	int		 ae_type, ae_permset, ae_tag, ae_id;
 	uid_t		 ae_uid;
@@ -171,14 +179,17 @@
 		case ARCHIVE_ENTRY_ACL_OTHER:
 			acl_set_tag_type(acl_entry, ACL_OTHER);
 			break;
+#ifdef ACL_TYPE_NFS4
 		case ARCHIVE_ENTRY_ACL_EVERYONE:
 			acl_set_tag_type(acl_entry, ACL_EVERYONE);
 			break;
+#endif
 		default:
 			/* XXX */
 			break;
 		}
 
+#ifdef ACL_TYPE_NFS4
 		switch (ae_type) {
 		case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
 			acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
@@ -200,6 +211,7 @@
 			// XXX error handling here.
 			break;
 		}
+#endif
 
 		acl_get_permset(acl_entry, &acl_permset);
 		acl_clear_perms(acl_permset);
@@ -210,6 +222,7 @@
 					     acl_perm_map[i].platform_perm);
 		}
 
+#ifdef ACL_TYPE_NFS4
 		acl_get_flagset_np(acl_entry, &acl_flagset);
 		acl_clear_flags_np(acl_flagset);
 		for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
@@ -217,6 +230,7 @@
 				acl_add_flag_np(acl_flagset,
 						acl_inherit_map[i].platform_inherit);
 		}
+#endif
 	}
 
 	/* Try restoring the ACL through 'fd' if we can. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
index bca2e35..a3d350b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
@@ -2215,7 +2215,8 @@
 	free(a->resource_fork);
 	free(a->compressed_buffer);
 	free(a->uncompressed_buffer);
-#ifdef HAVE_ZLIB_H
+#if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\
+	&& defined(HAVE_ZLIB_H)
 	if (a->stream_valid) {
 		switch (deflateEnd(&a->stream)) {
 		case Z_OK:
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
index 0f0780a..ed62009 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
@@ -525,7 +525,7 @@
 	static int set;
 	if (!set) {
 		set = 1;
-		lib = LoadLibrary("kernel32.dll");
+		lib = LoadLibrary(TEXT("kernel32.dll"));
 	}
 	if (lib == NULL) {
 		fprintf(stderr, "Can't load kernel32.dll?!\n");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_format.3 b/Utilities/cmlibarchive/libarchive/archive_write_format.3
index dad2f7d..39d3006 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_format.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_format.3
@@ -24,13 +24,14 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 2, 2012
+.Dd February 14, 2013
 .Dt ARCHIVE_WRITE_FORMAT 3
 .Os
 .Sh NAME
 .Nm archive_write_set_format_cpio ,
 .Nm archive_write_set_format_pax ,
 .Nm archive_write_set_format_pax_restricted ,
+.Nm archive_write_set_format_raw ,
 .Nm archive_write_set_format_shar ,
 .Nm archive_write_set_format_shar_dump ,
 .Nm archive_write_set_format_ustar
@@ -46,6 +47,8 @@
 .Ft int
 .Fn archive_write_set_format_pax_restricted "struct archive *"
 .Ft int
+.Fn archive_write_set_format_raw "struct archive *"
+.Ft int
 .Fn archive_write_set_format_shar "struct archive *"
 .Ft int
 .Fn archive_write_set_format_shar_dump "struct archive *"
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
index 641d56f..9055753 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
@@ -47,6 +47,7 @@
 	{ ARCHIVE_FORMAT_CPIO_SVR4_NOCRC,	archive_write_set_format_cpio_newc },
 	{ ARCHIVE_FORMAT_ISO9660,	archive_write_set_format_iso9660 },
 	{ ARCHIVE_FORMAT_MTREE,		archive_write_set_format_mtree },
+	{ ARCHIVE_FORMAT_RAW,		archive_write_set_format_raw },
 	{ ARCHIVE_FORMAT_SHAR,		archive_write_set_format_shar },
 	{ ARCHIVE_FORMAT_SHAR_BASE,	archive_write_set_format_shar },
 	{ ARCHIVE_FORMAT_SHAR_DUMP,	archive_write_set_format_shar_dump },
@@ -57,7 +58,7 @@
 				archive_write_set_format_pax_restricted },
 	{ ARCHIVE_FORMAT_TAR_USTAR,	archive_write_set_format_ustar },
 	{ ARCHIVE_FORMAT_XAR,		archive_write_set_format_xar },
-	{ ARCHIVE_FORMAT_ZIP,	archive_write_set_format_zip },
+	{ ARCHIVE_FORMAT_ZIP,		archive_write_set_format_zip },
 	{ 0,		NULL }
 };
 
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
index af3105e..4f3ce7d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
@@ -63,6 +63,7 @@
 	{ "pax",	archive_write_set_format_pax },
 	{ "paxr",	archive_write_set_format_pax_restricted },
 	{ "posix",	archive_write_set_format_pax },
+	{ "raw",	archive_write_set_format_raw },
 	{ "rpax",	archive_write_set_format_pax_restricted },
 	{ "shar",	archive_write_set_format_shar },
 	{ "shardump",	archive_write_set_format_shar_dump },
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c
index 9c0613c..4d343ea 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c
@@ -128,6 +128,9 @@
 	unsigned long fflags_clear;
 	dev_t rdevmajor;
 	dev_t rdevminor;
+	dev_t devmajor;
+	dev_t devminor;
+	int64_t ino;
 };
 
 struct mtree_writer {
@@ -210,6 +213,9 @@
 #define	F_SHA256	0x00800000		/* SHA-256 digest */
 #define	F_SHA384	0x01000000		/* SHA-384 digest */
 #define	F_SHA512	0x02000000		/* SHA-512 digest */
+#define	F_INO		0x04000000		/* inode number */
+#define	F_RESDEV	0x08000000		/* device ID on which the
+						 * entry resides */
 
 	/* Options */
 	int dironly;		/* If it is set, ignore all files except
@@ -823,8 +829,11 @@
 	archive_entry_fflags(entry, &me->fflags_set, &me->fflags_clear);
 	me->mtime = archive_entry_mtime(entry);
 	me->mtime_nsec = archive_entry_mtime_nsec(entry);
-	me->rdevmajor =	archive_entry_rdevmajor(entry);
+	me->rdevmajor = archive_entry_rdevmajor(entry);
 	me->rdevminor = archive_entry_rdevminor(entry);
+	me->devmajor = archive_entry_devmajor(entry);
+	me->devminor = archive_entry_devminor(entry);
+	me->ino = archive_entry_ino(entry);
 	me->size = archive_entry_size(entry);
 	if (me->filetype == AE_IFDIR) {
 		me->dir_info = calloc(1, sizeof(*me->dir_info));
@@ -882,7 +891,7 @@
 		mtree->first = 0;
 		archive_strcat(&mtree->buf, "#mtree\n");
 		if ((mtree->keys & SET_KEYS) == 0)
-			mtree->output_global_set = 0;/* Disalbed. */
+			mtree->output_global_set = 0;/* Disabled. */
 	}
 
 	mtree->entry_bytes_remaining = archive_entry_size(entry);
@@ -983,6 +992,15 @@
 	if ((keys & F_UID) != 0)
 		archive_string_sprintf(str, " uid=%jd", (intmax_t)me->uid);
 
+	if ((keys & F_INO) != 0)
+		archive_string_sprintf(str, " inode=%jd", (intmax_t)me->ino);
+	if ((keys & F_RESDEV) != 0) {
+		archive_string_sprintf(str,
+		    " resdevice=native,%ju,%ju",
+		    (uintmax_t)me->devmajor,
+		    (uintmax_t)me->devminor);
+	}
+
 	switch (me->filetype) {
 	case AE_IFLNK:
 		if ((keys & F_TYPE) != 0)
@@ -1117,7 +1135,7 @@
 		} else {
 			/* Whenever output_global_set is enabled
 			 * output global value(/set keywords)
-			 * even if the directory entry is not allowd
+			 * even if the directory entry is not allowed
 			 * to be written because the global values
 			 * can be used for the children. */
 			if (mtree->output_global_set)
@@ -1296,6 +1314,8 @@
 		if (strcmp(key, "indent") == 0) {
 			mtree->indent = (value != NULL)? 1: 0;
 			return (ARCHIVE_OK);
+		} else if (strcmp(key, "inode") == 0) {
+			keybit = F_INO;
 		}
 		break;
 	case 'l':
@@ -1314,7 +1334,9 @@
 			keybit = F_NLINK;
 		break;
 	case 'r':
-		if (strcmp(key, "ripemd160digest") == 0 ||
+		if (strcmp(key, "resdevice") == 0) {
+			keybit = F_RESDEV;
+		} else if (strcmp(key, "ripemd160digest") == 0 ||
 		    strcmp(key, "rmd160") == 0 ||
 		    strcmp(key, "rmd160digest") == 0)
 			keybit = F_RMD160;
@@ -1855,9 +1877,9 @@
 		return (ret);
 	}
 
-	/* Make a basename from dirname and slash */
+	/* Make a basename from file->parentdir.s and slash */
 	*slash  = '\0';
-	file->parentdir.length = slash - dirname;
+	file->parentdir.length = slash - file->parentdir.s;
 	archive_strcpy(&(file->basename),  slash + 1);
 	return (ret);
 }
@@ -2198,6 +2220,9 @@
 	np->mtime_nsec = file->mtime_nsec;
 	np->rdevmajor = file->rdevmajor;
 	np->rdevminor = file->rdevminor;
+	np->devmajor = file->devmajor;
+	np->devminor = file->devminor;
+	np->ino = file->ino;
 
 	return (ARCHIVE_WARN);
 }
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c
new file mode 100644
index 0000000..feff936
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c
@@ -0,0 +1,125 @@
+/*-
+ * Copyright (c) 2013 Marek Kubica
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#include "archive_entry.h"
+#include "archive_write_private.h"
+
+static ssize_t	archive_write_raw_data(struct archive_write *,
+		    const void *buff, size_t s);
+static int	archive_write_raw_free(struct archive_write *);
+static int	archive_write_raw_header(struct archive_write *,
+		    struct archive_entry *);
+
+struct raw {
+        int entries_written;
+};
+
+/*
+ * Set output format to 'raw' format.
+ */
+int
+archive_write_set_format_raw(struct archive *_a)
+{
+	struct archive_write *a = (struct archive_write *)_a;
+	struct raw *raw;
+
+	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+	    ARCHIVE_STATE_NEW, "archive_write_set_format_raw");
+
+	/* If someone else was already registered, unregister them. */
+	if (a->format_free != NULL)
+		(a->format_free)(a);
+
+	raw = (struct raw *)calloc(1, sizeof(*raw));
+	if (raw == NULL) {
+		archive_set_error(&a->archive, ENOMEM, "Can't allocate raw data");
+		return (ARCHIVE_FATAL);
+	}
+	raw->entries_written = 0;
+	a->format_data = raw;
+	a->format_name = "raw";
+        /* no options exist for this format */
+	a->format_options = NULL;
+	a->format_write_header = archive_write_raw_header;
+	a->format_write_data = archive_write_raw_data;
+	a->format_finish_entry = NULL;
+        /* nothing needs to be done on closing */
+	a->format_close = NULL;
+	a->format_free = archive_write_raw_free;
+	a->archive.archive_format = ARCHIVE_FORMAT_RAW;
+	a->archive.archive_format_name = "RAW";
+	return (ARCHIVE_OK);
+}
+
+static int
+archive_write_raw_header(struct archive_write *a, struct archive_entry *entry)
+{
+	struct raw *raw = (struct raw *)a->format_data;
+
+	if (archive_entry_filetype(entry) != AE_IFREG) {
+		archive_set_error(&a->archive, ERANGE,
+		    "Raw format only supports filetype AE_IFREG");
+		return (ARCHIVE_FATAL);
+	}
+
+
+	if (raw->entries_written > 0) {
+		archive_set_error(&a->archive, ERANGE,
+		    "Raw format only supports one entry per archive");
+		return (ARCHIVE_FATAL);
+	}
+	raw->entries_written++;
+
+	return (ARCHIVE_OK);
+}
+
+static ssize_t
+archive_write_raw_data(struct archive_write *a, const void *buff, size_t s)
+{
+	int ret;
+
+	ret = __archive_write_output(a, buff, s);
+	if (ret >= 0)
+		return (s);
+	else
+		return (ret);
+}
+
+static int
+archive_write_raw_free(struct archive_write *a)
+{
+	struct raw *raw;
+
+	raw = (struct raw *)a->format_data;
+	free(raw);
+	a->format_data = NULL;
+	return (ARCHIVE_OK);
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c
index 9ec15f9..c033fb3 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c
@@ -548,6 +548,7 @@
 				archive_strcat(&shar->work, ":");
 				shar_quote(&shar->work, g, 1);
 			}
+			archive_strcat(&shar->work, " ");
 			shar_quote(&shar->work,
 			    archive_entry_pathname(shar->entry), 1);
 			archive_strcat(&shar->work, "\n");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
index 5a9f114..3b07e35 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
@@ -29,24 +29,6 @@
  * Development supported by Google Summer of Code 2008.
  */
 
-/*
- * The current implementation is very limited:
- *
- *   - No encryption support.
- *   - No ZIP64 support.
- *   - No support for splitting and spanning.
- *   - Only supports regular file and folder entries.
- *
- * Note that generally data in ZIP files is little-endian encoded,
- * with some exceptions.
- *
- * TODO: Since Libarchive is generally 64bit oriented, but this implementation
- * does not yet support sizes exceeding 32bit, it is highly fragile for
- * big archives. This should change when ZIP64 is finally implemented, otherwise
- * some serious checking has to be done.
- *
- */
-
 #include "archive_platform.h"
 __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_zip.c 201168 2009-12-29 06:15:32Z kientzle $");
 
@@ -77,25 +59,80 @@
 #include "archive_crc32.h"
 #endif
 
-#define ZIP_SIGNATURE_LOCAL_FILE_HEADER 0x04034b50
-#define ZIP_SIGNATURE_DATA_DESCRIPTOR 0x08074b50
-#define ZIP_SIGNATURE_FILE_HEADER 0x02014b50
-#define ZIP_SIGNATURE_CENTRAL_DIRECTORY_END 0x06054b50
-#define ZIP_SIGNATURE_EXTRA_TIMESTAMP 0x5455
-#define ZIP_SIGNATURE_EXTRA_NEW_UNIX 0x7875
-#define ZIP_VERSION_EXTRACT 0x0014 /* ZIP version 2.0 is needed. */
-#define ZIP_VERSION_BY 0x0314 /* Made by UNIX, using ZIP version 2.0. */
-#define ZIP_FLAGS 0x08 /* Flagging bit 3 (count from 0) for using data descriptor. */
-#define ZIP_FLAGS_UTF8_NAME	(1 << 11)
+#define ZIP_ENTRY_FLAG_LENGTH_AT_END	(1<<3)
+#define ZIP_ENTRY_FLAG_UTF8_NAME	(1 << 11)
+
 
 enum compression {
-	COMPRESSION_STORE = 0
-#ifdef HAVE_ZLIB_H
-	,
+	COMPRESSION_UNSPECIFIED = -1,
+	COMPRESSION_STORE = 0,
 	COMPRESSION_DEFLATE = 8
+};
+
+#ifdef HAVE_ZLIB_H
+#define COMPRESSION_DEFAULT	COMPRESSION_DEFLATE
+#else
+#define COMPRESSION_DEFAULT	COMPRESSION_STORE
+#endif
+
+struct cd_segment {
+	struct cd_segment *next;
+	size_t buff_size;
+	unsigned char *buff;
+	unsigned char *p;
+};
+
+/* Bits used to enable/disable certain experimental features. */
+#define	EXPERIMENT_LA 1
+#define	EXPERIMENTS_ALL 0xffff
+
+struct zip {
+
+	int64_t entry_offset;
+	int64_t entry_compressed_size;
+	int64_t entry_uncompressed_size;
+	int64_t entry_compressed_written;
+	int64_t entry_uncompressed_written;
+	int64_t entry_uncompressed_limit;
+	struct archive_entry *entry;
+	uint32_t entry_crc32;
+	enum compression entry_compression;
+	int entry_flags;
+	int entry_uses_zip64;
+	int experiments;
+
+	unsigned char *file_header;
+	size_t file_header_extra_offset;
+	unsigned long (*crc32func)(unsigned long crc, const void *buff, size_t len);
+
+	struct cd_segment *central_directory;
+	struct cd_segment *central_directory_last;
+	size_t central_directory_bytes;
+	size_t central_directory_entries;
+
+	int64_t written_bytes; /* Overall position in file. */
+
+	struct archive_string_conv *opt_sconv;
+	struct archive_string_conv *sconv_default;
+	enum compression requested_compression;
+	int init_default_conversion;
+
+#define ZIP_FLAG_AVOID_ZIP64 1
+#define ZIP_FLAG_FORCE_ZIP64 2
+#define ZIP_FLAG_EXPERIMENT_EL 4
+	int flags;
+
+#ifdef HAVE_ZLIB_H
+	z_stream stream;
+	size_t len_buf;
+	unsigned char *buf;
 #endif
 };
 
+/* Don't call this min or MIN, since those are already defined
+   on lots of platforms (but not all). */
+#define zipmin(a, b) ((a) > (b) ? (b) : (a))
+
 static ssize_t archive_write_zip_data(struct archive_write *,
 		   const void *buff, size_t s);
 static int archive_write_zip_close(struct archive_write *);
@@ -108,106 +145,58 @@
 static unsigned int dos_time(const time_t);
 static size_t path_length(struct archive_entry *);
 static int write_path(struct archive_entry *, struct archive_write *);
+static void copy_path(struct archive_entry *, unsigned char *);
+static struct archive_string_conv *get_sconv(struct archive_write *, struct zip *);
 
-#define LOCAL_FILE_HEADER_SIGNATURE		0
-#define LOCAL_FILE_HEADER_VERSION		4
-#define LOCAL_FILE_HEADER_FLAGS			6
-#define LOCAL_FILE_HEADER_COMPRESSION		8
-#define LOCAL_FILE_HEADER_TIMEDATE		10
-#define LOCAL_FILE_HEADER_CRC32			14
-#define LOCAL_FILE_HEADER_COMPRESSED_SIZE	18
-#define LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE	22
-#define LOCAL_FILE_HEADER_FILENAME_LENGTH	26
-#define LOCAL_FILE_HEADER_EXTRA_LENGTH		28
-#define SIZE_LOCAL_FILE_HEADER			30
+static unsigned char *
+cd_alloc(struct zip *zip, size_t length)
+{
+	unsigned char *p;
 
-#define FILE_HEADER_SIGNATURE			0
-#define FILE_HEADER_VERSION_BY			4
-#define FILE_HEADER_VERSION_EXTRACT		6
-#define FILE_HEADER_FLAGS			8
-#define FILE_HEADER_COMPRESSION			10
-#define FILE_HEADER_TIMEDATE			12
-#define FILE_HEADER_CRC32			16
-#define FILE_HEADER_COMPRESSED_SIZE		20
-#define FILE_HEADER_UNCOMPRESSED_SIZE		24
-#define FILE_HEADER_FILENAME_LENGTH		28
-#define FILE_HEADER_EXTRA_LENGTH		30
-#define FILE_HEADER_COMMENT_LENGTH		32
-#define FILE_HEADER_DISK_NUMBER			34
-#define FILE_HEADER_ATTRIBUTES_INTERNAL		36
-#define FILE_HEADER_ATTRIBUTES_EXTERNAL		38
-#define FILE_HEADER_OFFSET			42
-#define SIZE_FILE_HEADER			46
+	if (zip->central_directory == NULL
+	    || (zip->central_directory_last->p + length
+		> zip->central_directory_last->buff + zip->central_directory_last->buff_size)) {
+		struct cd_segment *segment = calloc(1, sizeof(*segment));
+		if (segment == NULL)
+			return NULL;
+		segment->buff_size = 64 * 1024;
+		segment->buff = malloc(segment->buff_size);
+		if (segment->buff == NULL) {
+			free(segment);
+			return NULL;
+		}
+		segment->p = segment->buff;
 
-	/* Not mandatory, but recommended by specification. */
-#define DATA_DESCRIPTOR_SIGNATURE		0
-#define DATA_DESCRIPTOR_CRC32			4
-#define DATA_DESCRIPTOR_COMPRESSED_SIZE		8
-#define DATA_DESCRIPTOR_UNCOMPRESSED_SIZE	12
-#define SIZE_DATA_DESCRIPTOR			16
+		if (zip->central_directory == NULL) {
+			zip->central_directory
+			    = zip->central_directory_last
+			    = segment;
+		} else {
+			zip->central_directory_last->next = segment;
+			zip->central_directory_last = segment;
+		}
+	}
 
-#define EXTRA_DATA_LOCAL_TIME_ID		0
-#define EXTRA_DATA_LOCAL_TIME_SIZE		2
-#define EXTRA_DATA_LOCAL_TIME_FLAG		4
-#define EXTRA_DATA_LOCAL_MTIME			5
-#define EXTRA_DATA_LOCAL_ATIME			9
-#define EXTRA_DATA_LOCAL_CTIME			13
-#define EXTRA_DATA_LOCAL_UNIX_ID		17
-#define EXTRA_DATA_LOCAL_UNIX_SIZE		19
-#define EXTRA_DATA_LOCAL_UNIX_VERSION		21
-#define EXTRA_DATA_LOCAL_UNIX_UID_SIZE		22
-#define EXTRA_DATA_LOCAL_UNIX_UID		23
-#define EXTRA_DATA_LOCAL_UNIX_GID_SIZE		27
-#define EXTRA_DATA_LOCAL_UNIX_GID		28
-#define SIZE_EXTRA_DATA_LOCAL			32
+	p = zip->central_directory_last->p;
+	zip->central_directory_last->p += length;
+	zip->central_directory_bytes += length;
+	return (p);
+}
 
-#define EXTRA_DATA_CENTRAL_TIME_ID		0
-#define EXTRA_DATA_CENTRAL_TIME_SIZE		2
-#define EXTRA_DATA_CENTRAL_TIME_FLAG		4
-#define EXTRA_DATA_CENTRAL_MTIME		5
-#define EXTRA_DATA_CENTRAL_UNIX_ID		9
-#define EXTRA_DATA_CENTRAL_UNIX_SIZE		11
-#define SIZE_EXTRA_DATA_CENTRAL			13
+static unsigned long
+real_crc32(unsigned long crc, const void *buff, size_t len)
+{
+	return crc32(crc, buff, len);
+}
 
-#define CENTRAL_DIRECTORY_END_SIGNATURE		0
-#define CENTRAL_DIRECTORY_END_DISK		4
-#define CENTRAL_DIRECTORY_END_START_DISK	6
-#define CENTRAL_DIRECTORY_END_ENTRIES_DISK	8
-#define CENTRAL_DIRECTORY_END_ENTRIES		10
-#define CENTRAL_DIRECTORY_END_SIZE		12
-#define CENTRAL_DIRECTORY_END_OFFSET		16
-#define CENTRAL_DIRECTORY_END_COMMENT_LENGTH	20
-#define SIZE_CENTRAL_DIRECTORY_END		22
-
-struct zip_file_header_link {
-	struct zip_file_header_link *next;
-	struct archive_entry *entry;
-	int64_t offset;
-	unsigned long crc32;
-	int64_t compressed_size;
-	enum compression compression;
-	int flags;
-};
-
-struct zip {
-	uint8_t data_descriptor[SIZE_DATA_DESCRIPTOR];
-	struct zip_file_header_link *central_directory;
-	struct zip_file_header_link *central_directory_end;
-	int64_t offset;
-	int64_t written_bytes;
-	int64_t remaining_data_bytes;
-	enum compression compression;
-	int flags;
-	struct archive_string_conv *opt_sconv;
-	struct archive_string_conv *sconv_default;
-	int	init_default_conversion;
-
-#ifdef HAVE_ZLIB_H
-	z_stream stream;
-	size_t len_buf;
-	unsigned char *buf;
-#endif
-};
+static unsigned long
+fake_crc32(unsigned long crc, const void *buff, size_t len)
+{
+	(void)crc; /* UNUSED */
+	(void)buff; /* UNUSED */
+	(void)len; /* UNUSED */
+	return 0;
+}
 
 static int
 archive_write_zip_options(struct archive_write *a, const char *key,
@@ -217,24 +206,49 @@
 	int ret = ARCHIVE_FAILED;
 
 	if (strcmp(key, "compression") == 0) {
+		/*
+		 * Set compression to use on all future entries.
+		 * This only affects regular files.
+		 */
 		if (val == NULL || val[0] == 0) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "%s: compression option needs a compression name",
 			    a->format_name);
 		} else if (strcmp(val, "deflate") == 0) {
 #ifdef HAVE_ZLIB_H
-			zip->compression = COMPRESSION_DEFLATE;
+			zip->requested_compression = COMPRESSION_DEFLATE;
 			ret = ARCHIVE_OK;
 #else
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "deflate compression not supported");
 #endif
 		} else if (strcmp(val, "store") == 0) {
-			zip->compression = COMPRESSION_STORE;
+			zip->requested_compression = COMPRESSION_STORE;
 			ret = ARCHIVE_OK;
 		}
 		return (ret);
+	} else if (strcmp(key, "experimental") == 0) {
+		if (val == NULL || val[0] == 0) {
+			zip->flags &= ~ ZIP_FLAG_EXPERIMENT_EL;
+		} else {
+			zip->flags |= ZIP_FLAG_EXPERIMENT_EL;
+		}
+		return (ARCHIVE_OK);
+	} else if (strcmp(key, "fakecrc32") == 0) {
+		/*
+		 * FOR TESTING ONLY:  disable CRC calculation to speed up
+		 * certain complex tests.
+		 */
+		if (val == NULL || val[0] == 0) {
+			zip->crc32func = real_crc32;
+		} else {
+			zip->crc32func = fake_crc32;
+		}
+		return (ARCHIVE_OK);
 	} else if (strcmp(key, "hdrcharset")  == 0) {
+		/*
+		 * Set the character set used in translating filenames.
+		 */
 		if (val == NULL || val[0] == 0) {
 			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			    "%s: hdrcharset option needs a character-set name",
@@ -248,6 +262,21 @@
 				ret = ARCHIVE_FATAL;
 		}
 		return (ret);
+	} else if (strcmp(key, "zip64") == 0) {
+		/*
+		 * Bias decisions about Zip64: force them to be
+		 * generated in certain cases where they are not
+		 * forbidden or avoid them in certain cases where they
+		 * are not strictly required.
+		 */
+		if (val != NULL && *val != '\0') {
+			zip->flags |= ZIP_FLAG_FORCE_ZIP64;
+			zip->flags &= ~ZIP_FLAG_AVOID_ZIP64;
+		} else {
+			zip->flags &= ~ZIP_FLAG_FORCE_ZIP64;
+			zip->flags |= ZIP_FLAG_AVOID_ZIP64;
+		}
+		return (ARCHIVE_OK);
 	}
 
 	/* Note: The "warn" return is just to inform the options
@@ -261,9 +290,9 @@
 {
 	struct archive_write *a = (struct archive_write *)_a;
 	int ret = ARCHIVE_FAILED;
-	
+
 	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
-		ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER,
+		ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
 		"archive_write_zip_set_compression_deflate");
 	if (a->archive.archive_format != ARCHIVE_FORMAT_ZIP) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -273,11 +302,12 @@
 	} else {
 #ifdef HAVE_ZLIB_H
 		struct zip *zip = a->format_data;
-		zip->compression = COMPRESSION_DEFLATE;
+		zip->requested_compression = COMPRESSION_DEFLATE;
 		ret = ARCHIVE_OK;
 #else
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
 			"deflate compression not supported");
+		ret = ARCHIVE_FAILED;
 #endif
 	}
 	return (ret);
@@ -289,9 +319,9 @@
 	struct archive_write *a = (struct archive_write *)_a;
 	struct zip *zip = a->format_data;
 	int ret = ARCHIVE_FAILED;
-	
+
 	archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
-		ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER,
+		ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
 		"archive_write_zip_set_compression_deflate");
 	if (a->archive.archive_format != ARCHIVE_FORMAT_ZIP) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -299,7 +329,7 @@
 			" with zip format");
 		ret = ARCHIVE_FATAL;
 	} else {
-		zip->compression = COMPRESSION_STORE;
+		zip->requested_compression = COMPRESSION_STORE;
 		ret = ARCHIVE_OK;
 	}
 	return (ret);
@@ -324,14 +354,12 @@
 		    "Can't allocate zip data");
 		return (ARCHIVE_FATAL);
 	}
-	zip->central_directory = NULL;
-	zip->central_directory_end = NULL;
-	zip->offset = 0;
-	zip->written_bytes = 0;
-	zip->remaining_data_bytes = 0;
+
+	/* "Unspecified" lets us choose the appropriate compression. */
+	zip->requested_compression = COMPRESSION_UNSPECIFIED;
+	zip->crc32func = real_crc32;
 
 #ifdef HAVE_ZLIB_H
-	zip->compression = COMPRESSION_DEFLATE;
 	zip->len_buf = 65536;
 	zip->buf = malloc(zip->len_buf);
 	if (zip->buf == NULL) {
@@ -340,8 +368,6 @@
 		    "Can't allocate compression buffer");
 		return (ARCHIVE_FATAL);
 	}
-#else
-	zip->compression = COMPRESSION_STORE;
 #endif
 
 	a->format_data = zip;
@@ -355,9 +381,6 @@
 	a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
 	a->archive.archive_format_name = "ZIP";
 
-	archive_le32enc(&zip->data_descriptor[DATA_DESCRIPTOR_SIGNATURE],
-	    ZIP_SIGNATURE_DATA_DESCRIPTOR);
-
 	return (ARCHIVE_OK);
 }
 
@@ -376,17 +399,21 @@
 static int
 archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
 {
-	struct zip *zip;
-	uint8_t h[SIZE_LOCAL_FILE_HEADER];
-	uint8_t e[SIZE_EXTRA_DATA_LOCAL];
-	uint8_t *d;
-	struct zip_file_header_link *l;
-	struct archive_string_conv *sconv;
+	unsigned char local_header[32];
+	unsigned char local_extra[128];
+	struct zip *zip = a->format_data;
+	unsigned char *e;
+	unsigned char *cd_extra;
+	size_t filename_length;
+	const char *slink = NULL;
+	size_t slink_size = 0;
+	struct archive_string_conv *sconv = get_sconv(a, zip);
 	int ret, ret2 = ARCHIVE_OK;
 	int64_t size;
 	mode_t type;
+	int version_needed = 10;
 
-	/* Entries other than a regular file or a folder are skipped. */
+	/* Ignore types of entries that we don't support. */
 	type = archive_entry_filetype(entry);
 	if (type != AE_IFREG && type != AE_IFDIR && type != AE_IFLNK) {
 		archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -394,70 +421,64 @@
 		return ARCHIVE_FAILED;
 	};
 
-	/* Directory entries should have a size of 0. */
-	if (type == AE_IFDIR)
-		archive_entry_set_size(entry, 0);
-
-	zip = a->format_data;
-	/* Setup default conversion. */
-	if (zip->opt_sconv == NULL && !zip->init_default_conversion) {
-		zip->sconv_default =
-		    archive_string_default_conversion_for_write(&(a->archive));
-		zip->init_default_conversion = 1;
-	}
-
-	if (zip->flags == 0) {
-		/* Initialize the general purpose flags. */
-		zip->flags = ZIP_FLAGS;
-		if (zip->opt_sconv != NULL) {
-			if (strcmp(archive_string_conversion_charset_name(
-			    zip->opt_sconv), "UTF-8") == 0)
-				zip->flags |= ZIP_FLAGS_UTF8_NAME;
-#if HAVE_NL_LANGINFO
-		} else if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
-			zip->flags |= ZIP_FLAGS_UTF8_NAME;
-#endif
+	/* If we're not using Zip64, reject large files. */
+	if (zip->flags & ZIP_FLAG_AVOID_ZIP64) {
+		/* Reject entries over 4GB. */
+		if (archive_entry_size_is_set(entry)
+		    && (archive_entry_size(entry) > 0xffffffff)) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "Files > 4GB require Zip64 extensions");
+			return ARCHIVE_FAILED;
+		}
+		/* Reject entries if archive is > 4GB. */
+		if (zip->written_bytes > 0xffffffff) {
+			archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+			    "Archives > 4GB require Zip64 extensions");
+			return ARCHIVE_FAILED;
 		}
 	}
-	d = zip->data_descriptor;
-	size = archive_entry_size(entry);
-	zip->remaining_data_bytes = size;
 
-	/* Append archive entry to the central directory data. */
-	l = (struct zip_file_header_link *) malloc(sizeof(*l));
-	if (l == NULL) {
-		archive_set_error(&a->archive, ENOMEM,
-		    "Can't allocate zip header data");
-		return (ARCHIVE_FATAL);
+	/* Only regular files can have size > 0. */
+	if (type != AE_IFREG)
+		archive_entry_set_size(entry, 0);
+
+
+	/* Reset information from last entry. */
+	zip->entry_offset = zip->written_bytes;
+	zip->entry_uncompressed_limit = INT64_MAX;
+	zip->entry_compressed_size = 0;
+	zip->entry_uncompressed_size = 0;
+	zip->entry_compressed_written = 0;
+	zip->entry_uncompressed_written = 0;
+	zip->entry_flags = 0;
+	zip->entry_uses_zip64 = 0;
+	zip->entry_crc32 = zip->crc32func(0, NULL, 0);
+	if (zip->entry != NULL) {
+		archive_entry_free(zip->entry);
+		zip->entry = NULL;
 	}
+
 #if defined(_WIN32) && !defined(__CYGWIN__)
 	/* Make sure the path separators in pahtname, hardlink and symlink
 	 * are all slash '/', not the Windows path separator '\'. */
-	l->entry = __la_win_entry_in_posix_pathseparator(entry);
-	if (l->entry == entry)
-		l->entry = archive_entry_clone(entry);
+	zip->entry = __la_win_entry_in_posix_pathseparator(entry);
+	if (zip->entry == entry)
+		zip->entry = archive_entry_clone(entry);
 #else
-	l->entry = archive_entry_clone(entry);
+	zip->entry = archive_entry_clone(entry);
 #endif
-	if (l->entry == NULL) {
+	if (zip->entry == NULL) {
 		archive_set_error(&a->archive, ENOMEM,
 		    "Can't allocate zip header data");
-		free(l);
 		return (ARCHIVE_FATAL);
 	}
-	l->flags = zip->flags;
-	if (zip->opt_sconv != NULL)
-		sconv = zip->opt_sconv;
-	else
-		sconv = zip->sconv_default;
+
 	if (sconv != NULL) {
 		const char *p;
 		size_t len;
 
 		if (archive_entry_pathname_l(entry, &p, &len, sconv) != 0) {
 			if (errno == ENOMEM) {
-				archive_entry_free(l->entry);
-				free(l);
 				archive_set_error(&a->archive, ENOMEM,
 				    "Can't allocate memory for Pathname");
 				return (ARCHIVE_FATAL);
@@ -470,92 +491,268 @@
 			ret2 = ARCHIVE_WARN;
 		}
 		if (len > 0)
-			archive_entry_set_pathname(l->entry, p);
+			archive_entry_set_pathname(zip->entry, p);
 
 		/*
-		 * Although there is no character-set regulation for Symlink,
-		 * it is suitable to convert a character-set of Symlinke to
-		 * what those of the Pathname has been converted to.
+		 * There is no standard for symlink handling; we convert
+		 * it using the same character-set translation that we use
+		 * for filename.
 		 */
 		if (type == AE_IFLNK) {
 			if (archive_entry_symlink_l(entry, &p, &len, sconv)) {
 				if (errno == ENOMEM) {
-					archive_entry_free(l->entry);
-					free(l);
 					archive_set_error(&a->archive, ENOMEM,
 					    "Can't allocate memory "
 					    " for Symlink");
 					return (ARCHIVE_FATAL);
 				}
-				/*
-				 * Even if the strng conversion failed,
-				 * we should not report the error since
-				 * thre is no regulation for.
-				 */
+				/* No error if we can't convert. */
 			} else if (len > 0)
-				archive_entry_set_symlink(l->entry, p);
+				archive_entry_set_symlink(zip->entry, p);
 		}
 	}
-	/* If all characters in a filename are ASCII, Reset UTF-8 Name flag. */
-	if ((l->flags & ZIP_FLAGS_UTF8_NAME) != 0 &&
-	    is_all_ascii(archive_entry_pathname(l->entry)))
-		l->flags &= ~ZIP_FLAGS_UTF8_NAME;
 
-	/* Initialize the CRC variable and potentially the local crc32(). */
-	l->crc32 = crc32(0, NULL, 0);
+	/* If filename isn't ASCII and we can use UTF-8, set the UTF-8 flag. */
+	if (!is_all_ascii(archive_entry_pathname(zip->entry))) {
+		if (zip->opt_sconv != NULL) {
+			if (strcmp(archive_string_conversion_charset_name(
+					zip->opt_sconv), "UTF-8") == 0)
+				zip->entry_flags |= ZIP_ENTRY_FLAG_UTF8_NAME;
+#if HAVE_NL_LANGINFO
+		} else if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
+			zip->entry_flags |= ZIP_ENTRY_FLAG_UTF8_NAME;
+#endif
+		}
+	}
+	filename_length = path_length(zip->entry);
+
+	/* Determine appropriate compression and size for this entry. */
 	if (type == AE_IFLNK) {
-		const char *p = archive_entry_symlink(l->entry);
-		if (p != NULL)
-			size = strlen(p);
+		slink = archive_entry_symlink(zip->entry);
+		if (slink != NULL)
+			slink_size = strlen(slink);
 		else
-			size = 0;
-		zip->remaining_data_bytes = 0;
-		archive_entry_set_size(l->entry, size);
-		l->compression = COMPRESSION_STORE;
-		l->compressed_size = size;
+			slink_size = 0;
+		zip->entry_uncompressed_limit = slink_size;
+		zip->entry_compressed_size = slink_size;
+		zip->entry_uncompressed_size = slink_size;
+		zip->entry_crc32 = zip->crc32func(zip->entry_crc32,
+		    (const unsigned char *)slink, slink_size);
+		zip->entry_compression = COMPRESSION_STORE;
+		version_needed = 20;
+	} else if (type != AE_IFREG) {
+		zip->entry_compression = COMPRESSION_STORE;
+		zip->entry_uncompressed_limit = 0;
+		size = 0;
+		version_needed = 20;
+	} else if (archive_entry_size_is_set(zip->entry)) {
+		size = archive_entry_size(zip->entry);
+		zip->entry_uncompressed_limit = size;
+		zip->entry_compression = zip->requested_compression;
+		if (zip->entry_compression == COMPRESSION_UNSPECIFIED) {
+			zip->entry_compression = COMPRESSION_DEFAULT;
+		}
+		if (zip->entry_compression == COMPRESSION_STORE) {
+			zip->entry_compressed_size = size;
+			zip->entry_uncompressed_size = size;
+			version_needed = 10;
+		} else {
+			zip->entry_uncompressed_size = size;
+			version_needed = 20;
+		}
+		if ((zip->flags & ZIP_FLAG_FORCE_ZIP64) /* User asked. */
+		    || (zip->entry_uncompressed_size > ARCHIVE_LITERAL_LL(0xffffffff))) { /* Large entry. */
+			zip->entry_uses_zip64 = 1;
+			version_needed = 45;
+		}
+
+		/* We may know the size, but never the CRC. */
+		zip->entry_flags |= ZIP_ENTRY_FLAG_LENGTH_AT_END;
 	} else {
-		l->compression = zip->compression;
-		l->compressed_size = 0;
+		/* Prefer deflate if it's available, because deflate
+		 * has a clear end-of-data marker that makes
+		 * length-at-end more reliable. */
+		zip->entry_compression = COMPRESSION_DEFAULT;
+		zip->entry_flags |= ZIP_ENTRY_FLAG_LENGTH_AT_END;
+		if ((zip->flags & ZIP_FLAG_AVOID_ZIP64) == 0) {
+			zip->entry_uses_zip64 = 1;
+			version_needed = 45;
+		} else if (zip->entry_compression == COMPRESSION_STORE) {
+			version_needed = 10;
+		} else {
+			version_needed = 20;
+		}
 	}
-	l->next = NULL;
-	if (zip->central_directory == NULL) {
-		zip->central_directory = l;
+
+	/* Format the local header. */
+	memset(local_header, 0, sizeof(local_header));
+	memcpy(local_header, "PK\003\004", 4);
+	archive_le16enc(local_header + 4, version_needed);
+	archive_le16enc(local_header + 6, zip->entry_flags);
+	archive_le16enc(local_header + 8, zip->entry_compression);
+	archive_le32enc(local_header + 10, dos_time(archive_entry_mtime(zip->entry)));
+	archive_le32enc(local_header + 14, zip->entry_crc32);
+	if (zip->entry_uses_zip64) {
+		/* Zip64 data in the local header "must" include both
+		 * compressed and uncompressed sizes AND those fields
+		 * are included only if these are 0xffffffff;
+		 * THEREFORE these must be set this way, even if we
+		 * know one of them is smaller. */
+		archive_le32enc(local_header + 18, ARCHIVE_LITERAL_LL(0xffffffff));
+		archive_le32enc(local_header + 22, ARCHIVE_LITERAL_LL(0xffffffff));
 	} else {
-		zip->central_directory_end->next = l;
+		archive_le32enc(local_header + 18, zip->entry_compressed_size);
+		archive_le32enc(local_header + 22, zip->entry_uncompressed_size);
 	}
-	zip->central_directory_end = l;
+	archive_le16enc(local_header + 26, filename_length);
 
-	/* Store the offset of this header for later use in central
-	 * directory. */
-	l->offset = zip->written_bytes;
+	/* Format as much of central directory file header as we can: */
+	zip->file_header = cd_alloc(zip, 46);
+	/* If (zip->file_header == NULL) XXXX */
+	++zip->central_directory_entries;
+	memset(zip->file_header, 0, 46);
+	memcpy(zip->file_header, "PK\001\002", 4);
+	/* "Made by PKZip 2.0 on Unix." */
+	archive_le16enc(zip->file_header + 4, 3 * 256 + version_needed);
+	archive_le16enc(zip->file_header + 6, version_needed);
+	archive_le16enc(zip->file_header + 8, zip->entry_flags);
+	archive_le16enc(zip->file_header + 10, zip->entry_compression);
+	archive_le32enc(zip->file_header + 12, dos_time(archive_entry_mtime(zip->entry)));
+	archive_le16enc(zip->file_header + 28, filename_length);
+	/* Following Info-Zip, store mode in the "external attributes" field. */
+	archive_le32enc(zip->file_header + 38,
+	    ((uint32_t)archive_entry_mode(zip->entry)) << 16);
+	e = cd_alloc(zip, filename_length);
+	/* If (e == NULL) XXXX */
+	copy_path(zip->entry, e);
 
-	memset(h, 0, sizeof(h));
-	archive_le32enc(&h[LOCAL_FILE_HEADER_SIGNATURE],
-		ZIP_SIGNATURE_LOCAL_FILE_HEADER);
-	archive_le16enc(&h[LOCAL_FILE_HEADER_VERSION], ZIP_VERSION_EXTRACT);
-	archive_le16enc(&h[LOCAL_FILE_HEADER_FLAGS], l->flags);
-	archive_le16enc(&h[LOCAL_FILE_HEADER_COMPRESSION], l->compression);
-	archive_le32enc(&h[LOCAL_FILE_HEADER_TIMEDATE],
-		dos_time(archive_entry_mtime(entry)));
-	archive_le16enc(&h[LOCAL_FILE_HEADER_FILENAME_LENGTH],
-		(uint16_t)path_length(l->entry));
+	/* Format extra data. */
+	memset(local_extra, 0, sizeof(local_extra));
+	e = local_extra;
 
-	switch (l->compression) {
-	case COMPRESSION_STORE:
-		/* Setting compressed and uncompressed sizes even when
-		 * specification says to set to zero when using data
-		 * descriptors. Otherwise the end of the data for an
-		 * entry is rather difficult to find. */
-		archive_le32enc(&h[LOCAL_FILE_HEADER_COMPRESSED_SIZE],
-		    (uint32_t)size);
-		archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE],
-		    (uint32_t)size);
-		break;
+	/* First, extra blocks that are the same between
+	 * the local file header and the central directory.
+	 * We format them once and then duplicate them. */
+
+	/* UT timestamp, length depends on what timestamps are set. */
+	memcpy(e, "UT", 2);
+	archive_le16enc(e + 2,
+	    1
+	    + (archive_entry_mtime_is_set(entry) ? 4 : 0)
+	    + (archive_entry_atime_is_set(entry) ? 4 : 0)
+	    + (archive_entry_ctime_is_set(entry) ? 4 : 0));
+	e += 4;
+	*e++ =
+	    (archive_entry_mtime_is_set(entry) ? 1 : 0)
+	    | (archive_entry_atime_is_set(entry) ? 2 : 0)
+	    | (archive_entry_ctime_is_set(entry) ? 4 : 0);
+	if (archive_entry_mtime_is_set(entry)) {
+		archive_le32enc(e, (uint32_t)archive_entry_mtime(entry));
+		e += 4;
+	}
+	if (archive_entry_atime_is_set(entry)) {
+		archive_le32enc(e, (uint32_t)archive_entry_atime(entry));
+		e += 4;
+	}
+	if (archive_entry_ctime_is_set(entry)) {
+		archive_le32enc(e, (uint32_t)archive_entry_ctime(entry));
+		e += 4;
+	}
+
+	/* ux Unix extra data, length 11, version 1 */
+	/* TODO: If uid < 64k, use 2 bytes, ditto for gid. */
+	memcpy(e, "ux\013\000\001", 5);
+	e += 5;
+	*e++ = 4; /* Length of following UID */
+	archive_le32enc(e, (uint32_t)archive_entry_uid(entry));
+	e += 4;
+	*e++ = 4; /* Length of following GID */
+	archive_le32enc(e, (uint32_t)archive_entry_gid(entry));
+	e += 4;
+
+	/* Copy UT and ux into central directory as well. */
+	zip->file_header_extra_offset = zip->central_directory_bytes;
+	cd_extra = cd_alloc(zip, e - local_extra);
+	memcpy(cd_extra, local_extra, e - local_extra);
+
+	/*
+	 * Following extra blocks vary between local header and
+	 * central directory. These are the local header versions.
+	 * Central directory versions get formatted in
+	 * archive_write_zip_finish_entry() below.
+	 */
+
+	/* "[Zip64 entry] in the local header MUST include BOTH
+	 * original [uncompressed] and compressed size fields." */
+	if (zip->entry_uses_zip64) {
+		unsigned char *zip64_start = e;
+		memcpy(e, "\001\000\020\000", 4);
+		e += 4;
+		archive_le64enc(e, zip->entry_uncompressed_size);
+		e += 8;
+		archive_le64enc(e, zip->entry_compressed_size);
+		e += 8;
+		archive_le16enc(zip64_start + 2, e - (zip64_start + 4));
+	}
+
+	if (zip->flags & ZIP_FLAG_EXPERIMENT_EL) {
+		/* Experimental 'el' extension to improve streaming. */
+		unsigned char *external_info = e;
+		int included = 7;
+		memcpy(e, "el\000\000", 4); // 0x6c65 + 2-byte length
+		e += 4;
+		e[0] = included; /* bitmap of included fields */
+		e += 1;
+		if (included & 1) {
+			archive_le16enc(e, /* "Version created by" */
+			    3 * 256 + version_needed);
+			e += 2;
+		}
+		if (included & 2) {
+			archive_le16enc(e, 0); /* internal file attributes */
+			e += 2;
+		}
+		if (included & 4) {
+			archive_le32enc(e,  /* external file attributes */
+			    ((uint32_t)archive_entry_mode(zip->entry)) << 16);
+			e += 4;
+		}
+		if (included & 8) {
+			// Libarchive does not currently support file comments.
+		}
+		archive_le16enc(external_info + 2, e - (external_info + 4));
+	}
+
+	/* Update local header with size of extra data and write it all out: */
+	archive_le16enc(local_header + 28, e - local_extra);
+
+	ret = __archive_write_output(a, local_header, 30);
+	if (ret != ARCHIVE_OK)
+		return (ARCHIVE_FATAL);
+	zip->written_bytes += 30;
+
+	ret = write_path(zip->entry, a);
+	if (ret <= ARCHIVE_OK)
+		return (ARCHIVE_FATAL);
+	zip->written_bytes += ret;
+
+	ret = __archive_write_output(a, local_extra, e - local_extra);
+	if (ret != ARCHIVE_OK)
+		return (ARCHIVE_FATAL);
+	zip->written_bytes += e - local_extra;
+
+	/* For symlinks, write the body now. */
+	if (slink != NULL) {
+		ret = __archive_write_output(a, slink, slink_size);
+		if (ret != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
+		zip->entry_compressed_written += slink_size;
+		zip->entry_uncompressed_written += slink_size;
+		zip->written_bytes += slink_size;
+	}
+
 #ifdef HAVE_ZLIB_H
-	case COMPRESSION_DEFLATE:
-		archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE],
-		    (uint32_t)size);
-
+	if (zip->entry_compression == COMPRESSION_DEFLATE) {
 		zip->stream.zalloc = Z_NULL;
 		zip->stream.zfree = Z_NULL;
 		zip->stream.opaque = Z_NULL;
@@ -567,66 +764,10 @@
 			    "Can't init deflate compressor");
 			return (ARCHIVE_FATAL);
 		}
-		break;
+	}
 #endif
-	}
 
-	/* Formatting extra data. */
-	archive_le16enc(&h[LOCAL_FILE_HEADER_EXTRA_LENGTH], sizeof(e));
-	archive_le16enc(&e[EXTRA_DATA_LOCAL_TIME_ID],
-		ZIP_SIGNATURE_EXTRA_TIMESTAMP);
-	archive_le16enc(&e[EXTRA_DATA_LOCAL_TIME_SIZE], 1 + 4 * 3);
-	e[EXTRA_DATA_LOCAL_TIME_FLAG] = 0x07;
-	archive_le32enc(&e[EXTRA_DATA_LOCAL_MTIME],
-	    (uint32_t)archive_entry_mtime(entry));
-	archive_le32enc(&e[EXTRA_DATA_LOCAL_ATIME],
-	    (uint32_t)archive_entry_atime(entry));
-	archive_le32enc(&e[EXTRA_DATA_LOCAL_CTIME],
-	    (uint32_t)archive_entry_ctime(entry));
-
-	archive_le16enc(&e[EXTRA_DATA_LOCAL_UNIX_ID],
-		ZIP_SIGNATURE_EXTRA_NEW_UNIX);
-	archive_le16enc(&e[EXTRA_DATA_LOCAL_UNIX_SIZE], 1 + (1 + 4) * 2);
-	e[EXTRA_DATA_LOCAL_UNIX_VERSION] = 1;
-	e[EXTRA_DATA_LOCAL_UNIX_UID_SIZE] = 4;
-	archive_le32enc(&e[EXTRA_DATA_LOCAL_UNIX_UID],
-		(uint32_t)archive_entry_uid(entry));
-	e[EXTRA_DATA_LOCAL_UNIX_GID_SIZE] = 4;
-	archive_le32enc(&e[EXTRA_DATA_LOCAL_UNIX_GID],
-		(uint32_t)archive_entry_gid(entry));
-
-	archive_le32enc(&d[DATA_DESCRIPTOR_UNCOMPRESSED_SIZE],
-	    (uint32_t)size);
-
-	ret = __archive_write_output(a, h, sizeof(h));
-	if (ret != ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
-	zip->written_bytes += sizeof(h);
-
-	ret = write_path(l->entry, a);
-	if (ret <= ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
-	zip->written_bytes += ret;
-
-	ret = __archive_write_output(a, e, sizeof(e));
-	if (ret != ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
-	zip->written_bytes += sizeof(e);
-
-	if (type == AE_IFLNK) {
-		const unsigned char *p;
-
-		p = (const unsigned char *)archive_entry_symlink(l->entry);
-		ret = __archive_write_output(a, p, (size_t)size);
-		if (ret != ARCHIVE_OK)
-			return (ARCHIVE_FATAL);
-		zip->written_bytes += size;
-		l->crc32 = crc32(l->crc32, p, (unsigned)size);
-	}
-
-	if (ret2 != ARCHIVE_OK)
-		return (ret2);
-	return (ARCHIVE_OK);
+	return (ret2);
 }
 
 static ssize_t
@@ -634,22 +775,21 @@
 {
 	int ret;
 	struct zip *zip = a->format_data;
-	struct zip_file_header_link *l = zip->central_directory_end;
 
-	if ((int64_t)s > zip->remaining_data_bytes)
-		s = (size_t)zip->remaining_data_bytes;
+	if ((int64_t)s > zip->entry_uncompressed_limit)
+		s = (size_t)zip->entry_uncompressed_limit;
+	zip->entry_uncompressed_written += s;
 
 	if (s == 0) return 0;
 
-	switch (l->compression) {
+	switch (zip->entry_compression) {
 	case COMPRESSION_STORE:
 		ret = __archive_write_output(a, buff, s);
-		if (ret != ARCHIVE_OK) return (ret);
+		if (ret != ARCHIVE_OK)
+			return (ret);
 		zip->written_bytes += s;
-		zip->remaining_data_bytes -= s;
-		l->compressed_size += s;
-		l->crc32 = crc32(l->crc32, buff, (unsigned)s);
-		return (s);
+		zip->entry_compressed_written += s;
+		break;
 #if HAVE_ZLIB_H
 	case COMPRESSION_DEFLATE:
 		zip->stream.next_in = (unsigned char*)(uintptr_t)buff;
@@ -663,16 +803,13 @@
 					zip->len_buf);
 				if (ret != ARCHIVE_OK)
 					return (ret);
-				l->compressed_size += zip->len_buf;
+				zip->entry_compressed_written += zip->len_buf;
 				zip->written_bytes += zip->len_buf;
 				zip->stream.next_out = zip->buf;
 				zip->stream.avail_out = (uInt)zip->len_buf;
 			}
 		} while (zip->stream.avail_in != 0);
-		zip->remaining_data_bytes -= s;
-		/* If we have it, use zlib's fast crc32() */
-		l->crc32 = crc32(l->crc32, buff, (uInt)s);
-		return (s);
+		break;
 #endif
 
 	default:
@@ -680,153 +817,174 @@
 		    "Invalid ZIP compression type");
 		return ARCHIVE_FATAL;
 	}
+
+	zip->entry_uncompressed_limit -= s;
+	zip->entry_crc32 = zip->crc32func(zip->entry_crc32, buff, (unsigned)s);
+	return (s);
+
 }
 
 static int
 archive_write_zip_finish_entry(struct archive_write *a)
 {
-	/* Write the data descripter after file data has been written. */
-	int ret;
 	struct zip *zip = a->format_data;
-	uint8_t *d = zip->data_descriptor;
-	struct zip_file_header_link *l = zip->central_directory_end;
-#if HAVE_ZLIB_H
-	size_t reminder;
-#endif
+	int ret;
 
-	switch(l->compression) {
-	case COMPRESSION_STORE:
-		break;
 #if HAVE_ZLIB_H
-	case COMPRESSION_DEFLATE:
+	if (zip->entry_compression == COMPRESSION_DEFLATE) {
 		for (;;) {
+			size_t remainder;
 			ret = deflate(&zip->stream, Z_FINISH);
 			if (ret == Z_STREAM_ERROR)
 				return (ARCHIVE_FATAL);
-			reminder = zip->len_buf - zip->stream.avail_out;
-			ret = __archive_write_output(a, zip->buf, reminder);
+			remainder = zip->len_buf - zip->stream.avail_out;
+			ret = __archive_write_output(a, zip->buf, remainder);
 			if (ret != ARCHIVE_OK)
 				return (ret);
-			l->compressed_size += reminder;
-			zip->written_bytes += reminder;
+			zip->entry_compressed_written += remainder;
+			zip->written_bytes += remainder;
 			zip->stream.next_out = zip->buf;
 			if (zip->stream.avail_out != 0)
 				break;
 			zip->stream.avail_out = (uInt)zip->len_buf;
 		}
 		deflateEnd(&zip->stream);
-		break;
+	}
 #endif
+
+	/* Write trailing data descriptor. */
+	if ((zip->entry_flags & ZIP_ENTRY_FLAG_LENGTH_AT_END) != 0) {
+		char d[24];
+		memcpy(d, "PK\007\010", 4);
+		archive_le32enc(d + 4, zip->entry_crc32);
+		if (zip->entry_uses_zip64) {
+			archive_le64enc(d + 8, (uint64_t)zip->entry_compressed_written);
+			archive_le64enc(d + 16, (uint64_t)zip->entry_uncompressed_written);
+			ret = __archive_write_output(a, d, 24);
+			zip->written_bytes += 24;
+		} else {
+			archive_le32enc(d + 8, (uint32_t)zip->entry_compressed_written);
+			archive_le32enc(d + 12, (uint32_t)zip->entry_uncompressed_written);
+			ret = __archive_write_output(a, d, 16);
+			zip->written_bytes += 16;
+		}
+		if (ret != ARCHIVE_OK)
+			return (ARCHIVE_FATAL);
 	}
 
-	archive_le32enc(&d[DATA_DESCRIPTOR_CRC32], l->crc32);
-	archive_le32enc(&d[DATA_DESCRIPTOR_COMPRESSED_SIZE],
-		(uint32_t)l->compressed_size);
-	ret = __archive_write_output(a, d, SIZE_DATA_DESCRIPTOR);
-	if (ret != ARCHIVE_OK)
-		return (ARCHIVE_FATAL);
-	zip->written_bytes += SIZE_DATA_DESCRIPTOR;
+	/* Append Zip64 extra data to central directory information. */
+	if (zip->entry_compressed_written > ARCHIVE_LITERAL_LL(0xffffffff)
+	    || zip->entry_uncompressed_written > ARCHIVE_LITERAL_LL(0xffffffff)
+	    || zip->entry_offset > ARCHIVE_LITERAL_LL(0xffffffff)) {
+		unsigned char zip64[32];
+		unsigned char *z = zip64, *zd;
+		memcpy(z, "\001\000\000\000", 4);
+		z += 4;
+		if (zip->entry_uncompressed_written >= ARCHIVE_LITERAL_LL(0xffffffff)) {
+			archive_le64enc(z, zip->entry_uncompressed_written);
+			z += 8;
+		}
+		if (zip->entry_compressed_written >= ARCHIVE_LITERAL_LL(0xffffffff)) {
+			archive_le64enc(z, zip->entry_compressed_written);
+			z += 8;
+		}
+		if (zip->entry_offset >= ARCHIVE_LITERAL_LL(0xffffffff)) {
+			archive_le64enc(z, zip->entry_offset);
+			z += 8;
+		}
+		archive_le16enc(zip64 + 2, z - (zip64 + 4));
+		zd = cd_alloc(zip, z - zip64);
+		if (zd == NULL) {
+			archive_set_error(&a->archive, ENOMEM,
+				"Can't allocate zip data");
+			return (ARCHIVE_FATAL);
+		}
+		memcpy(zd, zip64, z - zip64);
+		/* Zip64 means version needs to be set to at least 4.5 */
+		if (archive_le16dec(zip->file_header + 6) < 45)
+			archive_le16enc(zip->file_header + 6, 45);
+	}
+
+	/* Fix up central directory file header. */
+	archive_le32enc(zip->file_header + 16, zip->entry_crc32);
+	archive_le32enc(zip->file_header + 20,
+	    zipmin(zip->entry_compressed_written, ARCHIVE_LITERAL_LL(0xffffffff)));
+	archive_le32enc(zip->file_header + 24,
+	    zipmin(zip->entry_uncompressed_written, ARCHIVE_LITERAL_LL(0xffffffff)));
+	archive_le16enc(zip->file_header + 30,
+	    zip->central_directory_bytes - zip->file_header_extra_offset);
+	archive_le32enc(zip->file_header + 42,
+	    zipmin(zip->entry_offset, ARCHIVE_LITERAL_LL(0xffffffff)));
+
 	return (ARCHIVE_OK);
 }
 
 static int
 archive_write_zip_close(struct archive_write *a)
 {
-	struct zip *zip;
-	struct zip_file_header_link *l;
-	uint8_t h[SIZE_FILE_HEADER];
-	uint8_t end[SIZE_CENTRAL_DIRECTORY_END];
-	uint8_t e[SIZE_EXTRA_DATA_CENTRAL];
+	uint8_t buff[64];
 	int64_t offset_start, offset_end;
-	int entries;
+	struct zip *zip = a->format_data;
+	struct cd_segment *segment;
 	int ret;
 
-	zip = a->format_data;
-	l = zip->central_directory;
-
-	/*
-	 * Formatting central directory file header fields that are
-	 * fixed for all entries.
-	 * Fields not used (and therefor 0) are:
-	 *
-	 *   - comment_length
-	 *   - disk_number
-	 *   - attributes_internal
-	 */
-	memset(h, 0, sizeof(h));
-	archive_le32enc(&h[FILE_HEADER_SIGNATURE], ZIP_SIGNATURE_FILE_HEADER);
-	archive_le16enc(&h[FILE_HEADER_VERSION_BY], ZIP_VERSION_BY);
-	archive_le16enc(&h[FILE_HEADER_VERSION_EXTRACT], ZIP_VERSION_EXTRACT);
-
-	entries = 0;
 	offset_start = zip->written_bytes;
-
-	/* Formatting individual header fields per entry and
-	 * writing each entry. */
-	while (l != NULL) {
-		archive_le16enc(&h[FILE_HEADER_FLAGS], l->flags);
-		archive_le16enc(&h[FILE_HEADER_COMPRESSION], l->compression);
-		archive_le32enc(&h[FILE_HEADER_TIMEDATE],
-			dos_time(archive_entry_mtime(l->entry)));
-		archive_le32enc(&h[FILE_HEADER_CRC32], l->crc32);
-		archive_le32enc(&h[FILE_HEADER_COMPRESSED_SIZE],
-			(uint32_t)l->compressed_size);
-		archive_le32enc(&h[FILE_HEADER_UNCOMPRESSED_SIZE],
-			(uint32_t)archive_entry_size(l->entry));
-		archive_le16enc(&h[FILE_HEADER_FILENAME_LENGTH],
-			(uint16_t)path_length(l->entry));
-		archive_le16enc(&h[FILE_HEADER_EXTRA_LENGTH], sizeof(e));
-		archive_le16enc(&h[FILE_HEADER_ATTRIBUTES_EXTERNAL+2],
-			archive_entry_mode(l->entry));
-		archive_le32enc(&h[FILE_HEADER_OFFSET], (uint32_t)l->offset);
-
-		/* Formatting extra data. */
-		archive_le16enc(&e[EXTRA_DATA_CENTRAL_TIME_ID],
-			ZIP_SIGNATURE_EXTRA_TIMESTAMP);
-		archive_le16enc(&e[EXTRA_DATA_CENTRAL_TIME_SIZE], 1 + 4);
-		e[EXTRA_DATA_CENTRAL_TIME_FLAG] = 0x07;
-		archive_le32enc(&e[EXTRA_DATA_CENTRAL_MTIME],
-			(uint32_t)archive_entry_mtime(l->entry));
-		archive_le16enc(&e[EXTRA_DATA_CENTRAL_UNIX_ID],
-			ZIP_SIGNATURE_EXTRA_NEW_UNIX);
-		archive_le16enc(&e[EXTRA_DATA_CENTRAL_UNIX_SIZE], 0x0000);
-
-		ret = __archive_write_output(a, h, sizeof(h));
+	segment = zip->central_directory;
+	while (segment != NULL) {
+		ret = __archive_write_output(a,
+		    segment->buff, segment->p - segment->buff);
 		if (ret != ARCHIVE_OK)
 			return (ARCHIVE_FATAL);
-		zip->written_bytes += sizeof(h);
-
-		ret = write_path(l->entry, a);
-		if (ret <= ARCHIVE_OK)
-			return (ARCHIVE_FATAL);
-		zip->written_bytes += ret;
-
-		ret = __archive_write_output(a, e, sizeof(e));
-		if (ret != ARCHIVE_OK)
-			return (ARCHIVE_FATAL);
-		zip->written_bytes += sizeof(e);
-
-		l = l->next;
-		entries++;
+		zip->written_bytes += segment->p - segment->buff;
+		segment = segment->next;
 	}
 	offset_end = zip->written_bytes;
 
-	/* Formatting end of central directory. */
-	memset(end, 0, sizeof(end));
-	archive_le32enc(&end[CENTRAL_DIRECTORY_END_SIGNATURE],
-		ZIP_SIGNATURE_CENTRAL_DIRECTORY_END);
-	archive_le16enc(&end[CENTRAL_DIRECTORY_END_ENTRIES_DISK], entries);
-	archive_le16enc(&end[CENTRAL_DIRECTORY_END_ENTRIES], entries);
-	archive_le32enc(&end[CENTRAL_DIRECTORY_END_SIZE],
-		(uint32_t)(offset_end - offset_start));
-	archive_le32enc(&end[CENTRAL_DIRECTORY_END_OFFSET],
-		(uint32_t)offset_start);
+	/* If central dir info is too large, write Zip64 end-of-cd */
+	if (offset_end - offset_start > ARCHIVE_LITERAL_LL(0xffffffff)
+	    || offset_start > ARCHIVE_LITERAL_LL(0xffffffff)
+	    || zip->central_directory_entries > 0xffffUL
+	    || (zip->flags & ZIP_FLAG_FORCE_ZIP64)) {
+	  /* Zip64 end-of-cd record */
+	  memset(buff, 0, 56);
+	  memcpy(buff, "PK\006\006", 4);
+	  archive_le64enc(buff + 4, 44);
+	  archive_le16enc(buff + 12, 45);
+	  archive_le16enc(buff + 14, 45);
+	  /* This is disk 0 of 0. */
+	  archive_le64enc(buff + 24, zip->central_directory_entries);
+	  archive_le64enc(buff + 32, zip->central_directory_entries);
+	  archive_le64enc(buff + 40, offset_end - offset_start);
+	  archive_le64enc(buff + 48, offset_start);
+	  ret = __archive_write_output(a, buff, 56);
+	  if (ret != ARCHIVE_OK)
+		  return (ARCHIVE_FATAL);
+	  zip->written_bytes += 56;
 
-	/* Writing end of central directory. */
-	ret = __archive_write_output(a, end, sizeof(end));
+	  /* Zip64 end-of-cd locator record. */
+	  memset(buff, 0, 20);
+	  memcpy(buff, "PK\006\007", 4);
+	  archive_le32enc(buff + 4, 0);
+	  archive_le64enc(buff + 8, offset_end);
+	  archive_le32enc(buff + 16, 1);
+	  ret = __archive_write_output(a, buff, 20);
+	  if (ret != ARCHIVE_OK)
+		  return (ARCHIVE_FATAL);
+	  zip->written_bytes += 20;
+
+	}
+
+	/* Format and write end of central directory. */
+	memset(buff, 0, sizeof(buff));
+	memcpy(buff, "PK\005\006", 4);
+	archive_le16enc(buff + 8, zipmin(0xffffU, zip->central_directory_entries));
+	archive_le16enc(buff + 10, zipmin(0xffffU, zip->central_directory_entries));
+	archive_le32enc(buff + 12, (uint32_t)zipmin(ARCHIVE_LITERAL_LL(0xffffffff), (offset_end - offset_start)));
+	archive_le32enc(buff + 16, (uint32_t)zipmin(ARCHIVE_LITERAL_LL(0xffffffff), offset_start));
+	ret = __archive_write_output(a, buff, 22);
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
-	zip->written_bytes += sizeof(end);
+	zip->written_bytes += 22;
 	return (ARCHIVE_OK);
 }
 
@@ -834,18 +992,21 @@
 archive_write_zip_free(struct archive_write *a)
 {
 	struct zip *zip;
-	struct zip_file_header_link *l;
+	struct cd_segment *segment;
 
 	zip = a->format_data;
 	while (zip->central_directory != NULL) {
-	   l = zip->central_directory;
-	   zip->central_directory = l->next;
-	   archive_entry_free(l->entry);
-	   free(l);
+		segment = zip->central_directory;
+		zip->central_directory = segment->next;
+		free(segment->buff);
+		free(segment);
 	}
 #ifdef HAVE_ZLIB_H
 	free(zip->buf);
 #endif
+	archive_entry_free(zip->entry);
+	/* TODO: Free opt_sconv, sconv_default */
+
 	free(zip);
 	a->format_data = NULL;
 	return (ARCHIVE_OK);
@@ -918,7 +1079,7 @@
 		return (ARCHIVE_FATAL);
 	written_bytes += strlen(path);
 
-	/* Folders are recognized by a traling slash. */
+	/* Folders are recognized by a trailing slash. */
 	if ((type == AE_IFDIR) & (path[strlen(path) - 1] != '/')) {
 		ret = __archive_write_output(archive, "/", 1);
 		if (ret != ARCHIVE_OK)
@@ -928,3 +1089,38 @@
 
 	return ((int)written_bytes);
 }
+
+static void
+copy_path(struct archive_entry *entry, unsigned char *p)
+{
+	const char *path;
+	size_t pathlen;
+	mode_t type;
+
+	path = archive_entry_pathname(entry);
+	pathlen = strlen(path);
+	type = archive_entry_filetype(entry);
+
+	memcpy(p, path, pathlen);
+
+	/* Folders are recognized by a trailing slash. */
+	if ((type == AE_IFDIR) & (path[pathlen - 1] != '/')) {
+		p[pathlen] = '/';
+		p[pathlen + 1] = '\0';
+	}
+}
+
+
+static struct archive_string_conv *
+get_sconv(struct archive_write *a, struct zip *zip)
+{
+	if (zip->opt_sconv != NULL)
+		return (zip->opt_sconv);
+
+	if (!zip->init_default_conversion) {
+		zip->sconv_default =
+		    archive_string_default_conversion_for_write(&(a->archive));
+		zip->init_default_conversion = 1;
+	}
+	return (zip->sconv_default);
+}
diff --git a/Utilities/cmlibarchive/libarchive/filter_fork_windows.c b/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
index fa59cc9..ad271fe 100644
--- a/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
+++ b/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
@@ -36,7 +36,7 @@
 {
 	HANDLE childStdout[2], childStdin[2],childStderr;
 	SECURITY_ATTRIBUTES secAtts;
-	STARTUPINFO staInfo;
+	STARTUPINFOA staInfo;
 	PROCESS_INFORMATION childInfo;
 	struct archive_string cmdline;
 	struct archive_string fullpath;
diff --git a/Utilities/cmlibarchive/libarchive/mtree.5 b/Utilities/cmlibarchive/libarchive/mtree.5
index 983fff7..8c45a7d 100644
--- a/Utilities/cmlibarchive/libarchive/mtree.5
+++ b/Utilities/cmlibarchive/libarchive/mtree.5
@@ -28,7 +28,7 @@
 .\"     From: @(#)mtree.8       8.2 (Berkeley) 12/11/93
 .\" $FreeBSD$
 .\"
-.Dd May 6, 2008
+.Dd September 4, 2013
 .Dt MTREE 5
 .Os
 .Sh NAME
@@ -134,6 +134,52 @@
 the
 .Xr cksum 1
 utility.
+.It Cm device
+The device number for
+.Sy block
+or
+.Sy char
+file types.
+The value must be one of the following forms:
+.Pp
+.Bl -tag -width 4n
+.It Ar format , Ns Ar major , Ns Ar minor Ns Bo , Ns Ar subunit Bc
+A device with
+.Ar major , minor
+and optional
+.Ar subunit
+fields.
+Their meaning is specified by the operating's system
+.Ar format .
+See below for valid formats.
+.It Ar number
+Opaque number (as stored on the file system).
+.El
+.Pp
+The following values for
+.Ar format
+are recognized:
+.Sy native ,
+.Sy 386bsd ,
+.Sy 4bsd ,
+.Sy bsdos ,
+.Sy freebsd ,
+.Sy hpux ,
+.Sy isc ,
+.Sy linux ,
+.Sy netbsd ,
+.Sy osf1 ,
+.Sy sco ,
+.Sy solaris ,
+.Sy sunos ,
+.Sy svr3 ,
+.Sy svr4 ,  
+and 
+.Sy ultrix .
+.Pp
+See
+.Xr mknod 8
+for more details.
 .It Cm contents
 The full pathname of a file that holds the contents of this file.
 .It Cm flags
@@ -150,6 +196,8 @@
 The file group as a symbolic name.
 .It Cm ignore
 Ignore any file hierarchy below this file.
+.It Cm inode
+The inode number.
 .It Cm link
 The target of the symbolic link when type=link.
 .It Cm md5
@@ -164,6 +212,16 @@
 The number of hard links the file is expected to have.
 .It Cm nochange
 Make sure this file or directory exists but otherwise ignore all attributes.
+.It Cm optional
+The file is optional; do not complain about the file if it is not in
+the file hierarchy.
+.It Cm resdevice
+The
+.Dq resident
+device number of the file, e.g. the ID of the device that
+contains the file.
+Its format is the same as the one for
+.Cm device .
 .It Cm ripemd160digest
 The
 .Tn RIPEMD160
@@ -192,6 +250,24 @@
 .It Cm sha256digest
 A synonym for
 .Cm sha256 .
+.It Cm sha384
+The
+.Tn FIPS
+180-2
+.Pq Dq Tn SHA-384
+message digest of the file.
+.It Cm sha384digest
+A synonym for
+.Cm sha384 .
+.It Cm sha512
+The
+.Tn FIPS
+180-2
+.Pq Dq Tn SHA-512
+message digest of the file.
+.It Cm sha512digest
+A synonym for
+.Cm sha512 .
 .It Cm size
 The size, in bytes, of the file.
 .It Cm time
diff --git a/bootstrap b/bootstrap
index 45f67cf..a3cc0a3 100755
--- a/bootstrap
+++ b/bootstrap
@@ -232,6 +232,7 @@
   cmCommandArgumentLexer \
   cmCommandArgumentParser \
   cmCommandArgumentParserHelper \
+  cmCPackPropertiesGenerator \
   cmDefinitions \
   cmDepends \
   cmDependsC \
@@ -258,6 +259,7 @@
   cmGeneratorExpression \
   cmGlobalGenerator \
   cmLocalGenerator \
+  cmInstalledFile \
   cmInstallGenerator \
   cmInstallExportGenerator \
   cmInstallFilesGenerator \
@@ -329,6 +331,7 @@
 KWSYS_CXX_SOURCES="\
   Directory \
   EncodingCXX \
+  FStream \
   Glob \
   RegularExpression \
   SystemTools"
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
index 7cd7fc1..d81f62a 100644
--- a/cmake_uninstall.cmake.in
+++ b/cmake_uninstall.cmake.in
@@ -3,7 +3,7 @@
 endif()
 
 file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
-string(REGEX REPLACE "\n" ";" files "${files}")
+string(REPLACE "\n" ";" files "${files}")
 foreach(file ${files})
   message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
   if(EXISTS "$ENV{DESTDIR}${file}")